You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by sk...@apache.org on 2019/07/23 23:52:54 UTC
[phoenix] branch 4.14-HBase-1.4 updated: PHOENIX-5382 : Improved
performace with Bulk operations over iterations
This is an automated email from the ASF dual-hosted git repository.
skadam pushed a commit to branch 4.14-HBase-1.4
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.14-HBase-1.4 by this push:
new 2ac2cda PHOENIX-5382 : Improved performace with Bulk operations over iterations
2ac2cda is described below
commit 2ac2cda33ca8b6d788c744584906f5f043df27c7
Author: Viraj Jasani <vj...@salesforce.com>
AuthorDate: Wed Jul 10 16:53:59 2019 +0530
PHOENIX-5382 : Improved performace with Bulk operations over iterations
Signed-off-by: s.kadam <sk...@apache.org>
---
.../main/java/org/apache/phoenix/compile/FromCompiler.java | 4 +++-
.../org/apache/phoenix/query/ConnectionQueryServicesImpl.java | 5 +++--
.../main/java/org/apache/phoenix/util/CSVCommonsLoader.java | 11 ++---------
.../src/main/java/org/apache/phoenix/util/Closeables.java | 5 ++---
.../src/main/java/org/apache/phoenix/util/SQLCloseables.java | 11 ++++++-----
5 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java
index 3faada7..eb4e6a8 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java
@@ -694,8 +694,10 @@ public class FromCompiler {
protected PTable addDynamicColumns(List<ColumnDef> dynColumns, PTable theTable)
throws SQLException {
if (!dynColumns.isEmpty()) {
- List<PColumn> allcolumns = new ArrayList<PColumn>();
List<PColumn> existingColumns = theTable.getColumns();
+ List<PColumn> allcolumns = new ArrayList<>(
+ theTable.getBucketNum() == null ? existingColumns :
+ existingColumns.subList(1, existingColumns.size()));
// Need to skip the salting column, as it's added in the makePTable call below
allcolumns.addAll(theTable.getBucketNum() == null ? existingColumns : existingColumns.subList(1, existingColumns.size()));
// Position still based on with the salting columns
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 1ab402e..5047991 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -3253,8 +3253,9 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
mutateTable.setInt(6, numColumns + 1);
mutateTable.execute();
}
- List<Mutation> tableMetadata = new ArrayList<>();
- tableMetadata.addAll(metaConnection.getMutationState().toMutations(metaConnection.getSCN()).next().getSecond());
+ List<Mutation> tableMetadata = new ArrayList<>(
+ metaConnection.getMutationState().toMutations(metaConnection.getSCN()).next()
+ .getSecond());
metaConnection.rollback();
PColumn column = new PColumnImpl(PNameFactory.newName("COLUMN_QUALIFIER"),
PNameFactory.newName(DEFAULT_COLUMN_FAMILY_NAME), PVarbinary.INSTANCE, null, null, true, numColumns,
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/CSVCommonsLoader.java b/phoenix-core/src/main/java/org/apache/phoenix/util/CSVCommonsLoader.java
index a5f0177..59ed9cf 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/CSVCommonsLoader.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/CSVCommonsLoader.java
@@ -158,11 +158,7 @@ public class CSVCommonsLoader {
* @return
*/
public static char asControlCharacter(char delimiter) {
- if(CTRL_CHARACTER_TABLE.containsKey(delimiter)) {
- return CTRL_CHARACTER_TABLE.get(delimiter);
- } else {
- return delimiter;
- }
+ return CTRL_CHARACTER_TABLE.getOrDefault(delimiter, delimiter);
}
/**
@@ -242,10 +238,7 @@ public class CSVCommonsLoader {
System.out.println(String.format("csv columns from database."));
break;
case IN_LINE:
- columns = new ArrayList<String>();
- for (String colName : parser.getHeaderMap().keySet()) {
- columns.add(colName); // iterates in column order
- }
+ columns = new ArrayList<>(parser.getHeaderMap().keySet());
System.out.println(String.format("csv columns from header line. length=%s, %s",
columns.size(), buildStringFromList(columns)));
break;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/Closeables.java b/phoenix-core/src/main/java/org/apache/phoenix/util/Closeables.java
index 3046929..66aa652 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/Closeables.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/Closeables.java
@@ -26,6 +26,7 @@ import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.LinkedList;
@@ -136,9 +137,7 @@ public class Closeables {
0);
frames.add(header);
- for (StackTraceElement ste : exception.getStackTrace()) {
- frames.add(ste);
- }
+ Collections.addAll(frames, exception.getStackTrace());
exceptionNum++;
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/SQLCloseables.java b/phoenix-core/src/main/java/org/apache/phoenix/util/SQLCloseables.java
index 77ce6d6..2f273c5 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/SQLCloseables.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/SQLCloseables.java
@@ -18,7 +18,10 @@
package org.apache.phoenix.util;
import java.sql.SQLException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
import com.google.common.collect.Iterables;
@@ -83,7 +86,7 @@ public class SQLCloseables {
private boolean hasSetStackTrace;
/**
- * Use the {@link #fromIOExceptions(Collection) factory}.
+ * Use the {@link #fromSQLExceptions(Collection) factory}.
*/
private MultipleCausesSQLException(Collection<? extends SQLException> exceptions) {
this.exceptions = exceptions;
@@ -113,9 +116,7 @@ public class SQLCloseables {
0);
frames.add(header);
- for (StackTraceElement ste : exception.getStackTrace()) {
- frames.add(ste);
- }
+ Collections.addAll(frames, exception.getStackTrace());
exceptionNum++;
}