internal override GremlinToSqlContext GetContext() { GremlinToSqlContext inputContext = GetInputContext(); if (inputContext.PivotVariable == null) { throw new QueryCompilationException("The PivotVariable can't be null."); } switch (Type) { //has(key) case GremlinHasType.HasProperty: inputContext.PivotVariable.Has(inputContext, PropertyKey); break; //hasNot(key) case GremlinHasType.HasNotProperty: inputContext.PivotVariable.HasNot(inputContext, PropertyKey); break; //has(key, value) | has(key, predicate) case GremlinHasType.HasPropertyValueOrPredicate: inputContext.PivotVariable.Has(inputContext, PropertyKey, ValueOrPredicate); break; //has(key, traversal) case GremlinHasType.HasPropertyTraversal: Traversal.GetStartOp().InheritedVariableFromParent(inputContext); if (Traversal.GetStartOp() is GremlinParentContextOp) { if (Traversal.GremlinTranslationOpList.Count > 1) { Traversal.InsertGremlinOperator(1, new GremlinValuesOp(PropertyKey)); } else { Traversal.AddGremlinOperator(new GremlinValuesOp(PropertyKey)); } } GremlinToSqlContext hasContext = Traversal.GetEndOp().GetContext(); inputContext.AddPredicate(hasContext.ToSqlBoolean()); break; //has(label, key, value) | has(label, key, predicate) case GremlinHasType.HasLabelPropertyValue: inputContext.PivotVariable.Has(inputContext, GremlinKeyword.Label, Label); inputContext.PivotVariable.Has(inputContext, PropertyKey, ValueOrPredicate); break; //hasId(values) case GremlinHasType.HasId: case GremlinHasType.HasLabel: inputContext.PivotVariable.HasIdOrLabel(inputContext, Type, ValuesOrPredicates); break; //=================================================================== //hasKey(values) || hasValue(values) case GremlinHasType.HasKey: case GremlinHasType.HasValue: inputContext.PivotVariable.HasKeyOrValue(inputContext, Type, ValuesOrPredicates); break; } return(inputContext); }
internal override GremlinToSqlContext GetContext() { GremlinToSqlContext inputContext = GetInputContext(); switch (OpType) { //has(key) case HasOpType.HasProperty: inputContext.PivotVariable.Has(inputContext, PropertyKey); break; //has(key, value) case HasOpType.HasPropertyValue: inputContext.PivotVariable.Has(inputContext, PropertyKey, Value); break; //has(key, predicate) case HasOpType.HasPropertyPredicate: inputContext.PivotVariable.Has(inputContext, PropertyKey, Predicate); break; //has(label, key, value) case HasOpType.HasLabelPropertyValue: inputContext.PivotVariable.Has(inputContext, Label, PropertyKey, Value); break; //has(label, key, predicate) case HasOpType.HasLabelPropertyPredicate: inputContext.PivotVariable.Has(inputContext, Label, PropertyKey, Predicate); break; case HasOpType.HasPropertyTraversal: Traversal.GetStartOp().InheritedVariableFromParent(inputContext); if (Traversal.GetStartOp() is GremlinParentContextOp) { if (Traversal.GremlinTranslationOpList.Count > 1) { Traversal.InsertGremlinOperator(1, new GremlinValuesOp(PropertyKey)); } else { Traversal.AddGremlinOperator(new GremlinValuesOp(PropertyKey)); } } GremlinToSqlContext hasContext = Traversal.GetEndOp().GetContext(); inputContext.PivotVariable.Has(inputContext, PropertyKey, hasContext); break; //hasId(values) case HasOpType.HasId: inputContext.PivotVariable.HasId(inputContext, Values); break; //hasId(predicate) case HasOpType.HasIdPredicate: inputContext.PivotVariable.HasId(inputContext, Predicate); break; //hasKey(values) case HasOpType.HasKey: inputContext.PivotVariable.HasKey(inputContext, Keys); break; //hasKey(predicate) case HasOpType.HasKeyPredicate: inputContext.PivotVariable.HasKey(inputContext, Predicate); break; //hasLabel(values) case HasOpType.HasLabel: inputContext.PivotVariable.HasLabel(inputContext, Values); break; //hasLabel(predicate) case HasOpType.HasLabelPredicate: inputContext.PivotVariable.HasLabel(inputContext, Predicate); break; //hasValue(values) case HasOpType.HasValue: inputContext.PivotVariable.HasValue(inputContext, Values); break; //hasValue(predicate) case HasOpType.HasValuePredicate: inputContext.PivotVariable.HasValue(inputContext, Predicate); break; } return(inputContext); }