Package org.apache.cassandra.thrift

Examples of org.apache.cassandra.thrift.SlicePredicate$SlicePredicateTupleScheme


    private void testRangeSliceCommandWrite() throws IOException
    {
        ByteBuffer startCol = ByteBuffer.wrap("Start".getBytes());
        ByteBuffer stopCol = ByteBuffer.wrap("Stop".getBytes());
        ByteBuffer emptyCol = ByteBuffer.wrap("".getBytes());
        SlicePredicate namesPred = new SlicePredicate();
        namesPred.column_names = Statics.NamedCols;
        SliceRange emptySliceRange = new SliceRange(emptyCol, emptyCol, false, 100);
        SliceRange nonEmptySliceRange = new SliceRange(startCol, stopCol, true, 100);
        SlicePredicate emptyRangePred = new SlicePredicate();
        emptyRangePred.slice_range = emptySliceRange;
        SlicePredicate nonEmptyRangePred = new SlicePredicate();
        nonEmptyRangePred.slice_range = nonEmptySliceRange;
        IPartitioner part = StorageService.getPartitioner();
        AbstractBounds bounds = new Range(part.getRandomToken(), part.getRandomToken());
       
        Message namesCmd = new RangeSliceCommand(Statics.KS, "Standard1", null, namesPred, bounds, 100).getMessage();
View Full Code Here


                new Column(getBytes(4), ByteBufferUtil.bytes("val4"), 1),
                new Column(getBytes(5), ByteBufferUtil.bytes("val5"), 1),
                new Column(getBytes(6), ByteBufferUtil.bytes("val6"), 1));
       
        // verify insert.
        final SlicePredicate sp = new SlicePredicate();
        sp.setSlice_range(new SliceRange());
        sp.getSlice_range().setCount(100);
        sp.getSlice_range().setStart(ArrayUtils.EMPTY_BYTE_ARRAY);
        sp.getSlice_range().setFinish(ArrayUtils.EMPTY_BYTE_ARRAY);
       
        assertRowAndColCount(1, 6, scfName, false, cfs.getRangeSlice(scfName, Util.range("f", "g"), 100, QueryFilter.getFilter(sp, cfs.getComparator())));
       
        // deeleet.
        RowMutation rm = new RowMutation(table.name, key.key);
View Full Code Here

        String cfName = "Standard1";
        Table table = Table.open(tableName);
        ColumnFamilyStore cfs = table.getColumnFamilyStore(cfName);
        DecoratedKey key = Util.dk("f-flush-resurrection");
       
        SlicePredicate sp = new SlicePredicate();
        sp.setSlice_range(new SliceRange());
        sp.getSlice_range().setCount(100);
        sp.getSlice_range().setStart(ArrayUtils.EMPTY_BYTE_ARRAY);
        sp.getSlice_range().setFinish(ArrayUtils.EMPTY_BYTE_ARRAY);
       
        // insert
        putColsStandard(cfs, key, column("col1", "val1", 1), column("col2", "val2", 1));
        assertRowAndColCount(1, 2, null, false, cfs.getRangeSlice(null, Util.range("f", "g"), 100, QueryFilter.getFilter(sp, cfs.getComparator())));
       
View Full Code Here

    private static SlicePredicate predicateFromString(String st)
    {
        assert st != null;
        TDeserializer deserializer = new TDeserializer(new TBinaryProtocol.Factory());
        SlicePredicate predicate = new SlicePredicate();
        try
        {
            deserializer.deserialize(predicate, FBUtilities.hexToBytes(st));
        }
        catch (TException e)
View Full Code Here

  public Select() {
    predicateMap = new HashMap<ColumnParent, SlicePredicate>();
  }

  private SlicePredicate getOrCreate(ColumnParent columnParent) {
    SlicePredicate predicate = predicateMap.get(columnParent);
    if (predicate == null) {
      predicate = new SlicePredicate();
      predicateMap.put(columnParent, predicate);
    }
    return predicate;
  }
View Full Code Here

  public Select addColumnName(String superColumnFamily, String superColumn,
      String columnName) {
    ColumnParent parent = new ColumnParent(superColumnFamily);
    parent.setSuper_column(ByteUtils.toBytes(superColumn));
    SlicePredicate predicate = getOrCreate(parent);
    if (predicate.getSlice_range() != null) {
      // TODO: Make this another exception
      throw new RuntimeException("Can't add columns if slice_range is not null");
    }
    predicate.addToColumn_names(ByteUtils.toBytes(columnName));
    return this;
  }
View Full Code Here

    predicate.addToColumn_names(ByteUtils.toBytes(columnName));
    return this;
  }

  public Select addColumnName(String columnFamily, String columnName) {
    SlicePredicate predicate = getOrCreate(new ColumnParent(columnFamily));
    if (predicate.getSlice_range() != null) {
      // TODO: Make this another exception
      throw new RuntimeException("Can't add columns if slice_range is not null");
    }
    predicate.addToColumn_names(ByteUtils.toBytes(columnName));
    return this;
  }
View Full Code Here

  }

  public Mutate deleteAll(String columnFamily) {
    Deletion deletion = new Deletion();
    deletion.setTimestamp(Long.MAX_VALUE); //TODO: check this
    deletion.predicate = new SlicePredicate();
    SliceRange sliceRange =
      new SliceRange(new byte[0], new byte[0], false, Integer.MAX_VALUE);
    deletion.predicate.slice_range = sliceRange;
    Mutation mutation = new Mutation();
    mutation.deletion = deletion;
View Full Code Here

  public Mutate delete(String columnFamily, String columnName) {
    Deletion deletion = new Deletion().setTimestamp(Long.MAX_VALUE);
    // TODO: This will also probably be slow. Try to group
    // deletes together
    deletion.predicate = new SlicePredicate();
    deletion.predicate.addToColumn_names(ByteUtils.toBytes(columnName));

    Mutation mutation = new Mutation();
    mutation.deletion = deletion;
    addToMutationMap(columnFamily, mutation);
View Full Code Here

  public Mutate delete(String superColumnFamily, String superColumnName,
      String columnName) {
    Deletion deletion = new Deletion().setTimestamp(Long.MAX_VALUE);
    // TODO: This will also probably be slow. Try to group
    // deletes together
    deletion.predicate = new SlicePredicate();
    deletion.super_column = ByteUtils.toBytes(superColumnName);
    deletion.predicate.addToColumn_names(ByteUtils.toBytes(columnName));

    Mutation mutation = new Mutation();
    mutation.deletion = deletion;
View Full Code Here

TOP

Related Classes of org.apache.cassandra.thrift.SlicePredicate$SlicePredicateTupleScheme

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.