@Test public void maxExpirationTimeForGroupByQuery() throws Throwable { setUpHost(false); Query query = Query.Builder.create() .addFieldClause(ServiceDocument.FIELD_NAME_KIND, Utils.buildKind(ExampleServiceState.class)) .build(); // create a group by paginated query with MAX expiration time QueryTask queryTask = QueryTask.Builder.createDirectTask() .addOption(QueryOption.GROUP_BY) .setGroupResultLimit(10) .orderAscending(ExampleServiceState.FIELD_NAME_ID, TypeName.STRING) .groupOrder(ExampleServiceState.FIELD_NAME_NAME, TypeName.STRING, SortOrder.ASC) .setQuery(query).build(); queryTask.documentExpirationTimeMicros = Long.MAX_VALUE; this.host.createQueryTaskService(queryTask, false, true, queryTask, null); assertThat(this.indexService.getPaginatedSearchersByExpirationTime()) .hasSize(1) .containsOnlyKeys(Long.MAX_VALUE); }
private void verifyGroupQueryPaginatedAcrossGroups(VerificationHost targetHost, List<String> groups) throws Throwable { Query query = Query.Builder.create() .addKindFieldClause(ExampleServiceState.class) .build(); // two pagination across two dimensions: number of groups, and documents per group QueryTask queryTask = QueryTask.Builder.create() .addOption(QueryOption.GROUP_BY) .addOption(QueryOption.EXPAND_CONTENT) .setResultLimit(this.serviceCount / 5) .setGroupResultLimit(2) .orderAscending(ExampleServiceState.FIELD_NAME_ID, TypeName.STRING) .groupOrder(ExampleServiceState.FIELD_NAME_NAME, TypeName.STRING, SortOrder.ASC) .setQuery(query).build(); URI queryTaskURI = this.host.createQueryTaskService(queryTask); QueryTask finalState = this.host.waitForQueryTask(queryTaskURI, TaskStage.FINISHED); int expectedCountPerPage = queryTask.querySpec.resultLimit; validateGroupByResults(targetHost, groups, null, finalState, null, expectedCountPerPage); }
private void verifyNumericGroupQueryPaginatedAcrossGroups(VerificationHost targetHost, List<Long> groups) throws Throwable { Query query = Query.Builder.create() .addKindFieldClause(ExampleServiceState.class) .build(); // two pagination across two dimensions: number of groups, and documents per group QueryTask queryTask = QueryTask.Builder.create() .addOption(QueryOption.GROUP_BY) .addOption(QueryOption.EXPAND_CONTENT) .setResultLimit(this.serviceCount / 5) .setGroupResultLimit(2) .orderAscending(ExampleServiceState.FIELD_NAME_NAME, TypeName.STRING) .groupOrder(ExampleServiceState.FIELD_NAME_SORTED_COUNTER, TypeName.LONG, SortOrder.DESC) .setQuery(query).build(); URI queryTaskURI = this.host.createQueryTaskService(queryTask); QueryTask finalState = this.host.waitForQueryTask(queryTaskURI, TaskStage.FINISHED); int expectedCountPerPage = queryTask.querySpec.resultLimit; validateNumericGroupByResults(targetHost, groups, null, finalState, null, expectedCountPerPage); }
private void verifyGroupQueryPaginatedAcrossGroups(VerificationHost targetHost, List<String> groups) throws Throwable { Query query = Query.Builder.create() .addKindFieldClause(ExampleServiceState.class) .build(); // two pagination across two dimensions: number of groups, and documents per group QueryTask queryTask = QueryTask.Builder.create() .addOption(QueryOption.GROUP_BY) .addOption(QueryOption.EXPAND_CONTENT) .setResultLimit(this.serviceCount / 5) .setGroupResultLimit(2) .orderAscending(ExampleServiceState.FIELD_NAME_ID, TypeName.STRING) .groupOrder(ExampleServiceState.FIELD_NAME_NAME, TypeName.STRING, SortOrder.ASC) .setQuery(query).build(); URI queryTaskURI = this.host.createQueryTaskService(queryTask); QueryTask finalState = this.host.waitForQueryTask(queryTaskURI, TaskStage.FINISHED); int expectedCountPerPage = queryTask.querySpec.resultLimit; validateGroupByResults(targetHost, groups, null, finalState, null, expectedCountPerPage); }
private void verifyNumericGroupQueryPaginatedAcrossGroups(VerificationHost targetHost, List<Long> groups) throws Throwable { Query query = Query.Builder.create() .addKindFieldClause(ExampleServiceState.class) .build(); // two pagination across two dimensions: number of groups, and documents per group QueryTask queryTask = QueryTask.Builder.create() .addOption(QueryOption.GROUP_BY) .addOption(QueryOption.EXPAND_CONTENT) .setResultLimit(this.serviceCount / 5) .setGroupResultLimit(2) .orderAscending(ExampleServiceState.FIELD_NAME_NAME, TypeName.STRING) .groupOrder(ExampleServiceState.FIELD_NAME_SORTED_COUNTER, TypeName.LONG, SortOrder.DESC) .setQuery(query).build(); URI queryTaskURI = this.host.createQueryTaskService(queryTask); QueryTask finalState = this.host.waitForQueryTask(queryTaskURI, TaskStage.FINISHED); int expectedCountPerPage = queryTask.querySpec.resultLimit; validateNumericGroupByResults(targetHost, groups, null, finalState, null, expectedCountPerPage); }