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


Java QueryBuilder.eq方法代碼示例

本文整理匯總了Java中com.datastax.driver.core.querybuilder.QueryBuilder.eq方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryBuilder.eq方法的具體用法?Java QueryBuilder.eq怎麽用?Java QueryBuilder.eq使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.datastax.driver.core.querybuilder.QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder.eq方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRecordById

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
@Override
public Response getRecordById(String keyspaceName, String tableName, String identifier) {
  long startTime = System.currentTimeMillis();
  ProjectLogger.log("Cassandra Service getRecordById 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.eq(Constants.IDENTIFIER, identifier);
    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 getRecordById method end at ==" + stopTime
      + " ,Total time elapsed = " + elapsedTime, LoggerEnum.PERF_LOG);
  return response;
}
 
開發者ID:project-sunbird,項目名稱:sunbird-utils,代碼行數:25,代碼來源:CassandraOperationImpl.java

示例2: deleteRows

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
public void deleteRows(String tablename, Map<String, String> cols) {
	String ns = "";
	String tbl = tablename;
	int ix = tbl.indexOf('.');
	if (ix >= 0) {
		ns = tablename.substring(0, ix);
		tbl = tablename.substring(ix+1);
	}
	Delete stmt = QueryBuilder.delete().from(ns, tbl);
	if (cols.size() == 1) {
		// only handles 1 WHERE value right now
		String k = cols.keySet().iterator().next();
		Clause eqclause = QueryBuilder.eq(k, cols.get(k));
		session.execute(stmt.where(eqclause));
	} else {
		session.execute(stmt);
	}
}
 
開發者ID:att,項目名稱:music,代碼行數:19,代碼來源:MusicClient.java

示例3: checkIfRowExsits

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
private void checkIfRowExsits(String table, byte[] rowKey, String colName) {
    Clause rkClause = QueryBuilder.eq("id", ByteBuffer.wrap(rowKey));
    Clause cnClause = QueryBuilder.eq("colname", colName);
    try {
        Query query = QueryBuilder.select().all().from(keys, table).where(rkClause).and(cnClause);
        ResultSet resultSet = session.execute(query);
        if (resultSet.isExhausted())
            return;
        else {
            Query delQuery = QueryBuilder.delete().from(keys, table).where(rkClause).and(cnClause);
            session.execute(delQuery);
        }
    } catch (Exception e) {
        System.out.println(" Exception:" + e.getMessage());
    }

}
 
開發者ID:guci314,項目名稱:playorm,代碼行數:18,代碼來源:CqlSession.java

示例4: remove

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
private void remove(Remove action, MetaLookup ormSession) {
    String colFamily = action.getColFamily().getColumnFamily();
    String table = lookupOrCreate(colFamily, ormSession);
    if (action.getAction() == null)
        throw new IllegalArgumentException("action param is missing ActionEnum so we know to remove entire row or just columns in the row");
    switch (action.getAction()) {
    case REMOVE_ENTIRE_ROW:
        Clause eqClause = QueryBuilder.eq("id", ByteBuffer.wrap(action.getRowKey()));
        Query query = QueryBuilder.delete().from(keys, table).where(eqClause);
        session.execute(query);
        break;
    case REMOVE_COLUMNS_FROM_ROW:
        removeColumns(action, table);
        break;
    default:
        throw new RuntimeException("bug, unknown remove action=" + action.getAction());
    }
}
 
開發者ID:guci314,項目名稱:playorm,代碼行數:19,代碼來源:CqlSession.java

示例5: findIndexRow

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
public boolean findIndexRow(String table, String rowKey, byte[] key, Object indValue) {
     Select selectQuery = QueryBuilder.select().all().from(keys, table).allowFiltering();
     Where selectWhere = selectQuery.where();
     Clause rkClause = QueryBuilder.eq("id", rowKey);
     selectWhere.and(rkClause);
     Clause indClause = null;
     if (indValue != null) {
         indClause = QueryBuilder.eq("colname", indValue);
     } else {
         if (table.equalsIgnoreCase("IntegerIndice")) {
             indClause = QueryBuilder.eq("colname", ByteBuffer.wrap(new byte[0]));
         } else {
             indClause = QueryBuilder.eq("colname", "");
         }
     }
     selectWhere.and(indClause);
     Clause keyClause = QueryBuilder.eq("colvalue", ByteBuffer.wrap(key));
     selectWhere.and(keyClause);
     Query query = selectWhere.limit(1);
     ResultSet resultSet = session.execute(query);
     return !resultSet.isExhausted();
}
 
