Search in sources :

Example 76 with TypeMismatchException

use of org.apache.asterix.runtime.exceptions.TypeMismatchException in project asterixdb by apache.

the class StringJoinDescriptor method createEvaluatorFactory.

@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
    return new IScalarEvaluatorFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
            return new IScalarEvaluator() {

                private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();

                private final ListAccessor listAccessor = new ListAccessor();

                private final DataOutput out = resultStorage.getDataOutput();

                private final IScalarEvaluatorFactory listEvalFactory = args[0];

                private final IScalarEvaluatorFactory sepEvalFactory = args[1];

                private final IPointable inputArgList = new VoidPointable();

                private final IPointable inputArgSep = new VoidPointable();

                private final IScalarEvaluator evalList = listEvalFactory.createScalarEvaluator(ctx);

                private final IScalarEvaluator evalSep = sepEvalFactory.createScalarEvaluator(ctx);

                @SuppressWarnings("unchecked")
                private ISerializerDeserializer<ANull> nullSerde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ANULL);

                private ISerializerDeserializer<AMissing> missingSerde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AMISSING);

                private final byte[] tempLengthArray = new byte[5];

                @Override
                public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                    resultStorage.reset();
                    evalList.evaluate(tuple, inputArgList);
                    evalSep.evaluate(tuple, inputArgSep);
                    byte[] listBytes = inputArgList.getByteArray();
                    int listOffset = inputArgList.getStartOffset();
                    if (listBytes[listOffset] != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG && listBytes[listOffset] != ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) {
                        throw new TypeMismatchException(getIdentifier(), 0, listBytes[listOffset], ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG, ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG);
                    }
                    byte[] sepBytes = inputArgSep.getByteArray();
                    int sepOffset = inputArgSep.getStartOffset();
                    if (sepBytes[sepOffset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                        throw new TypeMismatchException(getIdentifier(), 1, sepBytes[sepOffset], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                    }
                    int sepLen = UTF8StringUtil.getUTFLength(sepBytes, sepOffset + 1);
                    int sepMetaLen = UTF8StringUtil.getNumBytesToStoreLength(sepLen);
                    listAccessor.reset(listBytes, listOffset);
                    try {
                        // calculate length first
                        int utf8Len = 0;
                        int size = listAccessor.size();
                        for (int i = 0; i < size; i++) {
                            int itemOffset = listAccessor.getItemOffset(i);
                            ATypeTag itemType = listAccessor.getItemType(itemOffset);
                            // since the item itself has a typetag.
                            if (listAccessor.itemsAreSelfDescribing()) {
                                itemOffset += 1;
                            }
                            if (itemType != ATypeTag.STRING) {
                                if (itemType == ATypeTag.NULL) {
                                    nullSerde.serialize(ANull.NULL, out);
                                    result.set(resultStorage);
                                    return;
                                }
                                if (itemType == ATypeTag.MISSING) {
                                    missingSerde.serialize(AMissing.MISSING, out);
                                    result.set(resultStorage);
                                    return;
                                }
                                throw new UnsupportedItemTypeException(getIdentifier(), itemType.serialize());
                            }
                            int currentSize = UTF8StringUtil.getUTFLength(listBytes, itemOffset);
                            if (i != size - 1 && currentSize != 0) {
                                utf8Len += sepLen;
                            }
                            utf8Len += currentSize;
                        }
                        out.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                        int cbytes = UTF8StringUtil.encodeUTF8Length(utf8Len, tempLengthArray, 0);
                        out.write(tempLengthArray, 0, cbytes);
                        for (int i = 0; i < listAccessor.size(); i++) {
                            int itemOffset = listAccessor.getItemOffset(i);
                            if (listAccessor.itemsAreSelfDescribing()) {
                                itemOffset += 1;
                            }
                            utf8Len = UTF8StringUtil.getUTFLength(listBytes, itemOffset);
                            out.write(listBytes, UTF8StringUtil.getNumBytesToStoreLength(utf8Len) + itemOffset, utf8Len);
                            for (int j = 0; j < sepLen; j++) {
                                out.writeByte(sepBytes[sepOffset + 1 + sepMetaLen + j]);
                            }
                        }
                    } catch (IOException | AsterixException ex) {
                        throw new HyracksDataException(ex);
                    }
                    result.set(resultStorage);
                }
            };
        }
    };
}
Also used : DataOutput(java.io.DataOutput) TypeMismatchException(org.apache.asterix.runtime.exceptions.TypeMismatchException) IPointable(org.apache.hyracks.data.std.api.IPointable) IOException(java.io.IOException) IScalarEvaluator(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator) ISerializerDeserializer(org.apache.hyracks.api.dataflow.value.ISerializerDeserializer) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IScalarEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory) ListAccessor(org.apache.asterix.runtime.evaluators.common.ListAccessor) UnsupportedItemTypeException(org.apache.asterix.runtime.exceptions.UnsupportedItemTypeException) ArrayBackedValueStorage(org.apache.hyracks.data.std.util.ArrayBackedValueStorage) AsterixException(org.apache.asterix.common.exceptions.AsterixException) ATypeTag(org.apache.asterix.om.types.ATypeTag) IHyracksTaskContext(org.apache.hyracks.api.context.IHyracksTaskContext) VoidPointable(org.apache.hyracks.data.std.primitive.VoidPointable) IFrameTupleReference(org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference)

