.withColumnSlice( COL_VALUE ).execute().getResult();
results = query.getRowSlice( keys ).withColumnSlice( Collections.singletonList( COLUMN_NAME )).execute() .getResult();
private void testColumnCountRowRangeAndColumnSet(boolean rowDeleted) throws Exception { Collection<String> columns = getRandomColumns(new Random().nextInt(26) + 1); List<TestTokenRange> testRanges = TestUtils.getTestTokenRanges(); Map<String, Integer> expectedRowCounts = rowDeleted ? new HashMap<String, Integer>() : getExpectedRowCountsForTokenRanges(testRanges, columns.size()); Map<String, Integer> resultRowCounts = new HashMap<String, Integer>(); for (TestTokenRange testRange : testRanges) { Map<String, Integer> rowCounts = keyspace.prepareQuery(CF_COLUMN_RANGE_TEST) .getRowRange(null, null, testRange.startToken, testRange.endToken, -1) .withColumnSlice(columns) .getColumnCounts() .execute().getResult(); resultRowCounts.putAll(rowCounts); } Assert.assertEquals(expectedRowCounts, resultRowCounts); }
private void testColumnCountMultipleRowKeysAndColumnSet(boolean rowDeleted) throws Exception { Collection<String> rowKeys = getRandomRowKeys(); Collection<String> columns = getRandomColumns(new Random().nextInt(26) + 1); Map<String, Integer> columnCountsPerRowKey = keyspace .prepareQuery(CF_COLUMN_RANGE_TEST) .getRowSlice(rowKeys) .withColumnSlice(columns) .getColumnCounts() .execute().getResult(); Map<String, Integer> expected = new HashMap<String, Integer>(); if (!rowDeleted) { for (String key : rowKeys) { expected.put(key, columns.size()); } } Assert.assertEquals("expected: " + expected + " colCount: " + columnCountsPerRowKey, expected, columnCountsPerRowKey); }
rowQuery = rowQuery.withColumnSlice(columns);
rowQuery = rowQuery.withColumnSlice(columns);
@Test public void testRowKeysColumnSetQuery() throws Exception { keyspace.prepareQuery(CF_USER_INFO) .withCaching(true) .getRowSlice("acct_0", "acct_1", "acct_2", "acct_3") .withColumnSlice("firstname", "lastname", "age") .execute(); Rows<String, String> result = keyspace.prepareQuery(CF_USER_INFO) .withCaching(true) .getRowSlice("acct_4", "acct_5", "acct_6", "acct_7") .withColumnSlice("firstname", "lastname", "age") .execute() .getResult(); Assert.assertNotNull(result); Assert.assertTrue(4 == result.size()); for (Row<String, String> row : result) { int rowNo = Integer.parseInt(row.getKey().substring("acct_".length())); Assert.assertTrue(rowNo >= 4); Assert.assertTrue(rowNo <= 7); Assert.assertTrue(3 == row.getColumns().size()); } }
.withColumnSlice(columns) .execute().getResult();
.withColumnSlice(randomColumns) .execute().getResult();
@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(); } } };
Rows<String, String> rows = keyspace.prepareQuery(CF_ACCOUNTS).getRowSlice(keys).withColumnSlice("user", "pswd").execute().getResult(); if (rowDeleted) { Assert.assertTrue(rows.isEmpty()); rows = keyspace.prepareQuery(CF_ACCOUNTS).getRowSlice(keys).withColumnSlice("user").execute().getResult(); if (rowDeleted) { Assert.assertTrue(rows.isEmpty()); rows = keyspace.prepareQuery(CF_ACCOUNTS).getRowSlice(keys).withColumnSlice("pswd").execute().getResult(); if (rowDeleted) { Assert.assertTrue(rows.isEmpty());
@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(); } } };
query.withColumnSlice(columnSlice);
@Test public void testRowRangeColumnSetQuery() throws Exception { String startToken = Murmur3Partitioner.get().getTokenForKey(StringSerializer.get().fromString("A")); String endToken = Murmur3Partitioner.get().getTokenForKey(StringSerializer.get().fromString("G")); keyspace.prepareQuery(CF_ROW_RANGE) .withCaching(true) .getRowRange(null, null, startToken, endToken, 10) .withColumnSlice("a", "s", "d", "f") .execute(); Rows<String, String> result = keyspace.prepareQuery(CF_ROW_RANGE) .withCaching(true) .getRowRange(null, null, startToken, endToken, 10) .withColumnSlice("a", "s", "d", "f") .execute() .getResult(); Assert.assertNotNull(result); Assert.assertTrue(3 == result.size()); for (Row<String, String> row : result) { Assert.assertTrue(4 == row.getColumns().size()); } }
query.withColumnSlice(columnSlice);
query.withColumnSlice(columnSlice);