当前位置: 首页>>代码示例>>Java>>正文


Java Clause类代码示例

本文整理汇总了Java中com.datastax.driver.core.querybuilder.Clause的典型用法代码示例。如果您正苦于以下问题:Java Clause类的具体用法?Java Clause怎么用?Java Clause使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Clause类属于com.datastax.driver.core.querybuilder包,在下文中一共展示了Clause类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRecordById

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的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: getRecordsByProperty

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的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

示例3: deleteRows

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的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

示例4: checkIfRowExsits

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的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

示例5: remove

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的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

示例6: findIndexRow

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的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

示例7: createRowQueryFromValues

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的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

示例8: get

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的package包/类
public List<Row> get() {
    Select.Where where = QueryBuilder.select().from(parent.getKeyspace(), parent.getTable()).where();
    for (Clause clause : clauses) {
        where.and(clause);
    }
    if (searchBuilder != null) {
        where.and(QueryBuilder.eq(parent.getIndexColumn(), searchBuilder.refresh(refresh).toJson()));
    }
    BuiltStatement statement = limit == null ? where : where.limit(limit);

    String query = statement.toString();
    query = query.substring(0, query.length() - 1);
    StringBuilder sb = new StringBuilder(query);
    for (String extra : extras) {
        sb.append(" ");
        sb.append(extra);
        sb.append(" ");
    }
    return parent.execute(sb, fetchSize);
}
 
开发者ID:Stratio,项目名称:stratio-cassandra-test,代码行数:21,代码来源:CassandraUtilsSelect.java

示例9: ReadQueryDataImpl

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的package包/类
private ReadQueryDataImpl(Tablename tablename,
                          ImmutableMap<String, ImmutableList<Object>> keys,
                          ImmutableSet<Clause> whereClauses, 
                          ImmutableMap<String, Boolean> columnsToFetch, 
                          Integer limit, 
                          Boolean allowFiltering,
                          Integer fetchSize,
                          Boolean distinct,
                          PagingState pagingState) {
    this.tablename = tablename;
    this.keys = keys;
    this.whereClauses = whereClauses;
    this.columnsToFetch = columnsToFetch;
    this.limit = limit;
    this.allowFiltering = allowFiltering;
    this.fetchSize = fetchSize;
    this.distinct = distinct;
    this.pagingState = pagingState;
}
 
开发者ID:1and1,项目名称:Troilus,代码行数:20,代码来源:ReadQueryDataImpl.java

示例10: WriteQueryDataImpl

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的package包/类
private WriteQueryDataImpl(Tablename tablemname,
                           ImmutableMap<String, Object> keys, 
                           ImmutableList<Clause> whereConditions, 
                           ImmutableMap<String, Optional<Object>> valuesToMutate, 
                           ImmutableMap<String, ImmutableSet<Object>> setValuesToAdd,
                           ImmutableMap<String, ImmutableSet<Object>> setValuesToRemove,
                           ImmutableMap<String, ImmutableList<Object>> listValuesToAppend, 
                           ImmutableMap<String, ImmutableList<Object>> listValuesToPrepend,
                           ImmutableMap<String, ImmutableList<Object>> listValuesToRemove,
                           ImmutableMap<String, ImmutableMap<Object, Optional<Object>>> mapValuesToMutate,
                           ImmutableList<Clause> onlyIfConditions,
                           Boolean ifNotExists) {
    this.tablename = tablemname;
    this.keys = keys;
    this.whereConditions = whereConditions;
    this.valuesToMutate = valuesToMutate;
    this.setValuesToAdd = setValuesToAdd;
    this.setValuesToRemove = setValuesToRemove;
    this.listValuesToAppend = listValuesToAppend;
    this.listValuesToPrepend = listValuesToPrepend;
    this.listValuesToRemove = listValuesToRemove;
    this.mapValuesToMutate = mapValuesToMutate;
    this.onlyIfConditions = onlyIfConditions;
    this.ifNotExists = ifNotExists;
}
 
开发者ID:1and1,项目名称:Troilus,代码行数:26,代码来源:WriteQueryDataImpl.java

示例11: findByEndpointId

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的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

示例12: removeByEndpointId

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的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

示例13: delete

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的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

示例14: diffSet

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的package包/类
private Collection<RegularStatement> diffSet(String table, String column, Clause whereClause, Set<?> past,
        Set<?> present) {

    List<RegularStatement> queries = Lists.newArrayList();

    Set<?> removes = Sets.newHashSet(past);
    removes.removeAll(present);

    if (!removes.isEmpty()) {
        queries.add(QueryBuilder.update(table).with(removeAll(column, removes)).where(whereClause));
    }

    Set<?> adds = Sets.newHashSet(present);
    adds.removeAll(past);

    if (!adds.isEmpty()) {
        queries.add(QueryBuilder.update(table).with(addAll(column, adds)).where(whereClause));
    }

    return queries;
}
 
开发者ID:eevans,项目名称:lucidity,代码行数:22,代码来源:CassandraEntityStore.java

示例15: updateShardPointer

import com.datastax.driver.core.querybuilder.Clause; //导入依赖的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


注:本文中的com.datastax.driver.core.querybuilder.Clause类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。