Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Minor changes to CompileSelect #18

Open
wants to merge 3 commits into
base: clean-up
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 6 additions & 105 deletions GraphView/GraphViewQueryCompiler/CompileSelect.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using GraphView.GraphViewDBPortal;

namespace GraphView
Expand Down Expand Up @@ -446,7 +443,6 @@ private MatchGraph ConstructGraph2(out List<WTableReferenceWithAlias> nonVertexT

UnionFind unionFind = new UnionFind();
Dictionary<string, MatchNode> vertexTableCollection = new Dictionary<string, MatchNode>(StringComparer.OrdinalIgnoreCase);
// Dictionary<string, WNamedTableReference> vertexTableReferencesDict = new Dictionary<string, WNamedTableReference>();
List<ConnectedComponent> connectedSubGraphs = new List<ConnectedComponent>();
Dictionary<string, ConnectedComponent> subGraphMap = new Dictionary<string, ConnectedComponent>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, string> parent = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Expand All @@ -463,7 +459,6 @@ private MatchGraph ConstructGraph2(out List<WTableReferenceWithAlias> nonVertexT
foreach (WNamedTableReference vertexTableRef in vertexTableList)
{
vertexTableCollection.GetOrCreate(vertexTableRef.Alias.Value);
// vertexTableReferencesDict[vertexTableRef.Alias.Value] = vertexTableRef;
if (!parent.ContainsKey(vertexTableRef.Alias.Value))
parent[vertexTableRef.Alias.Value] = vertexTableRef.Alias.Value;
}
Expand Down Expand Up @@ -588,17 +583,6 @@ private MatchGraph ConstructGraph2(out List<WTableReferenceWithAlias> nonVertexT
{
srcNode.DanglingEdges.Add(edgeFromSrcNode);
srcNode.Properties.Add(GremlinKeyword.Star);
//if (edgeFromSrcNode.EdgeType == WEdgeType.BothEdge)
//{
// srcNode.Properties.Add(GremlinKeyword.EdgeAdj);
// srcNode.Properties.Add(GremlinKeyword.ReverseEdgeAdj);
//}
//else if (edgeFromSrcNode.EdgeType == WEdgeType.OutEdge) {
// srcNode.Properties.Add(GremlinKeyword.EdgeAdj);
//}
//else {
// srcNode.Properties.Add(GremlinKeyword.ReverseEdgeAdj);
//}
}
}
if (path.Tail == null) continue;
Expand Down Expand Up @@ -829,13 +813,6 @@ private static void CheckRemainingPredicatesAndAppendFilterOp(QueryCompilationCo
: context.OuterContextOp,
predicate.CompileToBatchFunction(context, command)));

//childrenProcessor.Add(
// new FilterOperator(
// childrenProcessor.Count != 0
// ? childrenProcessor.Last()
// : context.OuterContextOp,
// predicate.CompileToFunction(context, connection)));

toBeRemovedIndexes.Add(i);
context.CurrentExecutionOperator = childrenProcessor.Last();
}
Expand Down Expand Up @@ -1020,8 +997,7 @@ private GraphViewExecutionOperator ConstructOperator2(GraphViewCommand command,
currentNode.DanglingEdges[0].AttachedJsonQuery))
: new FetchNodeOperator(
command,
currentNode.AttachedJsonQuery
/*currentNode.AttachedJsonQueryOfNodesViaExternalAPI*/);
currentNode.AttachedJsonQuery);

