From 1d5c27b7f4656dbe96e93a869ced01f000fd9941 Mon Sep 17 00:00:00 2001 From: Alexey Shtele Date: Sun, 7 Aug 2022 16:38:28 +0400 Subject: [PATCH] Add Query.reqTotal Closes gh-93 --- .../ru/rt/restream/reindexer/Namespace.java | 6 +-- .../java/ru/rt/restream/reindexer/Query.java | 28 ++++++++--- .../restream/reindexer/QueryLogBuilder.java | 11 ++++ .../reindexer/QueryResultIterator.java | 7 ++- .../reindexer/QueryResultJsonIterator.java | 7 ++- .../reindexer/ReindexerNamespace.java | 2 +- ...eableIterator.java => ResultIterator.java} | 7 ++- .../reindexer/connector/AggregationTest.java | 14 +++--- .../reindexer/connector/JoinTest.java | 50 +++++++++---------- .../reindexer/connector/ReindexerTest.java | 23 +++++---- 10 files changed, 99 insertions(+), 56 deletions(-) rename src/main/java/ru/rt/restream/reindexer/{CloseableIterator.java => ResultIterator.java} (84%) diff --git a/src/main/java/ru/rt/restream/reindexer/Namespace.java b/src/main/java/ru/rt/restream/reindexer/Namespace.java index 9b6039c1..dcb56790 100644 --- a/src/main/java/ru/rt/restream/reindexer/Namespace.java +++ b/src/main/java/ru/rt/restream/reindexer/Namespace.java @@ -111,12 +111,12 @@ public interface Namespace { String getMeta(String key); /** - * Executes the given SQL query and returns a {@link CloseableIterator}. + * Executes the given SQL query and returns a {@link ResultIterator}. * * @param query the SQL query to execute - * @return the {@link CloseableIterator} to use + * @return the {@link ResultIterator} to use */ - CloseableIterator execSql(String query); + ResultIterator execSql(String query); /** * Executes the given SQL update query. diff --git a/src/main/java/ru/rt/restream/reindexer/Query.java b/src/main/java/ru/rt/restream/reindexer/Query.java index 2f44792c..8fd9cb63 100644 --- a/src/main/java/ru/rt/restream/reindexer/Query.java +++ b/src/main/java/ru/rt/restream/reindexer/Query.java @@ -47,6 +47,7 @@ import static ru.rt.restream.reindexer.binding.Consts.INNER_JOIN; import static ru.rt.restream.reindexer.binding.Consts.LEFT_JOIN; import static ru.rt.restream.reindexer.binding.Consts.MERGE; +import static ru.rt.restream.reindexer.binding.Consts.MODE_ACCURATE_TOTAL; import static ru.rt.restream.reindexer.binding.Consts.OR_INNER_JOIN; import static ru.rt.restream.reindexer.binding.Consts.VALUE_BOOL; import static ru.rt.restream.reindexer.binding.Consts.VALUE_NULL; @@ -611,6 +612,19 @@ public AggregationFacetRequest sort(String field, boolean desc) { } + + /** + * Calculate the total count of matching documents. + * + * @return the {@link Query} for further customizations + */ + public Query reqTotal() { + logBuilder.reqTotal(); + buffer.putVarUInt32(QUERY_REQ_TOTAL) + .putVarUInt32(MODE_ACCURATE_TOTAL); + return this; + } + /** * Limit is used to retrieve records from the namespace in a database and limit the number of items returned based * on a limit value @@ -736,7 +750,7 @@ private void putValue(Object value) { * @return stream of items */ public Stream stream() { - CloseableIterator iterator = execute(); + ResultIterator iterator = execute(); Spliterator spliterator = Spliterators.spliterator(iterator, iterator.size(), Spliterator.NONNULL); return StreamSupport.stream(spliterator, false).onClose(iterator::close); } @@ -747,7 +761,7 @@ public Stream stream() { * @return list of items */ public List toList() { - try (CloseableIterator iterator = execute()) { + try (ResultIterator iterator = execute()) { List result = new ArrayList<>(); while (iterator.hasNext()) { result.add(iterator.next()); @@ -784,7 +798,7 @@ public Optional findOne() { } private T getOneInternal() { - try (CloseableIterator iterator = execute()) { + try (ResultIterator iterator = execute()) { T item = null; if (iterator.hasNext()) { item = iterator.next(); @@ -804,7 +818,7 @@ private T getOneInternal() { * @return count of items */ public long count() { - try (CloseableIterator iterator = execute()) { + try (ResultIterator iterator = execute()) { return iterator.size(); } } @@ -824,7 +838,7 @@ public boolean notExists() { * @return true if the item exists */ public boolean exists() { - try (CloseableIterator iterator = execute()) { + try (ResultIterator iterator = execute()) { return iterator.hasNext(); } } @@ -834,7 +848,7 @@ public boolean exists() { * * @return an iterator over a query result */ - public CloseableIterator execute() { + public ResultIterator execute() { return execute(namespace.getItemClass()); } @@ -845,7 +859,7 @@ public CloseableIterator execute() { * @param itemClass the item class * @return an iterator over a query result */ - public CloseableIterator execute(Class itemClass) { + public ResultIterator execute(Class itemClass) { long[] ptVersions = prepareQueryAndGetPayloadTypesVersions(); RequestContext requestContext = transactionContext != null diff --git a/src/main/java/ru/rt/restream/reindexer/QueryLogBuilder.java b/src/main/java/ru/rt/restream/reindexer/QueryLogBuilder.java index e4eb49d3..fbae4469 100644 --- a/src/main/java/ru/rt/restream/reindexer/QueryLogBuilder.java +++ b/src/main/java/ru/rt/restream/reindexer/QueryLogBuilder.java @@ -34,6 +34,7 @@ class QueryLogBuilder { private String namespace; private QueryType type = QueryType.SELECT; + private boolean reqTotal; private Integer offset; private Integer limit; private final Map.AggregationFacetRequest, AggregateEntry> facetParams = new HashMap<>(); @@ -140,6 +141,9 @@ String getSql() { stringBuilder.append(" ") .append(getSelectPart()); } + if (reqTotal) { + stringBuilder.append(", COUNT(*)"); + } stringBuilder.append(" FROM"); } @@ -416,6 +420,13 @@ void facetSort(Query.AggregationFacetRequest facet, String sortIndex, boolean facetParams.get(facet).sortEntries.add(sortEntry); } + /** + * Set flag of request of total count of items. + */ + void reqTotal() { + this.reqTotal = true; + } + /** * Add query offset to builder. * diff --git a/src/main/java/ru/rt/restream/reindexer/QueryResultIterator.java b/src/main/java/ru/rt/restream/reindexer/QueryResultIterator.java index b930193e..95a73a36 100644 --- a/src/main/java/ru/rt/restream/reindexer/QueryResultIterator.java +++ b/src/main/java/ru/rt/restream/reindexer/QueryResultIterator.java @@ -39,7 +39,7 @@ * An iterator over a query result. * Maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. */ -public class QueryResultIterator implements CloseableIterator { +public class QueryResultIterator implements ResultIterator { private static final Logger LOGGER = LoggerFactory.getLogger(QueryResultIterator.class); @@ -269,6 +269,11 @@ private void fetchResults() { parseQueryResult(queryResult); } + @Override + public long getTotalCount() { + return queryResult.getTotalCount(); + } + @Override public long size() { return queryResult.getQCount(); diff --git a/src/main/java/ru/rt/restream/reindexer/QueryResultJsonIterator.java b/src/main/java/ru/rt/restream/reindexer/QueryResultJsonIterator.java index ec954f59..a6d3c18b 100644 --- a/src/main/java/ru/rt/restream/reindexer/QueryResultJsonIterator.java +++ b/src/main/java/ru/rt/restream/reindexer/QueryResultJsonIterator.java @@ -22,7 +22,7 @@ import java.nio.charset.StandardCharsets; import java.util.List; -public class QueryResultJsonIterator implements CloseableIterator { +public class QueryResultJsonIterator implements ResultIterator { private final RequestContext requestContext; @@ -113,6 +113,11 @@ public String fetchAll(String rootName) { return builder.toString(); } + @Override + public long getTotalCount() { + return queryResult.getTotalCount(); + } + @Override public long size() { return queryResult.getQCount(); diff --git a/src/main/java/ru/rt/restream/reindexer/ReindexerNamespace.java b/src/main/java/ru/rt/restream/reindexer/ReindexerNamespace.java index 9b96337f..01e01318 100644 --- a/src/main/java/ru/rt/restream/reindexer/ReindexerNamespace.java +++ b/src/main/java/ru/rt/restream/reindexer/ReindexerNamespace.java @@ -250,7 +250,7 @@ public String getMeta(String key) { } @Override - public CloseableIterator execSql(String query) { + public ResultIterator execSql(String query) { return reindexer.execSql(query, itemClass); } diff --git a/src/main/java/ru/rt/restream/reindexer/CloseableIterator.java b/src/main/java/ru/rt/restream/reindexer/ResultIterator.java similarity index 84% rename from src/main/java/ru/rt/restream/reindexer/CloseableIterator.java rename to src/main/java/ru/rt/restream/reindexer/ResultIterator.java index 3dcea97c..628ba0c8 100644 --- a/src/main/java/ru/rt/restream/reindexer/CloseableIterator.java +++ b/src/main/java/ru/rt/restream/reindexer/ResultIterator.java @@ -25,7 +25,12 @@ * @see Iterator * @see AutoCloseable */ -public interface CloseableIterator extends Iterator, AutoCloseable { +public interface ResultIterator extends Iterator, AutoCloseable { + + /** + * Return the total count of matching documents, if {@link Query} has set reqTotal() flag, else return 0. + */ + long getTotalCount(); /** * Returns the iterator size. diff --git a/src/test/java/ru/rt/restream/reindexer/connector/AggregationTest.java b/src/test/java/ru/rt/restream/reindexer/connector/AggregationTest.java index eb2f1ee4..615d9571 100644 --- a/src/test/java/ru/rt/restream/reindexer/connector/AggregationTest.java +++ b/src/test/java/ru/rt/restream/reindexer/connector/AggregationTest.java @@ -17,7 +17,7 @@ import org.junit.jupiter.api.Test; import ru.rt.restream.reindexer.AggregationResult; -import ru.rt.restream.reindexer.CloseableIterator; +import ru.rt.restream.reindexer.ResultIterator; import ru.rt.restream.reindexer.Namespace; import ru.rt.restream.reindexer.NamespaceOptions; import ru.rt.restream.reindexer.Query; @@ -48,7 +48,7 @@ public void testDistinct() { itemNamespace.insert(item); } - CloseableIterator result = itemNamespace.query() + ResultIterator result = itemNamespace.query() .aggregateDistinct("name") .execute(); AggregationResult aggResult = result.aggResults().get(0); @@ -72,7 +72,7 @@ public void testSum() { Query query = itemNamespace.query() .aggregateSum("price"); - CloseableIterator result = query.execute(); + ResultIterator result = query.execute(); AggregationResult sumResult = result.aggResults().get(0); assertThat(sumResult.getValue(), is(499500D)); } @@ -91,7 +91,7 @@ public void testAvg() { Query query = itemNamespace.query() .aggregateAvg("price"); query.aggregateFacet("id", "price").sort("id", true).offset(10).limit(100); - CloseableIterator result = query.execute(); + ResultIterator result = query.execute(); AggregationResult avgResult = result.aggResults().get(0); assertThat(avgResult.getValue(), is(499.5D)); } @@ -109,7 +109,7 @@ public void testMax() { Query query = itemNamespace.query() .aggregateMax("price"); - CloseableIterator result = query.execute(); + ResultIterator result = query.execute(); AggregationResult maxResult = result.aggResults().get(0); assertThat(maxResult.getValue(), is(999D)); } @@ -127,7 +127,7 @@ public void testMin() { Query query = itemNamespace.query() .aggregateMin("price"); - CloseableIterator result = query.execute(); + ResultIterator result = query.execute(); AggregationResult minResult = result.aggResults().get(0); assertThat(minResult.getValue(), is(0D)); } @@ -146,7 +146,7 @@ public void testFacet() { Query query = itemNamespace.query(); query.aggregateFacet("name", "price").sort("name", true).sort("price", false).limit(100); - CloseableIterator result = query.execute(); + ResultIterator result = query.execute(); AggregationResult aggResult = result.aggResults().get(0); List facets = aggResult.getFacets(); diff --git a/src/test/java/ru/rt/restream/reindexer/connector/JoinTest.java b/src/test/java/ru/rt/restream/reindexer/connector/JoinTest.java index a09efc91..0870d364 100644 --- a/src/test/java/ru/rt/restream/reindexer/connector/JoinTest.java +++ b/src/test/java/ru/rt/restream/reindexer/connector/JoinTest.java @@ -20,7 +20,7 @@ import com.google.gson.JsonParser; import com.google.gson.annotations.SerializedName; import org.junit.jupiter.api.Test; -import ru.rt.restream.reindexer.CloseableIterator; +import ru.rt.restream.reindexer.ResultIterator; import ru.rt.restream.reindexer.NamespaceOptions; import ru.rt.restream.reindexer.QueryResultJsonIterator; import ru.rt.restream.reindexer.Query; @@ -65,7 +65,7 @@ public void testJoinToManyExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .join(db.query("actors", Actor.class) .on("actorsIds", Query.Condition.SET, "id"), "joinedActors") .execute(); @@ -101,7 +101,7 @@ public void testJoinToManyNotExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .join(db.query("actors", Actor.class) .on("actorsIds", Query.Condition.SET, "id"), "joinedActors") .execute(); @@ -129,7 +129,7 @@ public void testJoinToManyWithFilterExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .join(db.query("actors", Actor.class).where("is_visible", EQ, true) .on("actorsIds", Query.Condition.SET, "id"), "joinedActors") .execute(); @@ -164,7 +164,7 @@ public void testJoinToManyWithFilterNotExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .join(db.query("actors", Actor.class).where("is_visible", EQ, true) .on("actorsIds", Query.Condition.SET, "id"), "joinedActors") .execute(); @@ -191,7 +191,7 @@ public void testLeftJoinToManyExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .leftJoin(db.query("actors", Actor.class) .on("actorsIds", Query.Condition.SET, "id"), "joinedActors") .execute(); @@ -226,7 +226,7 @@ public void testLeftJoinToManyNotExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .leftJoin(db.query("actors", Actor.class) .on("actorsIds", Query.Condition.SET, "id"), "joinedActors") .execute(); @@ -257,7 +257,7 @@ public void testLeftJoinToManyWithFilterExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .leftJoin(db.query("actors", Actor.class) .where("is_visible", EQ, true) .on("actorsIds", Query.Condition.SET, "id"), "joinedActors") @@ -293,7 +293,7 @@ public void testLeftJoinToManyWithFilterNotExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .leftJoin(db.query("actors", Actor.class) .where("is_visible", EQ, true) .on("actorsIds", Query.Condition.SET, "id"), "joinedActors") @@ -324,7 +324,7 @@ public void testJoinToOneExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .join(db.query("actors", Actor.class) .on("actorName", Query.Condition.EQ, "name"), "joinedActor") .execute(); @@ -357,7 +357,7 @@ public void testJoinToOneNotExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .join(db.query("actors", Actor.class) .on("actorsIds", Query.Condition.SET, "id"), "joinedActor") .execute(); @@ -383,7 +383,7 @@ public void testJoinToOneWithFilterExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .join(db.query("actors", Actor.class) .where("is_visible", EQ, true) .on("actorName", Query.Condition.SET, "name"), "joinedActor") @@ -415,7 +415,7 @@ public void testJoinToOneWithFilterNotExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .join(db.query("actors", Actor.class) .where("is_visible", EQ, true) .on("actorName", Query.Condition.SET, "name"), "joinedActor") @@ -442,7 +442,7 @@ public void testLeftJoinToOneExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .leftJoin(db.query("actors", Actor.class) .on("actorName", Query.Condition.SET, "name"), "joinedActor") .execute(); @@ -474,7 +474,7 @@ public void testLeftJoinToOneNotExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .leftJoin(db.query("actors", Actor.class) .on("actorName", Query.Condition.SET, "name"), "joinedActor") .execute(); @@ -504,7 +504,7 @@ public void testLeftJoinToOneWithFilterExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .leftJoin(db.query("actors", Actor.class) .where("is_visible", EQ, true) .on("actorName", Query.Condition.SET, "name"), "joinedActor") @@ -537,7 +537,7 @@ public void testLeftJoinToOneWithFilterNotExists() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .leftJoin(db.query("actors", Actor.class) .where("is_visible", EQ, true) .on("actorName", Query.Condition.SET, "name"), "joinedActors") @@ -574,7 +574,7 @@ public void testMultipleJoinsExists() { db.upsert("actors", actorById); db.upsert("actors", actorByName); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .join(db.query("actors", Actor.class) .on("actorsIds", Query.Condition.SET, "id"), "joinedActors") .join(db.query("actors", Actor.class) @@ -621,7 +621,7 @@ public void testMultipleJoinsNotExists() { db.upsert("actors", actorById); db.upsert("actors", actorByName); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .join(db.query("actors", Actor.class) .on("actorsIds", Query.Condition.SET, "id"), "joinedActors") .join(db.query("actors", Actor.class) @@ -656,7 +656,7 @@ public void testJoinOnMultipleConditions() { db.upsert("actors", actorById); db.upsert("actors", actorByName); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .join(db.query("actors", Actor.class) .on("actorsIds", Query.Condition.SET, "id") .on("actorName", Query.Condition.SET, "name"), "joinedActors") @@ -697,7 +697,7 @@ public void testJoinOnMultipleConditionsWithOrExists() { db.upsert("actors", actorById); db.upsert("actors", actorByName); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .join(db.query("actors", Actor.class) .on("actorsIds", Query.Condition.SET, "id") .or() @@ -752,7 +752,7 @@ public void testJoinInWherePart() { db.upsert("actors", actorById); db.upsert("actors", actorByName); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .where("id", RANGE, 0, 100) .or() .innerJoin(db.query("actors", Actor.class) @@ -819,7 +819,7 @@ public void testJoinInWherePartWithBrackets() { db.upsert("actors", actorById); db.upsert("actors", actorByName); - CloseableIterator items = db.query("items_with_join", ItemWithJoin.class) + ResultIterator items = db.query("items_with_join", ItemWithJoin.class) .where("id", RANGE, 0, 100) .or() .openBracket() @@ -859,7 +859,7 @@ public void testExecSqlWithJoinForOne() { db.upsert("items_with_join", itemWithJoin); db.upsert("actors", actor); - CloseableIterator items = db.execSql( + ResultIterator items = db.execSql( "SELECT * FROM items_with_join INNER JOIN actors ON items_with_join.actorName = actors.name", ItemWithJoin.class ); @@ -896,7 +896,7 @@ public void testExecSqlWithJoinForList() { db.upsert("actors", actor); } - CloseableIterator items = db.execSql( + ResultIterator items = db.execSql( "SELECT * FROM items_with_join INNER JOIN actors ON items_with_join.actorName = actors.name", ItemWithJoin.class ); diff --git a/src/test/java/ru/rt/restream/reindexer/connector/ReindexerTest.java b/src/test/java/ru/rt/restream/reindexer/connector/ReindexerTest.java index f082826c..5ed33584 100644 --- a/src/test/java/ru/rt/restream/reindexer/connector/ReindexerTest.java +++ b/src/test/java/ru/rt/restream/reindexer/connector/ReindexerTest.java @@ -17,7 +17,7 @@ import com.google.gson.Gson; import org.junit.jupiter.api.Test; -import ru.rt.restream.reindexer.CloseableIterator; +import ru.rt.restream.reindexer.ResultIterator; import ru.rt.restream.reindexer.Namespace; import ru.rt.restream.reindexer.NamespaceOptions; import ru.rt.restream.reindexer.QueryResultJsonIterator; @@ -708,7 +708,7 @@ public void testSelectItemWithLimit() { } @Test - public void testSelectItemWithOffset() { + public void testSelectItemWithOffsetAndReqTotal() { String namespaceName = "items"; db.openNamespace(namespaceName, NamespaceOptions.defaultOptions(), TestItem.class); @@ -722,10 +722,13 @@ public void testSelectItemWithOffset() { expectedItems.add(testItem); } - Iterator iterator = db.query("items", TestItem.class) + ResultIterator iterator = db.query("items", TestItem.class) .offset(50) + .reqTotal() .execute(); + assertThat(iterator.getTotalCount(), is(100L)); + while (iterator.hasNext()) { TestItem responseItem = iterator.next(); assertThat(expectedItems.remove(responseItem), is(true)); @@ -1092,7 +1095,7 @@ public void testInsertItemWithDoubleValue() { db.upsert(namespaceName, testItem); } - CloseableIterator execute = db.query("items", TestItem.class) + ResultIterator execute = db.query("items", TestItem.class) .where("id", EQ, 77) .execute(); @@ -1115,7 +1118,7 @@ public void testUpdateItemDoubleValue() { .set("doubleValue", 123.123D) .update(); - CloseableIterator items = db.query("items", TestItem.class) + ResultIterator items = db.query("items", TestItem.class) .where("id", EQ, 77) .execute(); @@ -2419,7 +2422,7 @@ public void testExecSqlForOne() { testItem.setNonIndex("testNonIndex"); db.insert(namespaceName, testItem); - CloseableIterator iterator = db.execSql("SELECT * FROM items WHERE id = 123", + ResultIterator iterator = db.execSql("SELECT * FROM items WHERE id = 123", TestItem.class); TestItem result = iterator.next(); assertThat(result.getId(), is(testItem.getId())); @@ -2443,7 +2446,7 @@ public void testExecSqlForList() { expectedItems.add(testItem); } - CloseableIterator iterator = db.execSql("SELECT * FROM items", + ResultIterator iterator = db.execSql("SELECT * FROM items", TestItem.class); while (iterator.hasNext()) { @@ -2505,7 +2508,7 @@ public void testNamespaceExecSqlForOne() { testItem.setName("TestName"); testItem.setNonIndex("testNonIndex"); ns.insert(testItem); - CloseableIterator iterator = ns.execSql("SELECT * FROM items WHERE id = 123"); + ResultIterator iterator = ns.execSql("SELECT * FROM items WHERE id = 123"); TestItem result = iterator.next(); assertThat(result.getId(), is(testItem.getId())); assertThat(result.getName(), is(testItem.getName())); @@ -2525,7 +2528,7 @@ public void testNamespaceExecSqlForList() { ns.upsert(testItem); expectedItems.add(testItem); } - CloseableIterator iterator = ns.execSql("SELECT * FROM items"); + ResultIterator iterator = ns.execSql("SELECT * FROM items"); while (iterator.hasNext()) { TestItem responseItem = iterator.next(); assertThat(expectedItems.remove(responseItem), is(true)); @@ -2647,7 +2650,7 @@ public void testQuerySelectId() { testItem.setName("TestName"); testItem.setNonIndex("testNonIndex"); ns.insert(testItem); - CloseableIterator it = ns.query() + ResultIterator it = ns.query() .select("id") .where("id", EQ, 123) .execute(TestItemId.class);