use of org.apache.hyracks.api.dataflow.value.IResultSerializerFactory in project asterixdb by apache.
the class MetadataProvider method getResultHandleRuntime.
@Override
public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getResultHandleRuntime(IDataSink sink, int[] printColumns, IPrinterFactory[] printerFactories, RecordDescriptor inputDesc, boolean ordered, JobSpecification spec) throws AlgebricksException {
ResultSetDataSink rsds = (ResultSetDataSink) sink;
ResultSetSinkId rssId = rsds.getId();
ResultSetId rsId = rssId.getResultSetId();
ResultWriterOperatorDescriptor resultWriter = null;
try {
IResultSerializerFactory resultSerializedAppenderFactory = resultSerializerFactoryProvider.getAqlResultSerializerFactoryProvider(printColumns, printerFactories, getWriterFactory());
resultWriter = new ResultWriterOperatorDescriptor(spec, rsId, ordered, getResultAsyncMode(), resultSerializedAppenderFactory);
} catch (IOException e) {
throw new AlgebricksException(e);
}
return new Pair<>(resultWriter, null);
}
use of org.apache.hyracks.api.dataflow.value.IResultSerializerFactory in project asterixdb by apache.
the class ResultSerializerFactoryProvider method getResultSerializerFactoryProvider.
public IResultSerializerFactory getResultSerializerFactoryProvider() {
return new IResultSerializerFactory() {
private static final long serialVersionUID = 1L;
@Override
public IResultSerializer createResultSerializer(final RecordDescriptor recordDesc, final PrintStream printStream) {
return new IResultSerializer() {
private static final long serialVersionUID = 1L;
ByteBufferInputStream bbis = new ByteBufferInputStream();
DataInputStream di = new DataInputStream(bbis);
@Override
public void init() throws HyracksDataException {
}
@Override
public boolean appendTuple(IFrameTupleAccessor tAccess, int tIdx) throws HyracksDataException {
int start = tAccess.getTupleStartOffset(tIdx) + tAccess.getFieldSlotsLength();
bbis.setByteBuffer(tAccess.getBuffer(), start);
Object[] record = new Object[recordDesc.getFieldCount()];
for (int i = 0; i < record.length; ++i) {
Object instance = recordDesc.getFields()[i].deserialize(di);
if (i == 0) {
printStream.print(String.valueOf(instance));
} else {
printStream.print(", " + String.valueOf(instance));
}
}
printStream.println();
return true;
}
};
}
};
}
Aggregations