Package org.apache.cassandra.thrift

Examples of org.apache.cassandra.thrift.Mutation


        Column col = new Column(StringSerializer.get().toByteBuffer("testBatchMutateColumn_" + j),
            StringSerializer.get().toByteBuffer("testBatchMutateColumn_value_" + j), connectionManager.createClock());
        //list.add(col);
        ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();
        cosc.setColumn(col);
        Mutation mutation = new Mutation();
        mutation.setColumn_or_supercolumn(cosc);
        mutations.add(mutation);
      }
      mutationMap.put("Standard1", mutations);
      outerMutationMap.put("testBatchMutateColumn_" + i, mutationMap);
    }
    keyspace.batchMutate(se.toBytesMap(outerMutationMap));
    // re-use later
    outerMutationMap.clear();

    // get value
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        ColumnPath cp = new ColumnPath("Standard1");
        cp.setColumn(bytes("testBatchMutateColumn_" + j));

        Column col = keyspace.getColumn("testBatchMutateColumn_" + i, cp);
        assertNotNull(col);
        String value = string(col.getValue());
        assertEquals("testBatchMutateColumn_value_" + j, value);

      }
    }

    // batch_mutate delete by key
    for (int i = 0; i < 10; i++) {
      ArrayList<Mutation> mutations = new ArrayList<Mutation>(10);
      Map<String, List<Mutation>> mutationMap = new HashMap<String, List<Mutation>>();
      SlicePredicate slicePredicate = new SlicePredicate();
      for (int j = 0; j < 10; j++) {
        slicePredicate.addToColumn_names(StringSerializer.get().toByteBuffer("testBatchMutateColumn_" + j));
      }
      Mutation mutation = new Mutation();
      Deletion deletion = new Deletion(connectionManager.createClock());
      deletion.setPredicate(slicePredicate);
      mutation.setDeletion(deletion);
      mutations.add(mutation);

      mutationMap.put("Standard1", mutations);
      outerMutationMap.put("testBatchMutateColumn_"+i, mutationMap);
    }
View Full Code Here


  }

  public Mutate put(String columnFamily, String columnName,
      byte[] value, long timestamp) {

    Mutation mutation = new Mutation();
    ColumnOrSuperColumn csc = new ColumnOrSuperColumn();
    csc.column = new Column(ByteUtils.toBytes(columnName), value, timestamp);
    mutation.setColumn_or_supercolumn(csc);
    addToMutationMap(columnFamily, mutation);

    return this;
  }
View Full Code Here

  }

  public Mutate put(String superColumnFamily, String superColumnName,
      String columnName, byte[] value, long timestamp) {

    Mutation mutation = new Mutation();
    ColumnOrSuperColumn csc = new ColumnOrSuperColumn();
    csc.super_column = new SuperColumn();
    csc.super_column.name = ByteUtils.toBytes(superColumnName);
    // TODO: This will probably be slow. Try to group all columns
    // under a supercolumn within a single mutation object
    csc.super_column.addToColumns(
        new Column(ByteUtils.toBytes(columnName), value, timestamp));
    mutation.setColumn_or_supercolumn(csc);
    addToMutationMap(superColumnFamily, mutation);

    return this;
  }
View Full Code Here

    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;
    addToMutationMap(columnFamily, mutation);
    return this;
  }
View Full Code Here

    // 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);
    return this;
  }
View Full Code Here

    // 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;
    addToMutationMap(superColumnFamily, mutation);
    return this;
  }
View Full Code Here

        Map<ByteBuffer,AbstractType> validators = getValidatorMap(cfDef);
        try
        {
            for (Tuple pair : pairs)
            {
               Mutation mutation = new Mutation();
               if (DataType.findType(pair.get(1)) == DataType.BAG) // supercolumn
               {
                   org.apache.cassandra.thrift.SuperColumn sc = new org.apache.cassandra.thrift.SuperColumn();
                   sc.name = objToBB(pair.get(0));
                   ArrayList<org.apache.cassandra.thrift.Column> columns = new ArrayList<org.apache.cassandra.thrift.Column>();
View Full Code Here

            writeMutations(key, mutationList);
    }

    private Mutation mutationFromTuple(Tuple t) throws IOException
    {
        Mutation mutation = new Mutation();
        if (t.get(1) == null)
        {
            if (allow_deletes)
            {
                mutation.deletion = new Deletion();
View Full Code Here

    private void writeColumnsFromBag(ByteBuffer key, DefaultDataBag bag) throws IOException
    {
        List<Mutation> mutationList = new ArrayList<Mutation>();
        for (Tuple pair : bag)
        {
            Mutation mutation = new Mutation();
            if (DataType.findType(pair.get(1)) == DataType.BAG) // supercolumn
            {
                SuperColumn sc = new SuperColumn();
                sc.setName(objToBB(pair.get(0)));
                List<org.apache.cassandra.thrift.Column> columns = new ArrayList<org.apache.cassandra.thrift.Column>();
View Full Code Here

            writeMutations(key, mutationList);
    }

    private Mutation mutationFromTuple(Tuple t) throws IOException
    {
        Mutation mutation = new Mutation();
        if (t.get(1) == null)
        {
            if (allow_deletes)
            {
                mutation.deletion = new Deletion();
View Full Code Here

TOP

Related Classes of org.apache.cassandra.thrift.Mutation

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.