private static IAType keyFieldType(List<String> expr, ARecordType recType) throws AlgebricksException { IAType fieldType = recType; fieldType = recType.getSubFieldType(expr); return fieldType; }
public List<IAType> getFieldTypes(List<List<String>> fields) throws AlgebricksException { List<IAType> typeList = new ArrayList<>(); for (List<String> field : fields) { typeList.add(getSubFieldType(field)); } return typeList; }
/** * Get the types of key fields for an index, either primary or secondary. * * @param recordType, * the main record type. * @param metaRecordType, * the auxiliary meta record type. * @param keys, * the list of key fields. * @param keySourceIndicators, * a list of integers to indicate that each key field is from the main record or the auxiliary meta * record. * @return a list of IATypes, one for each corresponding index key field. * @throws AlgebricksException */ public static List<IAType> getKeyTypes(ARecordType recordType, ARecordType metaRecordType, List<List<String>> keys, List<Integer> keySourceIndicators) throws AlgebricksException { List<IAType> keyTypes = new ArrayList<>(); int index = 0; for (List<String> partitioningKey : keys) { keyTypes.add(chooseSource(keySourceIndicators, index, recordType, metaRecordType) .getSubFieldType(partitioningKey)); ++index; } return keyTypes; }
public static IBinaryComparatorFactory[] computeFilterBinaryComparatorFactories(Dataset dataset, ARecordType itemType, IBinaryComparatorFactoryProvider comparatorFactoryProvider) throws AlgebricksException { if (dataset.getDatasetType() == DatasetType.EXTERNAL) { return null; } List<String> filterField = getFilterField(dataset); if (filterField == null) { return null; } IBinaryComparatorFactory[] bcfs = new IBinaryComparatorFactory[1]; IAType type = itemType.getSubFieldType(filterField); bcfs[0] = comparatorFactoryProvider.getBinaryComparatorFactory(type, true); return bcfs; }
public static ITypeTraits[] computeFilterTypeTraits(Dataset dataset, ARecordType itemType) throws AlgebricksException { if (dataset.getDatasetType() == DatasetType.EXTERNAL) { return null; } List<String> filterField = getFilterField(dataset); if (filterField == null) { return null; } ITypeTraits[] typeTraits = new ITypeTraits[1]; IAType type = itemType.getSubFieldType(filterField); typeTraits[0] = TypeTraitProvider.INSTANCE.getTypeTrait(type); return typeTraits; }
/** * Gets the comparator factories for the primary key fields of this dataset. * * @param metadataProvider, * the metadata provider. * @return the comparator factories for the primary key fields of this dataset. * @throws AlgebricksException */ public IBinaryComparatorFactory[] getPrimaryComparatorFactories(MetadataProvider metadataProvider, ARecordType recordType, ARecordType metaType) throws AlgebricksException { IStorageComponentProvider storageComponentProvider = metadataProvider.getStorageComponentProvider(); IBinaryComparatorFactoryProvider cmpFactoryProvider = storageComponentProvider.getComparatorFactoryProvider(); List<List<String>> partitioningKeys = getPrimaryKeys(); int numPrimaryKeys = partitioningKeys.size(); IBinaryComparatorFactory[] cmpFactories = new IBinaryComparatorFactory[numPrimaryKeys]; List<Integer> indicators = null; if (hasMetaPart()) { indicators = ((InternalDatasetDetails) getDatasetDetails()).getKeySourceIndicator(); } for (int i = 0; i < numPrimaryKeys; i++) { IAType keyType = (indicators == null || indicators.get(i) == 0) ? recordType.getSubFieldType(partitioningKeys.get(i)) : metaType.getSubFieldType(partitioningKeys.get(i)); cmpFactories[i] = cmpFactoryProvider.getBinaryComparatorFactory(keyType, true); } return cmpFactories; }
/** * Gets the hash function factories for the primary key fields of this dataset. * * @param metadataProvider, * the metadata provider. * @return the hash function factories for the primary key fields of this dataset. * @throws AlgebricksException */ public IBinaryHashFunctionFactory[] getPrimaryHashFunctionFactories(MetadataProvider metadataProvider) throws AlgebricksException { ARecordType recordType = (ARecordType) metadataProvider.findType(this); ARecordType metaType = (ARecordType) metadataProvider.findMetaType(this); List<List<String>> partitioningKeys = getPrimaryKeys(); int numPrimaryKeys = partitioningKeys.size(); IBinaryHashFunctionFactory[] hashFuncFactories = new IBinaryHashFunctionFactory[numPrimaryKeys]; List<Integer> indicators = null; if (hasMetaPart()) { indicators = ((InternalDatasetDetails) getDatasetDetails()).getKeySourceIndicator(); } for (int i = 0; i < numPrimaryKeys; i++) { IAType keyType = (indicators == null || indicators.get(i) == 0) ? recordType.getSubFieldType(partitioningKeys.get(i)) : metaType.getSubFieldType(partitioningKeys.get(i)); hashFuncFactories[i] = BinaryHashFunctionFactoryProvider.INSTANCE.getBinaryHashFunctionFactory(keyType); } return hashFuncFactories; }
private void setFilterTypeTraitsAndComparators() throws AlgebricksException { filterTypeTraits = new ITypeTraits[numFilterFields]; filterCmpFactories = new IBinaryComparatorFactory[numFilterFields]; secondaryFilterFields = new int[numFilterFields]; primaryFilterFields = new int[numFilterFields]; primaryBTreeFields = new int[numPrimaryKeys + 1]; secondaryBTreeFields = new int[index.getKeyFieldNames().size() + numPrimaryKeys]; for (int i = 0; i < primaryBTreeFields.length; i++) { primaryBTreeFields[i] = i; } for (int i = 0; i < secondaryBTreeFields.length; i++) { secondaryBTreeFields[i] = i; } IAType type = itemType.getSubFieldType(filterFieldName); filterCmpFactories[0] = BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(type, true); filterTypeTraits[0] = TypeTraitProvider.INSTANCE.getTypeTrait(type); secondaryFilterFields[0] = getNumSecondaryKeys() + numPrimaryKeys; primaryFilterFields[0] = numPrimaryKeys + 1; }
case INTERNAL: keyType = (hasMeta && primaryIndexKeyIndicators.get(j).intValue() == 1) ? metaType.getSubFieldType(pidxKeyFieldNames.get(j)) : recType.getSubFieldType(pidxKeyFieldNames.get(j)); break; case EXTERNAL:
public ITypeTraits[] getPrimaryTypeTraits(MetadataProvider metadataProvider, ARecordType recordType, ARecordType metaType) throws AlgebricksException { IStorageComponentProvider storageComponentProvider = metadataProvider.getStorageComponentProvider(); ITypeTraitProvider ttProvider = storageComponentProvider.getTypeTraitProvider(); List<List<String>> partitioningKeys = getPrimaryKeys(); int numPrimaryKeys = partitioningKeys.size(); ITypeTraits[] typeTraits = new ITypeTraits[numPrimaryKeys + 1 + (hasMetaPart() ? 1 : 0)]; List<Integer> indicators = null; if (hasMetaPart()) { indicators = ((InternalDatasetDetails) getDatasetDetails()).getKeySourceIndicator(); } for (int i = 0; i < numPrimaryKeys; i++) { IAType keyType = datasetType == DatasetType.EXTERNAL ? IndexingConstants.getFieldType(i) : (indicators == null || indicators.get(i) == 0) ? recordType.getSubFieldType(partitioningKeys.get(i)) : metaType.getSubFieldType(partitioningKeys.get(i)); typeTraits[i] = ttProvider.getTypeTrait(keyType); } typeTraits[numPrimaryKeys] = ttProvider.getTypeTrait(recordType); if (hasMetaPart()) { typeTraits[numPrimaryKeys + 1] = ttProvider.getTypeTrait(metaType); } return typeTraits; }
@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; } }
private void setPrimaryRecDescAndComparators() throws AlgebricksException { List<List<String>> partitioningKeys = dataset.getPrimaryKeys(); ISerializerDeserializer[] primaryRecFields = new ISerializerDeserializer[numPrimaryKeys + 1 + (dataset.hasMetaPart() ? 1 : 0)]; ITypeTraits[] primaryTypeTraits = new ITypeTraits[numPrimaryKeys + 1 + (dataset.hasMetaPart() ? 1 : 0)]; primaryComparatorFactories = new IBinaryComparatorFactory[numPrimaryKeys]; primaryBloomFilterKeyFields = new int[numPrimaryKeys]; ISerializerDeserializerProvider serdeProvider = metadataProvider.getDataFormat().getSerdeProvider(); List<Integer> indicators = null; if (dataset.hasMetaPart()) { indicators = ((InternalDatasetDetails) dataset.getDatasetDetails()).getKeySourceIndicator(); } for (int i = 0; i < numPrimaryKeys; i++) { IAType keyType = (indicators == null || indicators.get(i) == 0) ? itemType.getSubFieldType(partitioningKeys.get(i)) : metaType.getSubFieldType(partitioningKeys.get(i)); primaryRecFields[i] = serdeProvider.getSerializerDeserializer(keyType); primaryComparatorFactories[i] = BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(keyType, true); primaryTypeTraits[i] = TypeTraitProvider.INSTANCE.getTypeTrait(keyType); primaryBloomFilterKeyFields[i] = i; } primaryRecFields[numPrimaryKeys] = payloadSerde; primaryTypeTraits[numPrimaryKeys] = TypeTraitProvider.INSTANCE.getTypeTrait(itemType); if (dataset.hasMetaPart()) { primaryRecFields[numPrimaryKeys + 1] = payloadSerde; primaryTypeTraits[numPrimaryKeys + 1] = TypeTraitProvider.INSTANCE.getTypeTrait(metaType); } primaryRecDesc = new RecordDescriptor(primaryRecFields, primaryTypeTraits); }
IAType fieldType = recType.getSubFieldType(fieldName); if (fieldType == null) { String unTypeField = fieldName.get(0) == null ? "" : fieldName.get(0);
bridgeName = nestedFieldType.getTypeName(); subFieldName = splits.subList(0, j); nestedFieldType = ((ARecordType) enforcedRecordType).getSubFieldType(subFieldName); if (nestedFieldType == null) { openRecords = true;
(indicators == null || indicators.get(i) == 0) ? itemType.getSubFieldType(partitioningKeys.get(i)) : metaType.getSubFieldType(partitioningKeys.get(i)); primaryRecFields[i] = serdeProvider.getSerializerDeserializer(keyType); primaryTypeTraits[i] = TypeTraitProvider.INSTANCE.getTypeTrait(keyType);
IAType fieldType = sourceType.getSubFieldType(indexFieldId.fieldName); AbstractFunctionCallExpression theFieldAccessFunc; if (fieldType == null) {
IAType filterType = recType.getSubFieldType(filterFieldName);
IAType fieldType = recordType.getSubFieldType(filterField); if (fieldType == null) { throw new CompilationException(ErrorCode.COMPILATION_FIELD_NOT_FOUND, sourceLoc,
? recordType.getSubFieldType(primaryKeyFields.get(i)) : metaType.getSubFieldType(primaryKeyFields.get(i)); primaryComparatorFactories[i] = storageComponentProvider.getComparatorFactoryProvider() .getBinaryComparatorFactory(keyType, true);
new MutableObject<>(new ConstantExpression(new AsterixConstantValue(as)))); partitionFun.setSourceLocation(sourceLoc); return new Triple<>(evalFactory, partitionFun, recType.getSubFieldType(fldName));