CompiledComparison extends AbstractCompiledValue implements Negatable, OQLLexerTokenTypes, Indexable { @Override public int getSizeEstimate(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { IndexInfo[] idxInfo = getIndexInfo(context); if (idxInfo != null && idxInfo.length > 1) { return 0; } if (idxInfo == null) { return 1; } assert idxInfo.length == 1; Object key = idxInfo[0].evaluateIndexKey(context); if (key != null && key.equals(QueryService.UNDEFINED)) { return 0; } if (context instanceof QueryExecutionContext) { QueryExecutionContext qcontext = (QueryExecutionContext) context; if (qcontext.isHinted(idxInfo[0]._index.getName())) { return qcontext.getHintSize(idxInfo[0]._index.getName()); } } int op = reflectOnOperator(idxInfo[0]._key()); return idxInfo[0]._index.getSizeEstimate(key, op, idxInfo[0]._matchLevel); } CompiledComparison(CompiledValue left, CompiledValue right, int op); @Override List getChildren(); @Override int getType(); @Override Object evaluate(ExecutionContext context); @Override SelectResults filterEvaluate(ExecutionContext context, SelectResults intermediateResults,
      boolean completeExpansionNeeded, @Retained CompiledValue iterOperands,
      RuntimeIterator[] indpndntItrs, boolean isIntersection, boolean conditioningNeeded,
      boolean evaluateProjection); @Override SelectResults filterEvaluate(ExecutionContext context, SelectResults intermediateResults); @Override SelectResults auxFilterEvaluate(ExecutionContext context,
      SelectResults intermediateResults); @Override void negate(); @Override Set computeDependencies(ExecutionContext context); @Override boolean isRangeEvaluatable(); @Override int getSizeEstimate(ExecutionContext context); static String getSimpleClassName(Class cls); @Override IndexInfo[] getIndexInfo(ExecutionContext context); @Override boolean isProjectionEvaluationAPossibility(ExecutionContext context); @Override boolean isLimitApplicableAtIndexLevel(ExecutionContext context); @Override boolean isOrderByApplicableAtIndexLevel(ExecutionContext context,
      String canonicalizedOrderByClause); @Override boolean isConditioningNeededForIndex(RuntimeIterator independentIter,
      ExecutionContext context, boolean completeExpnsNeeded); @Override int getOperator(); @Override boolean isBetterFilter(Filter comparedTo, ExecutionContext context, final int thisSize); final CompiledValue _left; final CompiledValue _right; }
@Test public void getSizeEstimateShouldReturnOneWhenThereAreNoIndexes() throws NameResolutionException, TypeMismatchException, FunctionDomainException, QueryInvocationTargetException { assertThat(compiledComparison.getSizeEstimate(queryExecutionContext)).isEqualTo(1); }