@Override protected boolean intersectsIfType(AUnionType type) { return type.isUnknownableType(); }
public static boolean canBeUnknown(IAType t) { switch (t.getTypeTag()) { case MISSING: case NULL: case ANY: return true; case UNION: return ((AUnionType) t).isUnknownableType(); default: return false; } }
/** * Decide whether a type is an optional type * * @param type * @return true if it is optional; false otherwise */ public static boolean isOptional(IAType type) { return type.getTypeTag() == ATypeTag.UNION && ((AUnionType) type).isUnknownableType(); }
private boolean isUnknownable(IAType type) { switch (type.getTypeTag()) { case ANY: case MISSING: case NULL: return true; case UNION: return ((AUnionType) type).isUnknownableType(); default: return false; } } }
private static boolean[] isUnknownableType(IAType... inputTypes) { boolean[] unknownable = new boolean[inputTypes.length]; for (int index = 0; index < unknownable.length; ++index) { IAType type = inputTypes[index]; unknownable[index] = false; if (type.getTypeTag() != ATypeTag.UNION) { continue; } else { AUnionType unionType = (AUnionType) type; unknownable[index] = unionType.isUnknownableType(); } } return unknownable; }
public static final boolean hasOptionalField(ARecordType recType) { for (int i = 0; i < recType.getFieldTypes().length; i++) { IAType type = recType.getFieldTypes()[i]; if (type != null) { ATypeTag tag = type.getTypeTag(); if (tag == ATypeTag.NULL || tag == ATypeTag.MISSING) { return true; } if (tag != ATypeTag.UNION) { continue; } // union AUnionType unionType = (AUnionType) type; if (unionType.isUnknownableType()) { return true; } } } return false; }
public static Pair<IAType, Boolean> getNonNullableOpenFieldType(IAType fieldType, List<String> fieldName, ARecordType recType) throws AlgebricksException { Pair<IAType, Boolean> keyPairType = null; IAType subType = recType; boolean nullable = false; for (int i = 0; i < fieldName.size(); i++) { if (subType instanceof AUnionType) { nullable = nullable || ((AUnionType) subType).isUnknownableType(); subType = ((AUnionType) subType).getActualType(); } if (subType instanceof ARecordType) { subType = ((ARecordType) subType).getFieldType(fieldName.get(i)); } else { throw AsterixException.create(ErrorCode.COMPILATION_ILLEGAL_STATE, "Unexpected type " + fieldType); } if (subType == null) { keyPairType = Index.getNonNullableType(fieldType); break; } } if (subType != null) { keyPairType = Index.getNonNullableKeyFieldType(fieldName, recType); } keyPairType.second = keyPairType.second || nullable; return keyPairType; }
private int checkOptionalConstraints(ARecordType recType, BitSet nulls) { for (int i = 0; i < recType.getFieldTypes().length; i++) { if (nulls.get(i) == false) { IAType type = recType.getFieldTypes()[i]; if ((type.getTypeTag() != ATypeTag.NULL) && (type.getTypeTag() != ATypeTag.UNION)) { return i; } if (type.getTypeTag() != ATypeTag.UNION) { continue; } // union AUnionType unionType = (AUnionType) type; if (!unionType.isUnknownableType()) { return i; } } } return -1; }
public static final boolean isFixedSizedCollection(IAType type) { switch (type.getTypeTag()) { case UNION: if (!((AUnionType) type).isUnknownableType()) { return false; } else { return isFixedSizedCollection(((AUnionType) type).getActualType()); } default: return isFixedSizedCollection(type.getTypeTag()); } }
@Override public void generateNestedDerivedTypeNames() { if (isUnknownableType()) { IAType nullableType = getActualType(); if (nullableType.getTypeTag().isDerivedType() && nullableType.getTypeName() == null) { AbstractComplexType derivedType = (AbstractComplexType) nullableType; derivedType.setTypeName(getTypeName()); derivedType.generateNestedDerivedTypeNames(); } } }
&& ((AUnionType) enforcedFieldType).isUnknownableType()) { enforcedFieldType = ((AUnionType) enforcedFieldType).getActualType();
@Override public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, CompilerProperties compilerProps) throws AlgebricksException { AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr; IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue()); switch (t.getTypeTag()) { case OBJECT: { fd.setImmutableStates(t); break; } case UNION: { AUnionType unionT = (AUnionType) t; if (unionT.isUnknownableType()) { IAType t2 = unionT.getActualType(); if (t2.getTypeTag() == ATypeTag.OBJECT) { fd.setImmutableStates(t2); break; } } throw new NotImplementedException("field-access-by-index for data of type " + t); } default: { throw new NotImplementedException("field-access-by-index for data of type " + t); } } } }
public static int checkOptionalConstraints(ARecordType recType, BitSet nulls) { for (int i = 0; i < recType.getFieldTypes().length; i++) { if (nulls.get(i) == false) { IAType type = recType.getFieldTypes()[i]; if (type.getTypeTag() != ATypeTag.MISSING && type.getTypeTag() != ATypeTag.UNION) { return i; } if (type.getTypeTag() == ATypeTag.UNION) { // union AUnionType unionType = (AUnionType) type; if (!unionType.isUnknownableType()) { return i; } } } } return -1; }
throw new NotImplementedException("'Unorderedlist' type unsupported for CSV output"); case UNION: if (((AUnionType) type).isUnknownableType()) { return new AOptionalFieldPrinterFactory((AUnionType) type); } else {
return new AUnorderedlistPrinterFactory((AUnorderedListType) type); case UNION: if (((AUnionType) type).isUnknownableType()) { return new AOptionalFieldPrinterFactory((AUnionType) type); } else {
return new AUnorderedlistPrinterFactory((AUnorderedListType) type); case UNION: if (((AUnionType) type).isUnknownableType()) { return new AOptionalFieldPrinterFactory((AUnionType) type); } else {
return new AUnorderedlistPrinterFactory((AUnorderedListType) type); case UNION: if (((AUnionType) type).isUnknownableType()) { return new AOptionalFieldPrinterFactory((AUnionType) type); } else {
public static IValueParserFactory[] getValueParserFactories(ARecordType recordType) { int n = recordType.getFieldTypes().length; IValueParserFactory[] fieldParserFactories = new IValueParserFactory[n]; for (int i = 0; i < n; i++) { ATypeTag tag = null; if (recordType.getFieldTypes()[i].getTypeTag() == ATypeTag.UNION) { AUnionType unionType = (AUnionType) recordType.getFieldTypes()[i]; if (!unionType.isUnknownableType()) { throw new NotImplementedException("Non-optional UNION type is not supported."); } tag = unionType.getActualType().getTypeTag(); } else { tag = recordType.getFieldTypes()[i].getTypeTag(); } if (tag == null) { throw new NotImplementedException("Failed to get the type information for field " + i + "."); } fieldParserFactories[i] = getParserFactory(tag); } return fieldParserFactories; }
if (((AUnionType) fieldValueType).isUnknownableType()) { fieldValueTypeTag = ((AUnionType) fieldValueType).getActualType().getTypeTag(); fieldValueLength = NonTaggedFormatUtil.getFieldValueLength(serRecord, fieldValueOffset,
if (!ut.isUnknownableType()) { throw new TypeMismatchException(fun.getSourceLocation(), funcName, 0, actualTypeTag, ATypeTag.MULTISET, ATypeTag.ARRAY);