Package com.netflix.astyanax

Examples of com.netflix.astyanax.SerializerPackage


    @Override
    public ResponseData putComposite(String key, String colName, ByteBuffer value) throws OperationException
    {
        try
        {
            SerializerPackage sp = AstyanaxConnection.instance.keyspace().getSerializerPackage(cfName, false);
            // work around
            ByteBuffer rowKey = sp.keyAsByteBuffer(key);
            ByteBuffer column = sp.columnAsByteBuffer(colName);
            ColumnFamily<ByteBuffer, ByteBuffer> columnFamily = new ColumnFamily(cfName, ByteBufferSerializer.get(), ByteBufferSerializer.get());
            ColumnMutation mutation = AstyanaxConnection.instance.keyspace().prepareColumnMutation(columnFamily, rowKey, column);
            OperationResult<Void> result;
            if (isCounter)
                result = mutation.incrementCounterColumn(LongSerializer.get().fromByteBuffer(value)).execute();
View Full Code Here


        StringBuffer response = new StringBuffer();
        int bytes = 0;
        OperationResult<Column<ByteBuffer>> opResult = null;
        try
        {
            SerializerPackage sp = AstyanaxConnection.instance.keyspace().getSerializerPackage(cfName, false);
            ByteBuffer bbName = sp.columnAsByteBuffer(colName);
            ByteBuffer bbKey = sp.keyAsByteBuffer(key);
            ColumnFamily<ByteBuffer, ByteBuffer> columnFamily = new ColumnFamily(cfName, ByteBufferSerializer.get(), ByteBufferSerializer.get());
            opResult = AstyanaxConnection.instance.keyspace().prepareQuery(columnFamily).getKey(bbKey).getColumn(bbName).execute();
            bytes = opResult.getResult().getByteBufferValue().capacity();
            bytes += opResult.getResult().getRawName().capacity();
            String value = SystemUtils.convertToString(valueSerializer, opResult.getResult().getByteBufferValue());
View Full Code Here

    keyspace.prepareQuery(CF_SERIALIZER1)
    .withCql("select * from astyanaxunittests.serializer1")
    .execute();

    SerializerPackage serializer = keyspace.getSerializerPackage("Serializer1", false);

    System.out.println("");
    System.out.println("KeySerializer: " + serializer.getKeySerializer());
    System.out.println("ColumnNameSerializer: " + serializer.getColumnNameSerializer());
    System.out.println("ColumnSerializer: " + serializer.getColumnSerializer());
    System.out.println("DefaultValueSerializer: " + serializer.getDefaultValueSerializer());
    System.out.println("ValueSerializer: " + serializer.getValueSerializer());

    String ss1 = "ss1";
    ByteBuffer bb1 = StringSerializer.get().fromString(ss1);
    String ss1Result = serializer.getKeySerializer().getString(bb1);

    System.out.println("ss1Result: " + ss1Result);
    Assert.assertEquals(ss1, ss1Result);

    SpecificCompositeSerializer comp = (SpecificCompositeSerializer) serializer.getColumnNameSerializer();
    System.out.println(comp.getComparators().toString());

    Composite dc = new Composite(ss1);

    List<AbstractType<?>> types = new ArrayList<AbstractType<?>>();
    types.add(UTF8Type.instance);

    CompositeType c1 = CompositeType.getInstance(types);

    SpecificCompositeSerializer ccSerializer = new SpecificCompositeSerializer(c1);
    ByteBuffer bb2 = ccSerializer.toByteBuffer(dc);

    Composite c2 = (Composite) serializer.getColumnNameSerializer().fromByteBuffer(bb2);
    ss1Result =  (String) c2.get(0);

    Assert.assertEquals(ss1, ss1Result);
  }
View Full Code Here

            Assert.fail();
        }

        UUID currentUUID = TimeUUIDUtils.getUniqueTimeUUIDinMicros();

        SerializerPackage pkg = null;
        try {
            pkg = keyspace.getSerializerPackage(CF_TIME_UUID.getName(), false);
        } catch (ConnectionException e) {
            Assert.fail();
            e.printStackTrace();
        } catch (UnknownComparatorException e) {
            Assert.fail();
            e.printStackTrace();
        }
        Serializer<UUID> serializer = (Serializer<UUID>) pkg
                .getColumnNameSerializer();

        ByteBuffer buffer = serializer.toByteBuffer(currentUUID);
        String value = serializer.getString(buffer);
        LOG.info("UUID Time = " + value);
View Full Code Here

TOP

Related Classes of com.netflix.astyanax.SerializerPackage

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.