internal override List <RawRecord> CrossApply(RawRecord record) { List <RawRecord> results = new List <RawRecord>(); foreach (int propertyIndex in this.propertiesIndex) { FieldObject propertyObject = record[propertyIndex]; if (propertyObject == null) { continue; } VertexPropertyField vp = propertyObject as VertexPropertyField; if (vp != null) { foreach (VertexSinglePropertyField vsp in vp.Multiples.Values) { RawRecord r = new RawRecord(); r.Append(new StringField(vsp.PropertyValue, vsp.JsonDataType)); results.Add(r); } continue; } VertexSinglePropertyField singleVp = propertyObject as VertexSinglePropertyField; if (singleVp != null) { RawRecord r = new RawRecord(); r.Append(new StringField(singleVp.PropertyValue, singleVp.JsonDataType)); results.Add(r); continue; } EdgePropertyField edgePf = propertyObject as EdgePropertyField; if (edgePf != null) { RawRecord r = new RawRecord(); r.Append(new StringField(edgePf.PropertyValue, edgePf.JsonDataType)); results.Add(r); continue; } ValuePropertyField metaPf = propertyObject as ValuePropertyField; if (metaPf != null) { RawRecord r = new RawRecord(); r.Append(new StringField(metaPf.PropertyValue, metaPf.JsonDataType)); results.Add(r); continue; } Debug.Assert(false, "Should not get here."); } return(results); }
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)); }
internal override List <RawRecord> CrossApply(RawRecord record) { var results = new List <RawRecord>(); // Extract all properties if allPropertyIndex >= 0 if (allPropertyIndex >= 0 && record[allPropertyIndex] != null) { VertexField vertexField = record[allPropertyIndex] as VertexField; if (vertexField != null) { foreach (PropertyField property in vertexField.AllProperties) { string propertyName = property.PropertyName; switch (propertyName) { // Reversed properties for meta-data case "_edge": case "_partition": case "_reverse_edge": case "_nextEdgeOffset": case "_rid": case "_self": case "_etag": case "_attachments": case "_ts": continue; default: RawRecord r = new RawRecord(); if (property is VertexSinglePropertyField || property is ValuePropertyField) { r.Append(property); } else if (property is VertexPropertyField) { foreach (VertexSinglePropertyField p in ((VertexPropertyField)property).Multiples.Values) { r.Append(p); } } else { Debug.Assert(false, $"[PropertiesOperator.CrossApply] property type error: {property.GetType()}"); } results.Add(r); break; } } } else { EdgeField edgeField = record[allPropertyIndex] as EdgeField; if (edgeField == null) { throw new GraphViewException( string.Format("The FieldObject record[{0}] should be a VertexField or EdgeField but now it is {1}.", allPropertyIndex, record[allPropertyIndex].ToString())); } foreach (var propertyPair in edgeField.EdgeProperties) { string propertyName = propertyPair.Key; EdgePropertyField propertyField = propertyPair.Value; switch (propertyName) { // Reversed properties for meta-data case "_offset": case "_srcV": case "_sinkV": case "_srcVLabel": case "_sinkVLabel": continue; default: RawRecord r = new RawRecord(); r.Append(propertyField); results.Add(r); break; } } } } else { // TODO: Now translation code needn't to generate the key name for the operator foreach (var pair in propertyList) { //string propertyName = pair.Item1; int propertyValueIndex = pair.Item2; var propertyValue = record[propertyValueIndex]; if (propertyValue == null) { continue; } var result = new RawRecord(); result.Append(propertyValue); results.Add(result); } } return(results); }
internal override List <RawRecord> CrossApply(RawRecord record) { var results = new List <RawRecord>(); // Extract all values if allValuesIndex >= 0 if (allValuesIndex >= 0 && record[allValuesIndex] != null) { VertexField vertexField = record[allValuesIndex] as VertexField; if (vertexField != null) { foreach (PropertyField property in vertexField.AllProperties) { string propertyName = property.PropertyName; switch (propertyName) { // Reversed properties for meta-data case "_edge": case "_reverse_edge": case "_partition": case "_nextEdgeOffset": case "_rid": case "_self": case "_etag": case "_attachments": case "_ts": continue; default: RawRecord r = new RawRecord(); r.Append(new StringField(property.PropertyValue, property.JsonDataType)); results.Add(r); break; } } } else { EdgeField edgeField = record[allValuesIndex] as EdgeField; if (edgeField == null) { throw new GraphViewException( string.Format("The FieldObject record[{0}] should be a VertexField or EdgeField but now it is {1}.", allValuesIndex, record[allValuesIndex].ToString())); } foreach (var propertyPair in edgeField.EdgeProperties) { string propertyName = propertyPair.Key; EdgePropertyField propertyField = propertyPair.Value; switch (propertyName) { // Reversed properties for meta-data case "_offset": case "_srcV": case "_srcVLabel": case "_sinkV": case "_sinkVLabel": continue; default: RawRecord r = new RawRecord(); r.Append(new StringField(propertyField.ToValue, propertyField.JsonDataType)); results.Add(r); break; } } } } else { foreach (var propIdx in ValuesIdxList) { PropertyField propertyValue = record[propIdx] as PropertyField; if (propertyValue == null) { continue; } var result = new RawRecord(); result.Append(new StringField(propertyValue.ToValue, propertyValue.JsonDataType)); results.Add(result); } } return(results); }
internal override List <RawRecord> CrossApply(RawRecord record) { List <RawRecord> results = new List <RawRecord>(); FieldObject inputTarget = record[this.inputTargetIndex]; if (inputTarget is VertexField) { VertexField vertexField = (VertexField)inputTarget; foreach (VertexPropertyField property in vertexField.VertexProperties.Values) { string propertyName = property.PropertyName; Debug.Assert(!VertexField.IsVertexMetaProperty(propertyName)); Debug.Assert(propertyName == "_edge"); Debug.Assert(propertyName == "_reverse_edge"); switch (propertyName) { case "_rid": case "_self": case "_etag": case "_attachments": case "_ts": continue; default: foreach (VertexSinglePropertyField singleVp in property.Multiples.Values) { RawRecord r = new RawRecord(); r.Append(new StringField(singleVp.PropertyValue, singleVp.JsonDataType)); results.Add(r); } break; } } } else if (inputTarget is EdgeField) { EdgeField edgeField = (EdgeField)inputTarget; foreach (KeyValuePair <string, EdgePropertyField> propertyPair in edgeField.EdgeProperties) { string propertyName = propertyPair.Key; EdgePropertyField edgePropertyField = propertyPair.Value; switch (propertyName) { // Reserved properties for meta-data case "_edgeId": case "_offset": case "_srcV": case "_sinkV": case "_srcVLabel": case "_sinkVLabel": continue; default: RawRecord r = new RawRecord(); r.Append(new StringField(edgePropertyField.PropertyValue, edgePropertyField.JsonDataType)); results.Add(r); break; } } } else if (inputTarget is VertexSinglePropertyField) { VertexSinglePropertyField singleVp = inputTarget as VertexSinglePropertyField; foreach (KeyValuePair <string, ValuePropertyField> kvp in singleVp.MetaProperties) { RawRecord r = new RawRecord(); ValuePropertyField metaPropertyField = kvp.Value; r.Append(new StringField(metaPropertyField.PropertyValue, metaPropertyField.JsonDataType)); results.Add(r); } } else { throw new GraphViewException("The input of values() cannot be a meta or edge property."); } return(results); }
internal override List <RawRecord> CrossApply(RawRecord record) { List <RawRecord> results = new List <RawRecord>(); foreach (int propertyIndex in this.propertiesIndex) { FieldObject propertyObject = record[propertyIndex]; if (propertyObject == null) { continue; } VertexPropertyField vp = propertyObject as VertexPropertyField; if (vp != null) { foreach (VertexSinglePropertyField vsp in vp.Multiples.Values) { RawRecord r = new RawRecord(); r.Append(new VertexSinglePropertyField(vsp)); foreach (string metapropertyName in this.populateMetaproperties) { r.Append(vsp[metapropertyName]); } results.Add(r); } continue; } VertexSinglePropertyField singleVp = propertyObject as VertexSinglePropertyField; if (singleVp != null) { RawRecord r = new RawRecord(); r.Append(new VertexSinglePropertyField(singleVp)); foreach (string metapropertyName in this.populateMetaproperties) { r.Append(singleVp[metapropertyName]); } results.Add(r); continue; } EdgePropertyField edgePf = propertyObject as EdgePropertyField; if (edgePf != null) { if (this.populateMetaproperties.Count > 0) { throw new GraphViewException("An edge property cannot contain meta properties."); } RawRecord r = new RawRecord(); r.Append(new EdgePropertyField(edgePf)); results.Add(r); continue; } ValuePropertyField metaPf = propertyObject as ValuePropertyField; if (metaPf != null) { if (this.populateMetaproperties.Count > 0) { throw new GraphViewException("A meta property cannot contain meta properties."); } RawRecord r = new RawRecord(); r.Append(new ValuePropertyField(metaPf)); results.Add(r); continue; } Debug.Assert(false, "Should not get here."); } return(results); }
internal override List <RawRecord> CrossApply(RawRecord record) { MapField valueMap = new MapField(); FieldObject inputTarget = record[this.inputTargetIndex]; if (inputTarget is VertexField) { VertexField vertexField = (VertexField)inputTarget; if (this.propertyNameList.Any()) { foreach (string propertyName in this.propertyNameList) { FieldObject property = vertexField[propertyName]; if (property == null) { continue; } List <FieldObject> values = new List <FieldObject>(); VertexPropertyField vp = property as VertexPropertyField; if (vp != null) { foreach (VertexSinglePropertyField vsp in vp.Multiples.Values) { values.Add(vsp); } } valueMap.Add(new StringField(propertyName), new CollectionField(values)); } } else { foreach (VertexPropertyField property in vertexField.VertexProperties.Values) { string propertyName = property.PropertyName; Debug.Assert(!VertexField.IsVertexMetaProperty(propertyName)); Debug.Assert(!propertyName.Equals(KW_VERTEX_EDGE)); Debug.Assert(!propertyName.Equals(KW_VERTEX_REV_EDGE)); switch (propertyName) { case "_rid": case "_self": case "_etag": case "_attachments": case "_ts": continue; default: List <FieldObject> values = new List <FieldObject>(); foreach (VertexSinglePropertyField singleVp in property.Multiples.Values) { values.Add(singleVp); } valueMap.Add(new StringField(propertyName), new CollectionField(values)); break; } } } } else if (inputTarget is EdgeField) { EdgeField edgeField = (EdgeField)inputTarget; if (this.propertyNameList.Any()) { foreach (string propertyName in this.propertyNameList) { FieldObject property = edgeField[propertyName]; if (property == null) { continue; } EdgePropertyField edgePf = property as EdgePropertyField; if (edgePf != null) { valueMap.Add(new StringField(propertyName), edgePf); } } } else { foreach (KeyValuePair <string, EdgePropertyField> propertyPair in edgeField.EdgeProperties) { string propertyName = propertyPair.Key; EdgePropertyField edgePropertyField = propertyPair.Value; switch (propertyName) { // Reserved properties for meta-data case KW_EDGE_ID: //case KW_EDGE_OFFSET: case KW_EDGE_SRCV: case KW_EDGE_SINKV: case KW_EDGE_SRCV_LABEL: case KW_EDGE_SINKV_LABEL: continue; default: valueMap.Add(new StringField(propertyName), edgePropertyField); break; } } } } else if (inputTarget is VertexSinglePropertyField) { VertexSinglePropertyField singleVp = inputTarget as VertexSinglePropertyField; if (this.propertyNameList.Any()) { foreach (string propertyName in this.propertyNameList) { FieldObject property = singleVp[propertyName]; if (property == null) { continue; } ValuePropertyField metaPf = property as ValuePropertyField; if (metaPf != null) { valueMap.Add(new StringField(propertyName), metaPf); } } } else { foreach (KeyValuePair <string, ValuePropertyField> kvp in singleVp.MetaProperties) { valueMap.Add(new StringField(kvp.Key), kvp.Value); } } } else { throw new GraphViewException("The input of valueMap() cannot be a meta or edge property."); } RawRecord result = new RawRecord(); result.Append(valueMap); return(new List <RawRecord> { result }); }
internal override List <RawRecord> CrossApply(RawRecord record) { List <RawRecord> results = new List <RawRecord>(); FieldObject inputTarget = record[this.inputTargetIndex]; if (inputTarget is VertexField) { VertexField vertexField = (VertexField)inputTarget; foreach (VertexPropertyField property in vertexField.VertexProperties.Values) { string propertyName = property.PropertyName; Debug.Assert(!VertexField.IsVertexMetaProperty(propertyName)); Debug.Assert(!propertyName.Equals(KW_VERTEX_EDGE)); Debug.Assert(!propertyName.Equals(KW_VERTEX_REV_EDGE)); switch (propertyName) { case "_rid": case "_self": case "_etag": case "_attachments": case "_ts": continue; default: foreach (VertexSinglePropertyField singleVp in property.Multiples.Values) { RawRecord r = new RawRecord(); r.Append(new VertexSinglePropertyField(singleVp)); foreach (string metaPropertyName in this.populateMetaProperties) { r.Append(singleVp[metaPropertyName]); } results.Add(r); } break; } } } else if (inputTarget is EdgeField) { EdgeField edgeField = (EdgeField)inputTarget; foreach (KeyValuePair <string, EdgePropertyField> propertyPair in edgeField.EdgeProperties) { string propertyName = propertyPair.Key; EdgePropertyField edgePropertyField = propertyPair.Value; switch (propertyName) { // Reserved properties for meta-data case KW_EDGE_LABEL: case KW_EDGE_ID: //case KW_EDGE_OFFSET: case KW_EDGE_SRCV: case KW_EDGE_SINKV: case KW_EDGE_SRCV_LABEL: case KW_EDGE_SINKV_LABEL: continue; default: RawRecord r = new RawRecord(); r.Append(new EdgePropertyField(edgePropertyField)); results.Add(r); break; } } if (this.populateMetaProperties.Count > 0 && results.Count > 0) { throw new GraphViewException("An edge property cannot contain meta properties."); } } else if (inputTarget is VertexSinglePropertyField) { VertexSinglePropertyField singleVp = (VertexSinglePropertyField)inputTarget; foreach (KeyValuePair <string, ValuePropertyField> kvp in singleVp.MetaProperties) { RawRecord r = new RawRecord(); ValuePropertyField metaPropertyField = kvp.Value; r.Append(new ValuePropertyField(metaPropertyField)); results.Add(r); } if (this.populateMetaProperties.Count > 0 && results.Count > 0) { throw new GraphViewException("An edge property cannot contain meta properties."); } } else { throw new GraphViewException("The input of properties() cannot be a meta or edge property."); } return(results); }