本文整理匯總了Java中com.datastax.driver.core.querybuilder.QueryBuilder.in方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryBuilder.in方法的具體用法?Java QueryBuilder.in怎麽用?Java QueryBuilder.in使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.datastax.driver.core.querybuilder.QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder.in方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRecordsByProperty
import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
@Override
public Response getRecordsByProperty(String keyspaceName, String tableName, String propertyName,
List<Object> propertyValueList) {
long startTime = System.currentTimeMillis();
ProjectLogger.log("Cassandra Service getRecordsByProperty method started at ==" + startTime,
LoggerEnum.PERF_LOG);
Response response = new Response();
try {
Select selectQuery = QueryBuilder.select().all().from(keyspaceName, tableName);
Where selectWhere = selectQuery.where();
Clause clause = QueryBuilder.in(propertyName, propertyValueList);
selectWhere.and(clause);
ResultSet results = connectionManager.getSession(keyspaceName).execute(selectQuery);
response = CassandraUtil.createResponse(results);
} catch (Exception e) {
ProjectLogger.log(Constants.EXCEPTION_MSG_FETCH + tableName + " : " + e.getMessage(), e);
throw new ProjectCommonException(ResponseCode.SERVER_ERROR.getErrorCode(),
ResponseCode.SERVER_ERROR.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode());
}
long stopTime = System.currentTimeMillis();
long elapsedTime = stopTime - startTime;
ProjectLogger.log("Cassandra Service getRecordsByProperty method end at ==" + stopTime
+ " ,Total time elapsed = " + elapsedTime, LoggerEnum.PERF_LOG);
return response;
}
示例2: createRowQueryFromValues
import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
public static Where createRowQueryFromValues(List<byte[]> values, DboColumnMeta colMeta, Select selectQuery, String rowKey) {
Where selectWhere = selectQuery.where();
Clause rkClause = QueryBuilder.eq("id", rowKey);
selectWhere.and(rkClause);
Object[] valStrings = new Object[values.size()];
int count = 0;
for (byte[] value : values) {
valStrings[count] = StandardConverters.convertFromBytes(String.class, value);
count++;
}
Clause inClause = QueryBuilder.in("colname", valStrings);
selectWhere.and(inClause);
return selectWhere;
}
示例3: delete
import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
@Override
public void delete( final MapScope scope, final String key ) {
Statement deleteMapEntry;
Clause equalsEntryKey = QueryBuilder.eq("key", getMapEntryPartitionKey(scope, key));
deleteMapEntry = QueryBuilder.delete().from(MAP_ENTRIES_TABLE)
.where(equalsEntryKey);
session.execute(deleteMapEntry);
// not sure which bucket the value is in, execute a delete against them all
final int[] buckets = BUCKET_LOCATOR.getAllBuckets( scope.getName() );
List<ByteBuffer> mapKeys = new ArrayList<>();
for( int bucket : buckets){
mapKeys.add( getMapKeyPartitionKey(scope, bucket));
}
Statement deleteMapKey;
Clause inKey = QueryBuilder.in("key", mapKeys);
Clause column1Equals = QueryBuilder.eq("column1", DataType.text().serialize(key, ProtocolVersion.NEWEST_SUPPORTED));
deleteMapKey = QueryBuilder.delete().from(MAP_KEYS_TABLE)
.where(inKey).and(column1Equals);
session.execute(deleteMapKey);
}
示例4: getValueCQL
import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
private ByteBuffer getValueCQL( MapScope scope, String key, final ConsistencyLevel consistencyLevel ) {
Clause in = QueryBuilder.in("key", getMapEntryPartitionKey(scope, key) );
Statement statement = QueryBuilder.select().all().from(MAP_ENTRIES_TABLE)
.where(in)
.setConsistencyLevel(consistencyLevel);
ResultSet resultSet = session.execute(statement);
com.datastax.driver.core.Row row = resultSet.one();
return row != null ? row.getBytes("value") : null;
}
示例5: getAllKeys
import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
@Override
public MapKeyResults getAllKeys(final MapScope scope, final String cursor, final int limit ){
final int[] buckets = BUCKET_LOCATOR.getAllBuckets( scope.getName() );
final List<ByteBuffer> partitionKeys = new ArrayList<>(NUM_BUCKETS.length);
for (int bucket : buckets) {
partitionKeys.add(getMapKeyPartitionKey(scope, bucket));
}
Clause in = QueryBuilder.in("key", partitionKeys);
Statement statement;
if( isBlank(cursor) ){
statement = QueryBuilder.select().all().from(MAP_KEYS_TABLE)
.where(in)
.setFetchSize(limit);
}else{
statement = QueryBuilder.select().all().from(MAP_KEYS_TABLE)
.where(in)
.setFetchSize(limit)
.setPagingState(PagingState.fromString(cursor));
}
ResultSet resultSet = session.execute(statement);
PagingState pagingState = resultSet.getExecutionInfo().getPagingState();
final List<String> keys = new ArrayList<>();
Iterator<Row> resultIterator = resultSet.iterator();
int size = 0;
while( resultIterator.hasNext() && size < limit){
size++;
keys.add((String)DataType.text().deserialize(resultIterator.next().getBytes("column1"), ProtocolVersion.NEWEST_SUPPORTED));
}
return new MapKeyResults(pagingState != null ? pagingState.toString() : null, keys);
}
示例6: getValuesCQL
import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
private <T> T getValuesCQL(
final MapScope scope, final Collection<String> keys, final ResultsBuilderCQL<T> builder ) {
final List<ByteBuffer> serializedKeys = new ArrayList<>();
keys.forEach(key -> serializedKeys.add(getMapEntryPartitionKey(scope,key)));
Clause in = QueryBuilder.in("key", serializedKeys );
Statement statement = QueryBuilder.select().all().from(MAP_ENTRIES_TABLE)
.where(in);
ResultSet resultSet = session.execute(statement);
return builder.buildResultsCQL( resultSet );
}
示例7: getAllUniqueFields
import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
@Override
public Iterator<UniqueValue> getAllUniqueFields( final ApplicationScope collectionScope, final Id entityId ) {
Preconditions.checkNotNull( collectionScope, "collectionScope is required" );
Preconditions.checkNotNull( entityId, "entity id is required" );
Clause inKey = QueryBuilder.in("key", getLogPartitionKey(collectionScope.getApplication(), entityId));
Statement statement = QueryBuilder.select().all().from(TABLE_UNIQUE_VALUES_LOG)
.where(inKey);
return new AllUniqueFieldsIterator(session, statement, entityId);
}