Package me.prettyprint.cassandra.serializers

Examples of me.prettyprint.cassandra.serializers.StringSerializer


  /**
   * Convienience method for creating a column with a String name and String value
   */
  public static HColumn<String, String> createStringColumn(String name, String value) {
    StringSerializer se = StringSerializer.get();
    return createColumn(name, value, se, se);
  }
View Full Code Here


public class SuperColumnSliceTest {

  @Test
  public void testConstruction() {
    LongSerializer le = LongSerializer.get();
    StringSerializer se = StringSerializer.get();
    ByteBufferSerializer be = ByteBufferSerializer.get();
    // empty one
    List<SuperColumn> tColumns = new ArrayList<SuperColumn>();
    SuperSlice<String, Long, ByteBuffer> slice = new SuperSliceImpl<String, Long, ByteBuffer>(tColumns, se, le,
        be);
    Assert.assertTrue(slice.getSuperColumns().isEmpty());

    // non-empty one
    Column c = new Column(le.toByteBuffer(5L), be.toByteBuffer(ByteBuffer.wrap(new byte[] { 1 })), 2L);
    tColumns.add(new SuperColumn(se.toByteBuffer("super"), Arrays.asList(c)));
    slice = new SuperSliceImpl<String, Long, ByteBuffer>(tColumns, se, le, be);
    Assert.assertEquals(1, slice.getSuperColumns().size());
    Assert.assertEquals((Long) 5L, slice.getColumnByName("super").get(0).getName());
  }
View Full Code Here

public class ColumnSliceTest {


  @Test
  public void testConstruction() {
    StringSerializer se = StringSerializer.get();
    LongSerializer le = LongSerializer.get();
    List<Column> tColumns = new ArrayList<Column>();
    ColumnSlice<String, Long> slice = new ColumnSliceImpl<String, Long>(tColumns, se, le);
    Assert.assertTrue(slice.getColumns().isEmpty());

    tColumns.add(new Column(ByteBuffer.wrap(new byte[]{}), ByteBuffer.wrap(new byte[]{}), 0L));
    slice = new ColumnSliceImpl<String, Long>(tColumns, se, le);
    Assert.assertEquals(1, slice.getColumns().size());

    tColumns = new ArrayList<Column>();
    tColumns.add(new Column(se.toByteBuffer("1"), le.toByteBuffer(1L), 0L));
    slice = new ColumnSliceImpl<String, Long>(tColumns, se, le);
    Assert.assertEquals((Long) 1L, slice.getColumnByName("1").getValue());
  }
View Full Code Here

        KeyspaceDefinition definition = new ThriftKsDef("TestKeyspace");
        cluster.addKeyspace(definition);
        Keyspace keyspace = HFactory.createKeyspace("TestKeyspace", cluster);
        ColumnFamilyDefinition familyDefinition = new ThriftCfDef("TestKeyspace", "CFone");
        cluster.addColumnFamily(familyDefinition);
        Mutator<String> mutator = HFactory.createMutator(keyspace, new StringSerializer());
        mutator.insert("keyone", "CFone", HFactory.createStringColumn("name", "C Ronaldo"));
        ColumnQuery<String, String, String> columnQuery =
                HFactory.createStringColumnQuery(keyspace);
        columnQuery.setColumnFamily("CFone").setKey("keyone").setName("name");
        QueryResult<HColumn<String, String>> result = columnQuery.execute();
View Full Code Here

    mutator.addInsertion(ROW_KEY, columnFamily, HFactory.createStringColumn("c", "v3"));
    mutator.execute();
  }

  private QueryResult<OrderedRows<String, String, String>> readDataSet(final Keyspace keyspace, final String columnFamily) {
    final StringSerializer ss = StringSerializer.get();
    final RangeSlicesQuery<String, String, String> query = HFactory.createRangeSlicesQuery(keyspace, ss, ss, ss);
    query.setColumnFamily(columnFamily);
    query.setRange(null, null, false, Integer.MAX_VALUE);
    QueryResult<OrderedRows<String, String, String>> results = query.execute();
    return results;
View Full Code Here

    }

    protected void persist(Keyspace keyspace, String columnFamily, String rowKey, Map<String, String> columns)
            throws Exception {
      logger.debug("Writing [" + rowKey + "] in [" + columnFamily + "] @ [" + keyspace.getKeyspaceName() + "]");
        StringSerializer serializer = StringSerializer.get();
        Mutator<String> mutator = HFactory.createMutator(keyspace, serializer);
        for (String columnName : columns.keySet()) {
          logger.debug("Writing [" + columnName + "] @ [" + rowKey + "] in [" + columnFamily + "] @ [" + keyspace + "]");
            mutator.addInsertion(rowKey, columnFamily, HFactory.createStringColumn(columnName, columns.get(columnName)));
        }
View Full Code Here

        }
        mutator.execute();
    }

    protected void delete(Keyspace keyspace, String columnFamily, String rowKey, String... columnNames) throws Exception {
        StringSerializer serializer = StringSerializer.get();
        Mutator<String> mutator = HFactory.createMutator(keyspace, serializer);

        for (String columnName : columnNames) {
            mutator.addDeletion(rowKey, columnFamily, columnName, serializer);
        }
View Full Code Here

        }
        mutator.execute();
    }

    protected void delete(Keyspace keyspace, String columnFamily, String rowKey) throws Exception {
        StringSerializer serializer = StringSerializer.get();
        Mutator<String> mutator = HFactory.createMutator(keyspace, serializer);
        mutator.addDeletion(rowKey, columnFamily);
        mutator.execute();
    }
View Full Code Here

        mutator.addDeletion(rowKey, columnFamily);
        mutator.execute();
    }

    protected Map<String, String> select(Keyspace keyspace, String columnFamily, String rowKey) {
        StringSerializer serializer = StringSerializer.get();
        ColumnFamilyTemplate<String, String> template = new ThriftColumnFamilyTemplate<String, String>(keyspace,
                columnFamily, serializer, serializer);
        ColumnFamilyResult<String, String> result = template.queryColumns(rowKey);

        Map<String, String> row = new LinkedHashMap<String, String>();
View Full Code Here

    }

    protected Map<String, Map<String, String>> select(Keyspace keyspace, String columnFamily) {
      logger.debug("selecting from [" + columnFamily + "] @ [" + keyspace.getKeyspaceName() + "]");
     
        StringSerializer ss = new StringSerializer();
        RangeSlicesQuery<String, String, String> query = HFactory.createRangeSlicesQuery(keyspace, ss, ss, ss);

        query.setColumnFamily(columnFamily);
        query.setRange("", "", true, 100);
        query.setRowCount(100);
View Full Code Here

TOP

Related Classes of me.prettyprint.cassandra.serializers.StringSerializer

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.