Package org.apache.cassandra.thrift

Examples of org.apache.cassandra.thrift.ColumnOrSuperColumn$ColumnOrSuperColumnTupleScheme


                    }
                }
                else
                {

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


   public InternalCacheEntry load(Object key) throws CacheLoaderException {
      String hashKey = hashKey(key);
      Cassandra.Client cassandraClient = null;
      try {
         cassandraClient = dataSource.getConnection();
         ColumnOrSuperColumn column = cassandraClient.get(ByteBufferUtil.bytes(hashKey),
                  entryColumnPath, readConsistencyLevel);
         InternalCacheEntry ice = unmarshall(column.getColumn().getValue(), key);
         if (ice != null && ice.isExpired(System.currentTimeMillis())) {
            remove(key);
            return null;
         }
         return ice;
View Full Code Here

            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

        // read
        ColumnPath cp = new ColumnPath("Standard1");
        cp.setColumn("name".getBytes("utf-8"));

        ColumnOrSuperColumn got = client.get(key_user_id.getBytes(), cp,
                ConsistencyLevel.ONE);

        // assert
        assertNotNull("Got a null ColumnOrSuperColumn", got);
        assertEquals("Ran", new String(got.getColumn().getValue(), "utf-8"));
    }
View Full Code Here

            c.setName(ByteBufferUtil.bytes(name));
            c.setValue(ByteBufferUtil.bytes(value));
            c.setTimestamp(timestamp);

            Mutation m = new Mutation();
            ColumnOrSuperColumn cc = new ColumnOrSuperColumn();
            cc.setColumn(c);
            m.setColumn_or_supercolumn(cc);
            slice.add(m);
        }
        Map<ByteBuffer, Map<String, List<Mutation>>> mutationMap = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
        Map<String, List<Mutation>> cfMutations = new HashMap<String, List<Mutation>>();
View Full Code Here

    public String getColumn(String keyspace, String columnFamily, String key, String column,
            ConsistencyLevel consistencyLevel) throws InvalidRequestException, NotFoundException, UnavailableException,
            TimedOutException, TException, UnsupportedEncodingException {
        ColumnPath path = new ColumnPath(columnFamily);
        path.setColumn(ByteBufferUtil.bytes(column));
        ColumnOrSuperColumn column_result = getConnection(keyspace).get(ByteBufferUtil.bytes(key), path,
                consistencyLevel);
        return new String(column_result.getColumn().getValue(), "UTF8");
    }
View Full Code Here

    @Test
    public void testColumn() throws Exception {
        Column column = new Column(ByteBufferUtil.bytes("ADDR1"));
        column.setValue(ByteBufferUtil.bytes("1234 Fun St."));
        column.setTimestamp(System.currentTimeMillis() * 1000);
        ColumnOrSuperColumn col = new ColumnOrSuperColumn();
        col.setColumn(column);
        String json = JsonMarshaller.marshallColumn(col);
        assertEquals("{\"ADDR1\":\"1234 Fun St.\"}", json);
    }
View Full Code Here

    @Test
    public void testSlice() throws Exception {
        Column column1 = new Column(ByteBufferUtil.bytes("ADDR1"));
        column1.setValue(ByteBufferUtil.bytes("1234 Fun St."));
        column1.setTimestamp(System.currentTimeMillis() * 1000);
        ColumnOrSuperColumn col1 = new ColumnOrSuperColumn();
        col1.setColumn(column1);

        Column column2 = new Column(ByteBufferUtil.bytes("CITY"));
        column2.setValue(ByteBufferUtil.bytes("Souderton."));
        column2.setTimestamp(System.currentTimeMillis() * 1000);
        ColumnOrSuperColumn col2 = new ColumnOrSuperColumn();
        col2.setColumn(column2);

        List<ColumnOrSuperColumn> slice = new ArrayList<ColumnOrSuperColumn>();
        slice.add(col1);
        slice.add(col2);

View Full Code Here

    private Map<String,List<Mutation>> genDaysPrices(ByteBuffer date)
    {
        Map<String, List<Mutation>> prices = new HashMap<String,List<Mutation>>();
            
        Mutation m = new Mutation();
        m.setColumn_or_supercolumn(new ColumnOrSuperColumn().setColumn(
                new Column()
                .setName(date)
                .setValue(ByteBufferUtil.bytes(String.valueOf((double)(Pricer.randomizer.nextDouble()*1000))))
                .setTimestamp(System.currentTimeMillis())
                ));
View Full Code Here

                    }
                }

                if (mutation.hasAdditions()) {
                    for (Entry ent : mutation.getAdditions()) {
                        ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();
                        Column column = new Column(ent.getColumn().asByteBuffer());
                        column.setValue(ent.getValue().asByteBuffer());
                        column.setTimestamp(timestamp.additionTime);
                        cosc.setColumn(column);
                        org.apache.cassandra.thrift.Mutation m = new org.apache.cassandra.thrift.Mutation();
                        m.setColumn_or_supercolumn(cosc);
                        thriftMutation.add(m);
                    }
                }
View Full Code Here

TOP

Related Classes of org.apache.cassandra.thrift.ColumnOrSuperColumn$ColumnOrSuperColumnTupleScheme

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.