開發者ID:guci314,項目名稱:playorm,代碼行數:23,代碼來源:CqlSession.java

示例6: 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

示例7: findByEndpointId

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
@Override
public Optional<CassandraEndpointRegistration> findByEndpointId(String endpointId) {
  LOG.debug("Searching for endpoint registration by endpoint ID [{}]", endpointId);
  Optional<String> credentialsId = this.byEndpointId.getCredentialsIdByEndpointId(
      endpointId);
  if (credentialsId.isPresent()) {
    LOG.debug("[{}] Endpoint credentials ID by endpoint ID: {}",
        endpointId, credentialsId.get());
    Clause clause = QueryBuilder.eq(
        CassandraModelConstants.EP_REGISTRATION_CREDENTIALS_ID_PROPERTY,
        credentialsId.get());
    Statement statement = QueryBuilder.select().from(this.getColumnFamilyName())
        .where(clause);
    return Optional.ofNullable(this.findOneByStatement(statement));
  } else {
    LOG.debug("[{}] No credentials ID found by endpoint ID: {}", endpointId);
    return Optional.empty();
  }
}
 
開發者ID:kaaproject,項目名稱:kaa,代碼行數:20,代碼來源:EndpointRegistrationCassandraDao.java

示例8: removeByEndpointId

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
@Override
public void removeByEndpointId(String endpointId) {
  LOG.debug("Removing endpoint registration by endpoint ID", endpointId);
  Optional<String> credentialsId = this.byEndpointId.getCredentialsIdByEndpointId(
      endpointId);
  if (credentialsId.isPresent()) {
    Clause clause = QueryBuilder.eq(
        CassandraModelConstants.EP_REGISTRATION_BY_ENDPOINT_ID_ENDPOINT_ID_PROPERTY,
        endpointId);
    Statement statement = QueryBuilder.delete()
        .from(this.byEndpointId.getColumnFamilyName())
        .where(clause);
    this.execute(statement);
    clause = QueryBuilder.eq(
        CassandraModelConstants.EP_REGISTRATION_CREDENTIALS_ID_PROPERTY,
        credentialsId.get());
    statement = QueryBuilder.delete().from(this.getColumnFamilyName()).where(clause);
    this.execute(statement);
  } else {
    LOG.debug("[{}] No credentials ID found by endpoint ID: {}", endpointId);
  }
}
 
開發者ID:kaaproject,項目名稱:kaa,代碼行數:23,代碼來源:EndpointRegistrationCassandraDao.java

示例9: delete

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public void delete(String keyspace, String table, JSONArray columns,
		JSONObject where, ConsistencyLevel consistency_level)
		throws MemnonException, IOException {

	Delete.Selection selection = QueryBuilder.delete();
	if (columns == null) {
		selection.all();
	} else {
		Iterator columnIterator = columns.iterator();
		while (columnIterator.hasNext()) {
			selection.column((String) columnIterator.next());
		}
	}

	Delete statement = selection.from(table);
	Iterator whereIterator = where.entrySet().iterator();
	while (whereIterator.hasNext()) {
		Map.Entry pair = (Map.Entry) whereIterator.next();
		Clause clause = QueryBuilder.eq((String) pair.getKey(),
				pair.getValue());
		statement.where(clause);
	}

	executeStatement(keyspace, statement);
}
 
開發者ID:boneill42,項目名稱:memnon,代碼行數:27,代碼來源:CassandraStorage.java

