コード例 #1
0
        internal override GraphViewExecutionOperator Compile(QueryCompilationContext context, GraphViewConnection dbConnection)
        {
            var srcIdParameter      = Parameters[0] as WColumnReferenceExpression;
            var edgeOffsetParameter = Parameters[1] as WColumnReferenceExpression;
            var srcIdIndex          = context.LocateColumnReference(srcIdParameter);
            var edgeOffsetIndex     = context.LocateColumnReference(edgeOffsetParameter);
            var edgeAlias           = edgeOffsetParameter.TableReference;
            var propertiesList      = new List <Tuple <WValueExpression, WValueExpression, int> >();

            for (var i = 2; i < Parameters.Count; i += 2)
            {
                var keyExpression   = Parameters[i] as WValueExpression;
                var valueExpression = Parameters[i + 1] as WValueExpression;

                int propertyIndex;
                if (!context.TryLocateColumnReference(new WColumnReferenceExpression(edgeAlias, keyExpression.Value), out propertyIndex))
                {
                    propertyIndex = -1;
                }

                propertiesList.Add(new Tuple <WValueExpression, WValueExpression, int>(keyExpression, valueExpression, propertyIndex));
            }

            var updateEdgePropertiesOp = new UpdateEdgePropertiesOperator(context.CurrentExecutionOperator, dbConnection,
                                                                          srcIdIndex, edgeOffsetIndex, propertiesList);

            context.CurrentExecutionOperator = updateEdgePropertiesOp;

            return(updateEdgePropertiesOp);
        }
コード例 #2
0
        private void DropEdgeProperty(EdgePropertyField ep)
        {
            //EdgeField edgeField = ep.Edge;
            //if (edgeField.EdgeDocID != null) {  // This is a spilled edge
            //    JObject edgeDocument = this.connection.RetrieveDocumentById(edgeField.EdgeDocID);
            //    ((JArray)edgeDocument["_edge"])
            //        .First(edge => (string)edge["_srcV"] == edgeField.OutV && (long)edge["_offset"] == edgeField.Offset)
            //        [ep.PropertyName]
            //        .Remove();
            //    this.connection.ReplaceOrDeleteDocumentAsync(edgeField.EdgeDocID, edgeDocument).Wait();
            //}
            //else {  // This is not a spilled edge
            //    JObject edgeDocument = this.connection.RetrieveDocumentById(edgeField.EdgeDocID);
            //    ((JArray)edgeDocument["_edge"])
            //        .First(edge => (string)edge["_srcV"] == edgeField.OutV && (long)edge["_offset"] == edgeField.Offset)
            //        [ep.PropertyName]
            //        .Remove();
            //    this.connection.ReplaceOrDeleteDocumentAsync(edgeField.EdgeDocID, edgeDocument).Wait();
            //}

            //// Update edge field
            //bool found = edgeField.EdgeProperties.Remove(ep.PropertyName);
            //Debug.Assert(found);

            List <Tuple <WValueExpression, WValueExpression, int> > propertyList = new List <Tuple <WValueExpression, WValueExpression, int> >();

            propertyList.Add(
                new Tuple <WValueExpression, WValueExpression, int>(
                    new WValueExpression(ep.PropertyName, true),
                    new WValueExpression("null", false),
                    0));
            UpdateEdgePropertiesOperator op = new UpdateEdgePropertiesOperator(
                this.dummyInputOp,
                this.connection,
                0, 1,
                propertyList
                );
            RawRecord record = new RawRecord();

            record.Append(new StringField(ep.Edge.OutV));
            record.Append(new StringField(ep.Edge.Offset.ToString()));
            op.DataModify(record);

            // Now VertexCacheObject has been updated (in DataModify)
            Debug.Assert(!ep.Edge.EdgeProperties.ContainsKey(ep.PropertyName));
        }
コード例 #3
0
        private void UpdatePropertiesOfEdge(EdgeField edge)
        {
            List <Tuple <WValueExpression, WValueExpression, int> > propertyList =
                new List <Tuple <WValueExpression, WValueExpression, int> >();

            foreach (WPropertyExpression property in this.updateProperties)
            {
                if (property.Cardinality == GremlinKeyword.PropertyCardinality.list ||
                    property.MetaProperties.Count > 0)
                {
                    throw new Exception("Can't create meta property or duplicated property on edges");
                }

                propertyList.Add(new Tuple <WValueExpression, WValueExpression, int>(property.Key, property.Value, 0));
            }

            RawRecord record = new RawRecord();

            record.Append(new StringField(edge.OutV));
            record.Append(new StringField(edge.Offset.ToString()));
            UpdateEdgePropertiesOperator op = new UpdateEdgePropertiesOperator(this.InputOperator, this.Connection, 0, 1, propertyList);

            op.DataModify(record);
        }