Exemplo n.º 1
0
    def test_saveandload(self):
        f_dict = fastdict.FastCompressUInt32IntDict(self.dimension)    
        f_dict.set(123, 78912893, 0)
        f_dict.set(456, 789, 1)

        fastdict.save_compress_uint32_int("test.dict", f_dict)
        another_f_dict = fastdict.FastCompressUInt32IntDict(self.dimension)
        fastdict.load_compress_uint32_int("test.dict", another_f_dict)

        self.assertEqual(another_f_dict.size(), 2)
Exemplo n.º 2
0
    def test_saveandload(self):
        f_dict = fastdict.FastCompressUInt32IntDict(self.dimension)
        f_dict.set(123, 78912893, 0)
        f_dict.set(456, 789, 1)

        fastdict.save_compress_uint32_int("test.dict", f_dict)
        another_f_dict = fastdict.FastCompressUInt32IntDict(self.dimension)
        fastdict.load_compress_uint32_int("test.dict", another_f_dict)

        self.assertEqual(another_f_dict.size(), 2)
Exemplo n.º 3
0
    def test_keydimensions(self):
        f_dict = fastdict.FastCompressUInt32IntDict(self.dimension)
        f_dict.set_keydimensions([1, 2, 3])

        keydimensions = []
        f_dict.get_keydimensions(keydimensions)
        self.assertEqual(keydimensions, [1, 2, 3])

        fastdict.save_compress_uint32_int("test.dict", f_dict)
        another_f_dict = fastdict.FastCompressUInt32IntDict(self.dimension)
        fastdict.load_compress_uint32_int("test.dict", another_f_dict)

        keydimensions = []
        another_f_dict.get_keydimensions(keydimensions)
        self.assertEqual(keydimensions, [1, 2, 3])
Exemplo n.º 4
0
    def test_keydimensions(self):
        f_dict = fastdict.FastCompressUInt32IntDict(self.dimension)
        f_dict.set_keydimensions([1, 2, 3])

        keydimensions = []
        f_dict.get_keydimensions(keydimensions)
        self.assertEqual(keydimensions, [1, 2, 3])

        fastdict.save_compress_uint32_int("test.dict", f_dict)
        another_f_dict = fastdict.FastCompressUInt32IntDict(self.dimension)
        fastdict.load_compress_uint32_int("test.dict", another_f_dict)

        keydimensions = []
        another_f_dict.get_keydimensions(keydimensions)
        self.assertEqual(keydimensions, [1, 2, 3])
Exemplo n.º 5
0
    def load(self, filename):
        if self.storage.size() > 0:
            if self.config['t'] == 'string':       
                fastdict.load_compress_uint32_string(filename, self.load_dict) 
            elif self.config['t'] == 'int8':
                fastdict.load_compress_uint32_int8(filename, self.load_dict)
            elif self.config['t'] == 'int32':
                fastdict.load_compress_uint32_int(filename, self.load_dict)

            self.storage.merge(self.load_dict) 
            self.load_dict.clear()
        else:
            if self.config['t'] == 'string':        
                fastdict.load_compress_uint32_string(filename, self.storage)
            elif self.config['t'] == 'int8':
                fastdict.load_compress_uint32_int8(filename, self.storage)
            elif self.config['t'] == 'int32':
                fastdict.load_compress_uint32_int(filename, self.storage)

            key_dimensions = []
            self.storage.get_keydimensions(key_dimensions)
            self.key_dimensions = np.array(key_dimensions)
Exemplo n.º 6
0
    def load(self, filename):
        if self.storage.size() > 0:
            if self.config['t'] == 'string':
                fastdict.load_compress_uint32_string(filename, self.load_dict)
            elif self.config['t'] == 'int8':
                fastdict.load_compress_uint32_int8(filename, self.load_dict)
            elif self.config['t'] == 'int32':
                fastdict.load_compress_uint32_int(filename, self.load_dict)

            self.storage.merge(self.load_dict)
            self.load_dict.clear()
        else:
            if self.config['t'] == 'string':
                fastdict.load_compress_uint32_string(filename, self.storage)
            elif self.config['t'] == 'int8':
                fastdict.load_compress_uint32_int8(filename, self.storage)
            elif self.config['t'] == 'int32':
                fastdict.load_compress_uint32_int(filename, self.storage)

            key_dimensions = []
            self.storage.get_keydimensions(key_dimensions)
            self.key_dimensions = np.array(key_dimensions)
for key in f_dict.keys():
    print "key: " + str(key)

for key in f_dict.mget([123, 456]):
    print key.first
    print key.second

f_dict.set_keydimensions([1, 2, 3])

fastdict.save_compress_uint32_int("test.dict", f_dict)

f_dict = fastdict.FastCompressUInt32IntDict(8)

print f_dict.size()

fastdict.load_compress_uint32_int("test.dict", f_dict)

print f_dict.size()

f_dict_merge_source = fastdict.FastCompressUInt32IntDict(8)

f_dict_merge_source.set(789, 123, 3)

print f_dict_merge_source.size()

for key in f_dict_merge_source.keys():
    print "key: " + str(key)

f_dict.merge(f_dict_merge_source)

print "merged: "
for key in f_dict.keys():
    print "key: " + str(key)

for key in f_dict.mget([123, 456]):
    print key.first
    print key.second

f_dict.set_keydimensions([1, 2, 3])

fastdict.save_compress_uint32_int("test.dict", f_dict)

f_dict = fastdict.FastCompressUInt32IntDict(8)

print f_dict.size()

fastdict.load_compress_uint32_int("test.dict", f_dict)

print f_dict.size()
 
f_dict_merge_source = fastdict.FastCompressUInt32IntDict(8)

f_dict_merge_source.set(789, 123, 3)

print f_dict_merge_source.size()
 
for key in f_dict_merge_source.keys():
    print "key: " + str(key)

f_dict.merge(f_dict_merge_source)

print "merged: "