.offset(0)
.limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.withBindVariableValue("type", type);
// Default for result sets.
ResultSet combinedResultSet = null;
ResultSet resultSet;
int i = 0;
do {
// Get all cities.
resultSet = pqlService.select(statementBuilder.toStatement());
// Combine result sets with previous ones.
combinedResultSet = combinedResultSet == null
? resultSet
: Pql.combineResultSets(combinedResultSet, resultSet);
System.out.printf("%d) %d geo targets beginning at offset %d were found.\n", i++,
resultSet.getRows() == null ? 0 : resultSet.getRows().length,
statementBuilder.getOffset());
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (resultSet.getRows() != null && resultSet.getRows().length > 0);
// Change to your file location.
String filePath = File.createTempFile(type + "-", ".csv").toString();
// Write the result set to a CSV.