/** * If the field is an ancestor of the pattern, and if <code>inclusion</code> * is true, returns true. Otherwise, returns null, meaning that whether the * field is included or not cannot be decided. * * @param field The field name * @param pattern The projection pattern * @param inclusion flag to return if the field matches the given pattern * @return TRUE if field is ancestor of the pattern and * <code>inclusion</code> is true, else null */ public static Boolean fieldAncestorOfPattern(Path field, Path pattern, boolean inclusion) { if (field.matchingPrefix(pattern)) { if (inclusion) { return Boolean.TRUE; } else { return null; } } else { return null; } }
/** * If the field is an ancestor of the pattern, and if <code>inclusion</code> * is true, returns true. Otherwise, returns null, meaning that whether the * field is included or not cannot be decided. * * @param field The field name * @param pattern The projection pattern * @param inclusion flag to return if the field matches the given pattern * @return TRUE if field is ancestor of the pattern and * <code>inclusion</code> is true, else null */ public static Boolean fieldAncestorOfPattern(Path field, Path pattern, boolean inclusion) { if (field.matchingPrefix(pattern)) { if (inclusion) { return Boolean.TRUE; } else { return null; } } else { return null; } }
private static boolean isFieldQueried(Path field, Path qField, Path context) { LOGGER.debug("Checking if field {} is included in qfield={} with context={}", field, qField, context); Path absField = context.isEmpty() ? qField : new Path(context, qField); if (field.matchingPrefix(absField)) { LOGGER.debug("Field {} is queried", absField); return true; } else { LOGGER.debug("Field {} is not queried", absField); return false; } }
private static boolean isFieldQueried(Path field, Path qField, Path context) { LOGGER.debug("Checking if field {} is included in qfield={} with context={}", field, qField, context); Path absField = context.isEmpty() ? qField : new Path(context, qField); if (field.matchingPrefix(absField)) { LOGGER.debug("Field {} is queried", absField); return true; } else { LOGGER.debug("Field {} is not queried", absField); return false; } }
private static boolean isRequired(Path field, SortKey sort, Path ctx) { Path absField = new Path(ctx, field); return sort.getField().matchingPrefix(absField); } }
private static boolean isRequired(Path field, SortKey sort, Path ctx) { Path absField = new Path(ctx, field); return sort.getField().matchingPrefix(absField); } }
private Path removeContext(Path context, Path p, Path original) { if (context.isEmpty()) { return p; } else if (context.matchingPrefix(p)) { return p.suffix(-context.numSegments()); } else { return original; } } }
private Path toRelative(Path field, Path context) { Path abs = context.isEmpty() ? field : new Path(context, field); if (relativeTo.matchingPrefix(abs)) { return abs.suffix(-relativeTo.numSegments()); } else { throw new IllegalArgumentException("Cannot write " + abs + " relative to " + relativeTo); } } }
private Path toRelative(Path field, Path context) { Path abs = context.isEmpty() ? field : new Path(context, field); if (relativeTo.matchingPrefix(abs)) { return abs.suffix(-relativeTo.numSegments()); } else { throw new IllegalArgumentException("Cannot write " + abs + " relative to " + relativeTo); } } }
private Path removeContext(Path context, Path p, Path original) { if (context.isEmpty()) { return p; } else if (context.matchingPrefix(p)) { return p.suffix(-context.numSegments()); } else { return original; } } }
@Override public Boolean project(Path p, QueryEvaluationContext ctx) { decidingProjector=null; lastMatch = false; if (p.matchingPrefix(arrayFieldPattern)) { decidingProjector=this; return include ? Boolean.TRUE : Boolean.FALSE; } // Is this field pointing to an element of the array // It is so if 'p' has one more element than 'arrayFieldPattern', and // if it is a matching descendant if (p.numSegments() == arrayFieldPattern.numSegments() + 1 && p.matchingDescendant(arrayFieldPattern)) { Boolean ret=projectArray(p, ctx); if(ret!=null&&nestedProjector!=null) { decidingProjector=nestedProjector.getDecidingProjector(); } return ret; } return null; }
@Override public Projection.Inclusion project(Path p, QueryEvaluationContext ctx) { if (p.matchingPrefix(field)) { // If this is true, we're checking an ancestor of the // projection field, or the projection field itself, but // not a field that is a descendant of the projection // field if (include) { return Projection.Inclusion.explicit_inclusion; // Inclusion implies, because if we're going to // include a descendant of this field, this field // should also be included } else if (p.matches(field)) { return Projection.Inclusion.explicit_exclusion; // If this field is exclusively excluded, exclude it } // Otherwise, this projection does not tell anything about this particular field. } else if (recursive && // If this is a recursive projection p.numSegments() > field.numSegments() && // If we're checking a field deeper than our field p.prefix(field.numSegments()).matches(field) // And if we're checking a field under the subtree of our field ) { // This is an implied inclusion or exclusion, because the // projection is for an ancestor of this field. return include ? Projection.Inclusion.implicit_inclusion : Projection.Inclusion.implicit_exclusion; } return Projection.Inclusion.undecided; } }
@Override public Projection.Inclusion project(Path p, QueryEvaluationContext ctx) { if (p.matchingPrefix(field)) { // If this is true, we're checking an ancestor of the // projection field, or the projection field itself, but // not a field that is a descendant of the projection // field if (include) { return Projection.Inclusion.explicit_inclusion; // Inclusion implies, because if we're going to // include a descendant of this field, this field // should also be included } else if (p.matches(field)) { return Projection.Inclusion.explicit_exclusion; // If this field is exclusively excluded, exclude it } // Otherwise, this projection does not tell anything about this particular field. } else if (recursive && // If this is a recursive projection p.numSegments() > field.numSegments() && // If we're checking a field deeper than our field p.prefix(field.numSegments()).matches(field) // And if we're checking a field under the subtree of our field ) { // This is an implied inclusion or exclusion, because the // projection is for an ancestor of this field. return include ? Projection.Inclusion.implicit_inclusion : Projection.Inclusion.implicit_exclusion; } return Projection.Inclusion.undecided; } }
exactMatch=false; decidingProjector=null; if (p.matchingPrefix(field)) {