本文整理了Java中com.netflix.astyanax.query.RowQuery
类的一些代码示例,展示了RowQuery
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RowQuery
类的具体详情如下:
包路径:com.netflix.astyanax.query.RowQuery
类名称:RowQuery
[英]Interface to narrow down the path and column slices within a query after the keys were seleted using the ColumnFamilyQuery.
[中]接口,用于在使用ColumnFamilyQuery选择键后缩小查询中的路径和列切片。
代码示例来源:origin: apache/usergrid
@Override
public List<MvccLogEntry> load( final ApplicationScope collectionScope, final Id entityId, final UUID version,
final int maxSize ) {
Preconditions.checkNotNull( collectionScope, "collectionScope is required" );
Preconditions.checkNotNull( entityId, "entity id is required" );
Preconditions.checkNotNull( version, "version is required" );
Preconditions.checkArgument( maxSize > 0, "max Size must be greater than 0" );
ColumnList<UUID> columns;
try {
final Id applicationId = collectionScope.getApplication();
final ScopedRowKey<K> rowKey = createKey( applicationId, entityId );
columns =
keyspace.prepareQuery( CF_ENTITY_LOG ).getKey( rowKey ).withColumnRange( version, null, false, maxSize )
.execute().getResult();
}
catch ( ConnectionException e ) {
throw new RuntimeException( "Unable to load log entries", e );
}
return parseResults( columns, entityId );
}
代码示例来源:origin: apache/usergrid
@Override
public int getSystemVersion() {
try {
return keyspace.prepareQuery( CF_MIGRATION_INFO ).getKey( LEGACY_ROW_KEY ).getColumn( COLUMN_VERSION )
.execute().getResult().getIntegerValue();
}
//swallow, it doesn't exist
catch ( NotFoundException nfe ) {
return 0;
}
catch ( ConnectionException e ) {
throw new DataMigrationException( "Unable to retrieve status", e );
}
}
代码示例来源:origin: apache/usergrid
/**
* Get the edge types from the search criteria.
*
* @param scope The org scope
* @param search The edge type search info
* @param cf The column family to execute on
*/
private Iterator<String> getEdgeTypes( final ApplicationScope scope, final SearchEdgeType search,
final MultiTenantColumnFamily<ScopedRowKey<Id>, String> cf ) {
ValidationUtils.validateApplicationScope( scope );
GraphValidation.validateSearchEdgeType( search );
final ScopedRowKey< Id> sourceKey = new ScopedRowKey<>( scope.getApplication(), search.getNode() );
//resume from the last if specified. Also set the range
final RangeBuilder rangeBuilder = createRange( search );
RowQuery<ScopedRowKey<Id>, String> query =
keyspace.prepareQuery( cf ).getKey( sourceKey ).autoPaginate( true )
.withColumnRange( rangeBuilder.build() );
return new ColumnNameIterator<>( query, PARSER, search.getLast().isPresent() );
}
代码示例来源:origin: apache/usergrid
/**
* Execute the query again and set the reuslts
*/
private void advanceIterator() {
//run producing the values within a hystrix command. This way we'll time out if the read takes too long
try {
sourceIterator = rowQuery.execute().getResult().iterator();
}
catch ( ConnectionException e ) {
throw new RuntimeException( "Unable to get next page", e );
}
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
private void paginateColumnsForRowKey(String rowKey, boolean rowDeleted, int pageSize) throws Exception {
ColumnList<String> columns;
RowQuery<String, String> query = keyspace
.prepareQuery(TestUtils.CF_COLUMN_RANGE_TEST)
.getKey(rowKey)
.autoPaginate(true)
.withColumnRange(
new CqlRangeBuilder<String>().setStart("a")
.setFetchSize(pageSize).build());
int count = 1;
while (!(columns = query.execute().getResult()).isEmpty()) {
Assert.assertTrue(columns.size() <= pageSize);
for (Column<String> col : columns) {
int value = col.getName().charAt(0) - 'a' + 1;
Assert.assertEquals(count, value);
count++;
}
}
if (rowDeleted) {
Assert.assertTrue(count == 1);
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
.getColumn(columnName).execute();
OperationResult<ColumnList<UUID>> result2 = keyspace.prepareQuery(CF_TIME_UUID).getKey(rowKey).execute();
Assert.assertTrue(result2.getResult().size() >= (endTime - startTime));
.prepareQuery(CF_TIME_UUID)
.getKey(rowKey)
.withColumnRange(
new RangeBuilder()
.setLimit(10)
.setEnd(TimeUUIDUtils
.getTimeUUID(Long.MAX_VALUE >> 8))
.build()).execute();
.prepareQuery(CF_TIME_UUID)
.getKey(rowKey)
.withColumnRange(
new CqlRangeBuilder<UUID>()
.setFetchSize(10)
+ startTime))
.setEnd(TimeUUIDUtils.getTimeUUID(columnTime
+ endTime)).build()).autoPaginate(true);
OperationResult<ColumnList<UUID>> result3;
int pageCount = 0;
try {
LOG.info("starting pagination");
代码示例来源:origin: apache/usergrid
@Override
public Iterator<MvccEntity> loadAscendingHistory( final ApplicationScope applicationScope, final Id entityId,
final UUID version, final int fetchSize ) {
Preconditions.checkNotNull( applicationScope, "applicationScope is required" );
Preconditions.checkNotNull( entityId, "entity id is required" );
Preconditions.checkNotNull( version, "version is required" );
Preconditions.checkArgument( fetchSize > 0, "max Size must be greater than 0" );
final Id applicationId = applicationScope.getApplication();
final Id ownerId = applicationId;
final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() );
final CollectionPrefixedKey<Id> collectionPrefixedKey =
new CollectionPrefixedKey<>( collectionName, ownerId, entityId );
final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey =
ScopedRowKey.fromKey( applicationId, collectionPrefixedKey );
RowQuery<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> query =
keyspace.prepareQuery( columnFamily ).getKey( rowKey )
.withColumnRange( null, version, true, fetchSize );
return new ColumnNameIterator( query, new MvccColumnParser( entityId, getEntitySerializer() ), false );
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
.getKey(rowKey).getCount().execute().getResult();
Assert.assertEquals(nColumns, count);
.getKey(rowKey).getCount().execute().getResult();
Assert.assertEquals(nColumns / 2, count);
.withColumnRange(new RangeBuilder().setLimit(pageSize).build())
.autoPaginate(true);
while (!(result = query.execute().getResult()).isEmpty()) {
count += result.size();
.getKey(rowKey).getCount().execute().getResult();
Assert.assertEquals(0, count);
代码示例来源:origin: com.netflix.astyanax/astyanax-test
@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());
}
代码示例来源:origin: com.netflix.dynomitemanager/dynomitemanager-common
int count = bootKeyspace.prepareQuery(CF_LOCKS).getKey(choosingkey).getCount().execute().getResult();
if (count > 1) {
OperationResult<ColumnList<String>> result = bootKeyspace.prepareQuery(CF_LOCKS).getKey(lockKey).execute();
if (result.getResult().size() > 0
&& !result.getResult().getColumnByIndex(0).getName().equals(instance.getInstanceId()))
m.execute();
Thread.sleep(100);
result = bootKeyspace.prepareQuery(CF_LOCKS).getKey(lockKey).execute();
if (result.getResult().size() == 1
&& result.getResult().getColumnByIndex(0).getName().equals(instance.getInstanceId())) {
代码示例来源:origin: com.netflix.astyanax/astyanax-test
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);
}
}
代码示例来源:origin: com.bazaarvoice.emodb/emodb-event
_keyspace.prepareQuery(ColumnFamilies.MANIFEST, ConsistencyLevel.CL_LOCAL_ONE)
.getKey(channel)
.withColumnRange(new RangeBuilder().setLimit(100).build())
.autoPaginate(true));
_keyspace.prepareQuery(ColumnFamilies.SLAB, ConsistencyLevel.CL_LOCAL_ONE)
.getKey(slabId)
.withColumnRange(0, Constants.OPEN_SLAB_MARKER - 1, false, Integer.MAX_VALUE)
.getCount());
total += count;
_keyspace.prepareQuery(ColumnFamilies.MANIFEST, ConsistencyLevel.CL_LOCAL_ONE)
.getKey(channel)
.withColumnRange(new RangeBuilder().setStart(slabId).build())
.getCount());
total += slabs * Constants.MAX_SLAB_SIZE;
break;
代码示例来源:origin: com.netflix.astyanax/astyanax-test
@Test
public void testCopy() throws ConnectionException {
String keyName = "A";
keyspace.prepareQuery(CF_STANDARD1).getKey(keyName).copyTo(CF_STANDARD2, keyName).execute();
ColumnList<String> list1 = keyspace.prepareQuery(CF_STANDARD1).getKey(keyName).execute().getResult();
ColumnList<String> list2 = keyspace.prepareQuery(CF_STANDARD2).getKey(keyName).execute().getResult();
Iterator<Column<String>> iter1 = list1.iterator();
Iterator<Column<String>> iter2 = list2.iterator();
while (iter1.hasNext()) {
Column<String> column1 = iter1.next();
Column<String> column2 = iter2.next();
Assert.assertEquals(column1.getName(), column2.getName());
Assert.assertEquals(column1.getByteBufferValue(),column2.getByteBufferValue());
}
Assert.assertFalse(iter2.hasNext());
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
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);
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
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);
}
}
代码示例来源:origin: apache/usergrid
public ColumnNameIterator( RowQuery<?, C> rowQuery, final ColumnParser<C, T> parser, final boolean skipFirst ) {
this.rowQuery = rowQuery.autoPaginate( true );
this.parser = parser;
this.skipFirst = skipFirst;
}
代码示例来源:origin: com.netflix.astyanax/astyanax-cassandra
@Override
public SortedMap<String, String> getCheckpoints() throws ConnectionException {
SortedMap<String, String> checkpoints = Maps.newTreeMap(tokenComparator);
for (Column<String> column : keyspace.prepareQuery(columnFamily).getKey(bbKey).execute().getResult()) {
checkpoints.put(column.getName(), column.getStringValue());
}
return checkpoints;
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
.prepareQuery(CF_LONGCOLUMN)
.getKey("A")
.autoPaginate(true)
.withColumnRange(
new CqlRangeBuilder<Long>()
.setStart(column)
while (!(columns = query.execute().getResult()).isEmpty()) {
for (Column<Long> c : columns) {
colCount++;
.prepareQuery(CF_LONGCOLUMN)
.getKey("A")
.autoPaginate(true)
.withColumnRange(
new CqlRangeBuilder<Long>()
.setStart(-5L)
while (!(columns = query.execute().getResult()).isEmpty()) {
for (Column<Long> c : columns) {
colCount++;
代码示例来源:origin: apache/usergrid
@Override
public Iterator<MvccEntity> loadDescendingHistory( final ApplicationScope applicationScope, final Id entityId,
final UUID version, final int fetchSize ) {
Preconditions.checkNotNull( applicationScope, "applicationScope is required" );
Preconditions.checkNotNull( entityId, "entity id is required" );
Preconditions.checkNotNull( version, "version is required" );
Preconditions.checkArgument( fetchSize > 0, "max Size must be greater than 0" );
final Id applicationId = applicationScope.getApplication();
final Id ownerId = applicationId;
final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() );
final CollectionPrefixedKey<Id> collectionPrefixedKey =
new CollectionPrefixedKey<>( collectionName, ownerId, entityId );
final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey =
ScopedRowKey.fromKey( applicationId, collectionPrefixedKey );
RowQuery<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> query =
keyspace.prepareQuery( columnFamily ).getKey( rowKey )
.withColumnRange( version, null, false, fetchSize );
return new ColumnNameIterator( query, new MvccColumnParser( entityId, getEntitySerializer() ), false );
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
@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());
}
内容来源于网络,如有侵权,请联系作者删除!