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/11/07 02:29:45 UTC
[phoenix] branch 4.x-HBase-1.3 updated: PHOENIX-5556 Avoid
repeatedly loading IndexMetaData For IndexRegionObserver
This is an automated email from the ASF dual-hosted git repository.
chenglei pushed a commit to branch 4.x-HBase-1.3
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x-HBase-1.3 by this push:
new 985a16a PHOENIX-5556 Avoid repeatedly loading IndexMetaData For IndexRegionObserver
985a16a is described below
commit 985a16a9e754140159d580bace06411086ec52cc
Author: chenglei <ch...@apache.org>
AuthorDate: Thu Nov 7 10:29:05 2019 +0800
PHOENIX-5556 Avoid repeatedly loading IndexMetaData For IndexRegionObserver
---
.../phoenix/hbase/index/IndexRegionObserver.java | 39 ++++++++++++++--------
.../hbase/index/builder/IndexBuildManager.java | 4 +--
2 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java
index 83a54f6..e8d9a05 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java
@@ -518,16 +518,15 @@ public class IndexRegionObserver extends BaseRegionObserver {
}
}
- private void prepareIndexMutations(ObserverContext<RegionCoprocessorEnvironment> c,
- MiniBatchOperationInProgress<Mutation> miniBatchOp, BatchMutateContext context,
- Collection<? extends Mutation> mutations, long now) throws Throwable {
- IndexMetaData indexMetaData = this.builder.getIndexMetaData(miniBatchOp);
- if (!(indexMetaData instanceof PhoenixIndexMetaData)) {
- throw new DoNotRetryIOException(
- "preBatchMutateWithExceptions: indexMetaData is not an instance of PhoenixIndexMetaData " +
- c.getEnvironment().getRegion().getRegionInfo().getTable().getNameAsString());
- }
- List<IndexMaintainer> maintainers = ((PhoenixIndexMetaData)indexMetaData).getIndexMaintainers();
+ private void prepareIndexMutations(
+ ObserverContext<RegionCoprocessorEnvironment> c,
+ MiniBatchOperationInProgress<Mutation> miniBatchOp,
+ BatchMutateContext context,
+ Collection<? extends Mutation> mutations,
+ long now,
+ PhoenixIndexMetaData indexMetaData) throws Throwable {
+
+ List<IndexMaintainer> maintainers = indexMetaData.getIndexMaintainers();
// get the current span, or just use a null-span to avoid a bunch of if statements
try (TraceScope scope = Trace.startSpan("Starting to build index updates")) {
@@ -538,7 +537,7 @@ public class IndexRegionObserver extends BaseRegionObserver {
// get the index updates for all elements in this batch
Collection<Pair<Pair<Mutation, byte[]>, byte[]>> indexUpdates =
- this.builder.getIndexUpdates(miniBatchOp, mutations);
+ this.builder.getIndexUpdates(miniBatchOp, mutations, indexMetaData);
current.addTimelineAnnotation("Built index updates, doing preStep");
TracingUtils.addAnnotation(current, "index update count", indexUpdates.size());
@@ -607,10 +606,24 @@ public class IndexRegionObserver extends BaseRegionObserver {
}
}
+ protected PhoenixIndexMetaData getPhoenixIndexMetaData(
+ ObserverContext<RegionCoprocessorEnvironment> observerContext,
+ MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException {
+ IndexMetaData indexMetaData = this.builder.getIndexMetaData(miniBatchOp);
+ if (!(indexMetaData instanceof PhoenixIndexMetaData)) {
+ throw new DoNotRetryIOException(
+ "preBatchMutateWithExceptions: indexMetaData is not an instance of "+PhoenixIndexMetaData.class.getName() +
+ ", current table is:" +
+ observerContext.getEnvironment().getRegion().getRegionInfo().getTable().getNameAsString());
+ }
+ return (PhoenixIndexMetaData)indexMetaData;
+ }
+
public void preBatchMutateWithExceptions(ObserverContext<RegionCoprocessorEnvironment> c,
MiniBatchOperationInProgress<Mutation> miniBatchOp) throws Throwable {
ignoreAtomicOperations(miniBatchOp);
- BatchMutateContext context = new BatchMutateContext(this.builder.getIndexMetaData(miniBatchOp).getClientVersion());
+ PhoenixIndexMetaData indexMetaData = getPhoenixIndexMetaData(c, miniBatchOp);
+ BatchMutateContext context = new BatchMutateContext(indexMetaData.getClientVersion());
setBatchMutateContext(c, context);
Mutation firstMutation = miniBatchOp.getOperation(0);
ReplayWrite replayWrite = this.builder.getReplayWrite(firstMutation);
@@ -636,7 +649,7 @@ public class IndexRegionObserver extends BaseRegionObserver {
}
long start = EnvironmentEdgeManager.currentTimeMillis();
- prepareIndexMutations(c, miniBatchOp, context, mutations, now);
+ prepareIndexMutations(c, miniBatchOp, context, mutations, now, indexMetaData);
metricSource.updateIndexPrepareTime(EnvironmentEdgeManager.currentTimeMillis() - start);
// Sleep for one millisecond if we have prepared the index updates in less than 1 ms. The sleep is necessary to
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/builder/IndexBuildManager.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/builder/IndexBuildManager.java
index 6b7e416..7639a49 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/builder/IndexBuildManager.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/builder/IndexBuildManager.java
@@ -81,9 +81,9 @@ public class IndexBuildManager implements Stoppable {
public Collection<Pair<Pair<Mutation, byte[]>, byte[]>> getIndexUpdates(
MiniBatchOperationInProgress<Mutation> miniBatchOp,
- Collection<? extends Mutation> mutations) throws Throwable {
+ Collection<? extends Mutation> mutations,
+ IndexMetaData indexMetaData) throws Throwable {
// notify the delegate that we have started processing a batch
- final IndexMetaData indexMetaData = this.delegate.getIndexMetaData(miniBatchOp);
this.delegate.batchStarted(miniBatchOp, indexMetaData);
// Avoid the Object overhead of the executor when it's not actually parallelizing anything.