Esempio n. 1
0
def load(buff):
	"make a bitset from a bitflow"
	b = bitset.empty()
	buffer = StringIO(buff)
	b._size = struct.unpack('Q', buffer.read(8))[0]
	b._data = []
	while True:
		bloc = buffer.read(8)
		if bloc == "": break
		b._data.append(long(struct.unpack('Q', bloc)[0]))
	return b
Esempio n. 2
0
 def get(self, key, value):
     "A simple query for a key=value"
     value = str(value)
     cachekey = "%s:%s" % (key, value)
     try:
         return self.cache[cachekey]
     except KeyError:
         pass
     self.oups += 1
     index = self._index(key)
     try:
         b = index.get(value)
         v = bitset.fromblob(self.cpt, b)
     except KeyError:
         v = bitset.empty(self.cpt)
     self.cache[cachekey] = v
     return v