Package com.arcadedb.query.sql.parser
Class BinaryCondition
- java.lang.Object
-
- com.arcadedb.query.sql.parser.SimpleNode
-
- com.arcadedb.query.sql.parser.BooleanExpression
-
- com.arcadedb.query.sql.parser.BinaryCondition
-
- All Implemented Interfaces:
Node
public class BinaryCondition extends BooleanExpression
-
-
Field Summary
Fields Modifier and Type Field Description protected Expression
left
protected BinaryCompareOperator
operator
protected Expression
right
-
Fields inherited from class com.arcadedb.query.sql.parser.BooleanExpression
FALSE, TRUE
-
Fields inherited from class com.arcadedb.query.sql.parser.SimpleNode
children, firstToken, id, lastToken, parent, parser, value
-
-
Constructor Summary
Constructors Constructor Description BinaryCondition(int id)
BinaryCondition(SqlParser p, int id)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allowsIndexedFunctionExecutionOnTarget(FromClause target, CommandContext context)
tests if current expression involves an indexed function AND that function can be used on this targetboolean
canExecuteIndexedFunctionWithoutIndex(FromClause target, CommandContext context)
tests if current expression involves an indexed function AND that function can also be executed without using the indexBinaryCondition
copy()
void
deserialize(Result fromResult)
boolean
equals(Object o)
long
estimateIndexed(FromClause target, CommandContext context)
boolean
evaluate(Identifiable currentRecord, CommandContext ctx)
boolean
evaluate(Result currentRecord, CommandContext ctx)
Iterable<Record>
executeIndexedFunction(FromClause target, CommandContext context)
boolean
executeIndexedFunctionAfterIndexSearch(FromClause target, CommandContext context)
tests if current expression involves an indexed function AND the function has also to be executed after the index search.void
extractSubQueries(SubQueryCollector collector)
protected List<Object>
getExternalCalculationConditions()
List<BinaryCondition>
getIndexedFunctionConditions(DocumentType iSchemaClass, Database database)
Expression
getLeft()
List<String>
getMatchPatternInvolvedAliases()
protected int
getNumberOfExternalCalculations()
BinaryCompareOperator
getOperator()
Expression
getRight()
int
hashCode()
boolean
isCacheable()
BinaryCondition
isIndexedFunctionCondition(DocumentType iSchemaClass, Database database)
boolean
needsAliases(Set<String> aliases)
boolean
refersToParent()
Result
serialize()
void
setLeft(Expression left)
void
setOperator(BinaryCompareOperator operator)
void
setRight(Expression right)
protected boolean
supportsBasicCalculation()
void
toString(Map<String,Object> params, StringBuilder builder)
Optional<UpdateItem>
transformToUpdateItem()
returns the equivalent of current condition as an UPDATE expression with the same syntax, if possible.-
Methods inherited from class com.arcadedb.query.sql.parser.BooleanExpression
deserializeFromOResult, encapsulateInAndBlock, flatten, isEmpty
-
Methods inherited from class com.arcadedb.query.sql.parser.SimpleNode
childrenAccept, dump, getValue, jjtAccept, jjtAddChild, jjtClose, jjtGetChild, jjtGetFirstToken, jjtGetLastToken, jjtGetNumChildren, jjtGetParent, jjtGetValue, jjtOpen, jjtSetFirstToken, jjtSetLastToken, jjtSetParent, jjtSetValue, toString, toString
-
-
-
-
Field Detail
-
left
protected Expression left
-
operator
protected BinaryCompareOperator operator
-
right
protected Expression right
-
-
Constructor Detail
-
BinaryCondition
public BinaryCondition(int id)
-
BinaryCondition
public BinaryCondition(SqlParser p, int id)
-
-
Method Detail
-
evaluate
public boolean evaluate(Identifiable currentRecord, CommandContext ctx)
- Specified by:
evaluate
in classBooleanExpression
-
evaluate
public boolean evaluate(Result currentRecord, CommandContext ctx)
- Specified by:
evaluate
in classBooleanExpression
-
toString
public void toString(Map<String,Object> params, StringBuilder builder)
- Overrides:
toString
in classSimpleNode
-
supportsBasicCalculation
protected boolean supportsBasicCalculation()
- Specified by:
supportsBasicCalculation
in classBooleanExpression
- Returns:
- true if this expression can be calculated in plain Java, false otherwise
-
getNumberOfExternalCalculations
protected int getNumberOfExternalCalculations()
- Specified by:
getNumberOfExternalCalculations
in classBooleanExpression
- Returns:
- the number of sub-expressions that have to be calculated using an external engine
-
getExternalCalculationConditions
protected List<Object> getExternalCalculationConditions()
- Specified by:
getExternalCalculationConditions
in classBooleanExpression
- Returns:
- the sub-expressions that have to be calculated using an external engine
-
isIndexedFunctionCondition
public BinaryCondition isIndexedFunctionCondition(DocumentType iSchemaClass, Database database)
-
estimateIndexed
public long estimateIndexed(FromClause target, CommandContext context)
-
executeIndexedFunction
public Iterable<Record> executeIndexedFunction(FromClause target, CommandContext context)
-
canExecuteIndexedFunctionWithoutIndex
public boolean canExecuteIndexedFunctionWithoutIndex(FromClause target, CommandContext context)
tests if current expression involves an indexed function AND that function can also be executed without using the index- Parameters:
target
- the query targetcontext
- the execution context- Returns:
- true if current expression involves an indexed function AND that function can be used on this target, false otherwise
-
allowsIndexedFunctionExecutionOnTarget
public boolean allowsIndexedFunctionExecutionOnTarget(FromClause target, CommandContext context)
tests if current expression involves an indexed function AND that function can be used on this target- Parameters:
target
- the query targetcontext
- the execution context- Returns:
- true if current expression involves an indexed function AND that function can be used on this target, false otherwise
-
executeIndexedFunctionAfterIndexSearch
public boolean executeIndexedFunctionAfterIndexSearch(FromClause target, CommandContext context)
tests if current expression involves an indexed function AND the function has also to be executed after the index search. In some cases, the index search is accurate, so this condition can be excluded from further evaluation. In other cases the result from the index is a superset of the expected result, so the function has to be executed anyway for further filtering- Parameters:
target
- the query targetcontext
- the execution context- Returns:
- true if current expression involves an indexed function AND the function has also to be executed after the index search.
-
getIndexedFunctionConditions
public List<BinaryCondition> getIndexedFunctionConditions(DocumentType iSchemaClass, Database database)
- Overrides:
getIndexedFunctionConditions
in classBooleanExpression
-
needsAliases
public boolean needsAliases(Set<String> aliases)
- Specified by:
needsAliases
in classBooleanExpression
-
copy
public BinaryCondition copy()
- Specified by:
copy
in classBooleanExpression
-
extractSubQueries
public void extractSubQueries(SubQueryCollector collector)
- Specified by:
extractSubQueries
in classBooleanExpression
-
refersToParent
public boolean refersToParent()
- Specified by:
refersToParent
in classBooleanExpression
-
transformToUpdateItem
public Optional<UpdateItem> transformToUpdateItem()
Description copied from class:BooleanExpression
returns the equivalent of current condition as an UPDATE expression with the same syntax, if possible.Eg. name = 3 can be considered a condition or an assignment. This method transforms the condition in an assignment. This is used mainly for UPSERT operations.
- Overrides:
transformToUpdateItem
in classBooleanExpression
- Returns:
- the equivalent of current condition as an UPDATE expression with the same syntax, if possible.
-
getLeft
public Expression getLeft()
-
getOperator
public BinaryCompareOperator getOperator()
-
getRight
public Expression getRight()
-
setLeft
public void setLeft(Expression left)
-
setOperator
public void setOperator(BinaryCompareOperator operator)
-
setRight
public void setRight(Expression right)
-
getMatchPatternInvolvedAliases
public List<String> getMatchPatternInvolvedAliases()
- Specified by:
getMatchPatternInvolvedAliases
in classBooleanExpression
-
serialize
public Result serialize()
- Overrides:
serialize
in classBooleanExpression
-
deserialize
public void deserialize(Result fromResult)
- Overrides:
deserialize
in classBooleanExpression
-
isCacheable
public boolean isCacheable()
- Specified by:
isCacheable
in classBooleanExpression
-
-