public static GremlinPipeline optimizePipelineForQuery(final GremlinPipeline pipeline, final Pipe pipe) { if (!optimizePipelineForGraphQuery(pipeline, pipe)) if (!optimizePipelineForVertexQuery(pipeline, pipe)) pipeline.addPipe(pipe); return pipeline; }
/** * Add an IntervalFilterPipe to the end of the Pipeline. * If the incoming element has a value that is within the interval value range specified, then the element is allows to pass. * If hte incoming element's value for the key is null, the element is filtered. * * @param key the property key to check * @param startValue the start of the interval (inclusive) * @param endValue the end of the interval (exclusive) * @return the extended Pipeline */ public GremlinPipeline<S, ? extends Element> interval(final String key, final Comparable startValue, final Comparable endValue) { final Pipe pipe = new IntervalFilterPipe<Element>(key, startValue, endValue); return this.doQueryOptimization ? GremlinFluentUtility.optimizePipelineForQuery(this, pipe) : this.add(pipe); }
/** * Add a RageFilterPipe to the end of the Pipeline. * Analogous to a high/low index lookup. * * @param low the low end of the range * @param high the high end of the range * @return the extended Pipeline */ public GremlinPipeline<S, E> range(final int low, final int high) { final Pipe pipe = new RangeFilterPipe<E>(low, high); if (!this.doQueryOptimization) return this.add(pipe); else { return GremlinFluentUtility.optimizePipelineForQuery(this, pipe); } }
/** * Add an IdFilterPipe, LabelFilterPipe, or PropertyFilterPipe to the end of the Pipeline. * If the incoming element has the provided key/value as check with .equals(), then let the element pass. * If the key is id or label, then use respect id or label filtering. * * @param key the property key to check * @param predicate the comparison to use * @param value the object to filter on * @return the extended Pipeline */ public GremlinPipeline<S, ? extends Element> has(final String key, final Predicate predicate, final Object value) { if (key.equals(Tokens.ID)) { return this.add(new IdFilterPipe(predicate, value)); } else if (key.equals(Tokens.LABEL)) { return this.add(new LabelFilterPipe(predicate, value)); } else { final Pipe pipe = new PropertyFilterPipe(key, predicate, value); return this.doQueryOptimization ? GremlinFluentUtility.optimizePipelineForQuery(this, pipe) : this.add(pipe); } }