Example 77 with TypeMismatchException

use of org.apache.asterix.runtime.exceptions.TypeMismatchException in project asterixdb by apache.

the class Substring2Descriptor method createEvaluatorFactory.

@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
    return new IScalarEvaluatorFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
            return new IScalarEvaluator() {

                private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();

                private DataOutput out = resultStorage.getDataOutput();

                private IPointable argString = new VoidPointable();

                private IPointable argStart = new VoidPointable();

                private IScalarEvaluator evalString = args[0].createScalarEvaluator(ctx);

                private IScalarEvaluator evalStart = args[1].createScalarEvaluator(ctx);

                private final GrowableArray array = new GrowableArray();

                private final UTF8StringBuilder builder = new UTF8StringBuilder();

                private final UTF8StringPointable string = new UTF8StringPointable();

                @Override
                public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                    resultStorage.reset();
                    evalString.evaluate(tuple, argString);
                    evalStart.evaluate(tuple, argStart);
                    byte[] bytes = argStart.getByteArray();
                    int offset = argStart.getStartOffset();
                    int start = ATypeHierarchy.getIntegerValue(getIdentifier().getName(), 1, bytes, offset) - 1;
                    bytes = argString.getByteArray();
                    offset = argString.getStartOffset();
                    int len = argString.getLength();
                    if (bytes[offset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                        throw new TypeMismatchException(getIdentifier(), 0, bytes[offset], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                    }
                    string.set(bytes, offset + 1, len - 1);
                    array.reset();
                    try {
                        UTF8StringPointable.substr(string, start, Integer.MAX_VALUE, builder, array);
                    } catch (StringIndexOutOfBoundsException e) {
                        throw new RuntimeDataException(ErrorCode.OUT_OF_BOUND, getIdentifier(), 1, start);
                    } catch (IOException e) {
                        throw new HyracksDataException(e);
                    }
                    try {
                        out.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                        out.write(array.getByteArray(), 0, array.getLength());
                    } catch (IOException e) {
                        throw new HyracksDataException(e);
                    }
                    result.set(resultStorage);
                }
            };
        }
    };
}
Also used : DataOutput(java.io.DataOutput) UTF8StringPointable(org.apache.hyracks.data.std.primitive.UTF8StringPointable) TypeMismatchException(org.apache.asterix.runtime.exceptions.TypeMismatchException) GrowableArray(org.apache.hyracks.data.std.util.GrowableArray) IPointable(org.apache.hyracks.data.std.api.IPointable) IOException(java.io.IOException) IScalarEvaluator(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator) UTF8StringBuilder(org.apache.hyracks.data.std.util.UTF8StringBuilder) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IScalarEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory) ArrayBackedValueStorage(org.apache.hyracks.data.std.util.ArrayBackedValueStorage) IHyracksTaskContext(org.apache.hyracks.api.context.IHyracksTaskContext) VoidPointable(org.apache.hyracks.data.std.primitive.VoidPointable) IFrameTupleReference(org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference) RuntimeDataException(org.apache.asterix.common.exceptions.RuntimeDataException)

