Search in sources :

Example 6 with PointableAllocator

use of org.apache.asterix.om.pointables.PointableAllocator in project asterixdb by apache.

the class AOrderedlistPrinterFactory method createPrinter.

@Override
public IPrinter createPrinter() {
    PointableAllocator allocator = new PointableAllocator();
    final IAType inputType = orderedlistType == null ? DefaultOpenFieldType.getDefaultOpenFieldType(ATypeTag.ARRAY) : orderedlistType;
    final IVisitablePointable listAccessor = allocator.allocateListValue(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 {
            listAccessor.set(b, start, l);
            arg.first = ps;
            listAccessor.accept(printVisitor, arg);
        }
    };
}
Also used : PrintStream(java.io.PrintStream) IVisitablePointable(org.apache.asterix.om.pointables.base.IVisitablePointable) ATypeTag(org.apache.asterix.om.types.ATypeTag) APrintVisitor(org.apache.asterix.om.pointables.printer.json.lossless.APrintVisitor) IPrinter(org.apache.hyracks.algebricks.data.IPrinter) PointableAllocator(org.apache.asterix.om.pointables.PointableAllocator) IAType(org.apache.asterix.om.types.IAType) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 7 with PointableAllocator

use of org.apache.asterix.om.pointables.PointableAllocator 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);
        }
    };
}
Also used : PrintStream(java.io.PrintStream) IVisitablePointable(org.apache.asterix.om.pointables.base.IVisitablePointable) ATypeTag(org.apache.asterix.om.types.ATypeTag) APrintVisitor(org.apache.asterix.om.pointables.printer.json.clean.APrintVisitor) IPrinter(org.apache.hyracks.algebricks.data.IPrinter) PointableAllocator(org.apache.asterix.om.pointables.PointableAllocator) IAType(org.apache.asterix.om.types.IAType) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 8 with PointableAllocator

use of org.apache.asterix.om.pointables.PointableAllocator in project asterixdb by apache.

the class AOrderedlistPrinterFactory method createPrinter.

@Override
public IPrinter createPrinter() {
    final PointableAllocator allocator = new PointableAllocator();
    final IAType inputType = orderedlistType == null ? DefaultOpenFieldType.getDefaultOpenFieldType(ATypeTag.ARRAY) : orderedlistType;
    final IVisitablePointable listAccessor = allocator.allocateListValue(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 {
            listAccessor.set(b, start, l);
            arg.first = ps;
            listAccessor.accept(printVisitor, arg);
        }
    };
}
Also used : PrintStream(java.io.PrintStream) IVisitablePointable(org.apache.asterix.om.pointables.base.IVisitablePointable) ATypeTag(org.apache.asterix.om.types.ATypeTag) APrintVisitor(org.apache.asterix.om.pointables.printer.json.clean.APrintVisitor) IPrinter(org.apache.hyracks.algebricks.data.IPrinter) PointableAllocator(org.apache.asterix.om.pointables.PointableAllocator) IAType(org.apache.asterix.om.types.IAType) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 9 with PointableAllocator

use of org.apache.asterix.om.pointables.PointableAllocator in project asterixdb by apache.

the class AUnorderedlistPrinterFactory method createPrinter.

@Override
public IPrinter createPrinter() {
    PointableAllocator allocator = new PointableAllocator();
    final IAType inputType = unorderedlistType == null ? DefaultOpenFieldType.getDefaultOpenFieldType(ATypeTag.MULTISET) : unorderedlistType;
    final IVisitablePointable listAccessor = allocator.allocateListValue(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 {
            try {
                listAccessor.set(b, start, l);
                arg.first = ps;
                listAccessor.accept(printVisitor, arg);
            } catch (Exception e) {
                throw new HyracksDataException(e);
            }
        }
    };
}
Also used : PrintStream(java.io.PrintStream) IVisitablePointable(org.apache.asterix.om.pointables.base.IVisitablePointable) ATypeTag(org.apache.asterix.om.types.ATypeTag) APrintVisitor(org.apache.asterix.om.pointables.printer.json.clean.APrintVisitor) IPrinter(org.apache.hyracks.algebricks.data.IPrinter) PointableAllocator(org.apache.asterix.om.pointables.PointableAllocator) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IAType(org.apache.asterix.om.types.IAType) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 10 with PointableAllocator

use of org.apache.asterix.om.pointables.PointableAllocator 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);
        }
    };
}
Also used : PrintStream(java.io.PrintStream) IVisitablePointable(org.apache.asterix.om.pointables.base.IVisitablePointable) ATypeTag(org.apache.asterix.om.types.ATypeTag) APrintVisitor(org.apache.asterix.om.pointables.printer.adm.APrintVisitor) IPrinter(org.apache.hyracks.algebricks.data.IPrinter) PointableAllocator(org.apache.asterix.om.pointables.PointableAllocator) IAType(org.apache.asterix.om.types.IAType) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Aggregations

PointableAllocator (org.apache.asterix.om.pointables.PointableAllocator)14 IVisitablePointable (org.apache.asterix.om.pointables.base.IVisitablePointable)14 PrintStream (java.io.PrintStream)10 ATypeTag (org.apache.asterix.om.types.ATypeTag)10 IAType (org.apache.asterix.om.types.IAType)10 Pair (org.apache.hyracks.algebricks.common.utils.Pair)10 IPrinter (org.apache.hyracks.algebricks.data.IPrinter)10 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)6 DataOutput (java.io.DataOutput)4 IScalarEvaluator (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator)4 IPointable (org.apache.hyracks.data.std.api.IPointable)4 ArrayBackedValueStorage (org.apache.hyracks.data.std.util.ArrayBackedValueStorage)4 IFrameTupleReference (org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference)4 RecordBuilder (org.apache.asterix.builders.RecordBuilder)3 AsterixException (org.apache.asterix.common.exceptions.AsterixException)3 ARecordVisitablePointable (org.apache.asterix.om.pointables.ARecordVisitablePointable)3 APrintVisitor (org.apache.asterix.om.pointables.printer.adm.APrintVisitor)3 APrintVisitor (org.apache.asterix.om.pointables.printer.json.clean.APrintVisitor)3 APrintVisitor (org.apache.asterix.om.pointables.printer.json.lossless.APrintVisitor)3 RuntimeRecordTypeInfo (org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo)3