Package org.apache.cassandra.thrift

Examples of org.apache.cassandra.thrift.KeyRange$KeyRangeStandardScheme


            }
            conn = getConnection();

            if (ixClause.isEmpty())
            {
                KeyRange keyRange = new KeyRange(maxResult);
                keyRange.setStart_key(ByteBufferUtil.EMPTY_BYTE_BUFFER);
                keyRange.setEnd_key(ByteBufferUtil.EMPTY_BYTE_BUFFER);

                if (m.isCounterColumnType())
                {
                    List<KeySlice> ks = conn.getClient().get_range_slices(new ColumnParent(m.getTableName()),
                            slicePredicate, keyRange, getConsistencyLevel());
View Full Code Here


            sliceRange.setStart(ByteBufferUtil.EMPTY_BYTE_BUFFER);
            sliceRange.setFinish(ByteBufferUtil.EMPTY_BYTE_BUFFER);
            slicePredicate.setSlice_range(sliceRange);
        }

        KeyRange keyRange = new KeyRange(maxResults);
        keyRange.setStart_key(minVal == null ? "".getBytes() : minVal);
        keyRange.setEnd_key(maxVal == null ? "".getBytes() : maxVal);
        ColumnParent cp = new ColumnParent(m.getTableName());

        if (conditions != null && !conditions.isEmpty())
        {
            keyRange.setRow_filter(conditions);
            keyRange.setRow_filterIsSet(true);
        }

        Connection conn = getConnection();

        List<KeySlice> keys = conn.getClient().get_range_slices(cp, slicePredicate, keyRange, getConsistencyLevel());
View Full Code Here

        List<InputSplit> splits = new ArrayList<InputSplit>();

        try
        {
            List<Future<List<InputSplit>>> splitfutures = new ArrayList<Future<List<InputSplit>>>();
            KeyRange jobKeyRange = ConfigHelper.getInputKeyRange(conf);
            Range<Token> jobRange = null;
            if (jobKeyRange != null)
            {
                if (jobKeyRange.start_key == null)
                {
View Full Code Here

  /**
   *
   * @return The thrift representation of this object
   */
  public KeyRange toThrift() {
    KeyRange keyRange = new KeyRange(rowCount);
    keyRange.setStart_key(startKey == null ? ByteBuffer.wrap(new byte[0]) :
        keySerializer.toByteBuffer(startKey));
    keyRange.setEnd_key(endKey == null ? ByteBuffer.wrap(new byte[0]) :
        keySerializer.toByteBuffer(endKey));
    return keyRange;
  }
View Full Code Here

    prefixBytes = keyPrefixSerializer.toByteBuffer(keyPrefix);
    ps = new PrefixedSerializer<ByteBuffer, ByteBuffer>(prefixBytes, be, be);
  }

  public KeyRange prefixKeyRange(KeyRange unprefixed) {
    KeyRange prefixed = new KeyRange();
    prefixed.count = unprefixed.count;
    prefixed.end_token = unprefixed.end_token;
    prefixed.end_key = ps.toByteBuffer(unprefixed.end_key);
    prefixed.start_token = unprefixed.start_token;
    prefixed.start_key = ps.toByteBuffer(unprefixed.start_key);
View Full Code Here

    prefixed.start_key = ps.toByteBuffer(unprefixed.start_key);
    return prefixed;
  }

  public KeyRange unprefixKeyRange(KeyRange prefixed) {
    KeyRange unprefixed = new KeyRange();
    unprefixed.count = prefixed.count;
    unprefixed.end_token = prefixed.end_token;
    unprefixed.end_key = ps.fromByteBuffer(prefixed.end_key);
    unprefixed.start_token = prefixed.start_token;
    unprefixed.start_key = ps.fromByteBuffer(prefixed.start_key);
View Full Code Here

    this.prefixBytes = prefixBytes;
    ps = new PrefixedSerializer<ByteBuffer, ByteBuffer>(prefixBytes, be, be);
  }

  public KeyRange prefixKeyRange(KeyRange unprefixed) {
    KeyRange prefixed = new KeyRange();
    prefixed.count = unprefixed.count;
    prefixed.end_token = unprefixed.end_token;
    prefixed.end_key = ps.toByteBuffer(unprefixed.end_key);
    prefixed.start_token = unprefixed.start_token;
    prefixed.start_key = ps.toByteBuffer(unprefixed.start_key);
View Full Code Here

    prefixed.start_key = ps.toByteBuffer(unprefixed.start_key);
    return prefixed;
  }

  public KeyRange unprefixKeyRange(KeyRange prefixed) {
    KeyRange unprefixed = new KeyRange();
    unprefixed.count = prefixed.count;
    unprefixed.end_token = prefixed.end_token;
    unprefixed.end_key = ps.fromByteBuffer(prefixed.end_key);
    unprefixed.start_token = prefixed.start_token;
    unprefixed.start_key = ps.fromByteBuffer(prefixed.start_key);
View Full Code Here

        }
        final CountDownLatch doneSignal = new CountDownLatch(ranges.size());

        for (final Pair<String, String> tokenPair : ranges) {
            // Prepare the range of tokens for this token range
            final KeyRange range = new KeyRange()
                    .setCount(getBlockSize())
                    .setStart_token(tokenPair.left)
                    .setEnd_token(tokenPair.right);

            query.executor.submit(new Callable<Void>() {
                private boolean firstBlock = true;
               
                @Override
                public Void call() throws Exception {
                    if (error.get() == null && internalRun()) {
                        query.executor.submit(this);
                    }
                    else {
                        doneSignal.countDown();
                    }
                    return null;
                }

                private boolean internalRun() throws Exception {
                    try {
                        // Get the next block
                        List<KeySlice> ks = keyspace.connectionPool.executeWithFailover(
                                new AbstractKeyspaceOperationImpl<List<KeySlice>>(keyspace.tracerFactory
                                        .newTracer(CassandraOperationType.GET_ROWS_RANGE,
                                                columnFamily), query.pinnedHost, keyspace
                                        .getKeyspaceName()) {
                                    @Override
                                    public List<KeySlice> internalExecute(Client client, ConnectionContext context)
                                            throws Exception {
                                        return client.get_range_slices(new ColumnParent()
                                                .setColumn_family(columnFamily.getName()),
                                                predicate, range, ThriftConverter
                                                        .ToThriftConsistencyLevel(query.consistencyLevel));
                                    }

                                    @Override
                                    public ByteBuffer getRowKey() {
                                        if (range.getStart_key() != null)
                                            return ByteBuffer.wrap(range.getStart_key());
                                        return null;
                                    }
                                }, query.retry.duplicate()).getResult();

                        // Notify the callback
                        if (!ks.isEmpty()) {
                            KeySlice lastRow = Iterables.getLast(ks);
                            boolean bContinue = (ks.size() == getBlockSize());

                            if (getRepeatLastToken()) {
                                if (firstBlock) {
                                    firstBlock = false;
                                }
                                else {
                                    ks.remove(0);
                                }
                            }
                           
                            if (bIgnoreTombstones) {
                                Iterator<KeySlice> iter = ks.iterator();
                                while (iter.hasNext()) {
                                    if (iter.next().getColumnsSize() == 0)
                                        iter.remove();
                                }
                            }
                            Rows<K, C> rows = new ThriftRowsSliceImpl<K, C>(ks, columnFamily
                                    .getKeySerializer(), columnFamily.getColumnSerializer());
                            try {
                                callback.success(rows);
                            }
                            catch (Throwable t) {
                                ConnectionException ce = ThriftConverter.ToConnectionPoolException(t);
                                error.set(ce);
                                return false;
                            }
                           
                            if (bContinue) {
                                // Determine the start token for the next page
                                String token = partitioner.getTokenForKey(lastRow.bufferForKey()).toString();
                                checkpointManager.trackCheckpoint(tokenPair.left, token);
                                if (getRepeatLastToken()) {
                                    range.setStart_token(partitioner.getTokenMinusOne(token));
                                }
                                else {
                                    range.setStart_token(token);
                                }
                            }
                            else {
                                checkpointManager.trackCheckpoint(tokenPair.left, tokenPair.right);
                                return false;
View Full Code Here

                            @Override
                            public Rows<K, C> internalExecute(Client client, ConnectionContext context) throws Exception {
                                // This is a sorted list
                                // Same call for standard and super columns via
                                // the ColumnParent
                                KeyRange range = new KeyRange();
                                if (startKey != null)
                                    range.setStart_key(columnFamily.getKeySerializer().toByteBuffer(startKey));
                                if (endKey != null)
                                    range.setEnd_key(columnFamily.getKeySerializer().toByteBuffer(endKey));
                                range.setCount(count).setStart_token(startToken).setEnd_token(endToken);

                                List<org.apache.cassandra.thrift.KeySlice> keySlices = client.get_range_slices(
                                        new ColumnParent().setColumn_family(columnFamily.getName()), predicate, range,
                                        ThriftConverter.ToThriftConsistencyLevel(consistencyLevel));
View Full Code Here

TOP

Related Classes of org.apache.cassandra.thrift.KeyRange$KeyRangeStandardScheme

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.