Beispiel #1
0
 public AggregationStateFactoryCountMinSketch MakeCountMinSketch(
     StatementExtensionSvcContext statementExtensionSvcContext,
     ExprAggCountMinSketchNode expr,
     CountMinSketchSpec specification)
 {
     return(new AggregationStateFactoryCountMinSketch(expr, specification));
 }
Beispiel #2
0
 /// <summary>
 ///     NOTE: Code-generation-invoked method, method name and parameter order matters
 /// </summary>
 /// <param name="input">in</param>
 /// <param name="spec">spec</param>
 /// <returns>state</returns>
 /// <throws>IOException when there is a read exception</throws>
 public static CountMinSketchAggState ReadCountMinSketch(
     DataInput input,
     CountMinSketchSpec spec)
 {
     var state = spec.MakeAggState();
     ReadState(input, state.State);
     return state;
 }
Beispiel #3
0
        private CountMinSketchSpec ValidateSpecification(ExprValidationContext exprValidationContext)
        {
            // default specification
            var spec = new CountMinSketchSpec(new CountMinSketchSpecHashes(DEFAULT_EPS_OF_TOTAL_COUNT, DEFAULT_CONFIDENCE, DEFAULT_SEED), null, DEFAULT_AGENT);

            // no parameters
            if (ChildNodes.Count == 0)
            {
                return(spec);
            }

            // check expected parameter type: a json object
            if (ChildNodes.Count > 1 || !(ChildNodes[0] is ExprConstantNode))
            {
                throw DeclaredWrongParameterExpr;
            }
            var constantNode = (ExprConstantNode)ChildNodes[0];
            var value        = constantNode.GetConstantValue(exprValidationContext.ExprEvaluatorContext);

            if (!(value is IDictionary <string, object>))
            {
                throw DeclaredWrongParameterExpr;
            }

            // define what to populate
            var descriptors = new PopulateFieldWValueDescriptor[] {
                new PopulateFieldWValueDescriptor(NAME_EPS_OF_TOTAL_COUNT, typeof(double), spec.HashesSpec.GetType(), vv => {
                    if (vv != null)
                    {
                        spec.HashesSpec.EpsOfTotalCount = (double)vv;
                    }
                }, true),
                new PopulateFieldWValueDescriptor(NAME_CONFIDENCE, typeof(double), spec.HashesSpec.GetType(), vv => {
                    if (vv != null)
                    {
                        spec.HashesSpec.Confidence = (double)vv;
                    }
                }, true),
                new PopulateFieldWValueDescriptor(NAME_SEED, typeof(int), spec.HashesSpec.GetType(), vv => {
                    if (vv != null)
                    {
                        spec.HashesSpec.Seed = (int)vv;
                    }
                }, true),
                new PopulateFieldWValueDescriptor(NAME_TOPK, typeof(int), spec.GetType(), vv => {
                    if (vv != null)
                    {
                        spec.TopkSpec = (int)vv;
                    }
                }, true),
                new PopulateFieldWValueDescriptor(NAME_AGENT, typeof(string), spec.GetType(), vv => {
                    if (vv != null)
                    {
                        CountMinSketchAgent transform;
                        try {
                            var transformClass = exprValidationContext.EngineImportService.ResolveType((string)vv, false);
                            transform          = TypeHelper.Instantiate <CountMinSketchAgent>(transformClass);
                        }
                        catch (Exception e) {
                            throw new ExprValidationException("Failed to instantiate agent provider: " + e.Message, e);
                        }
                        spec.Agent = transform;
                    }
                }, true)
            };

            // populate from json, validates incorrect names, coerces types, instantiates transform
            PopulateUtil.PopulateSpecCheckParameters(descriptors, (IDictionary <String, object>)value, spec, ExprNodeOrigin.AGGPARAM, exprValidationContext);

            return(spec);
        }
 public AggregationState MakeCountMinSketch(int agentInstanceId, int groupId, int aggregationId, CountMinSketchSpec specification)
 {
     return(new CountMinSketchAggState(CountMinSketchState.MakeState(specification), specification.Agent));
 }
 public AggregationStateFactoryCountMinSketch(ExprAggCountMinSketchNode parent, CountMinSketchSpec specification)
 {
     Parent        = parent;
     Specification = specification;
 }