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

Function planForEqFilter

worker/task.go:1881–1920  ·  view source on GitHub ↗
(fc *functionContext, pred string, uidlist []uint64)

Source from the content-addressed store, hash-verified

1879}
1880
1881func planForEqFilter(fc *functionContext, pred string, uidlist []uint64) {
1882 if checkUidZero(uidlist) {
1883 // We have a uid which has 0 in it. Mostly it would happen when there is only 0. But any one item
1884 // being 0 could cause the query planner to fail. In case of 0 being present, we neeed to query the
1885 // index itself.
1886 fc.n = len(fc.tokens)
1887 return
1888 }
1889
1890 if uint64(len(uidlist)) < Config.TypeFilterUidLimit {
1891 fc.tokens = fc.tokens[:0]
1892 fc.n = len(uidlist)
1893 return
1894 }
1895
1896 estimatedCount := uint64(0)
1897 gotEstimate := false
1898 for _, eqToken := range fc.tokens {
1899 count := posting.GetStatsHolder().ProcessEqPredicate(pred, []byte(eqToken))
1900 if count != math.MaxUint64 && count != 0 {
1901 estimatedCount += count
1902 gotEstimate = true
1903 } else {
1904 break
1905 }
1906 }
1907
1908 if gotEstimate && estimatedCount == 0 {
1909 gotEstimate = false
1910 }
1911
1912 // TODO make a different config
1913 if gotEstimate && uint64(len(uidlist)) < estimatedCount/Config.TypeFilterUidLimit {
1914 fc.tokens = fc.tokens[:0]
1915 fc.n = len(uidlist)
1916 return
1917 }
1918
1919 fc.n = len(fc.tokens)
1920}
1921
1922func parseSrcFn(ctx context.Context, q *pb.Query) (*functionContext, error) {
1923 fnType, f := parseFuncType(q.SrcFunc)

Callers 1

parseSrcFnFunction · 0.85

Calls 3

GetStatsHolderFunction · 0.92
checkUidZeroFunction · 0.85
ProcessEqPredicateMethod · 0.80

Tested by

no test coverage detected