Example 78 with TypeMismatchException

use of org.apache.asterix.runtime.exceptions.TypeMismatchException in project asterixdb by apache.

the class LenDescriptor method createEvaluatorFactory.

@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
    return new IScalarEvaluatorFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
            return new IScalarEvaluator() {

                private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();

                private final DataOutput out = resultStorage.getDataOutput();

                private final IPointable inputVal = new VoidPointable();

                private final IScalarEvaluator evalList = args[0].createScalarEvaluator(ctx);

                // result
                private final AMutableInt64 res = new AMutableInt64(0);

                @SuppressWarnings("unchecked")
                private final ISerializerDeserializer<AInt64> int64Serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64);

                @Override
                public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                    resultStorage.reset();
                    evalList.evaluate(tuple, inputVal);
                    byte[] serList = inputVal.getByteArray();
                    int offset = inputVal.getStartOffset();
                    if (serList[offset] != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG && serList[offset] != ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) {
                        throw new TypeMismatchException(getIdentifier(), 0, serList[offset], ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG, ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG);
                    }
                    int numberOfitems = 0;
                    if (serList[offset] == ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG) {
                        numberOfitems = AOrderedListSerializerDeserializer.getNumberOfItems(serList, offset);
                    } else {
                        numberOfitems = AUnorderedListSerializerDeserializer.getNumberOfItems(serList, offset);
                    }
                    res.setValue(numberOfitems);
                    try {
                        int64Serde.serialize(res, out);
                    } catch (IOException e) {
                        throw new HyracksDataException(e);
                    }
                    result.set(resultStorage);
                }
            };
        }
    };
}
Also used : DataOutput(java.io.DataOutput) TypeMismatchException(org.apache.asterix.runtime.exceptions.TypeMismatchException) IPointable(org.apache.hyracks.data.std.api.IPointable) IOException(java.io.IOException) IScalarEvaluator(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator) ISerializerDeserializer(org.apache.hyracks.api.dataflow.value.ISerializerDeserializer) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IScalarEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory) ArrayBackedValueStorage(org.apache.hyracks.data.std.util.ArrayBackedValueStorage) IHyracksTaskContext(org.apache.hyracks.api.context.IHyracksTaskContext) VoidPointable(org.apache.hyracks.data.std.primitive.VoidPointable) IFrameTupleReference(org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference) AMutableInt64(org.apache.asterix.om.base.AMutableInt64)

Example 79 with TypeMismatchException

use of org.apache.asterix.runtime.exceptions.TypeMismatchException in project asterixdb by apache.

the class RecordPairsDescriptor method createEvaluatorFactory.

