Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow @filter directive to be used with expand queries. #4404

Merged
merged 6 commits into from
Dec 18, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/master' into martinmr/filter-on-…
…expand
martinmr committed Dec 12, 2019
commit d89a5ecf411c23868b7456370aa44b4020bf4265
57 changes: 0 additions & 57 deletions query/query.go
Original file line number Diff line number Diff line change
@@ -2489,45 +2489,6 @@ func getPredicatesFromTypes(typeNames []string) []string {
return preds
}

// getReversePredicates queries the schema and returns a list of the reverse
// predicates that exist within the given preds.
func getReversePredicates(ctx context.Context, preds []string) ([]string, error) {
var rpreds []string
predMap := make(map[string]bool)
for _, pred := range preds {
predMap[pred] = true
}

schs, err := worker.GetSchemaOverNetwork(ctx, &pb.SchemaRequest{Predicates: preds})
if err != nil {
return nil, err
}

for _, sch := range schs {
if _, ok := predMap[sch.Predicate]; !ok {
continue
}
if !sch.Reverse {
continue
}
rpreds = append(rpreds, "~"+sch.Predicate)
}
return rpreds, nil
}

// GetAllPredicates returns the list of all the unique predicates present in the list of subgraphs.
func GetAllPredicates(subGraphs []*SubGraph) []string {
predicatesMap := make(map[string]struct{})
for _, sg := range subGraphs {
sg.getAllPredicates(predicatesMap)
}
predicates := make([]string, 0, len(predicatesMap))
for predicate := range predicatesMap {
predicates = append(predicates, predicate)
}
return predicates
}

// filterUidPredicates takes a list of predicates and returns a list of the predicates
// that are of type uid or [uid].
func filterUidPredicates(ctx context.Context, preds []string) ([]string, error) {
@@ -2546,24 +2507,6 @@ func filterUidPredicates(ctx context.Context, preds []string) ([]string, error)
return filteredPreds, nil
}

func (sg *SubGraph) getAllPredicates(predicates map[string]struct{}) {
if len(sg.Attr) != 0 {
predicates[sg.Attr] = struct{}{}
}
for _, o := range sg.Params.Order {
predicates[o.Attr] = struct{}{}
}
for _, pred := range sg.Params.GroupbyAttrs {
predicates[pred.Attr] = struct{}{}
}
for _, filter := range sg.Filters {
filter.getAllPredicates(predicates)
}
for _, child := range sg.Children {
child.getAllPredicates(predicates)
}
}

// UidsToHex converts the new UIDs to hex string.
func UidsToHex(m map[string]uint64) map[string]string {
res := make(map[string]string)
You are viewing a condensed version of this merge commit. You can view the full changes here.