/** * Get the types of RTree index key fields * * @param index, * the index to consider. * @param recordType, * the main record type. * @param metaRecordType * the auxiliary meta record type. * @return a list of IATypes, one for each corresponding index key field. * @throws AlgebricksException */ public static List<IAType> getRTreeIndexKeyTypes(Index index, ARecordType recordType, ARecordType metaRecordType) throws AlgebricksException { List<Integer> keySourceIndicators = index.getKeyFieldSourceIndicators(); List<IAType> indexKeyTypes = new ArrayList<>(); ARecordType targetRecType = chooseSource(keySourceIndicators, 0, recordType, metaRecordType); Pair<IAType, Boolean> keyPairType = Index.getNonNullableOpenFieldType(index.getKeyFieldTypes().get(0), index.getKeyFieldNames().get(0), targetRecType); IAType keyType = keyPairType.first; IAType nestedKeyType = NonTaggedFormatUtil.getNestedSpatialType(keyType.getTypeTag()); int numKeys = KeyFieldTypeUtil.getNumSecondaryKeys(index, targetRecType, metaRecordType); for (int i = 0; i < numKeys; i++) { indexKeyTypes.add(nestedKeyType); } return indexKeyTypes; }
/** * Get the types of primary key (partitioning key) fields * * @param datasetDetails, * contains specific data structures for an internal dataset. * @param recordType, * the main record type. * @param metaRecordType * the auxiliary meta record type. * @return a list of IATypes, one for each corresponding primary key field. * @throws AlgebricksException */ public static List<IAType> getPartitioningKeyTypes(InternalDatasetDetails datasetDetails, ARecordType recordType, ARecordType metaRecordType) throws AlgebricksException { List<Integer> keySourceIndicators = datasetDetails.getKeySourceIndicator(); List<List<String>> partitioningKeys = datasetDetails.getPartitioningKey(); return getKeyTypes(recordType, metaRecordType, partitioningKeys, keySourceIndicators); }
switch (index.getIndexType()) { case BTREE: dest.addAll(KeyFieldTypeUtil.getBTreeIndexKeyTypes(index, recordType, metaRecordType)); break; case RTREE: dest.addAll(KeyFieldTypeUtil.getRTreeIndexKeyTypes(index, recordType, metaRecordType)); break; default: dest.addAll(KeyFieldTypeUtil.getPartitoningKeyTypes(dataset, recordType, metaRecordType));
/** * 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; }
KeyFieldTypeUtil.getKeyTypes(recType, metaRecType, partitioningExprs, keySourceIndicators); for (int i = 0; i < partitioningExprs.size(); i++) { List<String> partitioningExpr = partitioningExprs.get(i); RecordUtil.toFullyQualifiedName(partitioningExpr)); boolean nullable = KeyFieldTypeUtil.chooseSource(keySourceIndicators, i, recType, metaRecType) .isSubFieldNullable(partitioningExpr); if (nullable) {
/** * Creates output variables for the given unnest-map or left-outer-unnestmap operator * that does a secondary index lookup. * The order: SK, PK, [Optional: the result of a instantTryLock on PK] */ public static void appendSecondaryIndexOutputVars(Dataset dataset, ARecordType recordType, ARecordType metaRecordType, Index index, IOptimizationContext context, List<LogicalVariable> dest, boolean requireResultOfInstantTryLock) throws AlgebricksException { int numPrimaryKeys; if (dataset.getDatasetType() == DatasetType.EXTERNAL) { numPrimaryKeys = IndexingConstants .getRIDSize(((ExternalDatasetDetails) dataset.getDatasetDetails()).getProperties()); } else { numPrimaryKeys = dataset.getPrimaryKeys().size(); } int numSecondaryKeys = KeyFieldTypeUtil.getNumSecondaryKeys(index, recordType, metaRecordType); // In case of an inverted-index search, secondary keys will not be generated. int numVars = isInvertedIndex(index) ? numPrimaryKeys : numPrimaryKeys + numSecondaryKeys; // If it's an index-only plan, add one more variable to put the result of instantTryLock on PK - // whether this lock can be granted on a primary key. // If it is granted, then we don't need to do a post verification (select). // If it is not granted, then we need to do a secondary index lookup, do a primary index lookup, and select. if (requireResultOfInstantTryLock) { numVars += 1; } for (int i = 0; i < numVars; i++) { dest.add(context.newVar()); } }
private void initInternalDataset(IAType itemType, IAType metaItemType, IDatasetDetails datasetDetails) throws AlgebricksException { InternalDatasetDetails internalDatasetDetails = (InternalDatasetDetails) datasetDetails; ARecordType recordType = (ARecordType) itemType; ARecordType metaRecordType = (ARecordType) metaItemType; List<IAType> partitioningKeyTypes = KeyFieldTypeUtil.getPartitioningKeyTypes(internalDatasetDetails, recordType, metaRecordType); int n = partitioningKeyTypes.size(); schemaTypes = metaItemType == null ? new IAType[n + 1] : new IAType[n + 2]; for (int keyIndex = 0; keyIndex < n; ++keyIndex) { schemaTypes[keyIndex] = partitioningKeyTypes.get(keyIndex); } schemaTypes[n] = itemType; if (metaItemType != null) { schemaTypes[n + 1] = metaItemType; } }
public static void appendPrimaryIndexTypes(Dataset dataset, IAType itemType, IAType metaItemType, List<Object> target) throws AlgebricksException { ARecordType recordType = (ARecordType) itemType; ARecordType metaRecordType = (ARecordType) metaItemType; target.addAll(KeyFieldTypeUtil.getPartitoningKeyTypes(dataset, recordType, metaRecordType)); // Adds data record type. target.add(itemType); // Adds meta record type if any. if (dataset.hasMetaPart()) { target.add(metaItemType); } }
/** * Get the types of BTree index key fields * * @param index, * the index to consider. * @param recordType, * the main record type. * @param metaRecordType * the auxiliary meta record type. * @return a list of IATypes, one for each corresponding index key field. * @throws AlgebricksException */ public static List<IAType> getBTreeIndexKeyTypes(Index index, ARecordType recordType, ARecordType metaRecordType) throws AlgebricksException { List<Integer> keySourceIndicators = index.getKeyFieldSourceIndicators(); List<IAType> indexKeyTypes = new ArrayList<>(); for (int i = 0; i < index.getKeyFieldNames().size(); i++) { Pair<IAType, Boolean> keyPairType = Index.getNonNullableOpenFieldType(index.getKeyFieldTypes().get(i), index.getKeyFieldNames().get(i), chooseSource(keySourceIndicators, i, recordType, metaRecordType)); indexKeyTypes.add(keyPairType.first); } return indexKeyTypes; }
SecondaryUnnestMapOutputVarType keyVarType) throws AlgebricksException { int numPrimaryKeys; int numSecondaryKeys = KeyFieldTypeUtil.getNumSecondaryKeys(index, recordType, metaRecordType); if (dataset.getDatasetType() == DatasetType.EXTERNAL) { numPrimaryKeys = IndexingConstants
/** * Get the types of primary key (partitioning key) fields * * @param dataset, * the dataset to consider. * @param recordType, * the main record type. * @param metaRecordType * the auxiliary meta record type. * @return a list of IATypes, one for each corresponding primary key field. * @throws AlgebricksException */ public static List<IAType> getPartitoningKeyTypes(Dataset dataset, ARecordType recordType, ARecordType metaRecordType) throws AlgebricksException { if (dataset.getDatasetType() != DatasetType.INTERNAL) { return null; } InternalDatasetDetails datasetDetails = (InternalDatasetDetails) dataset.getDatasetDetails(); return getPartitioningKeyTypes(datasetDetails, recordType, metaRecordType); }
Pair<IAType, Boolean> keyPairType = Index.getNonNullableOpenFieldType(index.getKeyFieldTypes().get(0), index.getKeyFieldNames().get(0), chooseSource(keySourceIndicators, 0, recordType, metaRecordType)); IAType keyType = keyPairType.first; return NonTaggedFormatUtil.getNumDimensions(keyType.getTypeTag()) * 2;
.getDatatype(); searchKeyType = KeyFieldTypeUtil.getKeyTypes(recordDt, metaDt, searchKey, keyFieldSourceIndicator); } catch (RemoteException re) { throw HyracksDataException.create(re);
.findType(dataset.getMetaItemTypeDataverseName(), dataset.getMetaItemTypeName()); ARecordType metaRecType = (ARecordType) metaItemType; int numSecondaryKeys = KeyFieldTypeUtil.getNumSecondaryKeys(index, recType, metaRecType); List<String> fieldName; if (varIndex >= numSecondaryKeys) {
IAType fieldType = null; ARecordType subType = KeyFieldTypeUtil.chooseSource(keySourceIndicators, keyIndex, aRecordType, metaRecordType); boolean isOpen = subType.isOpen(); int i = 0;
throws AlgebricksException { List<IAType> fieldTypes = KeyFieldTypeUtil.getKeyTypes(recType, metaRecType, keyFieldNames, keySourceIndicators); int pos = 0; boolean openFieldCompositeIdx = false;