diff --git a/drift-codec-utils/src/main/java/com/facebook/drift/codec/utils/UuidToLeachSalzBinaryEncodingThriftCodec.java b/drift-codec-utils/src/main/java/com/facebook/drift/codec/utils/UuidToLeachSalzBinaryEncodingThriftCodec.java
index 5c1fefd47..f9d6e42ee 100644
--- a/drift-codec-utils/src/main/java/com/facebook/drift/codec/utils/UuidToLeachSalzBinaryEncodingThriftCodec.java
+++ b/drift-codec-utils/src/main/java/com/facebook/drift/codec/utils/UuidToLeachSalzBinaryEncodingThriftCodec.java
@@ -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;
@@ -33,24 +34,32 @@
/**
* This codec will encode UUIDs into the format specified in RFC 4122:
- *
+ *
* https://www.ietf.org/rfc/rfc4122.txt
- *
+ *
* Likewise, it presumes the input is of this format.
*/
public class UuidToLeachSalzBinaryEncodingThriftCodec
implements ThriftCodec
{
+ 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
diff --git a/drift-protocol/src/main/java/com/facebook/drift/protocol/TMemoryBufferWriteOnly.java b/drift-protocol/src/main/java/com/facebook/drift/protocol/TMemoryBufferWriteOnly.java
new file mode 100644
index 000000000..b77f303e0
--- /dev/null
+++ b/drift-protocol/src/main/java/com/facebook/drift/protocol/TMemoryBufferWriteOnly.java
@@ -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();
+ }
+}