* @throws Exception
*/
@Test
public void TestCopyBinary() throws Exception {
ReaderWriterProfiler.setProfilerOptions(null);
OrcLazyBinary lazyBinary = new OrcLazyBinary(new LazyBinaryTreeReader(0, 0) {
int nextCalls = 0;
@Override
public Object next(Object previous) throws IOException {
if (nextCalls == 0) {
nextCalls++;
return new BytesWritable("a".getBytes());
}
throw new IOException("next should only be called once");
}
@Override
protected boolean seekToRow(long currentRow) throws IOException {
return true;
}
});
BinaryObjectInspector binaryOI = (BinaryObjectInspector)
OrcLazyObjectInspectorUtils.createLazyObjectInspector(TypeInfoFactory.binaryTypeInfo);
OrcLazyBinary lazyBinary2 = (OrcLazyBinary) binaryOI.copyObject(lazyBinary);
Assert.assertEquals("a", new String(((BytesWritable) lazyBinary.materialize()).getBytes()));
Assert.assertEquals("a", new String(((BytesWritable) lazyBinary2.materialize()).getBytes()));
}