Skip to content

Instantly share code, notes, and snippets.

@stevenschlansker
Created May 16, 2025 23:37
Show Gist options
  • Save stevenschlansker/ed7dae863e78d3c87e30bdea39fa8dea to your computer and use it in GitHub Desktop.
Save stevenschlansker/ed7dae863e78d3c87e30bdea39fa8dea to your computer and use it in GitHub Desktop.
package org.apache.fury.format.encoder;
import org.apache.fury.format.row.binary.*;
import org.apache.fury.format.row.binary.writer.*;
import org.apache.arrow.vector.types.pojo.*;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.Schema;
import org.apache.fury.format.row.Row;
import org.apache.fury.format.row.ArrayData;
import org.apache.fury.format.row.MapData;
import org.apache.fury.format.row.binary.BinaryRow;
import org.apache.fury.format.row.binary.BinaryArray;
import org.apache.fury.format.row.binary.BinaryMap;
public final class CustomCodecTest_UuidTypeRowCodec419365604_769429195 implements org.apache.fury.format.encoder.GeneratedRowEncoder {
private final Class beanClass;
private Schema schema;
private BinaryRowWriter rowWriter;
private org.apache.fury.Fury fury;
private final BinaryArrayWriter arrayWriter;
private final BinaryArrayWriter arrayWriter1;
public CustomCodecTest_UuidTypeRowCodec419365604_769429195(java.lang.Object[] references) {
schema = (Schema)references[0];
rowWriter = (BinaryRowWriter)references[1];
fury = (org.apache.fury.Fury)references[2];
beanClass = org.apache.fury.format.encoder.CustomCodecTest$UuidType.class;
Field field1 = org.apache.fury.format.type.DataTypes.fieldOfSchema(schema, 1);
BinaryArrayWriter binaryArrayWriter = new BinaryArrayWriter(field1, rowWriter);
arrayWriter = binaryArrayWriter;
Field field22 = org.apache.fury.format.type.DataTypes.fieldOfSchema(schema, 2);
BinaryArrayWriter binaryArrayWriter1 = new BinaryArrayWriter(field22, rowWriter);
arrayWriter1 = binaryArrayWriter1;
}
@Override public final BinaryRow toRow(Object obj) {
org.apache.fury.format.encoder.CustomCodecTest.UuidType uuidType1 = (org.apache.fury.format.encoder.CustomCodecTest.UuidType)obj;
java.util.UUID f1 = uuidType1.f1;
if ((f1 == null)) {
rowWriter.setNullAt(0);
} else {
boolean isNull = false;
org.apache.fury.memory.MemoryBuffer rewrittenValue = org.apache.fury.format.type.CustomTypeEncoderRegistry$Gen1.encode(uuidType1, f1);
if (rewrittenValue == null) {
isNull = true;
}
if ((rewrittenValue == null)) {
rowWriter.setNullAt(0);
} else {
rowWriter.writeUnaligned(0, rewrittenValue, rewrittenValue.readerIndex(), rewrittenValue.remaining());
}
}
java.util.UUID[] f2 = uuidType1.f2;
if ((f2 == null)) {
rowWriter.setNullAt(1);
} else {
int writerIndex = rowWriter.writerIndex();
int length = f2.length;
arrayWriter.reset(length);
int len = f2.length;
int i = 0;
while (i < len) {
java.util.UUID elemValue = f2[i];
if ((elemValue == null)) {
arrayWriter.setNullAt(i);
} else {
boolean isNull3 = false;
org.apache.fury.memory.MemoryBuffer rewrittenValue1 = org.apache.fury.format.type.CustomTypeEncoderRegistry$Gen1.encode(uuidType1, elemValue);
if (rewrittenValue1 == null) {
isNull3 = true;
}
if ((rewrittenValue1 == null)) {
arrayWriter.setNullAt(i);
} else {
arrayWriter.writeUnaligned(i, rewrittenValue1, rewrittenValue1.readerIndex(), rewrittenValue1.remaining());
}
}
i++;
}
int writerIndex1 = rowWriter.writerIndex();
rowWriter.setOffsetAndSize(1, writerIndex, (writerIndex1 - writerIndex));
}
java.util.SortedSet f3 = uuidType1.f3;
if ((f3 == null)) {
rowWriter.setNullAt(2);
} else {
int writerIndex2 = rowWriter.writerIndex();
int value = f3.size();
arrayWriter1.reset(value);
java.util.Iterator iter = f3.iterator();
int i1 = 0;
while (iter.hasNext()) {
java.util.UUID elemValue1 = (java.util.UUID)iter.next();
if ((elemValue1 == null)) {
arrayWriter1.setNullAt(i1);
} else {
boolean isNull4 = false;
org.apache.fury.memory.MemoryBuffer rewrittenValue2 = org.apache.fury.format.type.CustomTypeEncoderRegistry$Gen1.encode(uuidType1, elemValue1);
if (rewrittenValue2 == null) {
isNull4 = true;
}
if ((rewrittenValue2 == null)) {
arrayWriter1.setNullAt(i1);
} else {
arrayWriter1.writeUnaligned(i1, rewrittenValue2, rewrittenValue2.readerIndex(), rewrittenValue2.remaining());
}
}
i1++;
}
int writerIndex3 = rowWriter.writerIndex();
rowWriter.setOffsetAndSize(2, writerIndex2, (writerIndex3 - writerIndex2));
}
BinaryRow binaryRow = rowWriter.getRow();
return binaryRow;
}
@Override public final Object fromRow(BinaryRow row) {
org.apache.fury.format.encoder.CustomCodecTest.UuidType uuidType2 = new org.apache.fury.format.encoder.CustomCodecTest.UuidType();
boolean value1 = row.isNullAt(0);
if ((!value1)) {
org.apache.fury.memory.MemoryBuffer memoryBuffer1 = row.getBuffer(0);
uuidType2.f1 = org.apache.fury.format.type.CustomTypeEncoderRegistry$Gen1.decode(uuidType2, ((java.util.UUID)null), memoryBuffer1);
}
boolean value2 = row.isNullAt(1);
if ((!value2)) {
BinaryArray binaryArray2 = row.getArray(1);
int value3 = binaryArray2.numElements();
java.util.UUID[] arr = new java.util.UUID[value3];
int len2 = binaryArray2.numElements();
int i2 = 0;
while (i2 < len2) {
if (!binaryArray2.isNullAt(i2)) {
org.apache.fury.memory.MemoryBuffer elemValue2 = binaryArray2.getBuffer(i2);
boolean isNull5 = false;
java.util.UUID decodedValue3 = org.apache.fury.format.type.CustomTypeEncoderRegistry$Gen1.decode(uuidType2, ((java.util.UUID)null), elemValue2);
if (decodedValue3 == null) {
isNull5 = true;
}
arr[i2] = decodedValue3;
}
i2++;
}
uuidType2.f2 = arr;
}
boolean value4 = row.isNullAt(2);
if ((!value4)) {
BinaryArray binaryArray10 = row.getArray(2);
java.util.SortedSet sortedSet4 = org.apache.fury.format.type.CustomTypeEncoderRegistry$Gen1.newCollection(((java.util.SortedSet<java.util.UUID>)null), ((java.util.UUID)null), binaryArray10.numElements());
int len3 = binaryArray10.numElements();
int i3 = 0;
while (i3 < len3) {
if (!binaryArray10.isNullAt(i3)) {
org.apache.fury.memory.MemoryBuffer elemValue3 = binaryArray10.getBuffer(i3);
boolean isNull7 = false;
java.util.UUID decodedValue5 = org.apache.fury.format.type.CustomTypeEncoderRegistry$Gen1.decode(uuidType2, ((java.util.UUID)null), elemValue3);
if (decodedValue5 == null) {
isNull7 = true;
}
sortedSet4.add(decodedValue5);
} else {
sortedSet4.add(null);
}
i3++;
}
uuidType2.f3 = sortedSet4;
}
return uuidType2;
}
}
package org.apache.fury.format.type;
public final class CustomTypeEncoderRegistry$Gen1 implements org.apache.fury.format.type.CustomTypeHandler {
private static final java.util.Map<CustomTypeRegistration, CustomCodec<?, ?>> REGISTRY;
private static final java.util.Map<CustomTypeRegistration, CustomCollectionFactory<?, ?>> COLLECTION_REGISTRY;
private static final org.apache.fury.format.encoder.CustomCodec CODEC_Object_CustomByteBuf3_1;
private static final org.apache.fury.format.encoder.CustomCodec CODEC_Object_UUID_2;
private static final org.apache.fury.format.encoder.CustomCodec CODEC_Object_CustomByteBuf2_3;
private static final org.apache.fury.format.encoder.CustomCodec CODEC_CustomType_ZoneId_4;
private static final org.apache.fury.format.encoder.CustomCodec CODEC_Object_CustomByteBuf_5;
private static final org.apache.fury.format.encoder.CustomCollectionFactory FACTORY_SortedSet_UUID_1;
static {
try {
java.util.HashMap hashMap = new java.util.HashMap(CustomTypeEncoderRegistry.REGISTRY);
REGISTRY = hashMap;
java.util.HashMap hashMap1 = new java.util.HashMap(CustomTypeEncoderRegistry.COLLECTION_REGISTRY);
COLLECTION_REGISTRY = hashMap1;
CODEC_Object_CustomByteBuf3_1 = CustomTypeEncoderRegistry.findCodec(REGISTRY, java.lang.Object.class, org.apache.fury.format.encoder.CustomCodecTest$CustomByteBuf3.class);
CODEC_Object_UUID_2 = CustomTypeEncoderRegistry.findCodec(REGISTRY, java.lang.Object.class, java.util.UUID.class);
CODEC_Object_CustomByteBuf2_3 = CustomTypeEncoderRegistry.findCodec(REGISTRY, java.lang.Object.class, org.apache.fury.format.encoder.CustomCodecTest$CustomByteBuf2.class);
CODEC_CustomType_ZoneId_4 = CustomTypeEncoderRegistry.findCodec(REGISTRY, org.apache.fury.format.encoder.CustomCodecTest$CustomType.class, java.time.ZoneId.class);
CODEC_Object_CustomByteBuf_5 = CustomTypeEncoderRegistry.findCodec(REGISTRY, java.lang.Object.class, org.apache.fury.format.encoder.CustomCodecTest$CustomByteBuf.class);
FACTORY_SortedSet_UUID_1 = CustomTypeEncoderRegistry.findCollectionFactory(COLLECTION_REGISTRY, java.util.SortedSet.class, java.util.UUID.class);
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
public org.apache.fury.format.encoder.CustomCodec findCodec(Class beanType, Class fieldType) {
return CustomTypeEncoderRegistry.findCodec(REGISTRY, beanType, fieldType);
}
public org.apache.fury.format.encoder.CustomCollectionFactory findCollectionFactory(Class containerType, Class elementType) {
return CustomTypeEncoderRegistry.findCollectionFactory(COLLECTION_REGISTRY, containerType, elementType);
}
public static org.apache.fury.format.row.binary.BinaryArray encode(Object bean, org.apache.fury.format.encoder.CustomCodecTest.CustomByteBuf3 fieldValue) {
return (org.apache.fury.format.row.binary.BinaryArray)CODEC_Object_CustomByteBuf3_1.encode(fieldValue);
}
public static org.apache.fury.format.encoder.CustomCodecTest.CustomByteBuf3 decode(Object bean, org.apache.fury.format.encoder.CustomCodecTest.CustomByteBuf3 fieldNull, org.apache.fury.format.row.binary.BinaryArray encodedValue) {
return (org.apache.fury.format.encoder.CustomCodecTest$CustomByteBuf3)CODEC_Object_CustomByteBuf3_1.decode(encodedValue);
}
public static org.apache.fury.memory.MemoryBuffer encode(Object bean, java.util.UUID fieldValue) {
return (org.apache.fury.memory.MemoryBuffer)CODEC_Object_UUID_2.encode(fieldValue);
}
public static java.util.UUID decode(Object bean, java.util.UUID fieldNull, org.apache.fury.memory.MemoryBuffer encodedValue) {
return (java.util.UUID)CODEC_Object_UUID_2.decode(encodedValue);
}
public static byte[] encode(Object bean, org.apache.fury.format.encoder.CustomCodecTest.CustomByteBuf2 fieldValue) {
return (byte[])CODEC_Object_CustomByteBuf2_3.encode(fieldValue);
}
public static org.apache.fury.format.encoder.CustomCodecTest.CustomByteBuf2 decode(Object bean, org.apache.fury.format.encoder.CustomCodecTest.CustomByteBuf2 fieldNull, byte[] encodedValue) {
return (org.apache.fury.format.encoder.CustomCodecTest$CustomByteBuf2)CODEC_Object_CustomByteBuf2_3.decode(encodedValue);
}
public static String encode(org.apache.fury.format.encoder.CustomCodecTest.CustomType bean, java.time.ZoneId fieldValue) {
return (String)CODEC_CustomType_ZoneId_4.encode(fieldValue);
}
public static java.time.ZoneId decode(org.apache.fury.format.encoder.CustomCodecTest.CustomType bean, java.time.ZoneId fieldNull, String encodedValue) {
return (java.time.ZoneId)CODEC_CustomType_ZoneId_4.decode(encodedValue);
}
public static org.apache.fury.memory.MemoryBuffer encode(Object bean, org.apache.fury.format.encoder.CustomCodecTest.CustomByteBuf fieldValue) {
return (org.apache.fury.memory.MemoryBuffer)CODEC_Object_CustomByteBuf_5.encode(fieldValue);
}
public static org.apache.fury.format.encoder.CustomCodecTest.CustomByteBuf decode(Object bean, org.apache.fury.format.encoder.CustomCodecTest.CustomByteBuf fieldNull, org.apache.fury.memory.MemoryBuffer encodedValue) {
return (org.apache.fury.format.encoder.CustomCodecTest$CustomByteBuf)CODEC_Object_CustomByteBuf_5.decode(encodedValue);
}
public static java.util.SortedSet newCollection(java.util.SortedSet collectionNull, java.util.UUID elementNull, int numElements) {
return (java.util.SortedSet)FACTORY_SortedSet_UUID_1.newCollection(numElements);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment