public String listToString(AOrderedList list) { StringBuilder sb = new StringBuilder(); boolean first = true; IAObject val; sb.append("[ "); for (int i = 0; i < list.size(); i++) { if (first) { first = false; } else { sb.append(", "); } val = list.getItem(i); if (val instanceof ARecord) { sb.append(recordToString((ARecord) val)); } else if (val instanceof AOrderedList) { sb.append(listToString((AOrderedList) val)); } else { sb.append(val); } } sb.append(" ]"); return sb.toString(); } }
private static AOrderedList stringListToAOrderedList(List<String> fields) { AOrderedList fieldList = new AOrderedList(new AOrderedListType(BuiltinType.ASTRING, null)); for (int i = 0; i < fields.size(); i++) { fieldList.add(new AString(fields.get(i))); } return fieldList; }
.booleanValue(); int numberOfFields = ((AOrderedList) recordType .getValueByPos(MetadataRecordTypes.RECORDTYPE_ARECORD_FIELDS_FIELD_INDEX)).size(); IACursor cursor = ((AOrderedList) recordType .getValueByPos(MetadataRecordTypes.RECORDTYPE_ARECORD_FIELDS_FIELD_INDEX)).getCursor(); String[] fieldNames = new String[numberOfFields]; IAType[] fieldTypes = new IAType[numberOfFields];
return new AOrderedList(type, items); } catch (IOException e) { throw HyracksDataException.create(e);
ArrayBackedValueStorage abvs = new ArrayBackedValueStorage(); DataOutput dos = abvs.getDataOutput(); AOrderedList as = new AOrderedList(fldName); try { SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(as.getType()).serialize(as, dos); } catch (HyracksDataException e) { throw new AlgebricksException(e);
@Override public boolean deepEqual(IAObject obj) { return equals(obj); }
public static void prepareMetaKeyAccessExpression(List<String> field, LogicalVariable resVar, List<Mutable<ILogicalExpression>> assignExpressions, List<LogicalVariable> vars, List<Mutable<ILogicalExpression>> varRefs, IVariableContext context, SourceLocation sourceLoc) { IAObject value = (field.size() > 1) ? new AOrderedList(field) : new AString(field.get(0)); ScalarFunctionCallExpression metaKeyFunction = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.META_KEY)); metaKeyFunction.setSourceLocation(sourceLoc); VariableReferenceExpression resVarRef = new VariableReferenceExpression(resVar); resVarRef.setSourceLocation(sourceLoc); metaKeyFunction.getArguments().add(new MutableObject<ILogicalExpression>(resVarRef)); metaKeyFunction.getArguments() .add(new MutableObject<>(new ConstantExpression(new AsterixConstantValue(value)))); assignExpressions.add(new MutableObject<ILogicalExpression>(metaKeyFunction)); LogicalVariable v = context.newVar(); vars.add(v); if (varRefs != null) { VariableReferenceExpression vRef = new VariableReferenceExpression(v); vRef.setSourceLocation(sourceLoc); varRefs.add(new MutableObject<ILogicalExpression>(vRef)); } }
private boolean setFieldNameSet(ILogicalExpression expr, Set<String> fieldNameSet) { if (expr.getExpressionTag() == LogicalExpressionTag.CONSTANT) { AOrderedList orderedList = (AOrderedList) (((AsterixConstantValue) ((ConstantExpression) expr).getValue()).getObject()); for (int i = 0; i < orderedList.size(); i++) { AString as = (AString) orderedList.getItem(i); fieldNameSet.add(as.getStringValue()); } return true; // Success } return false; }
@Override public int hashCode() { return InMemUtils.hashCursor(getCursor()); }
AOrderedList list = new AOrderedList(new AOrderedListType(valType, "orderedlist")); for (AsterixConstantValue value : values) { list.add(value.getObject());
private static ScalarFunctionCallExpression createFieldAccessExpression(ILogicalExpression target, List<String> field, SourceLocation sourceLoc) { FunctionIdentifier functionIdentifier; IAObject value; if (field.size() > 1) { functionIdentifier = BuiltinFunctions.FIELD_ACCESS_NESTED; value = new AOrderedList(field); } else { functionIdentifier = BuiltinFunctions.FIELD_ACCESS_BY_NAME; value = new AString(field.get(0)); } IFunctionInfo finfoAccess = FunctionUtil.getFunctionInfo(functionIdentifier); ScalarFunctionCallExpression faExpr = new ScalarFunctionCallExpression(finfoAccess, new MutableObject<>(target), new MutableObject<>(new ConstantExpression(new AsterixConstantValue(value)))); faExpr.setSourceLocation(sourceLoc); return faExpr; } }
private void getPathFromConstantExpression(String funcName, ILogicalExpression expression, Set<String> fieldNameSet, List<List<String>> pathList, SourceLocation sourceLoc) throws AlgebricksException { ConstantExpression ce = (ConstantExpression) expression; if (!(ce.getValue() instanceof AsterixConstantValue)) { throw new InvalidExpressionException(sourceLoc, funcName, 1, ce, LogicalExpressionTag.CONSTANT); } IAObject item = ((AsterixConstantValue) ce.getValue()).getObject(); ATypeTag type = item.getType().getTypeTag(); switch (type) { case STRING: String fn = ((AString) item).getStringValue(); fieldNameSet.add(fn); break; case ARRAY: AOrderedList pathOrdereList = (AOrderedList) item; String fieldName = ((AString) pathOrdereList.getItem(0)).getStringValue(); fieldNameSet.add(fieldName); List<String> path = new ArrayList<>(); for (int i = 0; i < pathOrdereList.size(); i++) { path.add(((AString) pathOrdereList.getItem(i)).getStringValue()); } pathList.add(path); break; default: throw new UnsupportedTypeException(sourceLoc, funcName, type); } }
private static String aOrderedListToString(AOrderedList ol) throws AlgebricksException { StringBuilder delimitedList = new StringBuilder(); IACursor cursor = ol.getCursor(); if (cursor.next()) { IAObject next = cursor.get(); delimitedList.append(aObjToString(next)); } while (cursor.next()) { IAObject next = cursor.get(); delimitedList.append(","); delimitedList.append(aObjToString(next)); } return delimitedList.toString(); } }
@SuppressWarnings("unchecked") @Override public void serialize(AOrderedList instance, DataOutput out) throws HyracksDataException { // TODO: schemaless ordered list serializer OrderedListBuilder listBuilder = new OrderedListBuilder(); listBuilder.reset(orderedlistType); ArrayBackedValueStorage itemValue = new ArrayBackedValueStorage(); for (int i = 0; i < instance.size(); i++) { itemValue.reset(); serializer.serialize(instance.getItem(i), itemValue.getDataOutput()); listBuilder.addItem(itemValue); } listBuilder.write(out, false); }
.getValueByPos(MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_PARAM_LIST_FIELD_INDEX)).getCursor(); List<String> params = new ArrayList<>(); while (cursor.next()) { .getValueByPos(MetadataRecordTypes.FUNCTION_ARECORD_FUNCTION_DEPENDENCIES_FIELD_INDEX)).getCursor(); List<List<List<String>>> dependencies = new ArrayList<>(); AOrderedList dependencyList; dependencies.add(new ArrayList<>()); dependencyList = (AOrderedList) dependenciesCursor.get(); IACursor qualifiedDependencyCursor = dependencyList.getCursor(); int j = 0; while (qualifiedDependencyCursor.next()) { qualifiedList = (AOrderedList) qualifiedDependencyCursor.get(); IACursor qualifiedNameCursor = qualifiedList.getCursor(); dependencies.get(i).add(new ArrayList<>()); while (qualifiedNameCursor.next()) {
@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; ILogicalExpression arg1 = funcExpr.getArguments().get(1).getValue(); if (arg1.getExpressionTag() != LogicalExpressionTag.CONSTANT) { return BuiltinType.ANY; } ConstantExpression ce = (ConstantExpression) arg1; IAObject v = ((AsterixConstantValue) ce.getValue()).getObject(); List<String> fieldPath = new ArrayList<>(); if (v.getType().getTypeTag() == ATypeTag.ARRAY) { for (int i = 0; i < ((AOrderedList) v).size(); i++) { fieldPath.add(((AString) ((AOrderedList) v).getItem(i)).getStringValue()); } } else { fieldPath.add(((AString) v).getStringValue()); } ARecordType recType = (ARecordType) firstArgType; IAType fieldType = recType.getSubFieldType(fieldPath); return fieldType == null ? BuiltinType.ANY : fieldType; } }
.getStringValue()); IACursor fieldNameCursor = ((AOrderedList) rec.getValueByPos(MetadataRecordTypes.INDEX_ARECORD_SEARCHKEY_FIELD_INDEX)).getCursor(); List<List<String>> searchKey = new ArrayList<>(); AOrderedList fieldNameList; while (fieldNameCursor.next()) { fieldNameList = (AOrderedList) fieldNameCursor.get(); IACursor nestedFieldNameCursor = (fieldNameList.getCursor()); List<String> nestedFieldName = new ArrayList<>(); while (nestedFieldNameCursor.next()) { IACursor fieldTypeCursor = new ACollectionCursor(); if (indexKeyTypeFieldPos > 0) { fieldTypeCursor = ((AOrderedList) rec.getValueByPos(indexKeyTypeFieldPos)).getCursor(); int keyFieldSourceIndicatorIndex = rec.getType().getFieldIndex(INDEX_SEARCHKEY_SOURCE_INDICATOR_FIELD_NAME); if (keyFieldSourceIndicatorIndex >= 0) { IACursor cursor = ((AOrderedList) rec.getValueByPos(keyFieldSourceIndicatorIndex)).getCursor(); while (cursor.next()) { keyFieldSourceIndicator.add((int) ((AInt8) cursor.get()).getByteValue());
@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()); AOrderedList fieldPath = (AOrderedList) (((AsterixConstantValue) ((ConstantExpression) fce.getArguments().get(1).getValue()) .getValue()).getObject()); List<String> listFieldPath = new ArrayList<>(); for (int i = 0; i < fieldPath.size(); i++) { listFieldPath.add(((AString) fieldPath.getItem(i)).getStringValue()); } switch (t.getTypeTag()) { case OBJECT: { fd.setImmutableStates(t, listFieldPath); break; } case ANY: fd.setImmutableStates(RecordUtil.FULLY_OPEN_RECORD_TYPE, listFieldPath); break; default: { throw new NotImplementedException("field-access-nested for data of type " + t); } } } }
IACursor cursor = ((AOrderedList) datasetRecord .getValueByPos(MetadataRecordTypes.DATASET_ARECORD_COMPACTION_POLICY_PROPERTIES_FIELD_INDEX)) .getCursor(); Map<String, String> compactionPolicyProperties = new LinkedHashMap<>(); String key; cursor = ((AOrderedList) datasetDetailsRecord .getValueByPos(MetadataRecordTypes.INTERNAL_DETAILS_ARECORD_PARTITIONKEY_FIELD_INDEX)) .getCursor(); List<List<String>> partitioningKey = new ArrayList<>(); List<IAType> partitioningKeyType = new ArrayList<>(); while (cursor.next()) { fieldNameList = (AOrderedList) cursor.get(); IACursor nestedFieldNameCursor = (fieldNameList.getCursor()); List<String> nestedFieldName = new ArrayList<>(); while (nestedFieldNameCursor.next()) { if (filterFieldPos >= 0) { filterField = new ArrayList<>(); cursor = ((AOrderedList) datasetDetailsRecord.getValueByPos(filterFieldPos)).getCursor(); while (cursor.next()) { filterField.add(((AString) cursor.get()).getStringValue()); if (keyFieldSourceIndicatorIndex >= 0) { cursor = ((AOrderedList) datasetDetailsRecord.getValueByPos(keyFieldSourceIndicatorIndex)) .getCursor(); while (cursor.next()) { keyFieldSourceIndicator.add((int) ((AInt8) cursor.get()).getByteValue());