Example #1
0
class InMemoryAttributeStorageUseSimpleHash(InMemoryAttributeStorage):
    def __init__(self):
        InMemoryAttributeStorage.__init__(self)
        self._hash = SimpleHash()

    def has_key_in_store(self, key):
        return self._hash.key_present(key)

    def copy(self):
        copy = type(self)()
        copy.particle_keys = self.particle_keys.copy()
        copy.index_array = self.index_array.copy()
        copy._hash.reindex(copy.particle_keys)
        for attribute, attribute_values in self.mapping_from_attribute_to_quantities.items(
        ):
            copy.mapping_from_attribute_to_quantities[
                attribute] = attribute_values.copy()
        return copy

    def get_indices_of(self, keys):
        if keys is None:
            return self.index_array

        if len(self.particle_keys) == 0:
            return ()

        return self._hash.lookup(keys)

    def reindex(self):
        self._hash.reindex(self.particle_keys)

    def __getstate__(self):
        state = self.__dict__.copy()
        state.pop("_hash")
        return state

    def __setstate__(self, state):
        self.__dict__ = state
        self._hash = SimpleHash()
        if len(self.particle_keys):
            self._hash.reindex(self.particle_keys)
Example #2
0
class InMemoryAttributeStorageUseSimpleHash(InMemoryAttributeStorage):
    
    def __init__(self):
        InMemoryAttributeStorage.__init__(self)
        self._hash=SimpleHash()
    
    def has_key_in_store(self, key):
        return self._hash.key_present(key)
        
    def copy(self):
        copy = type(self)()
        copy.particle_keys = self.particle_keys.copy()
        copy.index_array = self.index_array.copy()
        copy._hash.reindex(copy.particle_keys)
        for attribute, attribute_values in self.mapping_from_attribute_to_quantities.iteritems():
            copy.mapping_from_attribute_to_quantities[attribute] = attribute_values.copy()
        return copy
   
    def get_indices_of(self, keys):
        if keys is None:
            return self.index_array

        if len(self.particle_keys) == 0:
            return ()
        
        return self._hash.lookup(keys)
        
    def reindex(self):
        self._hash.reindex(self.particle_keys)

    def __getstate__(self):
        state=self.__dict__.copy()
        state.pop("_hash")
        return state
      

    def __setstate__(self,state):
        self.__dict__ = state
        self._hash=SimpleHash()
        if len(self.particle_keys):
          self._hash.reindex(self.particle_keys)
Example #3
0
 def __setstate__(self, state):
     self.__dict__ = state
     self._hash = SimpleHash()
     if len(self.particle_keys):
         self._hash.reindex(self.particle_keys)
Example #4
0
 def __init__(self):
     InMemoryAttributeStorage.__init__(self)
     self._hash = SimpleHash()
Example #5
0
 def __setstate__(self,state):
     self.__dict__ = state
     self._hash=SimpleHash()
     if len(self.particle_keys):
       self._hash.reindex(self.particle_keys)
Example #6
0
 def __init__(self):
     InMemoryAttributeStorage.__init__(self)
     self._hash=SimpleHash()