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


Java StorageProxy.cas方法代码示例

本文整理汇总了Java中org.apache.cassandra.service.StorageProxy.cas方法的典型用法代码示例。如果您正苦于以下问题:Java StorageProxy.cas方法的具体用法?Java StorageProxy.cas怎么用?Java StorageProxy.cas使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.service.StorageProxy的用法示例。


在下文中一共展示了StorageProxy.cas方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeWithCondition

import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
public ResultMessage executeWithCondition(QueryState queryState, QueryOptions options)
throws RequestExecutionException, RequestValidationException
{
    List<ByteBuffer> keys = buildPartitionKeyNames(options);
    // We don't support IN for CAS operation so far
    if (keys.size() > 1)
        throw new InvalidRequestException("IN on the partition key is not supported with conditional updates");

    ByteBuffer key = keys.get(0);
    long now = options.getTimestamp(queryState);
    Composite prefix = createClusteringPrefix(options);

    CQL3CasRequest request = new CQL3CasRequest(cfm, key, false);
    addConditions(prefix, request, options);
    request.addRowUpdate(prefix, this, options, now);

    ColumnFamily result = StorageProxy.cas(keyspace(),
                                           columnFamily(),
                                           key,
                                           request,
                                           options.getSerialConsistency(),
                                           options.getConsistency(),
                                           queryState.getClientState());
    return new ResultMessage.Rows(buildCasResultSet(key, result, options));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:26,代码来源:ModificationStatement.java

示例2: executeWithCondition

import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
public ResultMessage executeWithCondition(QueryState queryState, QueryOptions options)
throws RequestExecutionException, RequestValidationException
{
    CQL3CasRequest request = makeCasRequest(queryState, options);

    try (RowIterator result = StorageProxy.cas(keyspace(),
                                               columnFamily(),
                                               request.key,
                                               request,
                                               options.getSerialConsistency(),
                                               options.getConsistency(),
                                               queryState.getClientState()))
    {
        return new ResultMessage.Rows(buildCasResultSet(result, options));
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:ModificationStatement.java

示例3: executeWithCondition

import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
public ResultMessage executeWithCondition(QueryState queryState, QueryOptions options)
throws RequestExecutionException, RequestValidationException
{
    List<ByteBuffer> keys = buildPartitionKeyNames(options);
    // We don't support IN for CAS operation so far
    if (keys.size() > 1)
        throw new InvalidRequestException("IN on the partition key is not supported with conditional updates");

    ByteBuffer key = keys.get(0);
    long now = options.getTimestamp(queryState);
    Composite prefix = createClusteringPrefix(options);

    CQL3CasRequest request = new CQL3CasRequest(cfm, key, false);
    addConditions(prefix, request, options);
    request.addRowUpdate(prefix, this, options, now);

    ColumnFamily result = StorageProxy.cas(keyspace(),
                                           columnFamily(),
                                           key,
                                           request,
                                           options.getSerialConsistency(),
                                           options.getConsistency());
    return new ResultMessage.Rows(buildCasResultSet(key, result, options));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:25,代码来源:ModificationStatement.java

示例4: executeWithCondition

import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
public ResultMessage executeWithCondition(QueryState queryState, QueryOptions options)
throws RequestExecutionException, RequestValidationException
{
    List<ByteBuffer> variables = options.getValues();
    List<ByteBuffer> keys = buildPartitionKeyNames(variables);
    // We don't support IN for CAS operation so far
    if (keys.size() > 1)
        throw new InvalidRequestException("IN on the partition key is not supported with conditional updates");

    ByteBuffer key = keys.get(0);

    CQL3CasConditions conditions = new CQL3CasConditions(cfm, queryState.getTimestamp());
    Composite prefix = createClusteringPrefix(variables);
    ColumnFamily updates = ArrayBackedSortedColumns.factory.create(cfm);
    addUpdatesAndConditions(key, prefix, updates, conditions, variables, getTimestamp(queryState.getTimestamp(), variables));

    ColumnFamily result = StorageProxy.cas(keyspace(),
                                           columnFamily(),
                                           key,
                                           conditions,
                                           updates,
                                           options.getSerialConsistency(),
                                           options.getConsistency());
    return new ResultMessage.Rows(buildCasResultSet(key, result));
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:26,代码来源:ModificationStatement.java

示例5: executeWithCondition

import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
public ResultMessage executeWithCondition(QueryState queryState, QueryOptions options)
throws RequestExecutionException, RequestValidationException
{
    List<ByteBuffer> variables = options.getValues();
    List<ByteBuffer> keys = buildPartitionKeyNames(variables);
    // We don't support IN for CAS operation so far
    if (keys.size() > 1)
        throw new InvalidRequestException("IN on the partition key is not supported with conditional updates");

    ColumnNameBuilder clusteringPrefix = createClusteringPrefixBuilder(variables);

    ByteBuffer key = keys.get(0);
    ThriftValidation.validateKey(cfm, key);

    UpdateParameters updParams = new UpdateParameters(cfm, variables, queryState.getTimestamp(), getTimeToLive(variables), null);
    ColumnFamily updates = updateForKey(key, clusteringPrefix, updParams);

    // When building the conditions, we should not use the TTL. It's not useful, and if a very low ttl (1 seconds) is used, it's possible
    // for it to expire before actually build the conditions which would break since we would then test for the presence of tombstones.
    UpdateParameters condParams = new UpdateParameters(cfm, variables, queryState.getTimestamp(), 0, null);
    ColumnFamily expected = buildConditions(key, clusteringPrefix, condParams);

    ColumnFamily result = StorageProxy.cas(keyspace(),
                                           columnFamily(),
                                           key,
                                           clusteringPrefix,
                                           expected,
                                           updates,
                                           options.getSerialConsistency(),
                                           options.getConsistency());
    return new ResultMessage.Rows(buildCasResultSet(key, result));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:33,代码来源:ModificationStatement.java

示例6: executeWithCondition

import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
public ResultMessage executeWithCondition(QueryState queryState, QueryOptions options)
throws RequestExecutionException, RequestValidationException
{
    List<ByteBuffer> variables = options.getValues();
    List<ByteBuffer> keys = buildPartitionKeyNames(variables);
    // We don't support IN for CAS operation so far
    if (keys.size() > 1)
        throw new InvalidRequestException("IN on the partition key is not supported with conditional updates");

    Composite clusteringPrefix = createClusteringPrefix(variables);

    ByteBuffer key = keys.get(0);
    ThriftValidation.validateKey(cfm, key);

    UpdateParameters updParams = new UpdateParameters(cfm, variables, queryState.getTimestamp(), getTimeToLive(variables), null);
    ColumnFamily updates = updateForKey(key, clusteringPrefix, updParams);

    // When building the conditions, we should not use the TTL. It's not useful, and if a very low ttl (1 seconds) is used, it's possible
    // for it to expire before actually build the conditions which would break since we would then test for the presence of tombstones.
    UpdateParameters condParams = new UpdateParameters(cfm, variables, queryState.getTimestamp(), 0, null);
    ColumnFamily expected = buildConditions(key, clusteringPrefix, condParams);

    ColumnFamily result = StorageProxy.cas(keyspace(),
                                           columnFamily(),
                                           key,
                                           clusteringPrefix,
                                           expected,
                                           updates,
                                           options.getSerialConsistency(),
                                           options.getConsistency());
    return new ResultMessage.Rows(buildCasResultSet(key, result));
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:33,代码来源:ModificationStatement.java

示例7: executeWithConditions

import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private ResultMessage executeWithConditions(BatchQueryOptions options, QueryState state)
throws RequestExecutionException, RequestValidationException
{
    long now = state.getTimestamp();
    ByteBuffer key = null;
    String ksName = null;
    String cfName = null;
    CQL3CasRequest casRequest = null;
    Set<ColumnDefinition> columnsWithConditions = new LinkedHashSet<>();

    for (int i = 0; i < statements.size(); i++)
    {
        ModificationStatement statement = statements.get(i);
        QueryOptions statementOptions = options.forStatement(i);
        long timestamp = attrs.getTimestamp(now, statementOptions);
        List<ByteBuffer> pks = statement.buildPartitionKeyNames(statementOptions);
        if (pks.size() > 1)
            throw new IllegalArgumentException("Batch with conditions cannot span multiple partitions (you cannot use IN on the partition key)");
        if (key == null)
        {
            key = pks.get(0);
            ksName = statement.cfm.ksName;
            cfName = statement.cfm.cfName;
            casRequest = new CQL3CasRequest(statement.cfm, key, true);
        }
        else if (!key.equals(pks.get(0)))
        {
            throw new InvalidRequestException("Batch with conditions cannot span multiple partitions");
        }

        Composite clusteringPrefix = statement.createClusteringPrefix(statementOptions);
        if (statement.hasConditions())
        {
            statement.addConditions(clusteringPrefix, casRequest, statementOptions);
            // As soon as we have a ifNotExists, we set columnsWithConditions to null so that everything is in the resultSet
            if (statement.hasIfNotExistCondition() || statement.hasIfExistCondition())
                columnsWithConditions = null;
            else if (columnsWithConditions != null)
                Iterables.addAll(columnsWithConditions, statement.getColumnsWithConditions());
        }
        casRequest.addRowUpdate(clusteringPrefix, statement, statementOptions, timestamp);
    }

    ColumnFamily result = StorageProxy.cas(ksName, cfName, key, casRequest, options.getSerialConsistency(), options.getConsistency(), state.getClientState());

    return new ResultMessage.Rows(ModificationStatement.buildCasResultSet(ksName, key, cfName, result, columnsWithConditions, true, options.forStatement(0)));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:48,代码来源:BatchStatement.java

示例8: executeWithConditions

import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private ResultMessage executeWithConditions(BatchQueryOptions options, long now)
throws RequestExecutionException, RequestValidationException
{
    ByteBuffer key = null;
    String ksName = null;
    String cfName = null;
    CQL3CasRequest casRequest = null;
    Set<ColumnDefinition> columnsWithConditions = new LinkedHashSet<>();

    for (int i = 0; i < statements.size(); i++)
    {
        ModificationStatement statement = statements.get(i);
        QueryOptions statementOptions = options.forStatement(i);
        long timestamp = attrs.getTimestamp(now, statementOptions);
        List<ByteBuffer> pks = statement.buildPartitionKeyNames(statementOptions);
        if (pks.size() > 1)
            throw new IllegalArgumentException("Batch with conditions cannot span multiple partitions (you cannot use IN on the partition key)");
        if (key == null)
        {
            key = pks.get(0);
            ksName = statement.cfm.ksName;
            cfName = statement.cfm.cfName;
            casRequest = new CQL3CasRequest(statement.cfm, key, true);
        }
        else if (!key.equals(pks.get(0)))
        {
            throw new InvalidRequestException("Batch with conditions cannot span multiple partitions");
        }

        Composite clusteringPrefix = statement.createClusteringPrefix(statementOptions);
        if (statement.hasConditions())
        {
            statement.addConditions(clusteringPrefix, casRequest, statementOptions);
            // As soon as we have a ifNotExists, we set columnsWithConditions to null so that everything is in the resultSet
            if (statement.hasIfNotExistCondition() || statement.hasIfExistCondition())
                columnsWithConditions = null;
            else if (columnsWithConditions != null)
                Iterables.addAll(columnsWithConditions, statement.getColumnsWithConditions());
        }
        casRequest.addRowUpdate(clusteringPrefix, statement, statementOptions, timestamp);
    }

    ColumnFamily result = StorageProxy.cas(ksName, cfName, key, casRequest, options.getSerialConsistency(), options.getConsistency());

    return new ResultMessage.Rows(ModificationStatement.buildCasResultSet(ksName, key, cfName, result, columnsWithConditions, true, options.forStatement(0)));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:47,代码来源:BatchStatement.java

示例9: executeWithConditions

import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private ResultMessage executeWithConditions(BatchVariables variables, ConsistencyLevel cl, ConsistencyLevel serialCf, long now)
throws RequestExecutionException, RequestValidationException
{
    ByteBuffer key = null;
    String ksName = null;
    String cfName = null;
    ColumnFamily updates = null;
    CQL3CasConditions conditions = null;
    Set<ColumnDefinition> columnsWithConditions = new LinkedHashSet<ColumnDefinition>();

    for (int i = 0; i < statements.size(); i++)
    {
        ModificationStatement statement = statements.get(i);
        List<ByteBuffer> statementVariables = variables.getVariablesForStatement(i);
        long timestamp = attrs.getTimestamp(now, statementVariables);
        List<ByteBuffer> pks = statement.buildPartitionKeyNames(statementVariables);
        if (pks.size() > 1)
            throw new IllegalArgumentException("Batch with conditions cannot span multiple partitions (you cannot use IN on the partition key)");
        if (key == null)
        {
            key = pks.get(0);
            ksName = statement.cfm.ksName;
            cfName = statement.cfm.cfName;
            conditions = new CQL3CasConditions(statement.cfm, now);
            updates = ArrayBackedSortedColumns.factory.create(statement.cfm);
        }
        else if (!key.equals(pks.get(0)))
        {
            throw new InvalidRequestException("Batch with conditions cannot span multiple partitions");
        }

        Composite clusteringPrefix = statement.createClusteringPrefix(statementVariables);
        if (statement.hasConditions())
        {
            statement.addUpdatesAndConditions(key, clusteringPrefix, updates, conditions, statementVariables, timestamp);
            // As soon as we have a ifNotExists, we set columnsWithConditions to null so that everything is in the resultSet
            if (statement.hasIfNotExistCondition() || statement.hasIfExistCondition())
                columnsWithConditions = null;
            else if (columnsWithConditions != null)
                Iterables.addAll(columnsWithConditions, statement.getColumnsWithConditions());
        }
        else
        {
            UpdateParameters params = statement.makeUpdateParameters(Collections.singleton(key), clusteringPrefix, statementVariables, false, cl, now);
            statement.addUpdateForKey(updates, key, clusteringPrefix, params);
        }
    }

    ColumnFamily result = StorageProxy.cas(ksName, cfName, key, conditions, updates, serialCf, cl);
    return new ResultMessage.Rows(ModificationStatement.buildCasResultSet(ksName, key, cfName, result, columnsWithConditions, true));
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:52,代码来源:BatchStatement.java


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