Sitelet https://github.com/objectify/objectify/commit/c96a82d274339781c0730d36346f5e92707a4a5f
Skip to content

Commit c96a82d

Browse files
committed
Add commented-out impl of explain(), which is not yet in the SDK
1 parent d616968 commit c96a82d

4 files changed

Lines changed: 33 additions & 4 deletions

File tree

‎src/main/java/com/googlecode/objectify/cmd/QueryExecute.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ default Stream<T> stream() {
4848
*/
4949
LoadResult<T> first();
5050

51+
// TODO: uncomment when this API lands in the google-cloud-sdk
52+
// /**
53+
// * Convenience method for the default explain options, which plans but does not analyze.
54+
// * https://cloud.google.com/datastore/docs/multiple-range-optimize-indexes
55+
// */
56+
// default ExplainResults<Entity> explain() {
57+
// return explain(ExplainOptions.newBuilder().build());
58+
// }
59+
//
60+
// /**
61+
// * https://cloud.google.com/datastore/docs/multiple-range-optimize-indexes
62+
// */
63+
// ExplainResults<Entity> explain(ExplainOptions options);
64+
5165
/**
5266
* <p>Generates a string that consistently and uniquely specifies this query. There
5367
* is no way to convert this string back into a query and there is no guarantee that

‎src/main/java/com/googlecode/objectify/impl/QueryEngine.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,9 @@ public AggregationResult queryAggregations(final StructuredQuery<?> query, final
117117
final AggregationResults results = ds.runAggregation(aggQuery).get();
118118
return Iterables.getOnlyElement(results);
119119
}
120+
121+
// TODO: uncomment when this API lands in the google-cloud-sdk
122+
// public ExplainResults<Entity> explain(final Query<?> query, final ExplainOptions options) {
123+
// return ds.run(query, options);
124+
// }
120125
}

‎src/main/java/com/googlecode/objectify/impl/QueryImpl.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,12 @@ public List<T> list() {
337337
return ResultProxy.create(List.class, new MakeListResult<>(this.chunk(Integer.MAX_VALUE).iterator()));
338338
}
339339

340+
// TODO: uncomment when this API lands in the google-cloud-sdk
341+
// @Override
342+
// public ExplainResults<Entity> explain(final ExplainOptions options) {
343+
// return loader.createQueryEngine().explain(this.actual, options);
344+
// }
345+
340346
/**
341347
* Get an iterator over the keys. Not part of the public api, but used by QueryKeysImpl. Assumes
342348
* that setKeysOnly() has already been set.

‎src/main/java/com/googlecode/objectify/impl/Queryable.java‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
*
1717
* @author Jeff Schnitzer <jeff@infohazard.org>
1818
*/
19-
abstract class Queryable<T> extends SimpleQueryImpl<T>
20-
{
21-
/**
22-
*/
19+
abstract class Queryable<T> extends SimpleQueryImpl<T> {
20+
2321
Queryable(final LoaderImpl loader) {
2422
super(loader);
2523
}
@@ -60,4 +58,10 @@ public List<T> list() {
6058
return q.list();
6159
}
6260

61+
// TODO uncomment when this api lands in the google-cloud-datastore SDK
62+
// @Override
63+
// public ExplainResults<Entity> explain(final ExplainOptions options) {
64+
// final QueryImpl<T> q = createQuery();
65+
// return q.explain(options);
66+
// }
6367
}

0 commit comments

Comments
 (0)