private void testSingleRowAllColumnsColumnCountQuery(boolean rowDeleted) throws Exception { int expected = rowDeleted ? 0 : columnNames.size(); for (int i=0; i<TestRowCount; i++) { int count = keyspace.prepareQuery(CF_USER_INFO).getRow("acct_" + i).getCount().execute().getResult().intValue(); Assert.assertEquals(expected, count); } }
/** ALL COLUMN COUNT QUERIES */ private void testReadSingleRowAllColumnsWithColumnCount(boolean rowDeleted) throws Exception { for (int year = 2001; year <= 2014; year++) { Integer result = keyspace.prepareQuery(CF_POPULATION) .getRow(year) .getCount() .execute().getResult(); int expected = rowDeleted ? 0 : 4; Assert.assertTrue(expected == result.intValue()); } }
private void testColumnCountSingleRowAndAllColumns(boolean rowDeleted) throws Exception { char ch = 'A'; while (ch <= 'Z') { String rowKey = String.valueOf(ch); Integer columnCount = keyspace .prepareQuery(CF_COLUMN_RANGE_TEST) .getKey(rowKey) .getCount() .execute().getResult(); int expected = rowDeleted ? 0 : 26; Assert.assertTrue("expected: " + expected + " colCount: " + columnCount, expected == columnCount); ch++; } }
private void testSingleRowColumnSliceCollectionColumnCountQuery(boolean rowDeleted) throws Exception { int expected = rowDeleted ? 0 : columnNames.size(); for (int i=0; i<TestRowCount; i++) { int count = keyspace.prepareQuery(CF_USER_INFO).getRow("acct_" + i).withColumnSlice(columnNames).getCount().execute().getResult(); Assert.assertEquals(expected, count); } }
private void testSingleRowColumnSliceVarArgsColumnCountQuery(boolean rowDeleted) throws Exception { int expected = rowDeleted ? 0 : columnNames.size(); for (int i=0; i<TestRowCount; i++) { int count = keyspace.prepareQuery(CF_USER_INFO).getRow("acct_" + i) .withColumnSlice("firstname", "lastname", "address","age","ageShort", "ageLong","percentile", "married","single", "birthdate", "bytes", "uuid", "empty") .getCount().execute().getResult(); Assert.assertEquals(expected, count); } }
private void getColumnCountForRowKey(String rowKey, boolean rowDeleted) throws Exception { Integer count = keyspace .prepareQuery(CF_COLUMN_RANGE_TEST) .getKey(rowKey) .withColumnRange("a", "z", false, -1) .getCount() .execute().getResult(); int expectedCount = rowDeleted ? 0 : 26; Assert.assertTrue(count.intValue() == expectedCount); } }
private void testColumnCountSingleRowAndColumnSet(boolean rowDeleted) throws Exception { Random random = new Random(); char ch = 'A'; while (ch <= 'Z') { String rowKey = String.valueOf(ch); int numColumns = random.nextInt(26) + 1; // avoid 0 Integer columnCount = keyspace .prepareQuery(CF_COLUMN_RANGE_TEST) .getKey(rowKey) .withColumnSlice(getRandomColumns(numColumns)) .getCount() .execute().getResult(); int expected = rowDeleted ? 0 : numColumns; Assert.assertTrue("expected: " + expected + " colCount: " + columnCount, expected == columnCount); ch++; } }
.getKey(rowKey) .withColumnRange(startCol, "z", false, -1) .getCount() .execute().getResult();
@Override public <K, N> int getCount(String keyspace, String columnFamily, K key, CmbSerializer keySerializer, CmbSerializer columnNameSerializer) throws PersistenceException { long ts1 = System.currentTimeMillis(); logger.debug("event=increment_counter column_family=" + columnFamily); try { int count = getKeyspace(keyspace). prepareQuery(getColumnFamily(columnFamily)). getKey(key). getCount(). execute(). getResult(); return count; } catch (NotFoundException ex){ //ignore. return 0; } catch (ConnectionException ex) { throw new PersistenceException(ex); } finally { long ts2 = System.currentTimeMillis(); CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraTime, (ts2 - ts1)); CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraRead, 1L); } }
int count = bootKeyspace.prepareQuery(CF_LOCKS).getKey(choosingkey).getCount().execute().getResult(); if (count > 1) {
int count = bootKeyspace.prepareQuery(CF_LOCKS).getKey(choosingkey).getCount().execute().getResult(); if (count > 1) {