Exemple #1
0
        internal override ScalarFunction CompileToFunction(QueryCompilationContext context, GraphViewCommand command)
        {
            ScalarFunction f1 = FirstExpr.CompileToFunction(context, command);
            ScalarFunction f2 = SecondExpr.CompileToFunction(context, command);

            return(new BinaryScalarFunction(f1, f2, ExpressionType));
        }
        public GroupOperator(
            GraphViewExecutionOperator inputOp,
            ScalarFunction groupByKeyFunction,
            int groupByKeyFieldIndex,
            ConstantSourceOperator tempSourceOp,
            ContainerOperator groupedSourceOp,
            GraphViewExecutionOperator aggregateOp,
            int elementPropertyProjectionIndex,
            int carryOnCount)
        {
            this.inputOp = inputOp;

            this.groupByKeyFunction   = groupByKeyFunction;
            this.groupByKeyFieldIndex = groupByKeyFieldIndex;

            this.tempSourceOp    = tempSourceOp;
            this.groupedSourceOp = groupedSourceOp;
            this.aggregateOp     = aggregateOp;

            this.elementPropertyProjectionIndex = elementPropertyProjectionIndex;
            this.carryOnCount = carryOnCount;

            groupedStates = new Dictionary <FieldObject, List <RawRecord> >();
            Open();
        }
        internal override BooleanFunction CompileToFunction(QueryCompilationContext context, GraphViewCommand command)
        {
            ScalarFunction f1 = FirstExpr.CompileToFunction(context, command);
            ScalarFunction f2 = SecondExpr.CompileToFunction(context, command);

            return(new ComparisonFunction(f1, f2, ComparisonType));
        }
 internal UnfoldOperator(
     GraphViewExecutionOperator inputOp,
     ScalarFunction getUnfoldTargetFunc,
     List <string> unfoldCompose1Columns)
     : base(inputOp)
 {
     this.getUnfoldTargetFunc   = getUnfoldTargetFunc;
     this.unfoldCompose1Columns = unfoldCompose1Columns;
 }
Exemple #5
0
 internal UnfoldOperator(
     GraphViewExecutionOperator inputOp,
     ScalarFunction getUnfoldTargetFunc,
     List <string> populateColumns)
     : base(inputOp)
 {
     this.getUnfoldTargetFunc = getUnfoldTargetFunc;
     this.populateColumns     = populateColumns;
 }
Exemple #6
0
 internal UnfoldOperator(
     GraphViewExecutionOperator pInputOperator,
     ScalarFunction pUnfoldTarget,
     List <string> pUnfoldColumns)
     : base(pInputOperator)
 {
     this._unfoldTarget  = pUnfoldTarget;
     this._unfoldColumns = pUnfoldColumns;
 }
Exemple #7
0
        public GroupSideEffectOperator(
            GraphViewExecutionOperator inputOp,
            GroupFunction groupState,
            ScalarFunction groupByKeyFunction)
        {
            this.inputOp            = inputOp;
            this.GroupState         = groupState;
            this.groupByKeyFunction = groupByKeyFunction;

            this.Open();
        }
 public AddEOperator(GraphViewExecutionOperator inputOp, GraphViewConnection connection,
                     ScalarFunction pSrcFunction, ScalarFunction pSinkFunction,
                     int otherVTag, JObject pEdgeJsonObject, List <string> pProjectedFieldList)
     : base(inputOp, connection)
 {
     _srcFunction    = pSrcFunction;
     _sinkFunction   = pSinkFunction;
     _otherVTag      = otherVTag;
     _edgeJsonObject = pEdgeJsonObject;
     _edgeProperties = pProjectedFieldList;
 }
Exemple #9
0
 public GroupInBatchOperator(
     GraphViewExecutionOperator inputOp,
     ScalarFunction groupByKeyFunction,
     Container container,
     GraphViewExecutionOperator aggregateOp,
     bool isProjectingACollection,
     int carryOnCount)
     : base(inputOp, groupByKeyFunction, container, aggregateOp,
            isProjectingACollection, carryOnCount)
 {
     this.processedGroupIndex = 0;
 }
