/** * private constructor, to prevent constructing it arbitrarily * * @param inputType */ public AListVisitablePointable(AbstractCollectionType inputType) { if (inputType instanceof AOrderedListType) { ordered = true; } if (inputType != null && inputType.getItemType() != null) { itemType = inputType.getItemType(); if (itemType.getTypeTag() == ATypeTag.ANY) { typedItemList = false; } else { typedItemList = true; itemTag = inputType.getItemType().getTypeTag(); } } else { this.typedItemList = false; } }
@Override protected IAType getResultType(ILogicalExpression expr, IAType... strippedInputTypes) throws AlgebricksException { IAType argType = strippedInputTypes[0]; ATypeTag argTypeTag = argType.getTypeTag(); if (argTypeTag == ATypeTag.ARRAY || argTypeTag == ATypeTag.MULTISET) { /** if the input is a singleton list, return it's item type if any */ AbstractCollectionType collectionType = (AbstractCollectionType) argType; return collectionType.getItemType(); } else { /** if the input is not a singleton list, return the original input type */ return argType; } }
public boolean isFixedType(AbstractCollectionType inputType) { return NonTaggedFormatUtil.isFixedSizedCollection(inputType.getItemType()); }
@Override public void reset(AbstractCollectionType listType) { this.outputStorage.reset(); this.offsetArray = null; this.offsets.clear(); this.offsetPosition = 0; this.numberOfItems = 0; if (listType == null || listType.getItemType() == null) { this.itemTypeTag = ATypeTag.ANY; fixedSize = false; } else { this.itemTypeTag = listType.getItemType().getTypeTag(); fixedSize = NonTaggedFormatUtil.isFixedSizedCollection(listType.getItemType()); } headerSize = 2; metadataInfoSize = 8; }
@Override protected IAType getResultType(ILogicalExpression expr, IAType... strippedInputTypes) throws AlgebricksException { ATypeTag tag = strippedInputTypes[0].getTypeTag(); if (tag == ATypeTag.ANY) { return BuiltinType.ANY; } if (tag != ATypeTag.ARRAY && tag != ATypeTag.MULTISET) { return strippedInputTypes[0]; } AbstractCollectionType act = (AbstractCollectionType) strippedInputTypes[0]; IAType t = act.getItemType(); return AUnionType.createUnknownableType(t); } }
public int getFixedLength(AbstractCollectionType inputType) throws HyracksDataException { return NonTaggedFormatUtil.getFieldValueLength(bytes, 0, inputType.getItemType().getTypeTag(), false); }
@Override public void init(PrintStream out, DataGeneratorContext ctx) throws Exception { super.init(out, ctx); if (act.getItemType().getTypeTag() == ATypeTag.STRING) { constructor = null; } else { constructor = getConstructor(act.getItemType()); } }
@Override protected IAType getResultType(ILogicalExpression expr, IAType... strippedInputTypes) throws AlgebricksException { IAType type = strippedInputTypes[0]; if (type.getTypeTag().isListType()) { return AUnionType.createNullableType(((AbstractCollectionType) type).getItemType()); } return BuiltinType.ANY; } }
@Override protected IAType getResultType(ILogicalExpression expr, IAType... strippedInputTypes) throws AlgebricksException { IAType type = strippedInputTypes[0]; if (type.getTypeTag() == ATypeTag.ANY) { return BuiltinType.ANY; } IAType itemType = ((AbstractCollectionType) type).getItemType(); if (itemType.getTypeTag() == ATypeTag.ANY) { return itemType; } // Could have out-of-bound access or null elements. return AUnionType.createUnknownableType(itemType); }
public static IAType getTokenType(IAType keyType) throws AlgebricksException { IAType type = keyType; ATypeTag typeTag = keyType.getTypeTag(); // Extract item type from list. if (typeTag == ATypeTag.MULTISET || typeTag == ATypeTag.ARRAY) { AbstractCollectionType listType = (AbstractCollectionType) keyType; if (!listType.isTyped()) { throw new AlgebricksException("Cannot build an inverted index on untyped lists.)"); } type = listType.getItemType(); } return type; }
@Override protected IAType getResultType(ILogicalExpression expr, IAType... strippedInputTypes) throws AlgebricksException { IAType type = strippedInputTypes[0]; if (type.getTypeTag() == ATypeTag.ANY) { return BuiltinType.ANY; } IAType itemType = ((AbstractCollectionType) type).getItemType(); if (nullable) { itemType = AUnionType.createNullableType(itemType); } if (missable) { itemType = AUnionType.createMissableType(itemType); } return itemType; } }
@Override protected IAType getResultType(ILogicalExpression expr, IAType... strippedInputTypes) throws AlgebricksException { IAType argType = strippedInputTypes[0]; IAType outputType = resultType; if (!argType.getTypeTag().isListType() || isUnknownable(((AbstractCollectionType) argType).getItemType())) { outputType = AUnionType.createUnknownableType(outputType); } return outputType; }
private void writeCollectionType(Datatype instance, AbstractComplexType type, DataOutput out) throws HyracksDataException { AbstractCollectionType listType = (AbstractCollectionType) type; IAType itemType = listType.getItemType(); if (itemType.getTypeTag().isDerivedType()) { handleNestedDerivedType(itemType.getTypeName(), (AbstractComplexType) itemType, instance, instance.getDataverseName(), instance.getDatatypeName()); } aString.setValue(listType.getItemType().getTypeName()); stringSerde.serialize(aString, out); }
List<Mutable<ILogicalExpression>> args = funcExpr.getArguments(); IAType requiredItemType = requiredListType.getItemType(); IAType inputItemType = inputListType.getItemType(); boolean changed = false; for (int j = 0; j < args.size(); j++) {
protected final void parseCollection(AbstractCollectionType collectionType, ADMToken endToken, DataOutput out) throws IOException { final IMutableValueStorage valueBuffer = parserContext.enterCollection(); final IAsterixListBuilder arrayBuilder = parserContext.getCollectionBuilder(collectionType); final boolean isOpen = collectionType.getItemType().getTypeTag() == ATypeTag.ANY; while (nextToken() != endToken) { valueBuffer.reset(); if (isOpen) { parseValue(BuiltinType.ANY, valueBuffer.getDataOutput()); } else { //fail fast if current value is null if (currentToken() == ADMToken.NULL) { throw new RuntimeDataException(ErrorCode.PARSER_COLLECTION_ITEM_CANNOT_BE_NULL); } parseValue(collectionType.getItemType(), valueBuffer.getDataOutput()); } arrayBuilder.addItem(valueBuffer); } parserContext.exitCollection(valueBuffer, arrayBuilder); arrayBuilder.write(out, true); }
@Override public void init(PrintStream out, DataGeneratorContext ctx) throws Exception { super.init(out, ctx); IAType t = act.getItemType(); if (t.getTypeTag() != ATypeTag.OBJECT) { throw new NotImplementedException("list annotation only works with record item types for now."); } ARecordType rt = (ARecordType) t; RecordDataGenAnnotation dga = firstDataGenAnnotation(rt); if (dga == null) { throw new Exception("No annotation on item type " + t); } itemGen = new RecordGenerator(rt, dga, null); itemGen.init(out, ctx); }
case ARRAY: { AbstractCollectionType act = (AbstractCollectionType) t; return act.getItemType(); if (tag2 == ATypeTag.MULTISET || tag2 == ATypeTag.ARRAY) { AbstractCollectionType act = (AbstractCollectionType) t2; return act.getItemType();
if (reqType.getTypeTag().equals(ATypeTag.MULTISET)) { unOrderedListBuilder.reset(reqType); reqItemType = reqType.getItemType(); reqItemType = reqType.getItemType();
|| expr.getFunctionIdentifier().equals(BuiltinFunctions.ORDERED_LIST_CONSTRUCTOR)) { AbstractCollectionType listType = (AbstractCollectionType) TypeCastUtils.getRequiredType(expr); if (listType != null && (listType.getItemType().getTypeTag() == ATypeTag.ANY || listType.getItemType() instanceof AbstractCollectionType)) {
public void processListValue(IValueReference listArg, IAType fieldType, DataOutput out, int level) throws IOException { ArrayBackedValueStorage itemValue = getTempBuffer(); IARecordBuilder listRecordBuilder = getRecordBuilder(); AListPointable list = getListPointable(); list.set(listArg); OrderedListBuilder innerListBuilder = getOrderedListBuilder(); innerListBuilder.reset(listType); listRecordBuilder.reset(null); AbstractCollectionType act = (AbstractCollectionType) fieldType; int itemCount = list.getItemCount(); for (int l = 0; l < itemCount; l++) { itemValue.reset(); listRecordBuilder.init(); byte tagId = list.getItemTag(act, l); addFieldType(tagId, listRecordBuilder); if (tagId == ATypeTag.SERIALIZED_RECORD_TYPE_TAG) { ArrayBackedValueStorage tmpAbvs = getTempBuffer(); list.getItemValue(act, l, tmpAbvs.getDataOutput()); addNestedField(tmpAbvs, act.getItemType(), listRecordBuilder, level + 1); } listRecordBuilder.write(itemValue.getDataOutput(), true); innerListBuilder.addItem(itemValue); } innerListBuilder.write(out, true); }