@Override public boolean apply(@Nullable Row<ByteBuffer, ByteBuffer> row) { return (row != null) && row.getColumns().size() > 0; } }
private List<MvccLogEntry> parseResults( final ColumnList<UUID> columns, final Id entityId ) { List<MvccLogEntry> results = new ArrayList<MvccLogEntry>( columns.size() ); for ( Column<UUID> col : columns ) { final UUID storedVersion = col.getName(); final StageStatus stage = col.getValue( SER ); results.add( new MvccLogEntryImpl( entityId, storedVersion, stage.stage, stage.state ) ); } return results; }
/** * A single row is present, only parse the single row * @param result * @return */ private List<T> singleRowResult( final Rows<R, C> result ) { if (logger.isTraceEnabled()) logger.trace( "Only a single row has columns. Parsing directly" ); for ( R key : result.getKeys() ) { final ColumnList<C> columnList = result.getRow( key ).getColumns(); final int size = columnList.size(); if ( size > 0 ) { final List<T> results = new ArrayList<>(size); for(Column<C> column: columnList){ results.add(columnParser.parseColumn( column )); } return results; } } //we didn't have any results, just return nothing return Collections.<T>emptyList(); }
/** * Return true if we have < 2 rows with columns, false otherwise */ private boolean containsSingleRowOnly( final Rows<R, C> result ) { int count = 0; for ( R key : result.getKeys() ) { if ( result.getRow( key ).getColumns().size() > 0 ) { count++; //we have more than 1 row with values, return them if ( count > 1 ) { return false; } } } return true; }
if ( columns.size() == 0 ) { continue;
if ( columns.size() == 0 ) { continue;
if ( columns.size() == 0 ) { continue;
@Override public Boolean apply(Rows<String, String> rows) { // Process the row here ... // This will be called from multiple threads so make sure your code is thread safe for (Row<String, String> row : rows) { ColumnList<String> colList = row.getColumns(); Assert.assertTrue("ColList: " + colList.size(), 26 == colList.size()); rowCount.incrementAndGet(); } return true; } })
@Override public Boolean apply(Row<K,C> input) { counter.addAndGet(input.getColumns().size()); return true; }
@Override public boolean apply(@Nullable Row<ByteBuffer, ByteBuffer> row) { return (row != null) && row.getColumns().size() > 0; } }
@Override public Boolean apply(Row<K,C> input) { counter.addAndGet(input.getColumns().size()); return true; }
@Override public boolean apply(@Nullable Row<ByteBuffer, ByteBuffer> row) { return (row != null) && row.getColumns().size() > 0; } }
@Override public void success(Rows<String, String> rows) { for (Row<String, String> row : rows) { LOG.info("ROW: " + row.getKey() + " " + row.getColumns().size()); counter.incrementAndGet(); } }
private void checkResult(ColumnList<Population> result, Population ... expected) throws Exception { Assert.assertFalse(result.isEmpty()); Assert.assertEquals(expected.length, result.size()); int index = 0; for (Population p : expected) { Assert.assertEquals(p, result.getColumnByIndex(index++).getName()); } }
@Override public synchronized Boolean apply(Row<K, C> row) { long size = 0; for (Column<C> column : row.getColumns()) { size += column.getRawName().limit() + column.getByteBufferValue().limit(); } StringBuilder sb = new StringBuilder(); sb.append(String.format("- row: '%s' size: '%dl' count: '%dl' \n", row.getKey(), size, row.getColumns().size())); if (showColumns) { for (Column<C> column : row.getColumns()) { sb.append(String.format(" '%s' (ts='%dl', ttl='%d')\n", column.getName(), column.getTimestamp(), column.getTtl())); } } try { out.write(sb.toString().getBytes()); } catch (IOException e) { } return true; }
@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()); }
@Test public void testColumnSlice() throws ConnectionException { OperationResult<ColumnList<String>> r1 = keyspace .prepareQuery(CF_STANDARD1).getKey("A") .withColumnSlice("a", "b").execute(); Assert.assertEquals(2, r1.getResult().size()); }
@Test public void testSingleRowColumnSliceQueryWithCollection() throws Exception { for (int i=0; i<TestRowCount; i++) { ColumnList<String> result = keyspace.prepareQuery(CF_USER_INFO) .withCaching(true) .getRow("acct_" + i) .withColumnSlice("firstname", "lastname", "address", "age") .execute() .getResult(); Assert.assertNotNull(result); Assert.assertTrue(4 == result.size()); Assert.assertEquals("john_" + i, result.getColumnByName("firstname").getStringValue()); Assert.assertEquals("smith_" + i, result.getColumnByName("lastname").getStringValue()); Assert.assertEquals("john smith address " + i, result.getColumnByName("address").getStringValue()); Assert.assertTrue(30 + i == result.getColumnByName("age").getIntegerValue()); } }
@Test public void testTtlValues() throws Exception { MutationBatch mb = keyspace.prepareMutationBatch(); mb.withRow(CF_TTL, "row") .putColumn("TTL0", "TTL0", 0) .putColumn("TTLNULL", "TTLNULL", null) .putColumn("TTL1", "TTL1", 1); mb.execute(); Thread.sleep(2000); ColumnList<String> result = keyspace.prepareQuery(CF_TTL) .getRow("row") .execute().getResult(); Assert.assertEquals(2, result.size()); Assert.assertNotNull(result.getColumnByName("TTL0")); Assert.assertNotNull(result.getColumnByName("TTLNULL")); } }
@Test public void testSingleColumnMutation() throws Exception { keyspace.prepareColumnMutation(CF_SINGLE_COLUMN, 1L, "1").putValue("11", null).execute(); keyspace.prepareColumnMutation(CF_SINGLE_COLUMN, 1L, "2").putValue("22", null).execute(); keyspace.prepareColumnMutation(CF_SINGLE_COLUMN, 1L, "3").putValue("33", null).execute(); ColumnList<String> result = keyspace.prepareQuery(CF_SINGLE_COLUMN).getRow(1L).execute().getResult(); Assert.assertTrue(3 == result.size()); Assert.assertEquals("11", result.getColumnByName("1").getStringValue()); Assert.assertEquals("22", result.getColumnByName("2").getStringValue()); Assert.assertEquals("33", result.getColumnByName("3").getStringValue()); keyspace.prepareColumnMutation(CF_SINGLE_COLUMN, 1L, "2").putEmptyColumn(null).execute(); keyspace.prepareColumnMutation(CF_SINGLE_COLUMN, 1L, "3").deleteColumn().execute(); result = keyspace.prepareQuery(CF_SINGLE_COLUMN).getRow(1L).execute().getResult(); Assert.assertTrue(2 == result.size()); Assert.assertEquals("11", result.getColumnByName("1").getStringValue()); Assert.assertNull(result.getColumnByName("2").getStringValue()); } }