示例10: updateShardPointer

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
public void updateShardPointer(final Shard shard){

        Assignment assignment = QueryBuilder.set(COLUMN_POINTER, shard.getPointer());

        Clause queueNameClause = QueryBuilder.eq(COLUMN_QUEUE_NAME, shard.getQueueName());
        Clause regionClause = QueryBuilder.eq(COLUMN_REGION, shard.getRegion());
        Clause activeClause = QueryBuilder.eq(COLUMN_ACTIVE, 1);
        Clause shardIdClause = QueryBuilder.eq(COLUMN_SHARD_ID, shard.getShardId());

        Statement update = QueryBuilder.update(getTableName(shard.getType()))
                .with(assignment)
                .where(queueNameClause)
                .and(regionClause)
                .and(activeClause)
                .and(shardIdClause);

        cassandraClient.getQueueMessageSession().execute(update);

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

示例11: loadMessageData

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
@Override
public DatabaseQueueMessageBody loadMessageData(final UUID messageId ){

    logger.trace("loadMessageData {}", messageId);

    Clause messageIdClause = QueryBuilder.eq( COLUMN_MESSAGE_ID, messageId );

    Statement select = QueryBuilder.select().from( TABLE_MESSAGE_DATA).where(messageIdClause);

    Row row = cassandraClient.getApplicationSession().execute(select).one();
    if ( row == null ) {
        return null;
    }

    return new DatabaseQueueMessageBody(
            row.getBytes( COLUMN_MESSAGE_DATA),
            row.getString( COLUMN_CONTENT_TYPE));
}
 
開發者ID:apache,項目名稱:usergrid,代碼行數:19,代碼來源:QueueMessageSerializationImpl.java

示例12: createDeleteAllMessagesStatement

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
private Statement createDeleteAllMessagesStatement( Shard shard ) {

        Clause queueNameClause = QueryBuilder.eq(      COLUMN_QUEUE_NAME, shard.getQueueName() );
        Clause regionClause = QueryBuilder.eq(         COLUMN_REGION, shard.getRegion() );
        Clause shardIdClause = QueryBuilder.eq(        COLUMN_SHARD_ID, shard.getShardId() );

        DatabaseQueueMessage.Type dbqmType = Shard.Type.DEFAULT.equals( shard.getType() )
            ? DatabaseQueueMessage.Type.DEFAULT : DatabaseQueueMessage.Type.INFLIGHT;

        Statement deleteAll = QueryBuilder.delete().from( getTableName( dbqmType ))
            .where(queueNameClause)
            .and(regionClause)
            .and(shardIdClause);

        return deleteAll;
    }
 
開發者ID:apache,項目名稱:usergrid,代碼行數:17,代碼來源:QueueMessageSerializationImpl.java

示例13: getRecordsByProperty

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
@Override
public Response getRecordsByProperty(String keyspaceName, String tableName, String propertyName,
    Object propertyValue) {
  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.eq(propertyName, propertyValue);
    selectWhere.and(clause);
    ResultSet results = null;
    Session session = connectionManager.getSession(keyspaceName);
    results = session.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,代碼行數:28,代碼來源:CassandraOperationImpl.java

示例14: selectRows

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
public List<Map<String, Object>> selectRows(final String tablename, Map<String, String> cols) {
	String ns = "";
	String tbl = tablename;
	int ix = tbl.indexOf('.');
	if (ix >= 0) {
		ns = tablename.substring(0, ix);
		tbl = tablename.substring(ix+1);
	}
	Select sel = QueryBuilder.select().all().from(ns, tbl);
	Statement stmt = sel;
	if (cols.size() == 1) {
		// only handles 1 WHERE value right now
		String k = cols.keySet().iterator().next();
		Clause eqclause = QueryBuilder.eq(k, cols.get(k));
		stmt = sel.where(eqclause);
	}
	ResultSet resultset = session.execute(stmt);
	List<Map<String, Object>> results = new ArrayList<Map<String,Object>>();
	for (Row row : resultset) {
		Map<String, Object> map = new HashMap<String, Object>();
		for (Definition definition : row.getColumnDefinitions()) {
			map.put(definition.getName(), readRow(row, definition.getName(), definition.getType()));
		}
		results.add(map);
	}
	return results;
}
 
開發者ID:att,項目名稱:music,代碼行數:28,代碼來源:MusicClient.java

示例15: addWhereClause

import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
private static void addWhereClause(Where where, List<CassandraColumnHandle> partitionKeyColumns, List<Object> filterPrefix)
{
    for (int i = 0; i < filterPrefix.size(); i++) {
        CassandraColumnHandle column = partitionKeyColumns.get(i);
        Object value = column.getCassandraType().getJavaValue(filterPrefix.get(i));
        Clause clause = QueryBuilder.eq(CassandraCqlUtils.validColumnName(column.getName()), value);
        where.and(clause);
    }
}
 
開發者ID:y-lan,項目名稱:presto,代碼行數:10,代碼來源:CassandraSession.java


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