Пример #1
0
        public List <string> Next()
        {
            WSqlScript sqlScript = this.GetEndOp().ToSqlScript();

            SqlScript = sqlScript.ToString();

            GraphViewExecutionOperator op = sqlScript.Batches[0].Compile(null, this.connection);
            List <RawRecord>           rawRecordResults = new List <RawRecord>();
            RawRecord outputRec = null;

            while ((outputRec = op.Next()) != null)
            {
                rawRecordResults.Add(outputRec);
            }

            List <string> results = new List <string>();

            switch (outputFormat)
            {
            case OutputFormat.GraphSON:
                results.Add(GraphSONProjector.ToGraphSON(rawRecordResults, this.connection));
                break;

            default:
                foreach (var record in rawRecordResults)
                {
                    FieldObject field = record[0];
                    results.Add(field.ToString());
                }
                break;
            }

            return(results);
        }
 protected UpdatePropertiesBaseOperator(GraphViewExecutionOperator inputOp, GraphViewConnection connection,
                                        List <Tuple <WValueExpression, WValueExpression, int> > pPropertiesToBeUpdated, UpdatePropertyMode pMode = UpdatePropertyMode.Set)
     : base(inputOp, connection)
 {
     PropertiesToBeUpdated = pPropertiesToBeUpdated;
     Mode = pMode;
 }
Пример #3
0
        protected ChooseWithOptionsOperator(SerializationInfo info, StreamingContext context)
        {
            this.inputOp     = (GraphViewExecutionOperator)info.GetValue("inputOp", typeof(GraphViewExecutionOperator));
            this.targetSubOp = (GraphViewExecutionOperator)info.GetValue("targetSubOp", typeof(GraphViewExecutionOperator));

            List <FieldObject> traversalListTuple1 =
                GraphViewSerializer.DeserializeList <FieldObject>(info, "traversalListTuple1");
            List <GraphViewExecutionOperator> traversalListTuple3 =
                GraphViewSerializer.DeserializeList <GraphViewExecutionOperator>(info, "traversalListTuple3");

            this.traversalList = new List <Tuple <FieldObject, Container, GraphViewExecutionOperator> >();
            Debug.Assert(traversalListTuple1.Count == traversalListTuple3.Count);
            for (int i = 0; i < traversalListTuple1.Count; i++)
            {
                this.traversalList.Add(new Tuple <FieldObject, Container, GraphViewExecutionOperator>(
                                           traversalListTuple1[i], new Container(), traversalListTuple3[i]));
            }

            this.optionNoneTraversalOp = (GraphViewExecutionOperator)info.GetValue("optionNoneTraversalOp", typeof(GraphViewExecutionOperator));

            this.selectOption   = new List <int>();
            this.currentIndex   = 0;
            this.outputBuffer   = new Queue <RawRecord>();
            this.needInitialize = true;
        }
Пример #4
0
        internal override ScalarFunction CompileToFunction(QueryCompilationContext context, GraphViewConnection dbConnection)
        {
            QueryCompilationContext    subContext = new QueryCompilationContext(context);
            GraphViewExecutionOperator subQueryOp = SubQueryExpr.Compile(subContext, dbConnection);

            return(new ScalarSubqueryFunction(subQueryOp, subContext.OuterContextOp));
        }
Пример #5
0
        internal override GraphViewExecutionOperator Compile(QueryCompilationContext context, GraphViewConnection dbConnection)
        {
            WScalarSubquery srcSubQuery  = this.Parameters[0] as WScalarSubquery;
            WScalarSubquery sinkSubQuery = this.Parameters[1] as WScalarSubquery;

            if (srcSubQuery == null || sinkSubQuery == null)
            {
                throw new SyntaxErrorException("The first two parameters of AddE can only be WScalarSubquery.");
            }
            WValueExpression otherVTagParameter = this.Parameters[2] as WValueExpression;
            WValueExpression edgeLabel          = this.Parameters[3] as WValueExpression;

            Debug.Assert(otherVTagParameter != null, "otherVTagParameter != null");
            //
            // if otherVTag == 0, this newly added edge's otherV() is the src vertex.
            // Otherwise, it's the sink vertex
            //
            int otherVTag = int.Parse(otherVTagParameter.Value);

            List <WPropertyExpression> edgeProperties = new List <WPropertyExpression>();
            List <string> projectedField = new List <string>();

            for (int i = 4; i < this.Parameters.Count; i += 1)
            {
                WPropertyExpression addedProperty = this.Parameters[i] as WPropertyExpression;
                if (addedProperty != null)
                {
                    edgeProperties.Add(addedProperty);
                }

                WValueExpression projectedProperty = this.Parameters[i] as WValueExpression;
                if (projectedProperty != null)
                {
                    projectedField.Add(projectedProperty.Value);
                }
            }
            JObject edgeJsonObject = this.ConstructEdgeJsonObject(edgeLabel, edgeProperties);

            QueryCompilationContext    srcSubContext = new QueryCompilationContext(context);
            GraphViewExecutionOperator srcSubQueryOp = srcSubQuery.SubQueryExpr.Compile(srcSubContext, dbConnection);

            QueryCompilationContext    sinkSubContext = new QueryCompilationContext(context);
            GraphViewExecutionOperator sinkSubQueryOp = sinkSubQuery.SubQueryExpr.Compile(sinkSubContext, dbConnection);

            GraphViewExecutionOperator addEOp = new AddEOperator(context.CurrentExecutionOperator, dbConnection,
                                                                 srcSubContext.OuterContextOp, srcSubQueryOp, sinkSubContext.OuterContextOp, sinkSubQueryOp,
                                                                 otherVTag, edgeJsonObject, projectedField);

            context.CurrentExecutionOperator = addEOp;

            foreach (string propertyName in projectedField)
            {
                ColumnGraphType columnGraphType = GraphViewReservedProperties.IsEdgeReservedProperty(propertyName)
                    ? GraphViewReservedProperties.ReservedEdgePropertiesColumnGraphTypes[propertyName]
                    : ColumnGraphType.Value;
                context.AddField(this.Alias.Value, propertyName, columnGraphType);
            }

            return(addEOp);
        }