Exemple #10
0
 public GroupSideEffectOperator(
     GraphViewExecutionOperator inputOp,
     GroupFunction groupFunction,
     string sideEffectKey,
     ScalarFunction groupByKeyFunction)
 {
     this.inputOp            = inputOp;
     this.groupFunction      = groupFunction;
     this.groupByKeyFunction = groupByKeyFunction;
     this.sideEffectKey      = sideEffectKey;
     this.Open();
 }
        public void AddOptionTraversal(ScalarFunction value, Container container, GraphViewExecutionOperator optionTraversalOp)
        {
            if (value == null)
            {
                this.optionNoneTraversalOp = optionTraversalOp;
                this.optionNoneContainer   = container;
                return;
            }

            this.traversalList.Add(new Tuple <FieldObject, Container, GraphViewExecutionOperator>(
                                       value.Evaluate(null),
                                       container,
                                       optionTraversalOp));
        }
        public override RawRecord Next()
        {
            RawRecord inputRec;

            while (this.inputOp.State() && (inputRec = this.inputOp.Next()) != null)
            {
                List <FieldObject> path = new List <FieldObject>();
                int activeByFuncIndex   = 0;

                foreach (Tuple <ScalarFunction, bool> tuple in pathStepList)
                {
                    ScalarFunction accessPathStepFunc = tuple.Item1;
                    bool           needsUnfold        = tuple.Item2;

                    FieldObject step = accessPathStepFunc.Evaluate(inputRec);
                    if (step == null)
                    {
                        continue;
                    }

                    if (needsUnfold)
                    {
                        CollectionField subPath = step as CollectionField;
                        Debug.Assert(subPath != null, "(subPath as CollectionField) != null");

                        foreach (FieldObject subPathStep in subPath.Collection)
                        {
                            path.Add(GetStepProjectionResult(subPathStep, ref activeByFuncIndex));
                        }
                    }
                    else
                    {
                        path.Add(GetStepProjectionResult(step, ref activeByFuncIndex));
                    }
                }

                RawRecord r = new RawRecord(inputRec);
                r.Append(new CollectionField(path));
                return(r);
            }

            Close();
            return(null);
        }
Exemple #13
0
        public GroupOperator(
            GraphViewExecutionOperator inputOp,
            ScalarFunction groupByKeyFunction,
            Container container,
            GraphViewExecutionOperator aggregateOp,
            bool isProjectingACollection,
            int carryOnCount)
        {
            this.inputOp = inputOp;

            this.groupByKeyFunction = groupByKeyFunction;

            this.container   = container;
            this.aggregateOp = aggregateOp;

            this.isProjectingACollection = isProjectingACollection;
            this.carryOnCount            = carryOnCount;

            this.groupedStates = new Dictionary <FieldObject, List <RawRecord> >();
            this.Open();
        }
Exemple #14
0
        public override FieldObject Evaluate(RawRecord record)
        {
            List <FieldObject> path = new List <FieldObject>();

            foreach (Tuple <ScalarFunction, bool, HashSet <string> > tuple in pathStepList)
            {
                ScalarFunction   accessPathStepFunc = tuple.Item1;
                bool             needsUnfold        = tuple.Item2;
                HashSet <string> stepLabels         = tuple.Item3;

                if (accessPathStepFunc == null)
                {
                    PathStepField pathStepField = new PathStepField(null);
                    foreach (string label in stepLabels)
                    {
                        pathStepField.AddLabel(label);
                    }
                    path.Add(pathStepField);
                    continue;
                }

                FieldObject step = accessPathStepFunc.Evaluate(record);
                if (step == null)
                {
                    PathStepField lastPathStep;

                    if (path.Any())
                    {
                        lastPathStep = (PathStepField)path[path.Count - 1];
                    }
                    else
                    {
                        lastPathStep = new PathStepField(null);
                        path.Add(lastPathStep);
                    }

                    foreach (string label in stepLabels)
                    {
                        lastPathStep.AddLabel(label);
                    }
                    continue;
                }

                if (needsUnfold)
                {
                    PathField subPath = step as PathField;
                    Debug.Assert(subPath != null, "(subPath as PathField) != null");

                    foreach (PathStepField subPathStep in subPath.Path.Cast <PathStepField>())
                    {
                        if (subPathStep.StepFieldObject == null)
                        {
                            if (path.Any())
                            {
                                PathStepField lastPathStep = (PathStepField)path[path.Count - 1];
                                foreach (string label in subPathStep.Labels)
                                {
                                    lastPathStep.AddLabel(label);
                                }
                            }
                            else
                            {
                                path.Add(subPathStep);
                            }
                            continue;
                        }

                        PathStepField pathStepField = new PathStepField(subPathStep.StepFieldObject);
                        foreach (string label in subPathStep.Labels)
                        {
                            pathStepField.AddLabel(label);
                        }
                        path.Add(pathStepField);
                    }

                    PathStepField lastSubPathStep = (PathStepField)path.Last();
                    foreach (string label in stepLabels)
                    {
                        lastSubPathStep.AddLabel(label);
                    }
                }
                else
                {
                    PathStepField pathStepField = new PathStepField(step);
                    foreach (string label in stepLabels)
                    {
                        pathStepField.AddLabel(label);
                    }
                    path.Add(pathStepField);
                }
            }

            return(new PathField(path));
        }
