Beispiel #1
0
        /// <summary>
        ///     Check if the hint is present in the attributes provided.
        /// </summary>
        /// <param name="enum">The @enum.</param>
        /// <param name="attributes">the attributes to inspect</param>
        /// <returns>indicator</returns>
        public static HintAttribute GetHint(
            this HintEnum @enum,
            IEnumerable <Attribute> attributes)
        {
            if (attributes == null)
            {
                return(null);
            }

            foreach (var hintAnnotation in attributes.OfType <HintAttribute>())
            {
                try {
                    var setOfHints = ValidateGetListed(hintAnnotation);
                    if (setOfHints.ContainsKey(@enum))
                    {
                        return(hintAnnotation);
                    }
                }
                catch (AnnotationException e) {
                    throw new EPException("Invalid hint: " + e.Message, e);
                }
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        ///     Returns all values assigned for a given hint, if any
        /// </summary>
        /// <param name="hintEnum">The hint enum.</param>
        /// <param name="annotations">the to be interogated</param>
        /// <returns>
        ///     hint assigned values or null if none found
        /// </returns>
        public static IList <string> GetHintAssignedValues(
            this HintEnum hintEnum,
            IEnumerable <Attribute> annotations)
        {
            IList <string> allHints = null;

            try {
                foreach (var annotation in annotations)
                {
                    var hintValues = ValidateGetListed(annotation);
                    if (hintValues == null || !hintValues.ContainsKey(hintEnum))
                    {
                        continue;
                    }

                    if (allHints == null)
                    {
                        allHints = hintValues.Get(hintEnum);
                    }
                    else
                    {
                        allHints.AddAll(hintValues.Get(hintEnum));
                    }
                }
            }
            catch (AnnotationException ex) {
                throw new EPException("Failed to interpret hint annotation: " + ex.Message, ex);
            }

            return(allHints);
        }
Beispiel #3
0
        /// <summary>True if the hint requires params. </summary>
        /// <returns>indicator</returns>
        public static bool IsRequiresParameters(this HintEnum @enum)
        {
            if (IsAcceptsParameters(@enum))
            {
                return(true);
            }

            switch (@enum)
            {
            case HintEnum.ITERATE_ONLY:
                return(false);

            case HintEnum.DISABLE_RECLAIM_GROUP:
                return(false);

            case HintEnum.RECLAIM_GROUP_AGED:
                return(true);

            case HintEnum.RECLAIM_GROUP_FREQ:
                return(true);

            case HintEnum.ENABLE_WINDOW_SUBQUERY_INDEXSHARE:
                return(false);

            case HintEnum.DISABLE_WINDOW_SUBQUERY_INDEXSHARE:
                return(false);

            case HintEnum.SET_NOINDEX:
                return(false);

            case HintEnum.FORCE_NESTED_ITER:
                return(false);

            case HintEnum.PREFER_MERGE_JOIN:
                return(false);

            case HintEnum.INDEX:
                return(false);

            case HintEnum.EXCLUDE_PLAN:
                return(false);

            case HintEnum.DISABLE_UNIQUE_IMPLICIT_IDX:
                return(false);

            case HintEnum.MAX_FILTER_WIDTH:
                return(true);

            case HintEnum.DISABLE_WHEREEXPR_MOVETO_FILTER:
                return(false);

            case HintEnum.ENABLE_OUTPUTLIMIT_OPT:
                return(false);

            case HintEnum.DISABLE_OUTPUTLIMIT_OPT:
                return(false);
            }

            throw new ArgumentException();
        }
Beispiel #4
0
        /// <summary>Returns the constant. </summary>
        /// <returns>constant</returns>
        public static string GetValue(this HintEnum @enum)
        {
            switch (@enum)
            {
            case HintEnum.ITERATE_ONLY:
                return("ITERATE_ONLY");

            case HintEnum.DISABLE_RECLAIM_GROUP:
                return("DISABLE_RECLAIM_GROUP");

            case HintEnum.RECLAIM_GROUP_AGED:
                return("RECLAIM_GROUP_AGED");

            case HintEnum.RECLAIM_GROUP_FREQ:
                return("RECLAIM_GROUP_FREQ");

            case HintEnum.ENABLE_WINDOW_SUBQUERY_INDEXSHARE:
                return("ENABLE_WINDOW_SUBQUERY_INDEXSHARE");

            case HintEnum.DISABLE_WINDOW_SUBQUERY_INDEXSHARE:
                return("DISABLE_WINDOW_SUBQUERY_INDEXSHARE");

            case HintEnum.SET_NOINDEX:
                return("SET_NOINDEX");

            case HintEnum.FORCE_NESTED_ITER:
                return("FORCE_NESTED_ITER");

            case HintEnum.PREFER_MERGE_JOIN:
                return("PREFER_MERGE_JOIN");

            case HintEnum.INDEX:
                return("INDEX");

            case HintEnum.EXCLUDE_PLAN:
                return("EXCLUDE_PLAN");

            case HintEnum.DISABLE_UNIQUE_IMPLICIT_IDX:
                return("DISABLE_UNIQUE_IMPLICIT_IDX");

            case HintEnum.MAX_FILTER_WIDTH:
                return("MAX_FILTER_WIDTH");

            case HintEnum.DISABLE_WHEREEXPR_MOVETO_FILTER:
                return("DISABLE_WHEREEXPR_MOVETO_FILTER");

            case HintEnum.ENABLE_OUTPUTLIMIT_OPT:
                return("ENABLE_OUTPUTLIMIT_OPT");

            case HintEnum.DISABLE_OUTPUTLIMIT_OPT:
                return("DISABLE_OUTPUTLIMIT_OPT");
            }

            throw new ArgumentException();
        }
Beispiel #5
0
 /// <summary>
 /// Returns hint value.
 /// </summary>
 /// <param name="hintEnum">The hint enum.</param>
 /// <param name="annotation">The annotation to look for.</param>
 /// <returns>hint assigned first value provided</returns>
 public static string GetHintAssignedValue(this HintEnum hintEnum, HintAttribute annotation)
 {
     try
     {
         var hintValues = ValidateGetListed(annotation);
         if (hintValues == null || !hintValues.ContainsKey(hintEnum))
         {
             return(null);
         }
         return(hintValues.Get(hintEnum)[0]);
     }
     catch (AttributeException ex)
     {
         throw new EPException("Failed to interpret hint annotation: " + ex.Message, ex);
     }
 }
Beispiel #6
0
 private static void ValidateParameters(HintEnum val, String hintVal)
 {
     if (IsRequiresParameters(val))
     {
         if (hintVal.IndexOf('=') == -1)
         {
             throw new AttributeException("Hint '" + val + "' requires a parameter value");
         }
     }
     if (!IsAcceptsParameters(val))
     {
         if (hintVal.IndexOf('=') != -1)
         {
             throw new AttributeException("Hint '" + val + "' does not accept a parameter value");
         }
     }
 }
Beispiel #7
0
 public static bool HasHint(
     this HintEnum @enum,
     IEnumerable <Attribute> attributes)
 {
     return(GetHint(@enum, attributes) != null);
 }