@Test public void testRequiresTransaction() throws Exception { ProcessorPlan[] plans = new ProcessorPlan[2]; plans[0] = new FakeProcessorPlan(1); plans[1] = new FakeProcessorPlan(1) { public Boolean requiresTransaction(boolean transactionalReads) { return true; } }; BatchedUpdatePlan plan = new BatchedUpdatePlan(Arrays.asList(plans), plans.length, null, true); assertTrue(plan.requiresTransaction(false)); }
@Override public Boolean requiresTransaction(boolean transactionalReads) { if (!singleResult) { for (int i = 0; i < updatePlans.length; i++) { Boolean requires = updatePlans[i].requiresTransaction(transactionalReads); if (requires != null && requires) { startTxn[i] = true; } } return false; } boolean possible = false; for (int i = 0; i < updatePlans.length; i++) { Boolean requires = updatePlans[i].requiresTransaction(transactionalReads); if (requires != null) { if (requires) { return true; } } else { if (possible) { return true; } possible = true; } } if (possible) { return null; } return false; }
BatchedUpdatePlan extends ProcessorPlan { @Override public Boolean requiresTransaction(boolean transactionalReads) { if (!singleResult) { for (int i = 0; i < updatePlans.length; i++) { Boolean requires = updatePlans[i].requiresTransaction(transactionalReads); if (requires != null && requires) { startTxn[i] = true; } } return false; } boolean possible = false; for (int i = 0; i < updatePlans.length; i++) { Boolean requires = updatePlans[i].requiresTransaction(transactionalReads); if (requires != null) { if (requires) { return true; } } else { if (possible) { return true; } possible = true; } } if (possible) { return null; } return false; } }
BatchedUpdatePlan extends ProcessorPlan { @Override public Boolean requiresTransaction(boolean transactionalReads) { if (!singleResult) { for (int i = 0; i < updatePlans.length; i++) { Boolean requires = updatePlans[i].requiresTransaction(transactionalReads); if (requires != null && requires) { startTxn[i] = true; } } return false; } boolean possible = false; for (int i = 0; i < updatePlans.length; i++) { Boolean requires = updatePlans[i].requiresTransaction(transactionalReads); if (requires != null) { if (requires) { return true; } } else { if (possible) { return true; } possible = true; } } if (possible) { return null; } return false; } BatchedUpdatePlan(List<? extends ProcessorPlan> childPlans, int commandsInBatch, List<VariableContext> contexts, boolean singleResult); }
BatchedUpdatePlan extends ProcessorPlan { @Override public Boolean requiresTransaction(boolean transactionalReads) { if (!singleResult) { for (int i = 0; i < updatePlans.length; i++) { Boolean requires = updatePlans[i].requiresTransaction(transactionalReads); if (requires != null && requires) { startTxn[i] = true; } } return false; } boolean possible = false; for (int i = 0; i < updatePlans.length; i++) { Boolean requires = updatePlans[i].requiresTransaction(transactionalReads); if (requires != null) { if (requires) { return true; } } else { if (possible) { return true; } possible = true; } } if (possible) { return null; } return false; } BatchedUpdatePlan(List<? extends ProcessorPlan> childPlans, int commandsInBatch, List<VariableContext> contexts, boolean singleResult); BatchedUpdatePlan clone(); void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr); List getOutputElements(); void open(); TupleBatch nextBatch(); void close(); void reset(); PlanNode getDescriptionProperties(); String toString(); List getUpdatePlans(); @Override Boolean requiresTransaction(boolean transactionalReads); void setSingleResult(boolean singleResult); }
BatchedUpdatePlan extends ProcessorPlan { @Override public Boolean requiresTransaction(boolean transactionalReads) { if (!singleResult) { for (int i = 0; i < updatePlans.length; i++) { Boolean requires = updatePlans[i].requiresTransaction(transactionalReads); if (requires != null && requires) { startTxn[i] = true; } } return false; } boolean possible = false; for (int i = 0; i < updatePlans.length; i++) { Boolean requires = updatePlans[i].requiresTransaction(transactionalReads); if (requires != null) { if (requires) { return true; } } else { if (possible) { return true; } possible = true; } } if (possible) { return null; } return false; } BatchedUpdatePlan(List<? extends ProcessorPlan> childPlans, int commandsInBatch, List<VariableContext> contexts, boolean singleResult); BatchedUpdatePlan clone(); void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr); List getOutputElements(); void open(); TupleBatch nextBatch(); void close(); void reset(); PlanNode getDescriptionProperties(); String toString(); List getUpdatePlans(); @Override Boolean requiresTransaction(boolean transactionalReads); void setSingleResult(boolean singleResult);  }