/// <summary> /// Given an index with a defined set of hash(equals) and range(btree) props and uniqueness flag, /// and given a list of indexable properties and accessors for both hash and range, /// return the ordered keys and coercion information. /// </summary> /// <param name="indexMultiKey">index definition</param> /// <param name="hashIndexPropsProvided">hash indexable properties</param> /// <param name="hashJoinedProps">keys for hash indexable properties</param> /// <param name="rangeIndexPropsProvided">btree indexable properties</param> /// <param name="rangeJoinedProps">keys for btree indexable properties</param> /// <returns>ordered set of key information</returns> public static IndexKeyInfo CompileIndexKeyInfo( IndexMultiKey indexMultiKey, string[] hashIndexPropsProvided, SubordPropHashKey[] hashJoinedProps, string[] rangeIndexPropsProvided, SubordPropRangeKey[] rangeJoinedProps) { // map the order of indexed columns (key) to the key information available var indexedKeyProps = indexMultiKey.HashIndexedProps; var isCoerceHash = false; var hashesDesc = new SubordPropHashKey[indexedKeyProps.Length]; var hashPropCoercionTypes = new Type[indexedKeyProps.Length]; for (var i = 0; i < indexedKeyProps.Length; i++) { var indexField = indexedKeyProps[i].IndexPropName; var index = CollectionUtil.FindItem(hashIndexPropsProvided, indexField); if (index == -1) { throw new IllegalStateException("Could not find index property for lookup '" + indexedKeyProps[i]); } hashesDesc[i] = hashJoinedProps[index]; hashPropCoercionTypes[i] = indexedKeyProps[i].CoercionType; var evaluatorHashkey = hashesDesc[i].HashKey.KeyExpr.ExprEvaluator; if (evaluatorHashkey != null && TypeHelper.GetBoxedType(indexedKeyProps[i].CoercionType) != TypeHelper.GetBoxedType(evaluatorHashkey.ReturnType)) // we allow null evaluator { isCoerceHash = true; } } // map the order of range columns (range) to the range information available indexedKeyProps = indexMultiKey.RangeIndexedProps; var rangesDesc = new SubordPropRangeKey[indexedKeyProps.Length]; var rangePropCoercionTypes = new Type[indexedKeyProps.Length]; var isCoerceRange = false; for (var i = 0; i < indexedKeyProps.Length; i++) { var indexField = indexedKeyProps[i].IndexPropName; var index = CollectionUtil.FindItem(rangeIndexPropsProvided, indexField); if (index == -1) { throw new IllegalStateException("Could not find range property for lookup '" + indexedKeyProps[i]); } rangesDesc[i] = rangeJoinedProps[index]; rangePropCoercionTypes[i] = rangeJoinedProps[index].CoercionType; if (TypeHelper.GetBoxedType(indexedKeyProps[i].CoercionType) != TypeHelper.GetBoxedType(rangePropCoercionTypes[i])) { isCoerceRange = true; } } return(new IndexKeyInfo(hashesDesc, new CoercionDesc(isCoerceHash, hashPropCoercionTypes), rangesDesc, new CoercionDesc(isCoerceRange, rangePropCoercionTypes))); }
private static SubordinateQueryPlannerIndexPropDesc GetIndexPropDesc(IDictionary <String, SubordPropHashKey> hashProps, IDictionary <String, SubordPropRangeKey> rangeProps) { // hash property names and types var hashIndexPropsProvided = new string[hashProps.Count]; var hashIndexCoercionType = new Type[hashProps.Count]; var hashJoinedProps = new SubordPropHashKey[hashProps.Count]; var count = 0; foreach (var entry in hashProps) { hashIndexPropsProvided[count] = entry.Key; hashIndexCoercionType[count] = entry.Value.CoercionType; hashJoinedProps[count++] = entry.Value; } // range property names and types var rangeIndexPropsProvided = new string[rangeProps.Count]; var rangeIndexCoercionType = new Type[rangeProps.Count]; var rangeJoinedProps = new SubordPropRangeKey[rangeProps.Count]; count = 0; foreach (var entry in rangeProps) { rangeIndexPropsProvided[count] = entry.Key; rangeIndexCoercionType[count] = entry.Value.CoercionType; rangeJoinedProps[count++] = entry.Value; } // Add all joined fields to an array for sorting var listPair = SubordinateQueryPlannerUtil.ToListOfHashedAndBtreeProps(hashIndexPropsProvided, hashIndexCoercionType, rangeIndexPropsProvided, rangeIndexCoercionType); return(new SubordinateQueryPlannerIndexPropDesc(hashIndexPropsProvided, hashIndexCoercionType, rangeIndexPropsProvided, rangeIndexCoercionType, listPair, hashJoinedProps, rangeJoinedProps)); }
public SubordSortedTableLookupStrategyFactory(bool isNWOnTrigger, int numStreams, SubordPropRangeKey rangeKey) { _rangeKey = rangeKey; _strategy = SortedAccessStrategyFactory.Make(isNWOnTrigger, -1, numStreams, rangeKey); _strategyDesc = new LookupStrategyDesc(LookupStrategyType.RANGE, ExprNodeUtility.ToExpressionStringsMinPrecedence(rangeKey.RangeInfo.Expressions)); }
public String ToQueryPlan() { return(GetType().FullName + " ranges=" + SubordPropRangeKey.ToQueryPlan(_rangeDescs)); }