async def prepare(tx): hyperdev = uuid4() nstore.add(tx, ntest, hyperdev, "title", "hyper.dev") nstore.add(tx, ntest, hyperdev, "keyword", "scheme") nstore.add(tx, ntest, hyperdev, "keyword", "hacker") copernic = uuid4() nstore.add(tx, ntest, copernic, "title", "blog.copernic.com") nstore.add(tx, ntest, copernic, "keyword", "corporate")
async def index(tx, store, docuid, counter): # translate keys that are string tokens, into uuid4 bytes with # store.tokens tokens = dict() for string, count in counter.items(): query = nstore.select(tx, store.tokens, string, nstore.var('uid')) try: uid = await query.__anext__() except StopAsyncIteration: uid = uuid4() nstore.add(tx, store.tokens, string, uid) else: uid = uid['uid'] tokens[uid] = count # store tokens to use later during search for filtering found.set(tx, found.pack((store.prefix_counters, docuid)), zstd.compress(found.pack(tuple(tokens.items())))) # store tokens keys for candidate selection for token in tokens: found.set(tx, found.pack((store.prefix_index, token, docuid)), b'')
async def prepare(tx): hyperdev = uuid4() post1 = uuid4() post2 = uuid4() nstore.add(tx, ntest, hyperdev, "title", "hyper.dev") nstore.add(tx, ntest, hyperdev, "keyword", "scheme") nstore.add(tx, ntest, hyperdev, "keyword", "hacker") nstore.add(tx, ntest, post1, "blog", hyperdev) nstore.add(tx, ntest, post1, "title", "hoply is awesome") nstore.add(tx, ntest, post2, "blog", hyperdev) nstore.add(tx, ntest, post2, "title", "hoply foundiple store")
async def prepare(tx): nstore.add(tx, ntest, hyperdev, "title", "hyper.dev") nstore.add(tx, ntest, hyperdev, "keyword", "scheme") nstore.add(tx, ntest, hyperdev, "keyword", "hacker") nstore.add(tx, ntest, copernic, "title", "blog.copernic.com") nstore.add(tx, ntest, copernic, "keyword", "corporate") nstore.add(tx, ntest, hypersocial, "title", "hypersocial.space") nstore.add(tx, ntest, hypersocial, "keyword", "python") nstore.add(tx, ntest, hypersocial, "keyword", "hacker")
async def prepare(tx): nstore.add(tx, ntest, expected, "title", "hyper.dev") nstore.add(tx, ntest, uuid4(), "title", "blog.copernic.com")
async def add(tx): nstore.add(tx, ntest, expected, "title", "hyper.dev")