MCPcopy
hub / github.com/dgraph-io/dgraph / TestCountReverseIndexEmptyPosting

Function TestCountReverseIndexEmptyPosting

posting/index_test.go:298–330  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

296}
297
298func TestCountReverseIndexEmptyPosting(t *testing.T) {
299 require.NoError(t, pstore.DropAll())
300 MemLayerInstance.clear()
301 indexNameCountVal := "testcount: [uid] @count @reverse ."
302
303 attr := x.AttrInRootNamespace("testcount")
304 addDelEdgeToUID(t, attr, 1, 23, uint64(10), uint64(11))
305 l, err := GetNoStore(x.DataKey(attr, 1), 12)
306 require.NoError(t, err)
307 l.RLock()
308 require.Equal(t, l.GetLength(12), -1)
309 l.RUnlock()
310
311 require.NoError(t, schema.ParseBytes([]byte(indexNameCountVal), 1))
312 currentSchema, _ := schema.State().Get(context.Background(), attr)
313 rb := IndexRebuild{
314 Attr: attr,
315 StartTs: 12,
316 OldSchema: nil,
317 CurrentSchema: &currentSchema,
318 }
319 rebuildInfo := rb.needsTokIndexRebuild()
320 prefixes, err := rebuildInfo.prefixesForTokIndexes()
321 require.NoError(t, err)
322 require.NoError(t, pstore.DropPrefix(prefixes...))
323 require.NoError(t, rebuildCountIndex(context.Background(), &rb))
324
325 l, err = GetNoStore(x.DataKey(attr, 1), 14)
326 require.NoError(t, err)
327 l.RLock()
328 require.Equal(t, l.GetLength(14), 0)
329 l.RUnlock()
330}
331
332func TestRebuildTokIndex(t *testing.T) {
333 addEdgeToValue(t, x.AttrInRootNamespace("name2"), 91, "Michonne", uint64(1), uint64(2))

Callers

nothing calls this directly

Calls 15

needsTokIndexRebuildMethod · 0.95
AttrInRootNamespaceFunction · 0.92
DataKeyFunction · 0.92
ParseBytesFunction · 0.92
StateFunction · 0.92
addDelEdgeToUIDFunction · 0.85
GetNoStoreFunction · 0.85
rebuildCountIndexFunction · 0.85
DropAllMethod · 0.80
RLockMethod · 0.80
GetLengthMethod · 0.80
RUnlockMethod · 0.80

Tested by

no test coverage detected