Beispiel #1
0
    def test_saveandload(self):
        f_dict = fastdict.FastCompressUInt32Int8Dict(self.dimension)    
        f_dict.set(123, 78912893, 0)
        f_dict.set(456, 789, 1)

        fastdict.save_compress_uint32_int8("test.dict", f_dict)
        another_f_dict = fastdict.FastCompressUInt32Int8Dict(self.dimension)
        fastdict.load_compress_uint32_int8("test.dict", another_f_dict)

        self.assertEqual(another_f_dict.size(), 2)
Beispiel #2
0
    def test_saveandload(self):
        f_dict = fastdict.FastCompressUInt32Int8Dict(self.dimension)
        f_dict.set(123, 78912893, 0)
        f_dict.set(456, 789, 1)

        fastdict.save_compress_uint32_int8("test.dict", f_dict)
        another_f_dict = fastdict.FastCompressUInt32Int8Dict(self.dimension)
        fastdict.load_compress_uint32_int8("test.dict", another_f_dict)

        self.assertEqual(another_f_dict.size(), 2)
Beispiel #3
0
    def test_keydimensions(self):
        f_dict = fastdict.FastCompressUInt32Int8Dict(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_int8("test.dict", f_dict)
        another_f_dict = fastdict.FastCompressUInt32Int8Dict(self.dimension)
        fastdict.load_compress_uint32_int8("test.dict", another_f_dict)

        keydimensions = []
        another_f_dict.get_keydimensions(keydimensions)
        self.assertEqual(keydimensions, [1, 2, 3])
Beispiel #4
0
    def test_keydimensions(self):
        f_dict = fastdict.FastCompressUInt32Int8Dict(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_int8("test.dict", f_dict)
        another_f_dict = fastdict.FastCompressUInt32Int8Dict(self.dimension)
        fastdict.load_compress_uint32_int8("test.dict", another_f_dict)

        keydimensions = []
        another_f_dict.get_keydimensions(keydimensions)
        self.assertEqual(keydimensions, [1, 2, 3])
Beispiel #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)
Beispiel #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)