This is an automated email from the ASF dual-hosted git repository. chinmayskulkarni pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push: new 3b31923 PHOENIX-5382 : Improved performace with Bulk operations over iterations 3b31923 is described below commit 3b31923d4c698ee2a38f5b9db104892a194e2131 Author: Viraj Jasani <vjas...@salesforce.com> AuthorDate: Sat Jun 29 23:41:22 2019 +0530 PHOENIX-5382 : Improved performace with Bulk operations over iterations Signed-off-by: Chinmay Kulkarni <chinmayskulka...@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 9f7bc8e..943c0d4 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 68cdcfe..7dca023 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 @@ -749,13 +749,12 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements RegionCopr 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 567a642..74cc3dd 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<Cell>keyValueList = preUpdateProcessor.preUpsert(mutation.getRow(), cellList); - for (Cell keyValue : keyValueList) { - keyValues.add(keyValue); - } + keyValues.addAll(keyValueList); } } } - Collections.sort(keyValues, pconn.getKeyValueBuilder().getKeyValueComparator()); + keyValues.sort(pconn.getKeyValueBuilder().getKeyValueComparator()); for (Cell kv : keyValues) { outputKey.set(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength()); context.write(outputKey, PhoenixKeyValueUtil.maybeCopyCell(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 efbed64..27fb417 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 @@ -3767,8 +3767,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++; }