use of org.apache.hyracks.algebricks.data.IAWriter in project asterixdb by apache.
the class SinkWriterRuntimeFactory method createPushRuntime.
@Override
public IPushRuntime createPushRuntime(IHyracksTaskContext ctx) throws HyracksDataException {
try {
PrintStream filePrintStream = new PrintStream(new BufferedOutputStream(new FileOutputStream(outputFile)));
IAWriter w = writerFactory.createWriter(fields, filePrintStream, printerFactories, inputRecordDesc);
return new SinkWriterRuntime(w, filePrintStream, inputRecordDesc, true);
} catch (IOException e) {
throw new HyracksDataException(e);
}
}
use of org.apache.hyracks.algebricks.data.IAWriter in project asterixdb by apache.
the class SerializedDataWriterFactory method createWriter.
@Override
public IAWriter createWriter(final int[] fields, final PrintStream ps, IPrinterFactory[] printerFactories, final RecordDescriptor inputRecordDescriptor) {
return new IAWriter() {
@Override
public void init() throws HyracksDataException {
// dump the SerializerDeserializers to disk
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(inputRecordDescriptor);
baos.writeTo(ps);
oos.close();
} catch (IOException e) {
throw new HyracksDataException(e);
}
}
@Override
public void printTuple(IFrameTupleAccessor tAccess, int tIdx) throws HyracksDataException {
for (int i = 0; i < fields.length; i++) {
int fldStart = tAccess.getTupleStartOffset(tIdx) + tAccess.getFieldSlotsLength() + tAccess.getFieldStartOffset(tIdx, fields[i]);
int fldLen = tAccess.getFieldLength(tIdx, fields[i]);
ps.write(tAccess.getBuffer().array(), fldStart, fldLen);
}
}
};
}
Aggregations