Exemple #15
0
 public BinaryScalarFunction(ScalarFunction f1, ScalarFunction f2, BinaryExpressionType binaryType)
 {
     this.f1         = f1;
     this.f2         = f2;
     this.binaryType = binaryType;
 }
Exemple #16
0
        public override RawRecord Next()
        {
            RawRecord inputRec;

            while (this.inputOp.State() && (inputRec = this.inputOp.Next()) != null)
            {
                List <FieldObject> path = new List <FieldObject>();
                int activeByFuncIndex   = 0;

                foreach (Tuple <ScalarFunction, bool, HashSet <string> > tuple in pathStepList)
                {
                    ScalarFunction   accessPathStepFunc = tuple.Item1;
                    bool             needsUnfold        = tuple.Item2;
                    HashSet <string> stepLabels         = tuple.Item3;

                    if (accessPathStepFunc == null)
                    {
                        PathStepField pathStepField = new PathStepField(null);
                        foreach (string label in stepLabels)
                        {
                            pathStepField.AddLabel(label);
                        }
                        path.Add(pathStepField);
                        continue;
                    }

                    FieldObject step = accessPathStepFunc.Evaluate(inputRec);
                    if (step == null)
                    {
                        PathStepField lastPathStep;

                        if (path.Any())
                        {
                            lastPathStep = (PathStepField)path[path.Count - 1];
                        }
                        else
                        {
                            lastPathStep = new PathStepField(null);
                            path.Add(lastPathStep);
                        }

                        foreach (string label in stepLabels)
                        {
                            lastPathStep.AddLabel(label);
                        }
                        continue;
                    }

                    if (needsUnfold)
                    {
                        PathField subPath = step as PathField;
                        Debug.Assert(subPath != null, "(subPath as PathField) != null");

                        foreach (PathStepField subPathStep in subPath.Path.Cast <PathStepField>())
                        {
                            if (subPathStep.StepFieldObject == null)
                            {
                                if (path.Any())
                                {
                                    PathStepField lastPathStep = (PathStepField)path[path.Count - 1];
                                    foreach (string label in subPathStep.Labels)
                                    {
                                        lastPathStep.AddLabel(label);
                                    }
                                }
                                else
                                {
                                    path.Add(subPathStep);
                                }
                                continue;
                            }

                            FieldObject   pathStep      = GetStepProjectionResult(subPathStep.StepFieldObject, ref activeByFuncIndex);
                            PathStepField pathStepField = new PathStepField(pathStep);
                            foreach (string label in subPathStep.Labels)
                            {
                                pathStepField.AddLabel(label);
                            }
                            path.Add(pathStepField);
                        }

                        PathStepField lastSubPathStep = (PathStepField)path.Last();
                        foreach (string label in stepLabels)
                        {
                            lastSubPathStep.AddLabel(label);
                        }
                    }
                    else
                    {
                        FieldObject pathStep = GetStepProjectionResult(step, ref activeByFuncIndex);

                        Compose1Field compose1PathStep = pathStep as Compose1Field;
                        Debug.Assert(compose1PathStep != null, "compose1PathStep != null");
                        //
                        // g.V().optional(__.count().V()).path()
                        //
                        if (compose1PathStep[compose1PathStep.DefaultProjectionKey] == null)
                        {
                            continue;
                        }

                        PathStepField pathStepField = new PathStepField(pathStep);
                        foreach (string label in stepLabels)
                        {
                            pathStepField.AddLabel(label);
                        }
                        path.Add(pathStepField);
                    }
                }

                RawRecord r = new RawRecord(inputRec);
                r.Append(new PathField(path));
                return(r);
            }

            this.Close();
            return(null);
        }
 public ComparisonFunction(ScalarFunction f1, ScalarFunction f2, BooleanComparisonType comparisonType)
 {
     firstScalarFunction  = f1;
     secondScalarFunction = f2;
     this.comparisonType  = comparisonType;
 }
 public InFunction(ScalarFunction lhsFunction, List <ScalarFunction> values, bool notDefined)
 {
     this.lhsFunction = lhsFunction;
     this.values      = values;
     this.notDefined  = notDefined;
 }