本文整理了Java中com.netflix.astyanax.query.RowQuery.execute
方法的一些代码示例,展示了RowQuery.execute
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RowQuery.execute
方法的具体详情如下:
包路径:com.netflix.astyanax.query.RowQuery
类名称:RowQuery
方法名:execute
暂无
代码示例来源: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: 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 List<MvccLogEntry> loadReversed( final ApplicationScope applicationScope, final Id entityId,
final UUID minVersion, final int maxSize ) {
ColumnList<UUID> columns;
try {
final Id applicationId = applicationScope.getApplication();
final ScopedRowKey<K> rowKey = createKey( applicationId, entityId );
columns = keyspace.prepareQuery( CF_ENTITY_LOG ).getKey( rowKey )
.withColumnRange( minVersion, null, true, maxSize ).execute().getResult();
}
catch ( ConnectionException e ) {
throw new RuntimeException( "Unable to load log entries", e );
}
return parseResults( columns, entityId );
}
代码示例来源: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
@Test
public void testGetSingleKey() throws ConnectionException {
for (char key = 'A'; key <= 'Z'; key++) {
String keyName = Character.toString(key);
OperationResult<ColumnList<String>> result = keyspace.prepareQuery(CF_STANDARD1).getKey(keyName).execute();
Assert.assertNotNull(result.getResult());
Assert.assertFalse(result.getResult().isEmpty());
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-contrib
private void verifyPresent(Keyspace ks, int rowKey) throws ConnectionException {
ColumnList<Long> result = ks.prepareQuery(CF_DUAL_WRITES).getRow(rowKey).execute().getResult();
if (result.isEmpty()) {
throw new RuntimeException("Row: " + rowKey + " missing from keysapce: " + ks.getKeyspaceName());
} else {
System.out.println("Verified Row: " + rowKey + " present in ks: " + ks.getKeyspaceName());
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-contrib
private void verifyNotPresent(Keyspace ks, int rowKey) throws ConnectionException {
ColumnList<Long> result = ks.prepareQuery(CF_DUAL_WRITES).getRow(rowKey).execute().getResult();
if (!result.isEmpty()) {
throw new RuntimeException("Row: " + rowKey + " present in keysapce: " + ks.getKeyspaceName());
} else {
System.out.println("Verified Row: " + rowKey + " NOT present in ks: " + ks.getKeyspaceName());
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
private void performSimpleRowQueryForRow(String rowKey, boolean rowDeleted, String expectedChar) throws Exception {
ColumnList<String> result = keyspace.prepareQuery(CF_ACCOUNTS).getRow(rowKey).execute().getResult();
if (rowDeleted) {
Assert.assertTrue(result.isEmpty());
} else {
Assert.assertFalse(result.isEmpty());
Column<String> col = result.getColumnByName("user");
Assert.assertEquals("user" + expectedChar, col.getStringValue());
col = result.getColumnByName("pswd");
Assert.assertEquals("pswd" + expectedChar, col.getStringValue());
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
private void testReadSingleRowAllColumns(boolean rowDeleted) throws Exception {
for (int year = 2001; year <= 2014; year++) {
ColumnList<Population> result = keyspace.prepareQuery(CF_POPULATION)
.getRow(year)
.execute().getResult();
if (rowDeleted) {
Assert.assertTrue(result.isEmpty());
continue;
} else {
checkResult(result, SanDiego, SanFrancisco, NewYork, Seattle);
}
}
}
代码示例来源: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());
}
代码示例来源: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
@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: org.togglz/togglz-cassandra
@Override
public FeatureState getFeatureState(Feature feature) {
try {
final ColumnList<String> state = keyspace
.prepareQuery(columnFamily)
.getRow(feature.name())
.execute()
.getResult();
return state.isEmpty() ? null : toFeatureState(feature, state);
}
catch (ConnectionException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
@Test
public void testUniquenessWithCustomMutation() throws Exception {
ColumnList<String> result = keyspace.prepareQuery(CF_UNIQUE_CONSTRAINT).getRow(10L).execute().getResult();
Assert.assertTrue(result.isEmpty());
ColumnPrefixUniquenessConstraint<Long> unique =
new ColumnPrefixUniquenessConstraint<Long>(keyspace, CF_UNIQUE_CONSTRAINT, 3L)
.withConsistencyLevel(ConsistencyLevel.CL_ONE);
unique.acquireAndApplyMutation(new Function<MutationBatch, Boolean>() {
public Boolean apply(MutationBatch input) {
input.withRow(CF_UNIQUE_CONSTRAINT, 10L).putEmptyColumn("MyCustomColumn", null);
return true;
}
});
result = keyspace.prepareQuery(CF_UNIQUE_CONSTRAINT).getRow(10L).execute().getResult();
Assert.assertFalse(result.isEmpty());
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
@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());
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
@Test
public void testSingleRowAllColumnsQuery() throws Exception {
for (int i=0; i<TestRowCount; i++) {
ColumnList<String> result = keyspace.prepareQuery(CF_USER_INFO)
.withCaching(true)
.getRow("acct_" + i)
.execute()
.getResult();
super.testAllColumnsForRow(result, i);
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-cql
private MutationBatch getMutationBatch() throws ConnectionException {
ColumnList<C> columnList = rowQuery.execute().getResult();
CqlKeyspaceImpl ksImpl = new CqlKeyspaceImpl(ksContext);
MutationBatch mBatch = ksImpl.prepareMutationBatch();
CqlColumnListMutationImpl<K,C> colListMutation = (CqlColumnListMutationImpl<K, C>)mBatch.withRow(cf, rowKey);
Iterator<Column<C>> iter = columnList.iterator();
boolean first = true;
while(iter.hasNext()) {
CqlColumnImpl<C> col = (CqlColumnImpl<C>) iter.next();
if (first && useOriginalTimestamp) {
colListMutation.setTimestamp(col.getTimestamp());
first = false;
}
colListMutation.putColumnWithGenericValue(col.getName(), col.getGenericValue(), null);
}
return mBatch;
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
@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"));
}
}
代码示例来源:origin: com.bazaarvoice.astyanax/astyanax-recipes
@Override
public ObjectMetadata readMetadata(String objectName) throws Exception, NotFoundException {
ColumnList<String> columns = keyspace.prepareQuery(cf).getKey(objectName).execute().getResult();
if (columns.isEmpty()) {
throw new NotFoundException(objectName);
}
return new ObjectMetadata().setObjectSize(columns.getLongValue(getColumnName(Columns.OBJECTSIZE), null))
.setChunkSize(columns.getIntegerValue(getColumnName(Columns.CHUNKSIZE), null))
.setChunkCount(columns.getIntegerValue(getColumnName(Columns.CHUNKCOUNT), null))
.setAttributes(columns.getStringValue(getColumnName(Columns.ATTRIBUTES), null));
}
代码示例来源:origin: com.netflix.astyanax/astyanax-recipes
@Override
public ObjectMetadata readMetadata(String objectName) throws Exception, NotFoundException {
ColumnList<String> columns = keyspace.prepareQuery(cf).getKey(objectName).execute().getResult();
if (columns.isEmpty()) {
throw new NotFoundException(objectName);
}
return new ObjectMetadata().setObjectSize(columns.getLongValue(getColumnName(Columns.OBJECTSIZE), null))
.setChunkSize(columns.getIntegerValue(getColumnName(Columns.CHUNKSIZE), null))
.setChunkCount(columns.getIntegerValue(getColumnName(Columns.CHUNKCOUNT), null))
.setAttributes(columns.getStringValue(getColumnName(Columns.ATTRIBUTES), null));
}
内容来源于网络,如有侵权,请联系作者删除!