CompiledComparison extends AbstractCompiledValue implements Negatable, OQLLexerTokenTypes, Indexable { @Override public Object evaluate(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { Object left = _left.evaluate(context); Object right = _right.evaluate(context); if (context.isCqQueryContext() && left instanceof Region.Entry) { try { left = ((Region.Entry<?, ?>) left).getValue(); } catch (EntryDestroyedException ex) { left = null; } } if (context.isCqQueryContext() && right instanceof Region.Entry) { try { right = ((Region.Entry<?, ?>) right).getValue(); } catch (EntryDestroyedException ex) { right = null; } } if (left == null || right == null) { return TypeUtils.compare(left, right, _operator); } if (!context.getCache().getPdxReadSerialized()) { if (left instanceof PdxInstance && !(right instanceof PdxInstance) && ((PdxInstance) left).getClassName().equals(right.getClass().getName())) { left = ((PdxInstance) left).getObject(); } else if (right instanceof PdxInstance && !(left instanceof PdxInstance) && ((PdxInstance) right).getClassName().equals(left.getClass().getName())) { right = ((PdxInstance) right).getObject(); } } if (left instanceof PdxString) { if (right instanceof String) { switch (_right.getType()) { case LITERAL: right = ((CompiledLiteral) _right).getSavedPdxString(); break; case QUERY_PARAM: right = ((CompiledBindArgument) _right).getSavedPdxString(context); break; case FUNCTION: case PATH: right = new PdxString((String) right); } } } else if (right instanceof PdxString) { switch (_left.getType()) { case LITERAL: left = ((CompiledLiteral) _left).getSavedPdxString(); break; case QUERY_PARAM: left = ((CompiledBindArgument) _left).getSavedPdxString(context); break; case FUNCTION: case PATH: left = new PdxString((String) left); } } return TypeUtils.compare(left, right, _operator); } 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 evaluateHandlesEntryDestroyedExceptionThrownByRegionEntryGetValue() throws NameResolutionException, TypeMismatchException, QueryInvocationTargetException, FunctionDomainException { CompiledValue left = mock(CompiledValue.class); CompiledValue right = mock(CompiledValue.class); ExecutionContext context = mock(ExecutionContext.class); when(context.isCqQueryContext()).thenReturn(true); Region.Entry<?, ?> leftEntry = mock(Region.Entry.class); when(left.evaluate(context)).thenReturn(leftEntry); when(leftEntry.getValue()).thenThrow(new EntryDestroyedException()); Region.Entry<?, ?> rightEntry = mock(Region.Entry.class); when(right.evaluate(context)).thenReturn(rightEntry); when(rightEntry.getValue()).thenThrow(new EntryDestroyedException()); CompiledComparison comparison = spy(new CompiledComparison(left, right, OQLLexerTokenTypes.TOK_EQ)); comparison.evaluate(context); }