accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshelser <...@git.apache.org>
Subject [GitHub] accumulo pull request #159: ACCUMULO-1280: many changes for closing iterator...
Date Tue, 28 Mar 2017 15:54:19 GMT
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/159#discussion_r108461701
  
    --- Diff: core/src/test/java/org/apache/accumulo/core/iterators/system/ColumnFamilySkippingIteratorTest.java
---
    @@ -236,4 +237,45 @@ public void test3() throws Exception {
     
         // System.out.println(ci.getCount());
       }
    +
    +  private static class CloseTestIter extends SortedMapIterator {
    +
    +    int closeCallCount = 0;
    +
    +    public CloseTestIter(SortedMap<Key,Value> map) {
    +      super(map);
    +    }
    +
    +    @Override
    +    public void close() {
    +      System.out.println("Closing inner CloseIterator.");
    +      closeCallCount++;
    +    }
    +  }
    +
    +  public void testClose() throws Exception {
    +    TreeMap<Key,Value> tm = new TreeMap<>();
    +    put(tm, "r1", "cf1", "cq1", 5, "v1");
    +    put(tm, "r1", "cf1", "cq3", 5, "v2");
    +    put(tm, "r2", "cf1", "cq1", 5, "v3");
    +    put(tm, "r2", "cf2", "cq4", 5, "v4");
    +    put(tm, "r2", "cf2", "cq5", 5, "v5");
    +    put(tm, "r3", "cf3", "cq6", 5, "v6");
    +
    +    CloseTestIter closeIter = new CloseTestIter(tm);
    +    ColumnFamilySkippingIterator cfi = new ColumnFamilySkippingIterator(closeIter);
    +
    +    assertEquals(0, closeIter.closeCallCount);
    +    HashSet<ByteSequence> colfams = new HashSet<>();
    +    colfams.add(new ArrayByteSequence("cf2"));
    +    cfi.seek(new Range(), colfams, true);
    +    testAndCallnext(cfi, "r2", "cf2", "cq4", 5, "v4");
    +    testAndCallnext(cfi, "r2", "cf2", "cq5", 5, "v5");
    +    assertFalse(cfi.hasTop());
    +
    +    System.out.println("Closing ColumnFamilySkippingIterator");
    +    cfi.close();
    --- End diff --
    
    Isn't this a bit contrived of a test? :) You're calling a method explicitly and then verifying
that your methods' functions were invoked.
    
    What if you used MAC and created a close method which wrote to some externally visible
location? e.g. a file or a znode.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message