//
// The graph contains more than one component
Expand Down Expand Up @@ -1098,7 +1074,6 @@ private GraphViewExecutionOperator ConstructOperator2(GraphViewCommand command,
context.LocateColumnReference(traversalEdge.EdgeAlias, GremlinKeyword.Star),
this.GetTraversalType(traversalEdge),
currentNode.AttachedJsonQuery,
//currentNode.AttachedJsonQueryOfNodesViaExternalAPI,
null, booleanFunction));
context.CurrentExecutionOperator = operatorChain.Last();
//
Expand Down Expand Up @@ -1177,7 +1152,6 @@ private GraphViewExecutionOperator ConstructOperator2(GraphViewCommand command,
else if (tableReference is WSchemaObjectFunctionTableReference)
{
var functionTableReference = tableReference as WSchemaObjectFunctionTableReference;
var functionName = functionTableReference.SchemaObject.Identifiers.Last().ToString();
var tableOp = functionTableReference.Compile(context, command);

tableReferences.Add(functionTableReference.Alias.Value);
Expand Down Expand Up @@ -1255,37 +1229,6 @@ private GraphViewExecutionOperator ConstructOperator2(GraphViewCommand command,
projectOperator.AddSelectScalarElement(scalarFunction);
}

//// Rebuilds the output layout of the context
//context.ClearField();
//int i = 0;
//if (context.CarryOn)
//{
// foreach (var parentFieldPair in context.ParentContextRawRecordLayout)
// {
// context.RawRecordLayout.Add(parentFieldPair.Key, parentFieldPair.Value);
// }
// i = context.ParentContextRawRecordLayout.Count;
//}

//foreach (var expr in selectScalarExprList)
//{
// var alias = expr.ColumnName;
// WColumnReferenceExpression columnReference;
// if (alias == null)
// {
// columnReference = expr.SelectExpr as WColumnReferenceExpression;
// if (columnReference == null)
// {
// var value = expr.SelectExpr as WValueExpression;
// columnReference = new WColumnReferenceExpression("", value.Value);
// }
// }
// else
// columnReference = new WColumnReferenceExpression("", alias);
// // TODO: Change to Addfield with correct ColumnGraphType
// context.RawRecordLayout.Add(columnReference, i++);
//}

operatorChain.Add(projectOperator);
context.CurrentExecutionOperator = projectOperator;
}
Expand Down Expand Up @@ -1330,7 +1273,6 @@ private GraphViewExecutionOperator ConstructOperator2(GraphViewCommand command,
CapAggregate capAggregate = new CapAggregate();
for (int i = 0; i < fcall.Parameters.Count; i += 2)
{
WColumnNameList columnNameList = fcall.Parameters[i] as WColumnNameList;
WValueExpression capName = fcall.Parameters[i+1] as WValueExpression;

IAggregateFunction sideEffectState;
Expand Down Expand Up @@ -1370,16 +1312,6 @@ private GraphViewExecutionOperator ConstructOperator2(GraphViewCommand command,
}
}

//// Rebuilds the output layout of the context
//context.ClearField();

//foreach (var expr in selectScalarExprList)
//{
// var alias = expr.ColumnName;
// // TODO: Change to Addfield with correct ColumnGraphType
// context.AddField("", alias ?? GremlinKeyword.TableDefaultColumnName, ColumnGraphType.Value);
//}

operatorChain.Add(projectAggregationOp);
context.CurrentExecutionOperator = projectAggregationOp;
}
Expand Down Expand Up @@ -1423,44 +1355,17 @@ public void Union(string a, string b)

partial class WWithPathClause
{
//internal override GraphViewExecutionOperator Generate(GraphViewConnection dbConnection)
//{
// foreach (var path in Paths)
// {
// //path.Item2.SelectElements = new List<WSelectElement>();
// PathOperators.Add(new Tuple<string, GraphViewExecutionOperator, int>(path.Item1,
// path.Item2.Generate(dbConnection), path.Item3));
// }
// if (PathOperators.Count != 0) return PathOperators.First().Item2;
// else return null;
//}

}

partial class WChoose
{
//internal override GraphViewExecutionOperator Generate(GraphViewConnection dbConnection)
//{
// List<GraphViewExecutionOperator> Source = new List<GraphViewExecutionOperator>();
// foreach (var x in InputExpr)
// {
// Source.Add(x.Generate(dbConnection));
// }
// return new ConcatenateOperator(Source);
//}

}

partial class WCoalesce
{
//internal override GraphViewExecutionOperator Generate(GraphViewConnection dbConnection)
//{
// List<GraphViewExecutionOperator> Source = new List<GraphViewExecutionOperator>();
// foreach (var x in InputExpr)
// {
// Source.Add(x.Generate(dbConnection));
// }
// var op = new CoalesceOperator(Source, CoalesceNumber);
// return new OutputOperator(op, op.header, null);
//}

}

partial class WSqlBatch
Expand Down Expand Up @@ -1835,12 +1740,10 @@ internal override GraphViewExecutionOperator Compile(QueryCompilationContext con
}

WSelectQueryBlock.ConstructJsonQueryOnNode(command, matchNode, null, command.Connection.RealPartitionKey);
//WSelectQueryBlock.ConstructJsonQueryOnNodeViaExternalAPI(matchNode, null);

FetchNodeOperator fetchNodeOp = new FetchNodeOperator(
command,
matchNode.AttachedJsonQuery
/*matchNode.AttachedJsonQueryOfNodesViaExternalAPI*/);
matchNode.AttachedJsonQuery);

foreach (string propertyName in matchNode.Properties) {
ColumnGraphType columnGraphType = GraphViewReservedProperties.IsNodeReservedProperty(propertyName)
Expand Down Expand Up @@ -1888,7 +1791,6 @@ internal override GraphViewExecutionOperator Compile(QueryCompilationContext con
//
if (isSendQueryRequired) {
WSelectQueryBlock.ConstructJsonQueryOnNode(command, matchNode, null, command.Connection.RealPartitionKey);
//WSelectQueryBlock.ConstructJsonQueryOnNodeViaExternalAPI(matchNode, null);
}

WBooleanExpression nodeCondition = null;
Expand Down Expand Up @@ -1918,7 +1820,7 @@ internal override GraphViewExecutionOperator Compile(QueryCompilationContext con
TraversalOperator traversalOp = new TraversalOperator(
context.CurrentExecutionOperator, command,
edgeFieldIndex, this.GetTraversalTypeParameter(),
matchNode.AttachedJsonQuery/*, matchNode.AttachedJsonQueryOfNodesViaExternalAPI*/, null, booleanFunction);
matchNode.AttachedJsonQuery, null, booleanFunction);
context.CurrentExecutionOperator = traversalOp;

// Update context's record layout
Expand Down Expand Up @@ -3655,4 +3557,3 @@ internal override GraphViewExecutionOperator Compile(QueryCompilationContext con
}
}
}