@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
    return new IScalarEvaluatorFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException {
            // For writing each individual output record.
            final ArrayBackedValueStorage itemStorage = new ArrayBackedValueStorage();
            final DataOutput itemOutput = itemStorage.getDataOutput();
            final RecordBuilder recBuilder = new RecordBuilder();
            recBuilder.reset(RecordUtil.FULLY_OPEN_RECORD_TYPE);
            // For writing the resulting list of records.
            final OrderedListBuilder listBuilder = new OrderedListBuilder();
            final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
            final DataOutput resultOut = resultStorage.getDataOutput();
            // Sets up the constant field names, "name" for the key field, "value" for the value field.
            final ArrayBackedValueStorage nameStorage = new ArrayBackedValueStorage();
            final ArrayBackedValueStorage valueStorage = new ArrayBackedValueStorage();
            AObjectSerializerDeserializer serde = AObjectSerializerDeserializer.INSTANCE;
            try {
                serde.serialize(new AString("name"), nameStorage.getDataOutput());
                serde.serialize(new AString("value"), valueStorage.getDataOutput());
            } catch (IOException e) {
                throw new HyracksDataException(e);
            }
            return new IScalarEvaluator() {

                private final IScalarEvaluator argEvaluator = args[0].createScalarEvaluator(ctx);

                private final IPointable argPtr = new VoidPointable();

                private final ARecordVisitablePointable recordVisitablePointable = new ARecordVisitablePointable(recType);

                @Override
                public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                    // Resets the result storage.
                    resultStorage.reset();
                    // Gets the input record.
                    argEvaluator.evaluate(tuple, argPtr);
                    byte inputTypeTag = argPtr.getByteArray()[argPtr.getStartOffset()];
                    if (inputTypeTag != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
                        throw new TypeMismatchException(getIdentifier(), 0, inputTypeTag, ATypeTag.SERIALIZED_RECORD_TYPE_TAG);
                    }
                    recordVisitablePointable.set(argPtr);
                    listBuilder.reset(AOrderedListType.FULL_OPEN_ORDEREDLIST_TYPE);
                    List<IVisitablePointable> fieldNames = recordVisitablePointable.getFieldNames();
                    List<IVisitablePointable> fieldValues = recordVisitablePointable.getFieldValues();
                    // Adds each field of the input record as a key-value pair into the result.
                    int numFields = recordVisitablePointable.getFieldNames().size();
                    for (int fieldIndex = 0; fieldIndex < numFields; ++fieldIndex) {
                        itemStorage.reset();
                        recBuilder.init();
                        recBuilder.addField(nameStorage, fieldNames.get(fieldIndex));
                        recBuilder.addField(valueStorage, fieldValues.get(fieldIndex));
                        recBuilder.write(itemOutput, true);
                        listBuilder.addItem(itemStorage);
                    }
                    // Writes the result and sets the result pointable.
                    listBuilder.write(resultOut, true);
                    result.set(resultStorage);
                }
            };
        }
    };
}
Also used : DataOutput(java.io.DataOutput) OrderedListBuilder(org.apache.asterix.builders.OrderedListBuilder) TypeMismatchException(org.apache.asterix.runtime.exceptions.TypeMismatchException) RecordBuilder(org.apache.asterix.builders.RecordBuilder) AObjectSerializerDeserializer(org.apache.asterix.dataflow.data.nontagged.serde.AObjectSerializerDeserializer) IOException(java.io.IOException) IPointable(org.apache.hyracks.data.std.api.IPointable) IScalarEvaluator(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IScalarEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory) ARecordVisitablePointable(org.apache.asterix.om.pointables.ARecordVisitablePointable) ArrayBackedValueStorage(org.apache.hyracks.data.std.util.ArrayBackedValueStorage) IVisitablePointable(org.apache.asterix.om.pointables.base.IVisitablePointable) IHyracksTaskContext(org.apache.hyracks.api.context.IHyracksTaskContext) VoidPointable(org.apache.hyracks.data.std.primitive.VoidPointable) IFrameTupleReference(org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference) AString(org.apache.asterix.om.base.AString)

Example 80 with TypeMismatchException

use of org.apache.asterix.runtime.exceptions.TypeMismatchException in project asterixdb by apache.

the class RecordRemoveFieldsEvalFactory method createScalarEvaluator.

