You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* saving state
* added new fingerprint func using BLAKE2b
* renamed function to Hash256 for clarity.
* replaced 64 fingerprint hash with Hash256
* pickTokenizer use hash tokenizer when list is lossy.
* added tokenizer identifier list for enforcing tokenizer.
* compare func using hash index if available and eq won't compare values
* fixed minor comment glitches
* use tokenizer identifier consts, change hash to non-lossy.
* using non-lossy hash so no need for extra logic in handleCompareFunction
* simplify pickTokenizer and
* simplify pickTokenizer
* using tokenizer id
* added id value for custom tokenizers, IdentCustom
* using tokenizer ids when possible
fixed bug in getInequalityTokens with fulltext indexes.
* added hash index tests
* Manish's review. Fixed a new bug introduced by this PR during IdentCustom comparison. Simplify pickTokenizer. Added comments.
* Remove Long term for exact index warning.
* fixed logic
* pickTokenizer return error when comparison func doesn't have non-lossy (eq) or sortable (le, ge, gt, lt) index
* added warning for eq comparison without non-lossy tokenizer
* re-fixed this slippery lil bug
* removed extra glog
t.Run("schema specific predicate fields", wrap(SchemaQueryTestPredicate2))
48
48
t.Run("schema specific predicate field", wrap(SchemaQueryTestPredicate3))
49
+
t.Run("hash index queries", wrap(QueryHashIndex))
49
50
t.Run("cleanup", wrap(SchemaQueryCleanup))
50
51
}
51
52
@@ -318,3 +319,116 @@ func SchemaQueryTestHTTP(t *testing.T, c *dgo.Dgraph) {
318
319
}`
319
320
CompareJSON(t, js, string(m["data"]))
320
321
}
322
+
323
+
funcQueryHashIndex(t*testing.T, c*dgo.Dgraph) {
324
+
ctx:=context.Background()
325
+
326
+
require.NoError(t, c.Alter(ctx, &api.Operation{
327
+
Schema: `
328
+
name: string @index(hash) @lang .
329
+
`,
330
+
}))
331
+
332
+
txn:=c.NewTxn()
333
+
_, err:=txn.Mutate(ctx, &api.Mutation{
334
+
SetNquads: []byte(`
335
+
_:p0 <name> "" .
336
+
_:p1 <name> "0" .
337
+
_:p2 <name> "srfrog" .
338
+
_:p3 <name> "Lorem ipsum" .
339
+
_:p4 <name> "Lorem ipsum dolor sit amet" .
340
+
_:p5 <name> "Lorem ipsum dolor sit amet, consectetur adipiscing elit" .
341
+
_:p6 <name> "Lorem ipsum"@en .
342
+
_:p7 <name> "Lorem ipsum dolor sit amet"@en .
343
+
_:p8 <name> "Lorem ipsum dolor sit amet, consectetur adipiscing elit"@en .
344
+
_:p9 <name> "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed varius tellus ut sem bibendum, eu tristique augue congue. Praesent eget odio tincidunt, pellentesque ante sit amet, tempus sem. Donec et tellus et diam facilisis egestas ut ac risus. Proin feugiat risus tristique erat condimentum placerat. Nulla eget ligula tempus, blandit leo vel, accumsan tortor. Phasellus et felis in diam ultricies porta nec in ipsum. Phasellus id leo sagittis, bibendum enim ut, pretium lectus. Quisque ac ex viverra, suscipit turpis sed, scelerisque metus. Sed non dui facilisis, viverra leo eget, vulputate erat. Etiam nec enim sed nisi imperdiet cursus. Suspendisse sed ligula non nisi pharetra varius." .
345
+
_:pa <name> ""@fr .
346
+
`),
347
+
})
348
+
require.NoError(t, err)
349
+
require.NoError(t, txn.Commit(ctx))
350
+
351
+
tests:= []struct {
352
+
in, outstring
353
+
}{
354
+
{
355
+
in: `schema(pred: [name]) {}`,
356
+
out: `
357
+
{
358
+
"schema": [
359
+
{
360
+
"index": true,
361
+
"lang": true,
362
+
"predicate": "name",
363
+
"tokenizer": [
364
+
"hash"
365
+
],
366
+
"type": "string"
367
+
}
368
+
]
369
+
}`,
370
+
},
371
+
{
372
+
in: `{q(func:eq(name,"")){name}}`,
373
+
out: `{"q": [{"name":""}]}`,
374
+
},
375
+
{
376
+
in: `{q(func:eq(name,"0")){name}}`,
377
+
out: `{"q": [{"name":"0"}]}`,
378
+
},
379
+
{
380
+
in: `{q(func:eq(name,"srfrog")){name}}`,
381
+
out: `{"q": [{"name":"srfrog"}]}`,
382
+
},
383
+
{
384
+
in: `{q(func:eq(name,"Lorem ipsum")){name}}`,
385
+
out: `{"q": [{"name":"Lorem ipsum"}]}`,
386
+
},
387
+
{
388
+
in: `{q(func:eq(name,"Lorem ipsum dolor sit amet")){name}}`,
389
+
out: `{"q": [{"name":"Lorem ipsum dolor sit amet"}]}`,
0 commit comments