def idToPoint(id): """ Converts a hashkey into some point Keyword Arguments: id -- the multihash id/key of a node/value """ idLong = multihash.parseHash(id) return idLong
def idToPoint(id): """ Converts a hashkey into some point Keyword Arguments: id -- the multihash id/key of a node/value """ idLong = multihash.parseHash(id) return idLong
def idToPoint(dim, id): """ We're using a unit space for the position of our nodes. The mapping we use is to use the hash ID as the seed to an RNG. We should switch to either 1) A universal RNG 2) The mapping done by Symphony """ idLong = MultiHash.parseHash(id) return tuple([idLong, 0])
def idToPoint(dim, id): """ We're using a unit space for the position of our nodes. The mapping we use is to use the hash ID as the seed to an RNG. We should switch to either 1) A universal RNG 2) The mapping done by Symphony """ idLong = MultiHash.parseHash(id) return tuple([idLong,0])
def idToPoint(dim,id): assert(dim == 2) """ We're using a unit space for the position of our nodes. The mapping we use is to use the hash ID as the seed to an RNG. We should switch to either 1) A universal RNG 2) The mapping done by Symphony """ idLong = MultiHash.parseHash(id) random.seed(idLong) r = random.random()**0.5 theta = random.random()*math.pi*2 x = math.cos(theta)*r y = math.sin(theta)*r return (x, y)
def idToPoint(dim, id): assert (dim == 2) """ We're using a unit space for the position of our nodes. The mapping we use is to use the hash ID as the seed to an RNG. We should switch to either 1) A universal RNG 2) The mapping done by Symphony """ idLong = MultiHash.parseHash(id) random.seed(idLong) r = random.random()**0.5 theta = random.random() * math.pi * 2 x = math.cos(theta) * r y = math.sin(theta) * r return (x, y)
def generateBloomFilter(wordlist): f = 0 j = 0 for w in wordlist: hashInt = 0 hashVal = pmh.genHash(w, 0x12) for i in range(0, 10): try: tmpInt = 2**256-1 for j in range(0,10): tmpInt &= pmh.parseHash(hashVal) hashVal = pmh.genHash(hashVal, 0x12) hashInt = (hashInt << 256) | tmpInt except Exception as e: print("error ",e) print(hashVal, w, i, j, len(wordlist)) hashVal = pmh.genHash(hashVal, 0x12) f |= hashInt j += 1 return f
def generateBloomFilter(wordlist): f = 0 j = 0 for w in wordlist: hashInt = 0 hashVal = pmh.genHash(w, 0x12) for i in range(0, 10): try: tmpInt = 2**256 - 1 for j in range(0, 10): tmpInt &= pmh.parseHash(hashVal) hashVal = pmh.genHash(hashVal, 0x12) hashInt = (hashInt << 256) | tmpInt except Exception as e: print("error ", e) print(hashVal, w, i, j, len(wordlist)) hashVal = pmh.genHash(hashVal, 0x12) f |= hashInt j += 1 return f
def wordInFilter(bloomInt, testWord): hashVal = pmh.genHash(testWord, 0x12) hashInt = pmh.parseHash(hashVal) return (bloomInt & hashInt) == hashInt
def wordInFilter(bloomInt, testWord): hashVal = pmh.genHash(testWord, 0x12) hashInt = pmh.parseHash(hashVal) return (bloomInt & hashInt) == hashInt