Search in sources :

Example 1 with IPrintVisitor

use of org.apache.asterix.om.pointables.printer.IPrintVisitor 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 AListVisitablePointable olPointable = new AListVisitablePointable(DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE);
    final AListVisitablePointable ulPointable = new AListVisitablePointable(DefaultOpenFieldType.NESTED_OPEN_AUNORDERED_LIST_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;
                case ARRAY:
                    olPointable.set(b, s, l);
                    visitor.visit(olPointable, streamTag);
                    break;
                case MULTISET:
                    ulPointable.set(b, s, l);
                    visitor.visit(ulPointable, streamTag);
                    break;
                default:
                    throw new HyracksDataException("No printer for type " + typeTag);
            }
        }
    };
}
Also used : PrintStream(java.io.PrintStream) ARecordVisitablePointable(org.apache.asterix.om.pointables.ARecordVisitablePointable) AListVisitablePointable(org.apache.asterix.om.pointables.AListVisitablePointable) ATypeTag(org.apache.asterix.om.types.ATypeTag) IPrintVisitor(org.apache.asterix.om.pointables.printer.IPrintVisitor) APrintVisitor(org.apache.asterix.om.pointables.printer.adm.APrintVisitor) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 2 with IPrintVisitor

use of org.apache.asterix.om.pointables.printer.IPrintVisitor 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 AListVisitablePointable olPointable = new AListVisitablePointable(DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE);
    final AListVisitablePointable ulPointable = new AListVisitablePointable(DefaultOpenFieldType.NESTED_OPEN_AUNORDERED_LIST_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;
                case ARRAY:
                    olPointable.set(b, s, l);
                    visitor.visit(olPointable, streamTag);
                    break;
                case MULTISET:
                    ulPointable.set(b, s, l);
                    visitor.visit(ulPointable, streamTag);
                    break;
                default:
                    throw new HyracksDataException("No printer for type " + typeTag);
            }
        }
    };
}
Also used : PrintStream(java.io.PrintStream) ARecordVisitablePointable(org.apache.asterix.om.pointables.ARecordVisitablePointable) AListVisitablePointable(org.apache.asterix.om.pointables.AListVisitablePointable) ATypeTag(org.apache.asterix.om.types.ATypeTag) IPrintVisitor(org.apache.asterix.om.pointables.printer.IPrintVisitor) APrintVisitor(org.apache.asterix.om.pointables.printer.json.clean.APrintVisitor) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 3 with IPrintVisitor

use of org.apache.asterix.om.pointables.printer.IPrintVisitor 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);
            }
        }
    };
}
Also used : PrintStream(java.io.PrintStream) ARecordVisitablePointable(org.apache.asterix.om.pointables.ARecordVisitablePointable) ATypeTag(org.apache.asterix.om.types.ATypeTag) IPrintVisitor(org.apache.asterix.om.pointables.printer.IPrintVisitor) APrintVisitor(org.apache.asterix.om.pointables.printer.csv.APrintVisitor) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 4 with IPrintVisitor

use of org.apache.asterix.om.pointables.printer.IPrintVisitor 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 AListVisitablePointable olPointable = new AListVisitablePointable(DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE);
    final AListVisitablePointable ulPointable = new AListVisitablePointable(DefaultOpenFieldType.NESTED_OPEN_AUNORDERED_LIST_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;
                case ARRAY:
                    olPointable.set(b, s, l);
                    visitor.visit(olPointable, streamTag);
                    break;
                case MULTISET:
                    ulPointable.set(b, s, l);
                    visitor.visit(ulPointable, streamTag);
                    break;
                default:
                    throw new HyracksDataException("No printer for type " + typeTag);
            }
        }
    };
}
Also used : PrintStream(java.io.PrintStream) ARecordVisitablePointable(org.apache.asterix.om.pointables.ARecordVisitablePointable) AListVisitablePointable(org.apache.asterix.om.pointables.AListVisitablePointable) ATypeTag(org.apache.asterix.om.types.ATypeTag) IPrintVisitor(org.apache.asterix.om.pointables.printer.IPrintVisitor) APrintVisitor(org.apache.asterix.om.pointables.printer.json.lossless.APrintVisitor) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Aggregations

PrintStream (java.io.PrintStream)4 ARecordVisitablePointable (org.apache.asterix.om.pointables.ARecordVisitablePointable)4 IPrintVisitor (org.apache.asterix.om.pointables.printer.IPrintVisitor)4 ATypeTag (org.apache.asterix.om.types.ATypeTag)4 Pair (org.apache.hyracks.algebricks.common.utils.Pair)4 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)4 AListVisitablePointable (org.apache.asterix.om.pointables.AListVisitablePointable)3 APrintVisitor (org.apache.asterix.om.pointables.printer.adm.APrintVisitor)1 APrintVisitor (org.apache.asterix.om.pointables.printer.csv.APrintVisitor)1 APrintVisitor (org.apache.asterix.om.pointables.printer.json.clean.APrintVisitor)1 APrintVisitor (org.apache.asterix.om.pointables.printer.json.lossless.APrintVisitor)1