Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.facebook.drift.codec.utils;

import com.facebook.drift.codec.CodecThriftType;
import com.facebook.drift.codec.ThriftCodec;
import com.facebook.drift.codec.internal.coercion.FromThrift;
import com.facebook.drift.codec.internal.coercion.ToThrift;
Expand All @@ -33,24 +34,32 @@

/**
* This codec will encode UUIDs into the format specified in RFC 4122:
*
* <p>
* https://www.ietf.org/rfc/rfc4122.txt
*
* <p>
* Likewise, it presumes the input is of this format.
*/
public class UuidToLeachSalzBinaryEncodingThriftCodec
implements ThriftCodec<UUID>
{
private static final ThriftType THRIFT_TYPE = new ThriftType(ThriftType.BINARY, UUID.class);

@Inject
public UuidToLeachSalzBinaryEncodingThriftCodec(ThriftCatalog thriftCatalog)
{
thriftCatalog.addDefaultCoercions(getClass());
}

@CodecThriftType
public static ThriftType getThriftType()
{
return THRIFT_TYPE;
}

@Override
public ThriftType getType()
{
return new ThriftType(ThriftType.BINARY, UUID.class);
return THRIFT_TYPE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.drift.protocol;

import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;

public class TMemoryBufferWriteOnly
implements TTransport
{
private ByteArrayDataOutput data;

public TMemoryBufferWriteOnly(int size)
{
data = ByteStreams.newDataOutput(size);
}

@Override
public void read(byte[] buf, int off, int len)
throws TTransportException
{
throw new UnsupportedOperationException("Read operation is not supported");
}

@Override
public void write(byte[] buf, int off, int len)
throws TTransportException
{
data.write(buf, off, len);
}

public byte[] getBytes()
{
return data.toByteArray();
}
}