/** * @param subFieldName * The full pathname of the child * @param parent * The type of the parent * @return the type of the child */ public IAType getSubFieldType(List<String> subFieldName, IAType parent) { ARecordType subRecordType = (ARecordType) parent; for (int i = 0; i < (subFieldName.size() - 1); i++) { subRecordType = (ARecordType) subRecordType.getFieldType(subFieldName.get(i)); } return subRecordType.getFieldType(subFieldName.get(subFieldName.size() - 1)); }
if (inputRecordType.getFieldType(fieldName).getTypeTag() == ATypeTag.OBJECT) { ARecordType nestedType = (ARecordType) inputRecordType.getFieldType(fieldName); resultFieldTypes.add(inputRecordType.getFieldType(fieldName));
if (recType0.getFieldType(fieldName).getTypeTag() == ATypeTag.OBJECT) { ARecordType nestedType = (ARecordType) recType0.getFieldType(fieldName); resultFieldTypes.add(recType0.getFieldType(fieldName));
private void addField(ARecordType inputRecordType, String fieldName, List<String> resultFieldNames, List<IAType> resultFieldTypes) throws AlgebricksException { resultFieldNames.add(fieldName); if (inputRecordType.getFieldType(fieldName).getTypeTag() == ATypeTag.OBJECT) { ARecordType nestedType = (ARecordType) inputRecordType.getFieldType(fieldName); //Deep Copy prevents altering of input types resultFieldTypes.add(nestedType.deepCopy(nestedType)); } else { resultFieldTypes.add(inputRecordType.getFieldType(fieldName)); } }
curFieldType = curRecType.getFieldType(attrName);
private static boolean generalizeRecordFields(ARecordType leftType, ARecordType rightType, Set<String> allPossibleAdditionalFieldNames, List<String> fieldNames, List<IAType> fieldTypes) { boolean allMatched = true; Set<String> existingFieldNames = new HashSet<>(fieldNames); for (String fieldName : leftType.getFieldNames()) { IAType leftFieldType = leftType.getFieldType(fieldName); IAType rightFieldType = rightType.getFieldType(fieldName); IAType generalizedFieldType = rightFieldType == null ? null : generalizeTypes(leftFieldType, rightFieldType); if (generalizedFieldType == null || generalizedFieldType.equals(BuiltinType.ANY)) { allPossibleAdditionalFieldNames.add(fieldName); allMatched = false; } else if (!existingFieldNames.contains(fieldName)) { fieldNames.add(fieldName); fieldTypes.add(generalizedFieldType); } } return allMatched; }
} else { final IAType fieldType = recordType.getFieldType(fieldName);
@Override protected IAType getResultType(ILogicalExpression expr, IAType... strippedInputTypes) throws AlgebricksException { IAType firstArgType = strippedInputTypes[0]; if (firstArgType.getTypeTag() != ATypeTag.OBJECT) { return BuiltinType.ANY; } AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr; String fieldName = ConstantExpressionUtil.getStringArgument(funcExpr, 1); if (fieldName == null) { return BuiltinType.ANY; } ARecordType recType = (ARecordType) firstArgType; IAType fieldType = recType.getFieldType(fieldName); return fieldType == null ? BuiltinType.ANY : fieldType; } }
/** * @param subFieldName * The full pathname of the child * @return the type of the child * @throws AsterixException */ public IAType getSubFieldType(List<String> subFieldName) throws AlgebricksException { IAType subRecordType = getFieldType(subFieldName.get(0)); for (int i = 1; i < subFieldName.size(); i++) { if (subRecordType == null) { return null; } if (subRecordType.getTypeTag().equals(ATypeTag.UNION)) { //enforced SubType subRecordType = ((AUnionType) subRecordType).getActualType(); if (subRecordType.getTypeTag() != ATypeTag.OBJECT) { throw new AsterixException( "Field accessor is not defined for values of type " + subRecordType.getTypeTag()); } } subRecordType = ((ARecordType) subRecordType).getFieldType(subFieldName.get(i)); } return subRecordType; }
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; }
IAType subRecordType = getFieldType(subFieldName.get(0)); for (int i = 1; i < subFieldName.size(); i++) { if (subRecordType == null) { "Illegal field type " + subRecordType.getTypeTag() + " when checking field nullability"); subRecordType = ((ARecordType) subRecordType).getFieldType(subFieldName.get(i));
upsertOp.setPrevFilterVar(context.newVar()); upsertOp.setPrevFilterType( ((ARecordType) targetDatasource.getItemType()).getFieldType(additionalFilteringField.get(0))); additionalFilteringAssign.getInputs().clear(); additionalFilteringAssign.getInputs().add(assign.getInputs().get(0)); if (additionalFilteringField != null) { upsertOp.setPrevFilterVar(context.newVar()); upsertOp.setPrevFilterType(recordType.getFieldType(additionalFilteringField.get(0)));
if (fieldExpr.first.size() > 1 && !isOpen) { while (i < fieldExpr.first.size() - 1 && !isOpen) { subType = (ARecordType) subType.getFieldType(fieldExpr.first.get(i)); i++; isOpen = subType.isOpen();
String fieldName = probeRecordType.getFieldNames()[j]; if (tmpValFieldName.contains(fieldName)) { tmpValFieldType = probeRecordType.getFieldType(fieldName); break;