BackendKeyUtils { public SchemaBoundStatement selectKeys(final BackendKeyFilter filter) throws Exception { final SelectBuilder select = new SelectBuilder().distinct().column(column).column(columnToken).from(keyspace, table); filter.getStart().map(this::convertStart).ifPresent(select::and); filter.getEnd().map(this::convertEnd).ifPresent(select::and); filter.getLimit().ifPresent(select::limit); return select.toBoundStatement(); } BackendKeyUtils(
        final String column, final String keyspace, final String table, final SchemaInstance schema
    ); SchemaBoundStatement selectKeys(final BackendKeyFilter filter);  }
@Test public void testClause() throws Exception { final BackendKeyUtils utils = new BackendKeyUtils("key", "keyspace", "table", schema); final String base = "SELECT DISTINCT key, token(key) FROM keyspace.table"; assertEquals(new SchemaBoundStatement(base, ImmutableList.of()), utils.selectKeys(new BackendKeyFilter())); assertEquals(new SchemaBoundStatement(base + " WHERE token(key) >= token(?)", ImmutableList.of(serializedKey)), utils.selectKeys(new BackendKeyFilter().withStart(new BackendKeyFilter.GTE(key)))); assertEquals( new SchemaBoundStatement(base + " WHERE token(key) >= token(?) and token(key) < ?", ImmutableList.of(serializedKey, 42L)), utils.selectKeys( new BackendKeyFilter() .withStart(new BackendKeyFilter.GTE(key)) .withEnd(new BackendKeyFilter.LTToken(42L)))); }