dlmarion commented on code in PR #5355:
URL: https://github.com/apache/accumulo/pull/5355#discussion_r1970650444


##########
server/manager/src/test/java/org/apache/accumulo/manager/tableOps/bulkVer2/LoadFilesTest.java:
##########
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.manager.tableOps.bulkVer2;
+
+import static 
org.apache.accumulo.manager.tableOps.bulkVer2.PrepBulkImportTest.nke;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.accumulo.core.clientImpl.bulk.Bulk.FileInfo;
+import org.apache.accumulo.core.clientImpl.bulk.Bulk.Files;
+import org.apache.accumulo.core.clientImpl.bulk.LoadMappingIterator;
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.dataImpl.KeyExtent;
+import org.apache.accumulo.core.fate.FateTxId;
+import org.apache.accumulo.core.metadata.schema.TabletMetadata;
+import org.apache.accumulo.core.metadata.schema.TabletsMetadata;
+import org.apache.accumulo.manager.Manager;
+import 
org.apache.accumulo.manager.tableOps.bulkVer2.LoadFiles.TabletsMetadataFactory;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.Text;
+import org.easymock.EasyMock;
+import org.junit.jupiter.api.Test;
+
+public class LoadFilesTest {
+
+  public static class TestTabletsMetadata extends TabletsMetadata {
+
+    public TestTabletsMetadata(AutoCloseable closeable, 
Iterable<TabletMetadata> tmi) {
+      super(closeable, tmi);
+    }
+
+  }
+
+  private static class CaptureLoader extends LoadFiles.Loader {
+
+    private static class LoadResult {
+      private final List<TabletMetadata> tablets;
+      private final Files files;
+
+      public LoadResult(List<TabletMetadata> tablets, Files files) {
+        super();
+        this.tablets = tablets;
+        this.files = files;
+      }
+
+      public List<TabletMetadata> getTablets() {
+        return tablets;
+      }
+
+      public Files getFiles() {
+        return files;
+      }
+
+    }
+
+    private final List<LoadResult> results = new ArrayList<>();
+
+    @Override
+    void load(List<TabletMetadata> tablets, Files files) {
+      results.add(new LoadResult(tablets, files));
+    }
+
+    public List<LoadResult> getLoadResults() {
+      return results;
+    }
+
+    @Override
+    long finish() {
+      return 0;
+    }
+
+  }
+
+  @Test
+  public void testFindOverlappingFiles() {
+
+    TableId tid = TableId.of("1a");
+    List<TabletMetadata> tm = new ArrayList<>();
+    tm.add(TabletMetadata.create(tid.canonical(), null, "a"));
+    for (int i = 97; i < 122; i++) {
+      tm.add(TabletMetadata.create(tid.canonical(), "" + (char) (i), "" + 
(char) (i + 1)));
+    }
+    tm.add(TabletMetadata.create(tid.canonical(), "z", null));
+
+    String fmtTid = FateTxId.formatTid(1234L);
+    List<TabletMetadata> tablets = LoadFiles.findOverlappingTablets(fmtTid,
+        new KeyExtent(tid, new Text("c"), null), tm.iterator());
+    assertEquals(3, tablets.size());
+    assertEquals(tm.get(0), tablets.get(0));
+    assertEquals(tm.get(1), tablets.get(1));
+    assertEquals(tm.get(2), tablets.get(2));
+
+    tablets = LoadFiles.findOverlappingTablets(fmtTid, new KeyExtent(tid, 
null, new Text("x")),
+        tm.iterator());
+    assertEquals(3, tablets.size());
+    assertEquals(tm.get(tm.size() - 3), tablets.get(tablets.size() - 3));
+    assertEquals(tm.get(tm.size() - 2), tablets.get(tablets.size() - 2));
+    assertEquals(tm.get(tm.size() - 1), tablets.get(tablets.size() - 1));
+
+    tablets =
+        LoadFiles.findOverlappingTablets(fmtTid, new KeyExtent(tid, null, 
null), tm.iterator());
+    assertEquals(tm, tablets);
+
+  }
+
+  @Test
+  public void testLoadFiles() throws Exception {
+
+    TableId tid = TableId.of("1");
+    List<TabletMetadata> tm = new ArrayList<>();
+    tm.add(TabletMetadata.create(tid.canonical(), null, "a"));
+    for (int i = 97; i < 122; i++) {

Review Comment:
   Updated in b217cfe



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to