@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
    final PointableAllocator pa = new PointableAllocator();
    final IVisitablePointable vp0 = pa.allocateRecordValue(inputRecType);
    final IVisitablePointable vp1 = pa.allocateListValue(inputListType);
    final IPointable inputArg0 = new VoidPointable();
    final IPointable inputArg1 = new VoidPointable();
    final IScalarEvaluator eval0 = inputRecordEvalFactory.createScalarEvaluator(ctx);
    final IScalarEvaluator eval1 = removeFieldPathsFactory.createScalarEvaluator(ctx);
    return new IScalarEvaluator() {

        private final RuntimeRecordTypeInfo runtimeRecordTypeInfo = new RuntimeRecordTypeInfo();

        private final List<RecordBuilder> rbStack = new ArrayList<>();

        private final ArrayBackedValueStorage tabvs = new ArrayBackedValueStorage();

        private final Deque<IVisitablePointable> recordPath = new ArrayDeque<>();

        private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();

        private DataOutput out = resultStorage.getDataOutput();

        @Override
        public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
            resultStorage.reset();
            eval0.evaluate(tuple, inputArg0);
            eval1.evaluate(tuple, inputArg1);
            byte inputTypeTag0 = inputArg0.getByteArray()[inputArg0.getStartOffset()];
            if (inputTypeTag0 != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
                throw new TypeMismatchException(BuiltinFunctions.REMOVE_FIELDS, 0, inputTypeTag0, ATypeTag.SERIALIZED_INT32_TYPE_TAG);
            }
            byte inputTypeTag1 = inputArg1.getByteArray()[inputArg1.getStartOffset()];
            if (inputTypeTag1 != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG) {
                throw new TypeMismatchException(BuiltinFunctions.REMOVE_FIELDS, 1, inputTypeTag1, ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG);
            }
            vp0.set(inputArg0);
            vp1.set(inputArg1);
            ARecordVisitablePointable recordPointable = (ARecordVisitablePointable) vp0;
            AListVisitablePointable listPointable = (AListVisitablePointable) vp1;
            try {
                recordPath.clear();
                rbStack.clear();
                processRecord(requiredRecType, recordPointable, listPointable, 0);
                rbStack.get(0).write(out, true);
            } catch (IOException | AsterixException e) {
                throw new HyracksDataException(e);
            }
            result.set(resultStorage);
        }

        private void processRecord(ARecordType requiredType, ARecordVisitablePointable srp, AListVisitablePointable inputList, int nestedLevel) throws IOException, AsterixException, HyracksDataException {
            if (rbStack.size() < (nestedLevel + 1)) {
                rbStack.add(new RecordBuilder());
            }
            rbStack.get(nestedLevel).reset(requiredType);
            rbStack.get(nestedLevel).init();
            List<IVisitablePointable> fieldNames = srp.getFieldNames();
            List<IVisitablePointable> fieldValues = srp.getFieldValues();
            List<IVisitablePointable> fieldTypes = srp.getFieldTypeTags();
            for (int i = 0; i < fieldNames.size(); i++) {
                IVisitablePointable subRecFieldName = fieldNames.get(i);
                recordPath.push(subRecFieldName);
                if (isValidPath(inputList)) {
                    if (requiredType != null && requiredType.getTypeTag() != ATypeTag.ANY) {
                        addKeptFieldToSubRecord(requiredType, subRecFieldName, fieldValues.get(i), fieldTypes.get(i), inputList, nestedLevel);
                    } else {
                        addKeptFieldToSubRecord(DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE, subRecFieldName, fieldValues.get(i), fieldTypes.get(i), inputList, nestedLevel);
                    }
                }
                recordPath.pop();
            }
        }

        private void addKeptFieldToSubRecord(ARecordType requiredType, IVisitablePointable fieldNamePointable, IVisitablePointable fieldValuePointable, IVisitablePointable fieldTypePointable, AListVisitablePointable inputList, int nestedLevel) throws IOException, AsterixException, HyracksDataException {
            runtimeRecordTypeInfo.reset(requiredType);
            int pos = runtimeRecordTypeInfo.getFieldIndex(fieldNamePointable.getByteArray(), fieldNamePointable.getStartOffset() + 1, fieldNamePointable.getLength() - 1);
            if (pos >= 0) {
                // Closed field
                if (PointableHelper.sameType(ATypeTag.OBJECT, fieldTypePointable)) {
                    processRecord((ARecordType) requiredType.getFieldTypes()[pos], (ARecordVisitablePointable) fieldValuePointable, inputList, nestedLevel + 1);
                    tabvs.reset();
                    rbStack.get(nestedLevel + 1).write(tabvs.getDataOutput(), true);
                    rbStack.get(nestedLevel).addField(pos, tabvs);
                } else {
                    rbStack.get(nestedLevel).addField(pos, fieldValuePointable);
                }
            } else {
                // Open field
                if (PointableHelper.sameType(ATypeTag.OBJECT, fieldTypePointable)) {
                    processRecord(null, (ARecordVisitablePointable) fieldValuePointable, inputList, nestedLevel + 1);
                    tabvs.reset();
                    rbStack.get(nestedLevel + 1).write(tabvs.getDataOutput(), true);
                    rbStack.get(nestedLevel).addField(fieldNamePointable, tabvs);
                } else {
                    rbStack.get(nestedLevel).addField(fieldNamePointable, fieldValuePointable);
                }
            }
        }

        private boolean isValidPath(AListVisitablePointable inputList) throws HyracksDataException {
            List<IVisitablePointable> items = inputList.getItems();
            List<IVisitablePointable> typeTags = inputList.getItemTags();
            int pathLen = recordPath.size();
            for (int i = 0; i < items.size(); i++) {
                IVisitablePointable item = items.get(i);
                if (PointableHelper.sameType(ATypeTag.ARRAY, typeTags.get(i))) {
                    List<IVisitablePointable> inputPathItems = ((AListVisitablePointable) item).getItems();
                    if (pathLen == inputPathItems.size()) {
                        boolean match = true;
                        Iterator<IVisitablePointable> fpi = recordPath.iterator();
                        for (int j = inputPathItems.size() - 1; j >= 0; j--) {
                            match &= PointableHelper.isEqual(inputPathItems.get(j), fpi.next());
                            if (!match) {
                                break;
                            }
                        }
                        if (match) {
                            // Not a valid path for the output record
                            return false;
                        }
                    }
                } else {
                    if (PointableHelper.isEqual(recordPath.getFirst(), item)) {
                        return false;
                    }
                }
            }
            return true;
        }
    };
}
Also used : DataOutput(java.io.DataOutput) TypeMismatchException(org.apache.asterix.runtime.exceptions.TypeMismatchException) IPointable(org.apache.hyracks.data.std.api.IPointable) IScalarEvaluator(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator) ARecordVisitablePointable(org.apache.asterix.om.pointables.ARecordVisitablePointable) AListVisitablePointable(org.apache.asterix.om.pointables.AListVisitablePointable) AsterixException(org.apache.asterix.common.exceptions.AsterixException) VoidPointable(org.apache.hyracks.data.std.primitive.VoidPointable) ArrayList(java.util.ArrayList) List(java.util.List) PointableAllocator(org.apache.asterix.om.pointables.PointableAllocator) RecordBuilder(org.apache.asterix.builders.RecordBuilder) IOException(java.io.IOException) Deque(java.util.Deque) ArrayDeque(java.util.ArrayDeque) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IVisitablePointable(org.apache.asterix.om.pointables.base.IVisitablePointable) ArrayBackedValueStorage(org.apache.hyracks.data.std.util.ArrayBackedValueStorage) IFrameTupleReference(org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference) RuntimeRecordTypeInfo(org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo) ARecordType(org.apache.asterix.om.types.ARecordType)