Пример #6
0
        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();
        }
Пример #7
0
 protected CoalesceOperator(SerializationInfo info, StreamingContext context)
 {
     this.traversalList = GraphViewSerializer.DeserializeList <GraphViewExecutionOperator>(info, "traversalList");
     this.inputOp       = (GraphViewExecutionOperator)info.GetValue("inputOp", typeof(GraphViewExecutionOperator));
     this.outputBuffer  = new SortedDictionary <int, Queue <RawRecord> >();
     this.batchSize     = KW_DEFAULT_BATCH_SIZE;
 }
Пример #8
0
 public GroupFunction(GroupState groupState, GraphViewExecutionOperator aggregateOp, Container container, bool isProjectingACollection)
 {
     this.groupState              = groupState;
     this.aggregateOp             = aggregateOp;
     this.container               = container;
     this.isProjectingACollection = isProjectingACollection;
 }
 public DropOperator(GraphViewExecutionOperator dummyInputOp, GraphViewConnection connection, int dropTargetIndex)
     : base(dummyInputOp, connection)
 {
     this.dropTargetIndex = dropTargetIndex;
     this.connection      = connection;
     this.dummyInputOp    = dummyInputOp;
 }
Пример #10
0
 public PropertiesOperator2(
     GraphViewExecutionOperator inputOp,
     List <int> propertiesIndex,
     List <string> populateMetaproperties) : base(inputOp)
 {
     this.propertiesIndex        = propertiesIndex;
     this.populateMetaproperties = populateMetaproperties;
 }
Пример #11
0
 internal AllPropertiesOperator(
     GraphViewExecutionOperator inputOp,
     int inputTargetIndex,
     List <string> populateMetaProperties) : base(inputOp)
 {
     this.inputTargetIndex       = inputTargetIndex;
     this.populateMetaProperties = populateMetaProperties;
 }
Пример #12
0
 internal GraphTraversalIterator(GraphViewExecutionOperator pCurrentOperator,
                                 GraphViewConnection connection, OutputFormat outputFormat)
 {
     this.connection      = connection;
     this.currentOperator = pCurrentOperator;
     this.outputFormat    = outputFormat;
     this.firstCall       = true;
 }
Пример #13
0
 public PropertiesOperator(
     GraphViewExecutionOperator pInputOperator,
     List <Tuple <string, int> > pPropertiesList,
     int pAllPropertyIndex) : base(pInputOperator)
 {
     propertyList     = pPropertiesList;
     allPropertyIndex = pAllPropertyIndex;
 }
        internal override BooleanFunction CompileToFunction(QueryCompilationContext context, GraphViewConnection dbConnection)
        {
            QueryCompilationContext    subContext = new QueryCompilationContext(context);
            GraphViewExecutionOperator subQueryOp = Subquery.SubQueryExpr.Compile(subContext, dbConnection);
            ExistsFunction             existsFunc = new ExistsFunction(subQueryOp, subContext.OuterContextOp);

            return(existsFunc);
        }
Пример #15
0
 internal PropertyMapOperator(
     GraphViewExecutionOperator inputOp,
     int inputTargetIndex,
     List <string> propertyNameList)
     : base(inputOp)
 {
     this.inputTargetIndex = inputTargetIndex;
     this.propertyNameList = propertyNameList;
 }
Пример #16
0
 internal UnfoldOperator(
     GraphViewExecutionOperator pInputOperator,
     ScalarFunction pUnfoldTarget,
     List <string> pUnfoldColumns)
     : base(pInputOperator)
 {
     this._unfoldTarget  = pUnfoldTarget;
     this._unfoldColumns = pUnfoldColumns;
 }
Пример #17
0
        public UnionOperator(GraphViewExecutionOperator inputOp, Container container)
        {
            this.inputOp       = inputOp;
            this.traversalList = new List <GraphViewExecutionOperator>();
            this.container     = container;

            this.needInitialize = true;
            this.Open();
        }
