Package com.netflix.astyanax

Examples of com.netflix.astyanax.MutationBatch


    @SuppressWarnings("unchecked")
    public void writeTuple(Tuple input, TupleMapper<K, C, V> tupleMapper) throws Exception {
        String columnFamilyName = tupleMapper.mapToColumnFamily(input);
        String keyspace = tupleMapper.mapToKeyspace(input);
        K rowKey = tupleMapper.mapToRowKey(input);
        MutationBatch mutation = getKeyspace(keyspace).prepareMutationBatch();
        ColumnFamily<K, C> columnFamily = new ColumnFamily<K, C>(columnFamilyName,
                (Serializer<K>) serializerFor(tupleMapper.getKeyClass()),
                (Serializer<C>) serializerFor(tupleMapper.getColumnNameClass()));
        this.addTupleToMutation(input, columnFamily, rowKey, mutation, tupleMapper);
        mutation.execute();
    }
View Full Code Here


    @SuppressWarnings("unchecked")
    public void writeTuple(TridentTuple input, TridentTupleMapper<K, C, V> tupleMapper) throws Exception {
        String columnFamilyName = tupleMapper.mapToColumnFamily(input);
        String keyspace = tupleMapper.mapToKeyspace(input);
        K rowKey = tupleMapper.mapToRowKey(input);
        MutationBatch mutation = getKeyspace(keyspace).prepareMutationBatch();
        ColumnFamily<K, C> columnFamily = new ColumnFamily<K, C>(columnFamilyName,
                (Serializer<K>) serializerFor(tupleMapper.getKeyClass()),
                (Serializer<C>) serializerFor(tupleMapper.getColumnNameClass()));
        this.addTupleToMutation(input, columnFamily, rowKey, mutation, tupleMapper);
        mutation.execute();
    }
