From 506d27587c39c2b9a5ca1dad53ce9396cae37561 Mon Sep 17 00:00:00 2001 From: DomGarguilo Date: Fri, 15 Dec 2023 09:55:59 -0500 Subject: [PATCH] Replace non api code --- .../testing/continuous/ManySplits.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/accumulo/testing/continuous/ManySplits.java b/src/main/java/org/apache/accumulo/testing/continuous/ManySplits.java index 09262d69..09c32c4e 100644 --- a/src/main/java/org/apache/accumulo/testing/continuous/ManySplits.java +++ b/src/main/java/org/apache/accumulo/testing/continuous/ManySplits.java @@ -18,6 +18,7 @@ */ package org.apache.accumulo.testing.continuous; +import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.NANOSECONDS; import static java.util.concurrent.TimeUnit.SECONDS; @@ -43,11 +44,8 @@ import org.apache.accumulo.core.client.admin.NewTableConfiguration; import org.apache.accumulo.core.conf.ConfigurationTypeHelper; import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.TableId; -import org.apache.accumulo.core.dataImpl.KeyExtent; -import org.apache.accumulo.core.metadata.MetadataTable; -import org.apache.accumulo.core.metadata.schema.DataFileValue; -import org.apache.accumulo.core.metadata.schema.MetadataSchema; import org.apache.accumulo.testing.TestProps; import org.apache.hadoop.io.Text; import org.slf4j.Logger; @@ -225,13 +223,15 @@ public static void main(String[] args) throws Exception { private static Map getTabletFileSizes(AccumuloClient client, String tableName) throws TableNotFoundException, AccumuloException, AccumuloSecurityException { TableId tableId = TableId.of(client.tableOperations().tableIdMap().get(tableName)); - try (Scanner scanner = client.createScanner(MetadataTable.NAME)) { - scanner.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME); - scanner.setRange(new KeyExtent(tableId, null, null).toMetaRange()); + try (Scanner scanner = client.createScanner("accumulo.metadata")) { + scanner.fetchColumnFamily("file"); + scanner.setRange(createMetaRangeForDefaultTablet(tableId.canonical())); Map result = new HashMap<>(); for (var entry : scanner) { - long tabletFileSize = new DataFileValue(entry.getValue().get()).getSize(); + String encodedDFV = new String(entry.getValue().get(), UTF_8); + String[] ba = encodedDFV.split(",", 2); + long tabletFileSize = Long.parseLong(ba[0]); result.merge(entry.getKey().getRow(), tabletFileSize, Long::sum); } @@ -251,4 +251,18 @@ public static String bytesToMemoryString(long bytes) { } } + private static Range createMetaRangeForDefaultTablet(String tableId) { + Text startRow = encodeRowForDefaultTablet(tableId); + Text endRow = new Text(startRow); + endRow.append(new byte[] {0}, 0, 1); + + return new Range(startRow, true, endRow, false); + } + + private static Text encodeRowForDefaultTablet(String tableId) { + Text entry = new Text(tableId); + entry.append(new byte[] {'<'}, 0, 1); // Delimiter for default tablet + return entry; + } + }