use of org.apache.asterix.om.pointables.base.IVisitablePointable 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);
}
};
}
use of org.apache.asterix.om.pointables.base.IVisitablePointable 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);
}
}
};
}
use of org.apache.asterix.om.pointables.base.IVisitablePointable 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.base.IVisitablePointable 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.base.IVisitablePointable in project asterixdb by apache.
the class JavaFunctionHelper method setArgument.
public void setArgument(int index, IValueReference valueReference) throws IOException, AsterixException {
IVisitablePointable pointable = null;
IJObject jObject = null;
IAType type = finfo.getParamList().get(index);
switch(type.getTypeTag()) {
case OBJECT:
pointable = pointableAllocator.allocateRecordValue(type);
pointable.set(valueReference);
jObject = pointableVisitor.visit((ARecordVisitablePointable) pointable, getTypeInfo(index, type));
break;
case ARRAY:
case MULTISET:
pointable = pointableAllocator.allocateListValue(type);
pointable.set(valueReference);
jObject = pointableVisitor.visit((AListVisitablePointable) pointable, getTypeInfo(index, type));
break;
case ANY:
throw new RuntimeDataException(ErrorCode.LIBRARY_JAVA_FUNCTION_HELPER_CANNOT_HANDLE_ARGU_TYPE, type.getTypeTag());
default:
pointable = pointableAllocator.allocateFieldValue(type);
pointable.set(valueReference);
jObject = pointableVisitor.visit((AFlatValuePointable) pointable, getTypeInfo(index, type));
break;
}
arguments[index] = jObject;
}
Aggregations