/** * Returns the same QueryPlus object with the identity replaced. This new identity will affect future calls to * {@link #withoutQueryMetrics()} but will not affect any currently-existing queryMetrics. */ public QueryPlus<T> withIdentity(String identity) { return new QueryPlus<>(query, queryMetrics, identity); }
/** * Returns a QueryPlus object with {@link QueryMetrics} from this QueryPlus object, and the provided {@link Query}. */ public <U> QueryPlus<U> withQuery(Query<U> replacementQuery) { return new QueryPlus<>(replacementQuery, queryMetrics, identity); }
/** * Returns the same QueryPlus object, if it doesn't have {@link QueryMetrics} ({@link #getQueryMetrics()} returns * null), or returns a new QueryPlus object with {@link Query} from this QueryPlus and null as QueryMetrics. */ private QueryPlus<T> withoutQueryMetrics() { if (queryMetrics == null) { return this; } else { return new QueryPlus<>(query, null, identity); } }
/** * Returns the minimum bare QueryPlus object with the given query. {@link #getQueryMetrics()} of the QueryPlus object, * returned from this factory method, returns {@code null}. */ public static <T> QueryPlus<T> wrap(Query<T> query) { Preconditions.checkNotNull(query); return new QueryPlus<>(query, null, null); }
/** * Equivalent of withQuery(getQuery().withQuerySegmentSpec(spec)). */ public QueryPlus<T> withQuerySegmentSpec(QuerySegmentSpec spec) { return new QueryPlus<>(query.withQuerySegmentSpec(spec), queryMetrics, identity); }
/** * Equivalent of withQuery(getQuery().withOverriddenContext(ImmutableMap.of(MAX_QUEUED_BYTES_KEY, maxQueuedBytes))). */ public QueryPlus<T> withMaxQueuedBytes(long maxQueuedBytes) { return new QueryPlus<>( query.withOverriddenContext(ImmutableMap.of(QueryContexts.MAX_QUEUED_BYTES_KEY, maxQueuedBytes)), queryMetrics, identity ); }
public QueryPlus<T> optimizeForSegment(PerSegmentQueryOptimizationContext optimizationContext) { return new QueryPlus<>(query.optimizeForSegment(optimizationContext), queryMetrics, identity); } }
/** * Returns the same QueryPlus object, if it already has {@link QueryMetrics} ({@link #getQueryMetrics()} returns not * null), or returns a new QueryPlus object with {@link Query} from this QueryPlus and QueryMetrics created using the * given {@link QueryToolChest}, via {@link QueryToolChest#makeMetrics(Query)} method. * * By convention, callers of {@code withQueryMetrics()} must also call .getQueryMetrics().emit() on the returned * QueryMetrics object, regardless if this object is the same as the object on which .withQueryMetrics() was initially * called (i. e. it already had non-null QueryMetrics), or if it is a new QueryPlus object. See {@link * MetricsEmittingQueryRunner} for example. */ public QueryPlus<T> withQueryMetrics(QueryToolChest<T, ? extends Query<T>> queryToolChest) { if (queryMetrics != null) { return this; } else { final QueryMetrics metrics = ((QueryToolChest) queryToolChest).makeMetrics(query); if (identity != null) { metrics.identity(identity); } return new QueryPlus<>(query, metrics, identity); } }
/** * Returns a QueryPlus object with {@link QueryMetrics} from this QueryPlus object, and the provided {@link Query}. */ public <U> QueryPlus<U> withQuery(Query<U> replacementQuery) { return new QueryPlus<>(replacementQuery, queryMetrics, identity); }
/** * Returns the same QueryPlus object with the identity replaced. This new identity will affect future calls to * {@link #withoutQueryMetrics()} but will not affect any currently-existing queryMetrics. */ public QueryPlus<T> withIdentity(String identity) { return new QueryPlus<>(query, queryMetrics, identity); }
/** * Returns the same QueryPlus object, if it doesn't have {@link QueryMetrics} ({@link #getQueryMetrics()} returns * null), or returns a new QueryPlus object with {@link Query} from this QueryPlus and null as QueryMetrics. */ private QueryPlus<T> withoutQueryMetrics() { if (queryMetrics == null) { return this; } else { return new QueryPlus<>(query, null, identity); } }
/** * Returns the minimum bare QueryPlus object with the given query. {@link #getQueryMetrics()} of the QueryPlus object, * returned from this factory method, returns {@code null}. */ public static <T> QueryPlus<T> wrap(Query<T> query) { Preconditions.checkNotNull(query); return new QueryPlus<>(query, null, null); }
/** * Equivalent of withQuery(getQuery().withQuerySegmentSpec(spec)). */ public QueryPlus<T> withQuerySegmentSpec(QuerySegmentSpec spec) { return new QueryPlus<>(query.withQuerySegmentSpec(spec), queryMetrics, identity); }
/** * Equivalent of withQuery(getQuery().withOverriddenContext(ImmutableMap.of(MAX_QUEUED_BYTES_KEY, maxQueuedBytes))). */ public QueryPlus<T> withMaxQueuedBytes(long maxQueuedBytes) { return new QueryPlus<>( query.withOverriddenContext(ImmutableMap.of(QueryContexts.MAX_QUEUED_BYTES_KEY, maxQueuedBytes)), queryMetrics, identity ); }
public QueryPlus<T> optimizeForSegment(PerSegmentQueryOptimizationContext optimizationContext) { return new QueryPlus<>(query.optimizeForSegment(optimizationContext), queryMetrics, identity); } }
/** * Returns the same QueryPlus object, if it already has {@link QueryMetrics} ({@link #getQueryMetrics()} returns not * null), or returns a new QueryPlus object with {@link Query} from this QueryPlus and QueryMetrics created using the * given {@link QueryToolChest}, via {@link QueryToolChest#makeMetrics(Query)} method. * * By convention, callers of {@code withQueryMetrics()} must also call .getQueryMetrics().emit() on the returned * QueryMetrics object, regardless if this object is the same as the object on which .withQueryMetrics() was initially * called (i. e. it already had non-null QueryMetrics), or if it is a new QueryPlus object. See {@link * MetricsEmittingQueryRunner} for example. */ public QueryPlus<T> withQueryMetrics(QueryToolChest<T, ? extends Query<T>> queryToolChest) { if (queryMetrics != null) { return this; } else { final QueryMetrics metrics = ((QueryToolChest) queryToolChest).makeMetrics(query); if (identity != null) { metrics.identity(identity); } return new QueryPlus<>(query, metrics, identity); } }