當前位置: 首頁>>代碼示例>>Java>>正文


Java QueryBuilder.in方法代碼示例

本文整理匯總了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;
}
 
開發者ID:project-sunbird,項目名稱:sunbird-utils,代碼行數:26,代碼來源:CassandraOperationImpl.java

示例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;
}
 
開發者ID:guci314,項目名稱:playorm,代碼行數:18,代碼來源:Cql3Util.java

示例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);


}
 
開發者ID:apache,項目名稱:usergrid,代碼行數:28,代碼來源:MapSerializationImpl.java

示例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;
    }
 
開發者ID:apache,項目名稱:usergrid,代碼行數:13,代碼來源:MapSerializationImpl.java

示例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);

}
 
開發者ID:apache,項目名稱:usergrid,代碼行數:43,代碼來源:MapSerializationImpl.java

示例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 );
}
 
開發者ID:apache,項目名稱:usergrid,代碼行數:17,代碼來源:MapSerializationImpl.java

示例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);


}
 
開發者ID:apache,項目名稱:usergrid,代碼行數:16,代碼來源:UniqueValueSerializationStrategyImpl.java


注:本文中的com.datastax.driver.core.querybuilder.QueryBuilder.in方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。