本文整理了Java中com.netflix.astyanax.query.RowQuery.getColumn
方法的一些代码示例,展示了RowQuery.getColumn
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RowQuery.getColumn
方法的具体详情如下:
包路径:com.netflix.astyanax.query.RowQuery
类名称:RowQuery
方法名:getColumn
[英]Specify the path to a single column (either Standard or Super). Notice that the sub column type and serializer will be used now.
[中]指定单个列(标准或超级)的路径。请注意,现在将使用子列类型和序列化程序。
代码示例来源: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
@Override
public Optional<Long> getMaxVersion( final ApplicationScope scope, final Id node ) {
ValidationUtils.validateApplicationScope( scope );
ValidationUtils.verifyIdentity( node );
ColumnFamilyQuery<ScopedRowKey<Id>, Boolean> query =
keyspace.prepareQuery( GRAPH_DELETE ).setConsistencyLevel( fig.getReadCL() );
Column<Boolean> result = null;
try {
result = query.getKey( ScopedRowKey.fromKey( scope.getApplication(), node ) ).getColumn( COLUMN_NAME ).execute()
.getResult();
}
catch(NotFoundException nfe){
//swallow, there's just no column
return Optional.absent();
}
catch ( ConnectionException e ) {
throw new RuntimeException( "Unable to connect to casandra", e );
}
return Optional.of( result.getLongValue() );
}
代码示例来源:origin: apache/usergrid
@Override
public String getStatusMessage(final String pluginName) {
final ScopedRowKey<String> rowKey = ScopedRowKey.fromKey( STATIC_ID, pluginName);
try {
return keyspace.prepareQuery( CF_MIGRATION_INFO ).getKey( rowKey ).getColumn( COL_STATUS_MESSAGE )
.execute().getResult().getStringValue();
}
//swallow, it doesn't exist
catch ( NotFoundException nfe ) {
return null;
}
catch ( ConnectionException e ) {
throw new DataMigrationException( "Unable to retrieve status", e );
}
}
代码示例来源:origin: apache/usergrid
@Override
public int getStatusCode(final String pluginName) {
final ScopedRowKey<String> rowKey = ScopedRowKey.fromKey( STATIC_ID, pluginName);
try {
return keyspace.prepareQuery( CF_MIGRATION_INFO ).getKey( rowKey ).getColumn( COLUMN_STATUS_CODE )
.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
@Override
public int getVersion(final String pluginName) {
final ScopedRowKey<String> rowKey = ScopedRowKey.fromKey( STATIC_ID, pluginName);
try {
return keyspace.prepareQuery( CF_MIGRATION_INFO ).getKey( rowKey ).getColumn( COLUMN_VERSION ).execute()
.getResult().getIntegerValue();
}
//swallow, it doesn't exist
catch ( NotFoundException nfe ) {
return 0;
}
catch ( ConnectionException e ) {
AstyanaxUtils.isSchemaMissing("Unable to connect to cassandra to retrieve status", e);
return 0;
}
}
代码示例来源:origin: apache/usergrid
Column<String> column = keyspace.prepareQuery( cf ).getKey( rowKey ).getColumn( colName ).execute().getResult();
column = keyspace.prepareQuery( cf ).getKey( rowKey ).getColumn( colName ).execute().getResult();
fail( "I shouldn't return a value" );
column = keyspace.prepareQuery( cf ).getKey( rowKey ).getColumn( colName ).execute().getResult();
fail( "I shouldn't return a value" );
代码示例来源:origin: apache/usergrid
Column<String> col = keyspace.prepareQuery( testCf ).getKey( key ).getColumn( colname ).execute().getResult();
keyspace.prepareQuery( testCf ).getKey( key ).getColumn( colname ).execute().getResult();
batch.execute();
col = keyspace.prepareQuery( testCf ).getKey( key ).getColumn( colname ).execute().getResult();
col = keyspace.prepareQuery( testCf ).getKey( key ).getColumn( colname ).execute().getResult();
keyspace.prepareQuery( testCf ).getKey( key ).getColumn( colname ).execute().getResult();
代码示例来源:origin: com.netflix.astyanax/astyanax-test
private void performSimpleRowSingleColumnQueryForRow(String rowKey, boolean rowDeleted, String expectedChar) throws Exception {
Column<String> col = keyspace.prepareQuery(CF_ACCOUNTS).getRow(rowKey).getColumn("user").execute().getResult();
if (rowDeleted) {
Assert.assertNull(col);
} else {
Assert.assertTrue(col.hasValue());
Assert.assertEquals("user" + expectedChar, col.getStringValue());
}
col = keyspace.prepareQuery(CF_ACCOUNTS).getRow(rowKey).getColumn("pswd").execute().getResult();
if (rowDeleted) {
Assert.assertNull(col);
} else {
Assert.assertTrue(col.hasValue());
Assert.assertEquals("pswd" + expectedChar, col.getStringValue());
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
@Test
public void testGetSingleColumnNotExists() throws ConnectionException {
Column<String> column = keyspace.prepareQuery(CF_STANDARD1).getRow("A").getColumn("DoesNotExist").execute().getResult();
Assert.assertNull(column);
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
private void testReadSingleRowSingleColumn(boolean rowDeleted) throws Exception {
for (int year = 2001; year <= 2014; year++) {
Column<Population> result = keyspace.prepareQuery(CF_POPULATION)
.getRow(year)
.getColumn(SanFrancisco.clone())
.execute().getResult();
if (rowDeleted) {
Assert.assertNull(result);
continue;
} else {
Assert.assertTrue(result.hasValue());
}
Assert.assertEquals(SanFrancisco, result.getName());
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
@Test
public void testGetSingleKeyNotExists() throws Exception {
Column<String> column = keyspace.prepareQuery(CF_STANDARD1).getRow("AA").getColumn("ab").execute().getResult();
Assert.assertNull(column);
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
@Test
public void testSingleRowSingleColumnQuery() throws Exception {
for (int i=0; i<TestRowCount; i++) {
Column<String> result = keyspace.prepareQuery(CF_USER_INFO)
.withCaching(true)
.getRow("acct_" + i)
.getColumn("address")
.execute()
.getResult();
Assert.assertNotNull(result);
Assert.assertEquals("address", result.getName());
Assert.assertNotNull(result.getStringValue());
Assert.assertEquals("john smith address " + i, result.getStringValue());
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-cassandra
@Override
public String getCheckpoint(String startToken) throws ConnectionException {
try {
return keyspace.prepareQuery(columnFamily).getKey(bbKey).getColumn(startToken).execute().getResult().getStringValue();
}
catch (NotFoundException e) {
return startToken;
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
@Test
public void testGetSingleColumn() throws Exception {
keyspace.prepareColumnMutation(CF_STANDARD1, "A", "a").putValue(1, null).execute();
Column<String> column = keyspace.prepareQuery(CF_STANDARD1).getRow("A").getColumn("a").execute().getResult();
Assert.assertNotNull(column);
Assert.assertEquals(1, column.getIntegerValue());
}
代码示例来源:origin: Netflix/CassJMeter
@Override
public ResponseData get(Object rkey, Object colName) throws OperationException
{
StringBuffer response = new StringBuffer();
int bytes = 0;
OperationResult<Column<Object>> opResult = null;
try
{
opResult = AstyanaxConnection.instance.keyspace().prepareQuery(cfs).getKey(rkey).getColumn(colName).execute();
bytes = opResult.getResult().getRawName().capacity();
bytes += opResult.getResult().getByteBufferValue().capacity();
String value = SystemUtils.convertToString(valueSerializer, opResult.getResult().getByteBufferValue());
response.append(value);
}
catch (NotFoundException ex)
{
// ignore this because nothing is available to show
response.append("...Not found...");
}
catch (ConnectionException e)
{
throw new OperationException(e);
}
return new AstyanaxResponseData(response.toString(), bytes, opResult, rkey, colName, null);
}
代码示例来源:origin: Comcast/cmb
@Override
public <K, N> long getCounter(String keyspace, String columnFamily,
K rowKey, N columnName, CmbSerializer keySerializer,
CmbSerializer columnNameSerializer) throws PersistenceException {
long ts1 = System.currentTimeMillis();
logger.debug("event=get_counter column_family=" + columnFamily);
try {
Column<N> result =
getKeyspace(keyspace).
prepareQuery((ColumnFamily<K, N>)getColumnFamily(columnFamily)).
getKey(rowKey).
getColumn(columnName).
execute().
getResult();
Long counterValue = result.getLongValue();
return counterValue;
} catch (ConnectionException ex) {
return 0;
} finally {
long ts2 = System.currentTimeMillis();
CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraTime, (ts2 - ts1));
CMBControllerServlet.valueAccumulator.addToCounter(AccumulatorName.CassandraRead, 1L);
}
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
@Test
public void testDelete() throws Exception {
LOG.info("Starting testDelete...");
String rowKey = "DeleteMe_testDelete";
MutationBatch m = keyspace.prepareMutationBatch();
m.withRow(CF_STANDARD1, rowKey).putColumn("Column1", "X", null).putColumn("Column2", "X", null);
m.execute();
Column<String> column = keyspace.prepareQuery(CF_STANDARD1).getRow(rowKey).getColumn("Column1").execute().getResult();
Assert.assertEquals("X", column.getStringValue());
m = keyspace.prepareMutationBatch();
m.withRow(CF_STANDARD1, rowKey).deleteColumn("Column1");
m.execute();
column = keyspace.prepareQuery(CF_STANDARD1).getRow(rowKey).getColumn("Column1").execute().getResult();
Assert.assertNull(column);
LOG.info("... testDelete");
}
代码示例来源:origin: com.netflix.astyanax/astyanax-recipes
@Override
public ByteBuffer readChunk(String objectName, int chunkId) throws Exception {
return keyspace.prepareQuery(cf).setConsistencyLevel(readConsistencyLevel).withRetryPolicy(retryPolicy)
.getKey(getRowKey(objectName, chunkId)).getColumn(getColumnName(Columns.DATA)).execute().getResult()
.getByteBufferValue();
}
代码示例来源:origin: com.bazaarvoice.astyanax/astyanax-recipes
@Override
public ByteBuffer readChunk(String objectName, int chunkId) throws Exception {
return keyspace.prepareQuery(cf).setConsistencyLevel(readConsistencyLevel).withRetryPolicy(retryPolicy)
.getKey(getRowKey(objectName, chunkId)).getColumn(getColumnName(Columns.DATA)).execute().getResult()
.getByteBufferValue();
}
代码示例来源:origin: com.netflix.astyanax/astyanax-test
@Test
public void testSerializedClassValue() throws Exception {
UserInfo smo = new UserInfo();
smo.setLastName("Landau");
smo.setFirstName("Eran");
ByteBuffer bb = ObjectSerializer.get().toByteBuffer(smo);
keyspace.prepareColumnMutation(CF_STANDARD1, "Key_SerializeTest",
"Column1").putValue(bb, null).execute();
UserInfo smo2 = (UserInfo) keyspace.prepareQuery(CF_STANDARD1)
.getKey("Key_SerializeTest").getColumn("Column1").execute()
.getResult().getValue(ObjectSerializer.get());
Assert.assertEquals(smo, smo2);
}
内容来源于网络,如有侵权,请联系作者删除!