Package org.apache.thrift

Examples of org.apache.thrift.TSerializer


    private static String cfdefToString(CfDef cfDef)
    {
        assert cfDef != null;
        // this is so awful it's kind of cool!
        TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory());
        try
        {
            return Hex.bytesToHex(serializer.serialize(cfDef));
        }
        catch (TException e)
        {
            throw new RuntimeException(e);
        }
View Full Code Here


        assert indexExpressions != null;
        // oh, you thought cfdefToString was awful?
        IndexClause indexClause = new IndexClause();
        indexClause.setExpressions(indexExpressions);
        indexClause.setStart_key("".getBytes());
        TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory());
        try
        {
            return Hex.bytesToHex(serializer.serialize(indexClause));
        }
        catch (TException e)
        {
            throw new RuntimeException(e);
        }
View Full Code Here

import org.apache.thrift.TSerializer;

public class CredentialHelper {

    public static byte[] asByteArray(AuthInfo cred) throws AccumuloSecurityException {
        TSerializer ts = new TSerializer();
        try {
            return ts.serialize(cred);
        } catch (TException e) {
            // This really shouldn't happen
            throw new AccumuloSecurityException(cred.getUser(), SecurityErrorCode.DEFAULT_SECURITY_ERROR, e);
        }
    }
View Full Code Here

    {
        public void serialize(IndexScanCommand o, DataOutput out) throws IOException
        {
            out.writeUTF(o.keyspace);
            out.writeUTF(o.column_family);
            TSerializer ser = new TSerializer(new TBinaryProtocol.Factory());
            FBUtilities.serialize(ser, o.index_clause, out);
            FBUtilities.serialize(ser, o.predicate, out);
            AbstractBounds.serializer().serialize(o.range, out);
        }
View Full Code Here

    @Override
    protected ByteBuffer delimitWithOriginal() throws Exception {

        TMemoryBuffer m = new TMemoryBuffer(1000000);
        TFramedTransport t = new TFramedTransport(m);
        TSerializer tt = new TSerializer();
        for (UserProfile up : getObjects()) {
            t.write(tt.serialize(up));
            t.flush();
        }
        return ByteBuffer.wrap(m.getArray(), 0, m.length());

    }
View Full Code Here

        properties.put("request.required.acks", "1");

        ProducerConfig config = new ProducerConfig(properties);
        Producer<String, byte[]> producer = new Producer<String, byte[]>(config);

        TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory());
        for (int i = 0; i < mNumMessages; ++i) {
            TestMessage testMessage = new TestMessage(System.currentTimeMillis() * 1000000L + i,
                                                      "some_value_" + i);
            if (i % 2 == 0) {
                testMessage.setEnumField(TestEnum.SOME_VALUE);
            } else {
                testMessage.setEnumField(TestEnum.SOME_OTHER_VALUE);
            }
            byte[] bytes;
            try {
                bytes = serializer.serialize(testMessage);
            } catch(TException e) {
                throw new RuntimeException("Failed to serialize message " + testMessage, e);
            }
            KeyedMessage<String, byte[]> data = new KeyedMessage<String, byte[]>(
                mTopic, Integer.toString(i), bytes);
View Full Code Here

        assert indexExpressions != null;
        // oh, you thought cfdefToString was awful?
        IndexClause indexClause = new IndexClause();
        indexClause.setExpressions(indexExpressions);
        indexClause.setStart_key("".getBytes());
        TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory());
        try
        {
            return Hex.bytesToHex(serializer.serialize(indexClause));
        }
        catch (TException e)
        {
            throw new RuntimeException(e);
        }
View Full Code Here

        dos.writeUTF(sliceCommand.column_family);
        dos.writeInt(sliceCommand.super_column == null ? 0 : sliceCommand.super_column.length);
        if (sliceCommand.super_column != null)
            dos.write(sliceCommand.super_column);

        TSerializer ser = new TSerializer(new TBinaryProtocol.Factory());
        try
        {
            byte[] serPred = ser.serialize(sliceCommand.predicate);
            dos.writeInt(serPred.length);
            dos.write(serPred);
        }
        catch (TException ex)
        {
View Full Code Here

    /** convert CfDef to string */
    protected static String cfdefToString(CfDef cfDef)
    {
        assert cfDef != null;
        // this is so awful it's kind of cool!
        TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory());
        try
        {
            return Hex.bytesToHex(serializer.serialize(cfDef));
        }
        catch (TException e)
        {
            throw new RuntimeException(e);
        }
View Full Code Here

    public static ByteBuffer toBytesUsingThrift(DocumentMetadata data) throws IOException
    {

        try
        {
            return ByteBuffer.wrap(CassandraUtils.compress(new TSerializer(protocolFactory).serialize(data)));
        }
        catch (TException e)
        {
            throw new IOException(e);
        }
View Full Code Here

TOP

Related Classes of org.apache.thrift.TSerializer

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.