Package org.apache.cassandra.thrift

Examples of org.apache.cassandra.thrift.Mutation$MutationTupleSchemeFactory


    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


    }

    /** compose Cassandra mutation from tuple */
    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

       
        List<Mutation> mutationList = new ArrayList<Mutation>(mutations.size());
        long timestamp = cassandraTemplate.createTimestamp();
        if (superColumnName != null) {
            List<Column> columns = new ArrayList<Column>();
            Mutation mutation = new Mutation();

            for (Map.Entry<String, ByteBuffer> entry : mutations.entrySet()) {
                Column column = new Column(bytes(entry.getKey()));
                column.setValue(entry.getValue());
                column.setTimestamp(timestamp);
                columns.add(column);
            }

            SuperColumn superColumn = new SuperColumn(bytes(superColumnName), columns);
            mutation.setColumn_or_supercolumn(new ColumnOrSuperColumn().setSuper_column(superColumn));
            mutationList.add(mutation);
        } else {
            for (Map.Entry<String, ByteBuffer> entry : mutations.entrySet()) {
                Column column = new Column(bytes(entry.getKey()));
                column.setValue(entry.getValue());
                column.setTimestamp(timestamp);
                Mutation mutation = new Mutation();
                mutation.setColumn_or_supercolumn(new ColumnOrSuperColumn().setColumn(column));
                mutationList.add(mutation);
            }
        }
        innerMutationMap.put(columnFamily, mutationList);
        result.put(bytes(rowKey), innerMutationMap);
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

        deletion.setSuper_column(superColumn);
      }
      if (column != null) { // Single column delete
        deletion.setPredicate(new SlicePredicate().setColumn_names(Arrays.asList(new byte[][] { column })));
      } // else Delete entire column family or supercolumn
      columnFamilyMutations.add(new Mutation().setDeletion(deletion));
    } else { // Insert/update
      ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();
      if(superColumn!=null) {
        List<Column> columns = new ArrayList<Column>();
        columns.add(new Column(column, value, System.currentTimeMillis()));
        cosc.setSuper_column(new SuperColumn(superColumn, columns));
      } else {
        cosc.setColumn(new Column(column, value, System.currentTimeMillis()));
      }
      columnFamilyMutations.add(new Mutation().setColumn_or_supercolumn(cosc));
    }
  }
View Full Code Here

       
        List<Mutation> mutationList = new ArrayList<Mutation>(mutations.size());
        long timestamp = cassandraTemplate.createTimestamp();
        if (superColumnName != null) {
            List<Column> columns = new ArrayList<Column>();
            Mutation mutation = new Mutation();

            for (Map.Entry<String, ByteBuffer> entry : mutations.entrySet()) {
                Column column = new Column(bytes(entry.getKey()));
                column.setValue(entry.getValue());
                column.setTimestamp(timestamp);
                columns.add(column);
            }

            SuperColumn superColumn = new SuperColumn(bytes(superColumnName), columns);
            mutation.setColumn_or_supercolumn(new ColumnOrSuperColumn().setSuper_column(superColumn));
            mutationList.add(mutation);
        } else {
            for (Map.Entry<String, ByteBuffer> entry : mutations.entrySet()) {
                Column column = new Column(bytes(entry.getKey()));
                column.setValue(entry.getValue());
                column.setTimestamp(timestamp);
                Mutation mutation = new Mutation();
                mutation.setColumn_or_supercolumn(new ColumnOrSuperColumn().setColumn(column));
                mutationList.add(mutation);
            }
        }
        innerMutationMap.put(columnFamily, mutationList);
        result.put(bytes(rowKey), innerMutationMap);
View Full Code Here

        Cassandra.Client client = new Cassandra.Client(
                                    new TBinaryProtocol(
                                        new TFramedTransportFactory().openTransport(
                                            InetAddress.getLocalHost().getHostName(), 9170)));
        client.set_keyspace(ksName);
        Mutation mutation = new Mutation();
        ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();
        cosc.setColumn(getColumnForInsert("v1", 3));
        mutation.setColumn_or_supercolumn(cosc);
        client.batch_mutate(
            Collections.singletonMap(ByteBufferUtil.bytes(3),
                                     Collections.singletonMap(cfName,
                                                              Collections.singletonList(mutation))),
            org.apache.cassandra.thrift.ConsistencyLevel.ONE);
View Full Code Here

        List<Mutation> mutationList = new ArrayList<Mutation>();
        cfMutation.put(ConfigHelper.getOutputColumnFamily(context.getConfiguration()), mutationList);

        if (value == null)
        {
            Mutation mutation = new Mutation();
            Deletion deletion = new Deletion(clock);
            mutation.setDeletion(deletion);
            mutationList.add(mutation);
        }
        else
        {
            List<byte[]> columnsToDelete = new ArrayList<byte[]>();
            for (IColumn column : value)
            {
                Mutation mutation = new Mutation();
                if (column.value() == null)
                {
                    if (columnsToDelete.size() != 1 || columnsToDelete.get(0) != null)
                    {
                        if (column.name() == null)
                            columnsToDelete.clear();
                        columnsToDelete.add(column.name());
                    }
                }
                else
                {

                    ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();
                    cosc.setColumn(new Column(column.name(), column.value(), clock));
                    mutation.setColumn_or_supercolumn(cosc);
                }
                mutationList.add(mutation);
            }

            if (columnsToDelete.size() > 0)
            {
                Mutation mutation = new Mutation();
                Deletion deletion = new Deletion(clock);

                if (columnsToDelete.size() != 1 || columnsToDelete.get(0) != null)
                {
                    deletion.setPredicate(new SlicePredicate().setColumn_names(columnsToDelete));
                }
                else
                {
                    SliceRange range = new SliceRange(new byte[]{ }, new byte[]{ }, false, Integer.MAX_VALUE);
                    deletion.setPredicate(new SlicePredicate().setSlice_range(range));
                }

                mutation.setDeletion(deletion);
                mutationList.add(mutation);
            }
        }
    }
View Full Code Here

         }
         if (columnName != null) { // Single column delete
            deletion.setPredicate(new SlicePredicate().setColumn_names(Collections
                     .singletonList(columnName)));
         } // else Delete entire column family or supercolumn
         columnFamilyMutations.add(new Mutation().setDeletion(deletion));
      } else { // Insert/update
         ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();
         if (superColumn != null) {
            List<Column> columns = new ArrayList<Column>(1);
            Column col = new Column(columnName);
            col.setValue(value);
            col.setTimestamp(microTimestamp());
            columns.add(col);
            cosc.setSuper_column(new SuperColumn(superColumn, columns));
         } else {
            Column col = new Column(columnName);
            col.setValue(value);
            col.setTimestamp(microTimestamp());
            cosc.setColumn(col);
         }
         columnFamilyMutations.add(new Mutation().setColumn_or_supercolumn(cosc));
      }
   }
View Full Code Here

TOP

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

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.