/** * Specify a non-contiguous set of columns to retrieve. * * @param columns * @return */ public Builder<K, C> withColumnSlice(Collection<C> columns) { this.columnSlice = new ColumnSlice<C>(columns); return this; }
/** * Specify a non-contiguous set of columns to retrieve. * * @param columns * @return */ public Builder<K, C> withColumnSlice(Collection<C> columns) { this.columnSlice = new ColumnSlice<C>(columns); return this; }
/** * Specify a non-contiguous set of columns to retrieve. * * @param columns * @return */ public Builder<K, C> withColumnSlice(C... columns) { this.columnSlice = new ColumnSlice<C>(ImmutableList.copyOf(columns)); return this; }
/** * Specify a non-contiguous set of columns to retrieve. * * @param columns * @return */ public Builder<K, C> withColumnSlice(C... columns) { this.columnSlice = new ColumnSlice<C>(ImmutableList.copyOf(columns)); return this; }
/** * Specify a range of columns to return. * * @param startColumn * First column in the range * @param endColumn * Last column in the range * @param reversed * True if the order should be reversed. Note that for reversed, * startColumn should be greater than endColumn. * @param count * Maximum number of columns to return (similar to SQL LIMIT) * @return */ public Builder<K, C> withColumnRange(C startColumn, C endColumn, boolean reversed, int count) { this.columnSlice = new ColumnSlice<C>(startColumn, endColumn).setReversed(reversed).setLimit(count); return this; }
/** * Specify a range of columns to return. * * @param startColumn * First column in the range * @param endColumn * Last column in the range * @param reversed * True if the order should be reversed. Note that for reversed, * startColumn should be greater than endColumn. * @param count * Maximum number of columns to return (similar to SQL LIMIT) * @return */ public Builder<K, C> withColumnRange(C startColumn, C endColumn, boolean reversed, int count) { this.columnSlice = new ColumnSlice<C>(startColumn, endColumn).setReversed(reversed).setLimit(count); return this; }
@Test public void testGetColumnSlice() throws ConnectionException { LOG.info("Starting testGetColumnSlice..."); OperationResult<ColumnList<String>> result = keyspace .prepareQuery(CF_STANDARD1) .getKey("A") .withColumnSlice( new ColumnSlice<String>("c", "h").setLimit(5)) .execute(); Assert.assertNotNull(result.getResult()); Assert.assertEquals(5, result.getResult().size()); }
@Override protected void internalRun() { try { OperationResult<Rows<K, C>> result = ks.prepareQuery(cfData).withRetryPolicy(retry) .setConsistencyLevel(consistencyLevel).getKeySlice(keys) .withColumnSlice(new ColumnSlice<C>(columnSlice)).execute(); for (Row<K, C> row : result.getResult()) { callback.apply(row); } } catch (ConnectionException e) { e.printStackTrace(); } } };
@Override protected void internalRun() { try { OperationResult<Rows<K, C>> result = ks.prepareQuery(cfData).withRetryPolicy(retry) .setConsistencyLevel(consistencyLevel).getKeySlice(keys) .withColumnSlice(new ColumnSlice<C>(columnSlice)).execute(); for (Row<K, C> row : result.getResult()) { callback.apply(row); } } catch (ConnectionException e) { e.printStackTrace(); } } };