String typeStr = "struct<a:int,b:string,c:float>";
TypeInfo info = TypeInfoUtils.getTypeInfoFromTypeString(typeStr);
StructObjectInspector oi = (StructObjectInspector) OrcStruct.createObjectInspector(info);
BinarySortableSerDe serde = OrcUtils.createBinarySerde(info);
OrcStruct struct = OrcUtils.createOrcStruct(info,
new IntWritable(1), new Text("Alice"), new FloatWritable(165.3f));
OrcWritable writable = new OrcWritable();
writable.set(struct);
assertTrue(struct == writable.get());
writable.setObjectInspector(oi);
writable.setSerde(serde);
WritableDeepCopier<OrcWritable> deepCopier = new WritableDeepCopier<OrcWritable>(OrcWritable.class);
OrcWritable copied = deepCopier.deepCopy(writable);
assertTrue(writable != copied);
assertEquals(writable, copied);
copied.setObjectInspector(oi);
copied.setSerde(serde);
OrcStruct copiedStruct = copied.get();
assertTrue(struct != copiedStruct);
assertEquals(struct, copiedStruct);
List<Object> items = oi.getStructFieldsDataAsList(struct);
List<Object> copiedItems = oi.getStructFieldsDataAsList(copiedStruct);
for (int i = 0; i < items.size(); i++) {
assertTrue(items.get(i) != copiedItems.get(i));
assertEquals(items.get(i), copiedItems.get(i));
}
OrcWritable copied2 = deepCopier.deepCopy(copied);
assertTrue(copied2 != copied);
assertEquals(copied2, copied);
copied2.setObjectInspector(oi);
copied2.setSerde(serde);
OrcStruct copiedStruct2 = copied2.get();
assertTrue(copiedStruct2 != copiedStruct);
assertEquals(copiedStruct2, copiedStruct);
List<Object> copiedItems2 = oi.getStructFieldsDataAsList(copiedStruct2);
for (int i = 0; i < items.size(); i++) {