@SuppressWarnings("unchecked") @Override public MutationPlan compilePlan(PhoenixStatement stmt, Sequence.ValueOp seqAction) throws SQLException { if(!getUdfParseNodes().isEmpty()) { stmt.throwIfUnallowedUserDefinedFunctions(getUdfParseNodes()); } DeleteCompiler compiler = new DeleteCompiler(stmt, this.getOperation()); MutationPlan plan = compiler.compile(this); plan.getContext().getSequenceManager().validateSequences(seqAction); return plan; } }
private List<PTable> getClientSideMaintainedIndexes(TableRef tableRef) { PTable table = tableRef.getTable(); if (!table.getIndexes().isEmpty()) { List<PTable> nonDisabledIndexes = Lists.newArrayListWithExpectedSize(table.getIndexes().size()); for (PTable index : table.getIndexes()) { if (index.getIndexState() != PIndexState.DISABLE && isMaintainedOnClient(index)) { nonDisabledIndexes.add(index); } } return nonDisabledIndexes; } return Collections.emptyList(); }
List<PTable> clientSideIndexes = getClientSideMaintainedIndexes(targetTableRef); final boolean hasClientSideIndexes = !clientSideIndexes.isEmpty();
List<PTable> clientSideIndexes = getClientSideMaintainedIndexes(targetTableRef); final boolean hasClientSideIndexes = !clientSideIndexes.isEmpty();
@Test public void testDelete() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); conn.createStatement().execute("CREATE TABLE t (k INTEGER NOT NULL PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)"); conn.createStatement().execute("CREATE INDEX idx ON t(v1,v2)"); conn.setAutoCommit(true); PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class); SQLParser parser = new SQLParser("DELETE FROM t"); DeleteStatement delete = (DeleteStatement) parser.parseStatement(); DeleteCompiler compiler = new DeleteCompiler(stmt, null); MutationPlan plan = compiler.compile(delete); assertEquals("T", plan.getQueryPlan().getTableRef().getTable().getTableName().getString()); assertTrue(plan.getClass().getName().contains("ServerSelectDeleteMutationPlan")); parser = new SQLParser("DELETE FROM t WHERE v1 = 'foo'"); delete = (DeleteStatement) parser.parseStatement(); plan = compiler.compile(delete); assertEquals("IDX", plan.getQueryPlan().getTableRef().getTable().getTableName().getString()); assertTrue(plan.getClass().getName().contains("ClientSelectDeleteMutationPlan")); }
if (otherTableRefs.isEmpty() || isMaintainedOnClient(table)) { mutations.put(rowKeyPtr, new RowMutationState(PRow.DELETE_MARKER, 0, statement.getConnection().getStatementExecutionCounter(), NULL_ROWTIMESTAMP_INFO, null));
List<PTable> clientSideIndexes = getClientSideMaintainedIndexes(targetTableRef); final boolean hasClientSideIndexes = !clientSideIndexes.isEmpty();
@SuppressWarnings("unchecked") @Override public MutationPlan compilePlan(PhoenixStatement stmt, Sequence.ValueOp seqAction) throws SQLException { if(!getUdfParseNodes().isEmpty()) { stmt.throwIfUnallowedUserDefinedFunctions(getUdfParseNodes()); } DeleteCompiler compiler = new DeleteCompiler(stmt, this.getOperation()); MutationPlan plan = compiler.compile(this); plan.getContext().getSequenceManager().validateSequences(seqAction); return plan; } }
private List<PTable> getClientSideMaintainedIndexes(TableRef tableRef) { PTable table = tableRef.getTable(); if (!table.getIndexes().isEmpty()) { List<PTable> nonDisabledIndexes = Lists.newArrayListWithExpectedSize(table.getIndexes().size()); for (PTable index : table.getIndexes()) { if (index.getIndexState() != PIndexState.DISABLE && isMaintainedOnClient(index)) { nonDisabledIndexes.add(index); } } return nonDisabledIndexes; } return Collections.emptyList(); }
@SuppressWarnings("unchecked") @Override public MutationPlan compilePlan(PhoenixStatement stmt, Sequence.ValueOp seqAction) throws SQLException { if(!getUdfParseNodes().isEmpty()) { stmt.throwIfUnallowedUserDefinedFunctions(getUdfParseNodes()); } DeleteCompiler compiler = new DeleteCompiler(stmt, this.getOperation()); MutationPlan plan = compiler.compile(this); plan.getContext().getSequenceManager().validateSequences(seqAction); return plan; } }
private List<PTable> getClientSideMaintainedIndexes(TableRef tableRef) { PTable table = tableRef.getTable(); if (!table.getIndexes().isEmpty()) { List<PTable> nonDisabledIndexes = Lists.newArrayListWithExpectedSize(table.getIndexes().size()); for (PTable index : table.getIndexes()) { if (index.getIndexState() != PIndexState.DISABLE && isMaintainedOnClient(index)) { nonDisabledIndexes.add(index); } } return nonDisabledIndexes; } return Collections.emptyList(); }
if (otherTableRefs.isEmpty() || isMaintainedOnClient(table)) { mutations.put(rowKeyPtr, new RowMutationState(PRow.DELETE_MARKER, 0, statement.getConnection().getStatementExecutionCounter(), NULL_ROWTIMESTAMP_INFO, null));
if (otherTableRefs.isEmpty() || isMaintainedOnClient(table)) { mutations.put(rowKeyPtr, new RowMutationState(PRow.DELETE_MARKER, 0, statement.getConnection().getStatementExecutionCounter(), NULL_ROWTIMESTAMP_INFO, null));