View Full Code Here

    @SuppressWarnings({ "static-access", "unchecked" })
    public void writeTuples(List<TridentTuple> inputs, TridentTupleMapper<K, C, V> tupleMapper) throws Exception {
        Map<String, MutationBatch> mutations = new HashMap<String, MutationBatch>();
        for (TridentTuple input : inputs) {
            String keyspace = tupleMapper.mapToKeyspace(input);
            MutationBatch mutation = mutations.get(keyspace);
            if(mutation == null) {
                mutation = getKeyspace(keyspace).prepareMutationBatch();
                mutations.put(keyspace, mutation);
            }
           
View Full Code Here

    @SuppressWarnings({ "static-access", "unchecked" })
    public void writeTuples(List<Tuple> inputs, TupleMapper<K, C, V> tupleMapper) throws Exception {
        Map<String, MutationBatch> mutations = new HashMap<String, MutationBatch>();
        for (Tuple input : inputs) {
            String keyspace = tupleMapper.mapToKeyspace(input);
            MutationBatch mutation = mutations.get(keyspace);
            if(mutation == null) {
                mutation = getKeyspace(keyspace).prepareMutationBatch();
                mutations.put(keyspace, mutation);
            }
           
View Full Code Here

  public void incrementCountColumn(Tuple input, TupleCounterMapper<K,C> tupleMapper) throws Exception {
        String columnFamilyName = tupleMapper.mapToColumnFamily(input);
        String keyspace = tupleMapper.mapToKeyspace(input);
        K rowKey = tupleMapper.mapToRowKey(input);
        long incrementAmount = tupleMapper.mapToIncrementAmount(input);
        MutationBatch mutation = getKeyspace(keyspace).prepareMutationBatch();
        ColumnFamily<K, C> columnFamily = new ColumnFamily<K, C>(columnFamilyName,
                (Serializer<K>) serializerFor(tupleMapper.getKeyClass()),
                (Serializer<C>) serializerFor(tupleMapper.getColumnNameClass()));
        for (C columnName : tupleMapper.mapToColumnList(input)) {
            mutation.withRow(columnFamily, rowKey).incrementCounterColumn(columnName, incrementAmount);
        }
        mutation.execute();
    }
View Full Code Here

        return values;
    }

    @Override
    public void multiPut(List<List<Object>> keys, List<T> values) {
        MutationBatch mutation = this.keyspace.prepareMutationBatch();
        ColumnFamily<Composite, String> cf = new ColumnFamily<Composite, String>(this.options.columnFamily,
                CompositeSerializer.get(), StringSerializer.get());

        for (int i = 0; i < keys.size(); i++) {
            Composite keyName = toKeyName(keys.get(i));
            byte[] bytes = serializer.serialize(values.get(i));
            if (options.ttl != null && options.ttl > 0) {
                mutation.withRow(cf, keyName).putColumn(this.options.columnName, bytes, options.ttl);
            } else {
                mutation.withRow(cf, keyName).putColumn(this.options.columnName, bytes);
            }
        }
        try {
            mutation.execute();
        } catch (ConnectionException e) {
            throw new RuntimeException("Batch mutation for state failed.", e);
        }
    }
View Full Code Here

    @SuppressWarnings("unchecked")
  public void incrementCountColumns(List<Tuple> inputs, TupleCounterMapper<K,C> tupleMapper) throws Exception {   
        Map<String, MutationBatch> mutations = new HashMap<String, MutationBatch>();
        for (Tuple input : inputs) {
            String keyspace = tupleMapper.mapToKeyspace(input);           
            MutationBatch mutation = mutations.get(keyspace);
            if(mutation == null) {
                mutation = getKeyspace(keyspace).prepareMutationBatch();
                mutations.put(keyspace, mutation);
            }
            String columnFamilyName = tupleMapper.mapToColumnFamily(input);
            K rowKey = tupleMapper.mapToRowKey(input);
            long incrementAmount = tupleMapper.mapToIncrementAmount(input);
            ColumnFamily<K, C> columnFamily = new ColumnFamily<K, C>(columnFamilyName,
                    (Serializer<K>) serializerFor(tupleMapper.getKeyClass()),
                    (Serializer<C>) serializerFor(tupleMapper.getColumnNameClass()));
            for (C columnName : tupleMapper.mapToColumnList(input)) {
                mutation.withRow(columnFamily, rowKey).incrementCounterColumn(columnName, incrementAmount);
            }
        }
        for(String key : mutations.keySet()) {
            mutations.get(key).execute();
        }
View Full Code Here

            AstyanaxContext<Keyspace> context = newContext("localhost:9160", KEYSPACE);
            Keyspace ks = context.getEntity();
            ColumnFamily<String, Composite> cf = new ColumnFamily<String, Composite>("composite",
                    StringSerializer.get(), CompositeSerializer.get());

            MutationBatch mutation = ks.prepareMutationBatch();

            mutation.withRow(cf, "mykey").putColumn(makeStringComposite("foo", "bar"),
                    "Hello Composite Column Range Query");
            mutation.withRow(cf, "mykey").putColumn(makeStringComposite("foo", "baz"), "My dog has fleas");
            mutation.withRow(cf, "mykey").putColumn(makeStringComposite("fzz", "baz"), "It is snowing");

            mutation.execute();

            // simple column fetch
            ColumnFamilyQuery<String, Composite> query = ks.prepareQuery(cf);
            Column<Composite> result = query.getKey("mykey").getColumn(makeStringComposite("foo", "bar")).execute()
                    .getResult();
View Full Code Here

            AstyanaxContext<Keyspace> context = newContext("localhost:9160", KEYSPACE);
            Keyspace ks = context.getEntity();
            ColumnFamily<String, Composite> cf = new ColumnFamily<String, Composite>("composite2",
                    StringSerializer.get(), CompositeSerializer.get());

            MutationBatch mutation = ks.prepareMutationBatch();
           
            List<String> combinations = combinationsWithRepitition("abcdef", 3);
           
            for(String str : combinations){
                LOG.debug("Will insert '{}'", str);
                mutation.withRow(cf, rowkey).putColumn(makeStringComposite(str.substring(0,1), str.substring(1,2), str.substring(2,3)), str);
            }

            mutation.execute();

            // build up a composite range query
            Composite start = makeStringEqualityComposite(new String[] { "a", "a", "a"}, new ComponentEquality[] {
                    ComponentEquality.EQUAL,ComponentEquality.EQUAL, ComponentEquality.EQUAL });
            Composite end = makeStringEqualityComposite(new String[] { "a", "a", "b"}, new ComponentEquality[] {
View Full Code Here

       
        AnnotatedCompositeSerializer<Composite2> acs = new AnnotatedCompositeSerializer<Composite2>(Composite2.class);
       
        ColumnFamily<String, Composite2> cf = new ColumnFamily<String, Composite2>("generic", StringSerializer.get(), acs);
       
        MutationBatch mutation = ks.prepareMutationBatch();
       
       
       
        mutation.withRow(cf, "foo").putColumn(c2, "Hello World");
       
        mutation.execute();
       
       
    }
View Full Code Here

TOP

Related Classes of com.netflix.astyanax.MutationBatch

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.