Пример #18
0
 internal UnfoldOperator(
     GraphViewExecutionOperator inputOp,
     ScalarFunction getUnfoldTargetFunc,
     List <string> unfoldCompose1Columns)
     : base(inputOp)
 {
     this.getUnfoldTargetFunc   = getUnfoldTargetFunc;
     this.unfoldCompose1Columns = unfoldCompose1Columns;
 }
Пример #19
0
 internal UnfoldOperator(
     GraphViewExecutionOperator inputOp,
     ScalarFunction getUnfoldTargetFunc,
     List <string> populateColumns)
     : base(inputOp)
 {
     this.getUnfoldTargetFunc = getUnfoldTargetFunc;
     this.populateColumns     = populateColumns;
 }
Пример #20
0
 internal ConstantOperator(
     GraphViewExecutionOperator inputOp,
     List <ScalarFunction> constantValues,
     bool isList)
     : base(inputOp)
 {
     this.constantValues = constantValues;
     this.isList         = isList;
 }
Пример #21
0
        public CoalesceOperator(GraphViewExecutionOperator inputOp, ContainerWithFlag container)
        {
            this.inputOp       = inputOp;
            this.container     = container;
            this.traversalList = new List <GraphViewExecutionOperator>();
            this.outputBuffer  = new SortedDictionary <int, Queue <RawRecord> >();

            this.batchSize = KW_DEFAULT_BATCH_SIZE;
            this.Open();
        }
Пример #22
0
        public PathOperator2(GraphViewExecutionOperator inputOp,
                             List <Tuple <ScalarFunction, bool> > pathStepList,
                             List <ScalarFunction> byFuncList)
        {
            this.inputOp      = inputOp;
            this.pathStepList = pathStepList;
            this.byFuncList   = byFuncList;

            this.Open();
        }
Пример #23
0
        internal override ScalarFunction CompileToFunction(QueryCompilationContext context, GraphViewCommand command)
        {
            QueryCompilationContext subContext = new QueryCompilationContext(context);
            Container container = new Container();

            subContext.OuterContextOp.SetContainer(container);
            GraphViewExecutionOperator subQueryOp = SubQueryExpr.Compile(subContext, command);

            return(new ScalarSubqueryFunction(subQueryOp, container));
        }
 public UpdateEdgePropertiesOperator(
     GraphViewExecutionOperator inputOp, GraphViewConnection connection,
     int srcVertexIdIndex, int edgeOffsetIndex,
     List <Tuple <WValueExpression, WValueExpression, int> > propertiesList,
     UpdatePropertyMode pMode = UpdatePropertyMode.Set)
     : base(inputOp, connection, propertiesList, pMode)
 {
     this._srcVertexIdIndex = srcVertexIdIndex;
     this._edgeOffsetIndex  = edgeOffsetIndex;
 }
 public UpdatePropertiesOperator(
     GraphViewExecutionOperator dummyInputOp,
     GraphViewConnection connection,
     int updateTargetIndex,
     List <WPropertyExpression> updateProperties)
     : base(dummyInputOp, connection)
 {
     this.updateTargetIndex = updateTargetIndex;
     this.updateProperties  = updateProperties;
 }
Пример #26
0
 protected OptionalOperator(SerializationInfo info, StreamingContext context)
 {
     this.inputIndexes      = GraphViewSerializer.DeserializeList <int>(info, "inputIndexes");
     this.inputOp           = (GraphViewExecutionOperator)info.GetValue("inputOp", typeof(GraphViewExecutionOperator));
     this.targetSubQueryOp  = (GraphViewExecutionOperator)info.GetValue("targetSubQueryOp", typeof(GraphViewExecutionOperator));
     this.optionalTraversal = (GraphViewExecutionOperator)info.GetValue("optionalTraversal", typeof(GraphViewExecutionOperator));
     this.currentIndex      = 0;
     this.haveOutput        = new HashSet <int>();
     this.needInitialize    = true;
 }
Пример #27
0
 public QueryDerivedInBatchOperator(
     GraphViewExecutionOperator inputOp,
     GraphViewExecutionOperator derivedQueryOp,
     Container container,
     ProjectAggregationInBatch projectAggregationInBatchOp,
     int carryOnCount)
     : base(inputOp, derivedQueryOp, container, carryOnCount)
 {
     this.projectAggregationInBatchOp = projectAggregationInBatchOp;
     this.outputBuffer = new SortedDictionary <int, RawRecord>();
 }
Пример #28
0
        public TreeSideEffectOperator(
            GraphViewExecutionOperator inputOp,
            TreeFunction treeState,
            int pathIndex)
        {
            this.inputOp   = inputOp;
            this.TreeState = treeState;
            this.pathIndex = pathIndex;

            this.Open();
        }
        internal override BooleanFunction CompileToFunction(QueryCompilationContext context, GraphViewCommand command)
        {
            QueryCompilationContext subContext = new QueryCompilationContext(context);
            Container container = new Container();

            subContext.OuterContextOp.SetContainer(container);
            GraphViewExecutionOperator subQueryOp = Subquery.SubQueryExpr.Compile(subContext, command);
            ExistsFunction             existsFunc = new ExistsFunction(subQueryOp, container);

            return(existsFunc);
        }
 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;
 }