use of org.apache.hyracks.dataflow.common.comm.io.FrameFixedFieldAppender in project asterixdb by apache.
the class InputFrameGenerator method generateDataFrame.
public List<IFrame> generateDataFrame(RecordDescriptor recordDescriptor, List<Object[]> listOfObject) throws HyracksDataException {
List<IFrame> listFrame = new ArrayList<>();
VSizeFrame frame = new VSizeFrame(manager);
FrameFixedFieldAppender appender = new FrameFixedFieldAppender(recordDescriptor.getFieldCount());
appender.reset(frame, true);
ByteArrayOutputStream baos = new ByteArrayOutputStream(manager.getInitialFrameSize());
DataOutputStream ds = new DataOutputStream(baos);
for (Object[] objs : listOfObject) {
for (int i = 0; i < recordDescriptor.getFieldCount(); i++) {
baos.reset();
recordDescriptor.getFields()[i].serialize(objs[i], ds);
if (!appender.appendField(baos.toByteArray(), 0, baos.size())) {
listFrame.add(frame);
frame = new VSizeFrame(manager);
appender.resetWithLeftOverData(frame);
if (!appender.appendField(baos.toByteArray(), 0, baos.size())) {
throw new HyracksDataException("Should never happen!");
}
}
}
}
listFrame.add(frame);
return listFrame;
}
use of org.apache.hyracks.dataflow.common.comm.io.FrameFixedFieldAppender in project asterixdb by apache.
the class FrameFixedFieldTupleAppenderTest method createAppender.
@Before
public void createAppender() throws HyracksDataException {
appender = new FrameFixedFieldAppender(fields.length);
FrameManager manager = new FrameManager(TEST_FRAME_SIZE);
IFrame frame = new VSizeFrame(manager);
appender.reset(frame, true);
}
Aggregations