Skip to content

Commit

Permalink
TEIID-5003 deprecating BatchedCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Jul 20, 2017
1 parent be4a203 commit ca95f31
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 17 deletions.
4 changes: 4 additions & 0 deletions api/src/main/java/org/teiid/language/BatchedCommand.java
Expand Up @@ -21,6 +21,10 @@
import java.util.Iterator;
import java.util.List;

/**
* @see BulkCommand
*/
@Deprecated
public interface BatchedCommand extends Command {

Iterator<? extends List<?>> getParameterValues();
Expand Down
40 changes: 40 additions & 0 deletions api/src/main/java/org/teiid/language/BulkCommand.java
@@ -0,0 +1,40 @@
/*
* JBoss, Home of Professional Open Source.
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership. Some portions may be licensed
* to Red Hat, Inc. under one or more contributor license agreements.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/

package org.teiid.language;

import java.util.Iterator;
import java.util.List;

/**
* A command the can optionally provide bulk values for {@link Parameter}s
*/
public interface BulkCommand extends BatchedCommand {

/**
* The {@link Parameter} values. May be null.
*/
Iterator<? extends List<?>> getParameterValues();

void setParameterValues(Iterator<? extends List<?>> values);

}
2 changes: 1 addition & 1 deletion api/src/main/java/org/teiid/language/Delete.java
Expand Up @@ -26,7 +26,7 @@
/**
* Represents a DELETE command.
*/
public class Delete extends BaseLanguageObject implements BatchedCommand {
public class Delete extends BaseLanguageObject implements BulkCommand {

private NamedTable table;
private Condition where;
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/teiid/language/Insert.java
Expand Up @@ -24,7 +24,7 @@
import org.teiid.language.visitor.LanguageObjectVisitor;


public class Insert extends BaseLanguageObject implements BatchedCommand {
public class Insert extends BaseLanguageObject implements BulkCommand {

private NamedTable table;
private List<ColumnReference> columns;
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/teiid/language/Parameter.java
Expand Up @@ -45,7 +45,7 @@ public void setValueIndex(int valueIndex) {
}

/**
* 0-based index of the parameter values in the {@link BatchedCommand#getParameterValues()} row value
* 0-based index of the parameter values in the {@link BulkCommand#getParameterValues()} row value
* @return
*/
public int getValueIndex() {
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/teiid/language/Update.java
Expand Up @@ -26,7 +26,7 @@
/**
* Represents an UPDATE command in the language objects.
*/
public class Update extends BaseLanguageObject implements BatchedCommand {
public class Update extends BaseLanguageObject implements BulkCommand {

private NamedTable table;
private List<SetClause> changes;
Expand Down
Expand Up @@ -25,8 +25,8 @@
import java.util.List;

import org.teiid.core.types.BinaryType;
import org.teiid.language.BatchedCommand;
import org.teiid.language.BatchedUpdates;
import org.teiid.language.BulkCommand;
import org.teiid.language.Command;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
Expand Down Expand Up @@ -90,8 +90,8 @@ private void internalExecute() throws TranslatorException {
String cql = visitor.getTranslatedSQL();
LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Source-Query:", cql); //$NON-NLS-1$
this.executionContext.logCommand(cql);
if (this.command instanceof BatchedCommand) {
BatchedCommand bc = (BatchedCommand)this.command;
if (this.command instanceof BulkCommand) {
BulkCommand bc = (BulkCommand)this.command;
if (bc.getParameterValues() != null) {
int count = 0;
List<Object[]> newValues = new ArrayList<Object[]>();
Expand Down
Expand Up @@ -30,8 +30,8 @@
import java.util.List;

import org.teiid.GeneratedKeys;
import org.teiid.language.BatchedCommand;
import org.teiid.language.BatchedUpdates;
import org.teiid.language.BulkCommand;
import org.teiid.language.Command;
import org.teiid.language.Insert;
import org.teiid.language.NamedTable;
Expand Down Expand Up @@ -250,8 +250,8 @@ private void executeTranslatedCommand(TranslatedCommand translatedComm) throws T
}
statement = pstatement;
Iterator<? extends List<?>> vi = null;
if (command instanceof BatchedCommand) {
BatchedCommand batchCommand = (BatchedCommand)command;
if (command instanceof BulkCommand) {
BulkCommand batchCommand = (BulkCommand)command;
vi = batchCommand.getParameterValues();
}

Expand Down
Expand Up @@ -22,7 +22,7 @@

import java.util.List;

import org.teiid.language.BatchedCommand;
import org.teiid.language.BulkCommand;
import org.teiid.language.Command;
import org.teiid.language.Literal;
import org.teiid.language.Parameter;
Expand Down Expand Up @@ -72,7 +72,7 @@ public void translateCommand(Command command) throws TranslatorException {
sqlConversionVisitor.append(command);
this.sql = sqlConversionVisitor.toString();
this.preparedValues = sqlConversionVisitor.getPreparedValues();
this.prepared = command instanceof BatchedCommand?sqlConversionVisitor.isUsingBinding():sqlConversionVisitor.isPrepared();
this.prepared = command instanceof BulkCommand?sqlConversionVisitor.isUsingBinding():sqlConversionVisitor.isPrepared();
}

/**
Expand Down
Expand Up @@ -58,8 +58,8 @@
import org.teiid.dqp.message.AtomicRequestID;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.AtomicResultsMessage;
import org.teiid.language.BatchedCommand;
import org.teiid.language.BatchedUpdates;
import org.teiid.language.BulkCommand;
import org.teiid.language.Call;
import org.teiid.logging.CommandLogMessage.Event;
import org.teiid.logging.LogConstants;
Expand Down Expand Up @@ -379,7 +379,7 @@ private void setExecution(Command command,
this.execution = Assertion.isInstanceOf(exec, ResultSetExecution.class, "QueryExpression Executions are expected to be ResultSetExecutions"); //$NON-NLS-1$
} else {
final boolean singleUpdateCount = connector.returnsSingleUpdateCount()
&& (translatedCommand instanceof BatchedUpdates || (translatedCommand instanceof BatchedCommand && ((BatchedCommand)translatedCommand).getParameterValues() != null));
&& (translatedCommand instanceof BatchedUpdates || (translatedCommand instanceof BulkCommand && ((BulkCommand)translatedCommand).getParameterValues() != null));

Assertion.isInstanceOf(exec, UpdateExecution.class, "Update Executions are expected to be UpdateExecutions"); //$NON-NLS-1$
this.execution = new ResultSetExecution() {
Expand Down
Expand Up @@ -926,7 +926,7 @@ org.teiid.language.Insert translate(Insert insert) {
return result;
}

private void setBatchValues(BatchedCommand bc) {
private void setBatchValues(BulkCommand bc) {
if (valueIndex == 0) {
return;
}
Expand Down
Expand Up @@ -22,8 +22,8 @@
import java.util.Arrays;
import java.util.List;

import org.teiid.language.BatchedCommand;
import org.teiid.language.BatchedUpdates;
import org.teiid.language.BulkCommand;
import org.teiid.language.Command;
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.translator.DataNotAvailableException;
Expand Down Expand Up @@ -55,7 +55,7 @@ public Execution createExecution(Command command, ExecutionContext executionCont
executionCount++;
commands.add(command);
FakeExecution result = new FakeExecution(executionContext);
if (command instanceof BatchedUpdates || (command instanceof BatchedCommand && ((BatchedCommand)command).getParameterValues() != null)) {
if (command instanceof BatchedUpdates || (command instanceof BulkCommand && ((BulkCommand)command).getParameterValues() != null)) {
result.batchOrBulk = true;
}
return result;
Expand Down

0 comments on commit ca95f31

Please sign in to comment.