You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ch...@apache.org on 2019/07/11 20:37:46 UTC
[phoenix] branch 4.x-HBase-1.5 updated: PHOENIX-5382 : Improved
performace with Bulk operations over iterations
This is an automated email from the ASF dual-hosted git repository.
chinmayskulkarni pushed a commit to branch 4.x-HBase-1.5
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x-HBase-1.5 by this push:
new 4a6b48c PHOENIX-5382 : Improved performace with Bulk operations over iterations
4a6b48c is described below
commit 4a6b48c2b46b60ecade32bad6823d77ff9ca8112
Author: Viraj Jasani <vj...@salesforce.com>
AuthorDate: Wed Jul 10 16:34:33 2019 +0530
PHOENIX-5382 : Improved performace with Bulk operations over iterations
Signed-off-by: Chinmay Kulkarni <ch...@apache.org>
---
.../main/java/org/apache/phoenix/compile/FromCompiler.java | 5 +++--
.../org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java | 7 +++----
.../phoenix/mapreduce/index/PhoenixIndexImportMapper.java | 6 ++----
.../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 ++++++-----
7 files changed, 21 insertions(+), 29 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 9ed206e..3bc15fd 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
@@ -734,10 +734,11 @@ 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();
// Need to skip the salting column, as it's handled in the PTable builder call below
- allcolumns.addAll(theTable.getBucketNum() == null ? existingColumns : existingColumns.subList(1, existingColumns.size()));
+ List<PColumn> allcolumns = new ArrayList<>(
+ theTable.getBucketNum() == null ? existingColumns :
+ existingColumns.subList(1, existingColumns.size()));
// Position still based on with the salting columns
int position = existingColumns.size();
PName defaultFamilyName = PNameFactory.newName(SchemaUtil.getEmptyColumnFamily(theTable));
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index a059b54..cc24511 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@ -744,13 +744,12 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
findAncestorViewsOfIndex(tenantId, schemaName, tableName, viewFinderResult,
table.isNamespaceMapped());
}
- if (viewFinderResult.getLinks().isEmpty()) {
+ List<TableInfo> tableViewInfoList = viewFinderResult.getLinks();
+ if (tableViewInfoList.isEmpty()) {
// no need to combine columns for local indexes on regular tables
return table;
}
- for (TableInfo viewInfo : viewFinderResult.getLinks()) {
- ancestorList.add(viewInfo);
- }
+ ancestorList.addAll(tableViewInfoList);
List<PColumn> allColumns = Lists.newArrayList();
List<PColumn> excludedColumns = Lists.newArrayList();
// add my own columns first in reverse order
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportMapper.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportMapper.java
index b1a14b4..14ffe73 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportMapper.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportMapper.java
@@ -140,13 +140,11 @@ public class PhoenixIndexImportMapper extends Mapper<NullWritable, PhoenixIndexD
}
for (List<Cell> cellList : mutation.getFamilyCellMap().values()) {
List<KeyValue>keyValueList = preUpdateProcessor.preUpsert(mutation.getRow(), KeyValueUtil.ensureKeyValues(cellList));
- for (KeyValue keyValue : keyValueList) {
- keyValues.add(keyValue);
- }
+ keyValues.addAll(keyValueList);
}
}
}
- Collections.sort(keyValues, pconn.getKeyValueBuilder().getKeyValueComparator());
+ keyValues.sort(pconn.getKeyValueBuilder().getKeyValueComparator());
for (KeyValue kv : keyValues) {
outputKey.set(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength());
context.write(outputKey, kv);
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 04034ca..e9fd074 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
@@ -3747,8 +3747,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++;
}