You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2019/12/19 18:24:03 UTC
[accumulo] branch master updated: Return TableId type in KeyExtent
method
This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/master by this push:
new 01506c6 Return TableId type in KeyExtent method
01506c6 is described below
commit 01506c6dd313a6bca42411f12f92839da29ac1d1
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Thu Dec 19 13:22:24 2019 -0500
Return TableId type in KeyExtent method
Stop unnecessary conversions of tableId to bytes and back in KeyExtent
utility method.
---
.../java/org/apache/accumulo/core/dataImpl/KeyExtent.java | 4 ++--
.../org/apache/accumulo/server/fs/VolumeManagerImpl.java | 4 ++--
.../apache/accumulo/test/replication/ReplicationIT.java | 14 ++++++--------
3 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/core/src/main/java/org/apache/accumulo/core/dataImpl/KeyExtent.java b/core/src/main/java/org/apache/accumulo/core/dataImpl/KeyExtent.java
index ad08785..5bded9b 100644
--- a/core/src/main/java/org/apache/accumulo/core/dataImpl/KeyExtent.java
+++ b/core/src/main/java/org/apache/accumulo/core/dataImpl/KeyExtent.java
@@ -451,10 +451,10 @@ public class KeyExtent implements WritableComparable<KeyExtent> {
}
}
- public static byte[] tableOfMetadataRow(Text row) {
+ public static TableId tableOfMetadataRow(Text row) {
KeyExtent ke = new KeyExtent();
ke.decodeMetadataRow(row);
- return ke.getTableId().canonical().getBytes(UTF_8);
+ return ke.getTableId();
}
public boolean contains(final ByteSequence bsrow) {
diff --git a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
index 6ca4b49..dbe75a4 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
@@ -392,8 +392,8 @@ public class VolumeManagerImpl implements VolumeManager {
public Path getFullPath(Key key) {
// TODO sanity check col fam
String relPath = key.getColumnQualifierData().toString();
- byte[] tableId = KeyExtent.tableOfMetadataRow(key.getRow());
- return getFullPath(TableId.of(new String(tableId)), relPath);
+ TableId tableId = KeyExtent.tableOfMetadataRow(key.getRow());
+ return getFullPath(tableId, relPath);
}
@Override
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java b/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java
index ebb1532..5fe22da 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java
@@ -18,7 +18,6 @@
*/
package org.apache.accumulo.test.replication;
-import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Collections.singletonMap;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import static org.junit.Assert.assertEquals;
@@ -153,15 +152,14 @@ public class ReplicationIT extends ConfigurableMacBase {
private Multimap<String,TableId> getLogs(AccumuloClient client, ServerContext context)
throws Exception {
// Map of server to tableId
- Multimap<TServerInstance,String> serverToTableID = HashMultimap.create();
+ Multimap<TServerInstance,TableId> serverToTableID = HashMultimap.create();
try (Scanner scanner = client.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
scanner.setRange(MetadataSchema.TabletsSection.getRange());
scanner.fetchColumnFamily(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME);
for (Entry<Key,Value> entry : scanner) {
- TServerInstance key =
- new TServerInstance(entry.getValue(), entry.getKey().getColumnQualifier());
- byte[] tableId = KeyExtent.tableOfMetadataRow(entry.getKey().getRow());
- serverToTableID.put(key, new String(tableId, UTF_8));
+ var tServer = new TServerInstance(entry.getValue(), entry.getKey().getColumnQualifier());
+ TableId tableId = KeyExtent.tableOfMetadataRow(entry.getKey().getRow());
+ serverToTableID.put(tServer, tableId);
}
// Map of logs to tableId
Multimap<String,TableId> logs = HashMultimap.create();
@@ -169,8 +167,8 @@ public class ReplicationIT extends ConfigurableMacBase {
for (Entry<TServerInstance,List<UUID>> entry : wals.getAllMarkers().entrySet()) {
for (UUID id : entry.getValue()) {
Pair<WalState,Path> state = wals.state(entry.getKey(), id);
- for (String tableId : serverToTableID.get(entry.getKey())) {
- logs.put(state.getSecond().toString(), TableId.of(tableId));
+ for (TableId tableId : serverToTableID.get(entry.getKey())) {
+ logs.put(state.getSecond().toString(), tableId);
}
}
}