use of org.apache.asterix.om.pointables.printer.csv.APrintVisitor in project asterixdb by apache.
the class ARecordPrinterFactory method createPrinter.
@Override
public IPrinter createPrinter() {
final PointableAllocator allocator = new PointableAllocator();
final IAType inputType = recType == null ? DefaultOpenFieldType.getDefaultOpenFieldType(ATypeTag.OBJECT) : recType;
final IVisitablePointable recAccessor = allocator.allocateRecordValue(inputType);
final APrintVisitor printVisitor = new APrintVisitor();
final Pair<PrintStream, ATypeTag> arg = new Pair<>(null, null);
return new IPrinter() {
@Override
public void init() {
arg.second = inputType.getTypeTag();
}
@Override
public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException {
recAccessor.set(b, start, l);
arg.first = ps;
recAccessor.accept(printVisitor, arg);
}
};
}
use of org.apache.asterix.om.pointables.printer.csv.APrintVisitor in project asterixdb by apache.
the class AObjectPrinterFactory method createPrinter.
@Override
public IPrinter createPrinter() {
final ARecordVisitablePointable rPointable = new ARecordVisitablePointable(DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE);
final Pair<PrintStream, ATypeTag> streamTag = new Pair<>(null, null);
final IPrintVisitor visitor = new APrintVisitor();
return (byte[] b, int s, int l, PrintStream ps) -> {
ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(b[s]);
if (!printFlatValue(typeTag, b, s, l, ps)) {
streamTag.first = ps;
streamTag.second = typeTag;
switch(typeTag) {
case OBJECT:
rPointable.set(b, s, l);
visitor.visit(rPointable, streamTag);
break;
default:
throw new HyracksDataException("No printer for type " + typeTag);
}
}
};
}
Aggregations