Aggregations

TypeMismatchException (org.apache.asterix.runtime.exceptions.TypeMismatchException)127 IPointable (org.apache.hyracks.data.std.api.IPointable)117 IFrameTupleReference (org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference)117 DataOutput (java.io.DataOutput)116 IScalarEvaluator (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator)116 ArrayBackedValueStorage (org.apache.hyracks.data.std.util.ArrayBackedValueStorage)116 VoidPointable (org.apache.hyracks.data.std.primitive.VoidPointable)114 IScalarEvaluatorFactory (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)110 IHyracksTaskContext (org.apache.hyracks.api.context.IHyracksTaskContext)110 ISerializerDeserializer (org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)93 IOException (java.io.IOException)84 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)67 InvalidDataFormatException (org.apache.asterix.runtime.exceptions.InvalidDataFormatException)44 UTF8StringPointable (org.apache.hyracks.data.std.primitive.UTF8StringPointable)33 AMutableInt64 (org.apache.asterix.om.base.AMutableInt64)22 ATypeTag (org.apache.asterix.om.types.ATypeTag)18 AsterixException (org.apache.asterix.common.exceptions.AsterixException)14 GregorianCalendarSystem (org.apache.asterix.om.base.temporal.GregorianCalendarSystem)13 AMutablePoint (org.apache.asterix.om.base.AMutablePoint)11 AMutableDateTime (org.apache.asterix.om.base.AMutableDateTime)10