Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BE4DC200B9E for ; Sat, 8 Oct 2016 22:46:52 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BCF59160ADF; Sat, 8 Oct 2016 20:46:52 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B0926160AAD for ; Sat, 8 Oct 2016 22:46:51 +0200 (CEST) Received: (qmail 31058 invoked by uid 500); 8 Oct 2016 20:46:50 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 31045 invoked by uid 99); 8 Oct 2016 20:46:50 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Oct 2016 20:46:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B4D6EE0230; Sat, 8 Oct 2016 20:46:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: elserj@apache.org To: commits@accumulo.apache.org Date: Sat, 08 Oct 2016 20:46:50 -0000 Message-Id: <3aded0ff5a2143c8b7f3cbb9691af8d7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/3] accumulo git commit: ACCUMULO-4494 Add families and inclusive to IteratorTestInput archived-at: Sat, 08 Oct 2016 20:46:52 -0000 Repository: accumulo Updated Branches: refs/heads/1.8 63364d53e -> d2a3f7f5a refs/heads/master c57a3801b -> f206bef21 ACCUMULO-4494 Add families and inclusive to IteratorTestInput Changed the relevant tests to use the new information. Added equals() and hashCode() for good measure. By default the families is empty and inclusive is false, so no existing code should break. Inserted a couple side changes to clear compiler warnings. Closes apache/accumulo#162 Signed-off-by: Josh Elser Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/d2a3f7f5 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/d2a3f7f5 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/d2a3f7f5 Branch: refs/heads/1.8 Commit: d2a3f7f5a32564a2a798141b62fbbec81145085a Parents: 63364d5 Author: Dylan Hutchison Authored: Sat Oct 8 08:39:22 2016 -0700 Committer: Josh Elser Committed: Sat Oct 8 16:22:29 2016 -0400 ---------------------------------------------------------------------- .../iteratortest/IteratorTestInput.java | 70 ++++++++++++++++++-- .../iteratortest/IteratorTestRunner.java | 2 +- .../testcases/DeepCopyTestCase.java | 4 +- .../testcases/IsolatedDeepCopiesTestCase.java | 11 +-- .../testcases/MultipleHasTopCalls.java | 4 +- .../iteratortest/testcases/ReSeekTestCase.java | 10 +-- 6 files changed, 78 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/d2a3f7f5/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/IteratorTestInput.java ---------------------------------------------------------------------- diff --git a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/IteratorTestInput.java b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/IteratorTestInput.java index dfffdeb..5bec064 100644 --- a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/IteratorTestInput.java +++ b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/IteratorTestInput.java @@ -18,12 +18,14 @@ package org.apache.accumulo.iteratortest; import static java.util.Objects.requireNonNull; +import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.SortedMap; import org.apache.accumulo.core.client.IteratorSetting; import org.apache.accumulo.core.client.Scanner; +import org.apache.accumulo.core.data.ByteSequence; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.Value; @@ -37,22 +39,45 @@ public class IteratorTestInput { private final Class> iteratorClass; private final Map iteratorOptions; private final Range range; + private final Collection families; + private final boolean inclusive; private final SortedMap input; /** * Construct an instance of the test input. * * @param iteratorClass - * The class for the iterator to test + * The class for the iterator to test. * @param iteratorOptions - * Options, if any, to provide to the iterator ({@link IteratorSetting}'s Map of properties) + * Options, if any, to provide to the iterator ({@link IteratorSetting}'s Map of properties). * @param range - * The Range of data to query ({@link Scanner#setRange(Range)}) + * The Range of data to query ({@link Scanner#setRange(Range)}). By default no column families filter is specified. * @param input * A sorted collection of Key-Value pairs acting as the table. */ public IteratorTestInput(Class> iteratorClass, Map iteratorOptions, Range range, SortedMap input) { + this(iteratorClass, iteratorOptions, range, input, Collections. emptySet(), false); + } + + /** + * Construct an instance of the test input. + * + * @param iteratorClass + * The class for the iterator to test. + * @param iteratorOptions + * Options, if any, to provide to the iterator ({@link IteratorSetting}'s Map of properties). + * @param range + * The Range of data to query ({@link Scanner#setRange(Range)}) + * @param input + * A sorted collection of Key-Value pairs acting as the table. + * @param families + * Column families passed to {@link SortedKeyValueIterator#seek}. + * @param inclusive + * Whether the families are inclusive or exclusive. + */ + public IteratorTestInput(Class> iteratorClass, Map iteratorOptions, Range range, + SortedMap input, Collection families, boolean inclusive) { // Already immutable this.iteratorClass = requireNonNull(iteratorClass); // Make it immutable to the test @@ -61,6 +86,8 @@ public class IteratorTestInput { this.range = requireNonNull(range); // Make it immutable to the test this.input = Collections.unmodifiableSortedMap((requireNonNull(input))); + this.families = Collections.unmodifiableCollection(requireNonNull(families)); + this.inclusive = inclusive; } public Class> getIteratorClass() { @@ -75,15 +102,44 @@ public class IteratorTestInput { return range; } + public Collection getFamilies() { + return families; + } + + public boolean isInclusive() { + return inclusive; + } + public SortedMap getInput() { return input; } @Override public String toString() { - StringBuilder sb = new StringBuilder(64); - sb.append("[iteratorClass=").append(iteratorClass).append(", iteratorOptions=").append(iteratorOptions).append(", range=").append(range) - .append(", input='").append(input).append("']"); - return sb.toString(); + return "[iteratorClass=" + iteratorClass + ", iteratorOptions=" + iteratorOptions + ", range=" + range + ", families=" + families + ", inclusive=" + + inclusive + ", input='" + input + "']"; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof IteratorTestInput)) + return false; + IteratorTestInput that = (IteratorTestInput) o; + + return inclusive == that.inclusive && iteratorClass.equals(that.iteratorClass) && iteratorOptions.equals(that.iteratorOptions) && range.equals(that.range) + && families.equals(that.families) && input.equals(that.input); + } + + @Override + public int hashCode() { + int result = iteratorClass.hashCode(); + result = 31 * result + iteratorOptions.hashCode(); + result = 31 * result + range.hashCode(); + result = 31 * result + families.hashCode(); + result = 31 * result + (inclusive ? 1 : 0); + result = 31 * result + input.hashCode(); + return result; } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d2a3f7f5/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/IteratorTestRunner.java ---------------------------------------------------------------------- diff --git a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/IteratorTestRunner.java b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/IteratorTestRunner.java index 99825a4..f418073 100644 --- a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/IteratorTestRunner.java +++ b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/IteratorTestRunner.java @@ -72,7 +72,7 @@ public class IteratorTestRunner { for (IteratorTestCase testCase : testCases) { log.info("Invoking {} on {}", testCase.getClass().getName(), testInput.getIteratorClass().getName()); - IteratorTestOutput actualOutput = null; + IteratorTestOutput actualOutput; try { actualOutput = testCase.test(testInput); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d2a3f7f5/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/DeepCopyTestCase.java ---------------------------------------------------------------------- diff --git a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/DeepCopyTestCase.java b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/DeepCopyTestCase.java index 3c3e6da..a5c9abd 100644 --- a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/DeepCopyTestCase.java +++ b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/DeepCopyTestCase.java @@ -17,10 +17,8 @@ package org.apache.accumulo.iteratortest.testcases; import java.io.IOException; -import java.util.Collections; import java.util.TreeMap; -import org.apache.accumulo.core.data.ByteSequence; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.iterators.SortedKeyValueIterator; @@ -44,7 +42,7 @@ public class DeepCopyTestCase extends OutputVerifyingTestCase { SortedKeyValueIterator copy = skvi.deepCopy(new SimpleIteratorEnvironment()); - copy.seek(testInput.getRange(), Collections. emptySet(), false); + copy.seek(testInput.getRange(), testInput.getFamilies(), testInput.isInclusive()); return new IteratorTestOutput(consume(copy)); } catch (IOException e) { return new IteratorTestOutput(e); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d2a3f7f5/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/IsolatedDeepCopiesTestCase.java ---------------------------------------------------------------------- diff --git a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/IsolatedDeepCopiesTestCase.java b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/IsolatedDeepCopiesTestCase.java index 1b8b05f..044bcc9 100644 --- a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/IsolatedDeepCopiesTestCase.java +++ b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/IsolatedDeepCopiesTestCase.java @@ -20,9 +20,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Random; -import java.util.Set; import java.util.TreeMap; import org.apache.accumulo.core.data.ByteSequence; @@ -57,8 +55,8 @@ public class IsolatedDeepCopiesTestCase extends OutputVerifyingTestCase { SortedKeyValueIterator copy2 = copy1.deepCopy(new SimpleIteratorEnvironment()); Range seekRange = testInput.getRange(); - Set seekColumnFamilies = Collections. emptySet(); - boolean seekInclusive = false; + Collection seekColumnFamilies = testInput.getFamilies(); + boolean seekInclusive = testInput.isInclusive(); skvi.seek(testInput.getRange(), seekColumnFamilies, seekInclusive); copy1.seek(testInput.getRange(), seekColumnFamilies, seekInclusive); @@ -72,7 +70,7 @@ public class IsolatedDeepCopiesTestCase extends OutputVerifyingTestCase { } } - TreeMap consumeMany(Collection> iterators, Range range, Set seekColumnFamilies, + TreeMap consumeMany(Collection> iterators, Range range, Collection seekColumnFamilies, boolean seekInclusive) throws IOException { TreeMap data = new TreeMap<>(); // All of the copies should have consistent results from concurrent use @@ -149,6 +147,9 @@ public class IsolatedDeepCopiesTestCase extends OutputVerifyingTestCase { } // Copy the value + if (null == topValue) { + throw new IllegalStateException("Should always find a non-null Value from the iterator being tested."); + } return new Value(topValue); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d2a3f7f5/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/MultipleHasTopCalls.java ---------------------------------------------------------------------- diff --git a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/MultipleHasTopCalls.java b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/MultipleHasTopCalls.java index 087516d..5a920fa 100644 --- a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/MultipleHasTopCalls.java +++ b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/MultipleHasTopCalls.java @@ -17,11 +17,9 @@ package org.apache.accumulo.iteratortest.testcases; import java.io.IOException; -import java.util.Collections; import java.util.Random; import java.util.TreeMap; -import org.apache.accumulo.core.data.ByteSequence; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.iterators.SortedKeyValueIterator; @@ -51,7 +49,7 @@ public class MultipleHasTopCalls extends OutputVerifyingTestCase { try { skvi.init(source, testInput.getIteratorOptions(), new SimpleIteratorEnvironment()); - skvi.seek(testInput.getRange(), Collections. emptySet(), false); + skvi.seek(testInput.getRange(), testInput.getFamilies(), testInput.isInclusive()); return new IteratorTestOutput(consume(skvi)); } catch (IOException e) { return new IteratorTestOutput(e); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d2a3f7f5/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/ReSeekTestCase.java ---------------------------------------------------------------------- diff --git a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/ReSeekTestCase.java b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/ReSeekTestCase.java index 512202c..7260d88 100644 --- a/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/ReSeekTestCase.java +++ b/iterator-test-harness/src/main/java/org/apache/accumulo/iteratortest/testcases/ReSeekTestCase.java @@ -17,7 +17,7 @@ package org.apache.accumulo.iteratortest.testcases; import java.io.IOException; -import java.util.Collections; +import java.util.Collection; import java.util.Random; import java.util.TreeMap; @@ -57,7 +57,7 @@ public class ReSeekTestCase extends OutputVerifyingTestCase { try { skvi.init(source, testInput.getIteratorOptions(), new SimpleIteratorEnvironment()); - skvi.seek(testInput.getRange(), Collections. emptySet(), false); + skvi.seek(testInput.getRange(), testInput.getFamilies(), testInput.isInclusive()); return new IteratorTestOutput(consume(skvi, testInput)); } catch (IOException e) { return new IteratorTestOutput(e); @@ -67,6 +67,8 @@ public class ReSeekTestCase extends OutputVerifyingTestCase { TreeMap consume(SortedKeyValueIterator skvi, IteratorTestInput testInput) throws IOException { final TreeMap data = new TreeMap<>(); final Range origRange = testInput.getRange(); + final Collection origFamilies = testInput.getFamilies(); + final boolean origInclusive = testInput.isInclusive(); int reseekCount = random.nextInt(RESEEK_INTERVAL); int i = 0; @@ -89,12 +91,12 @@ public class ReSeekTestCase extends OutputVerifyingTestCase { skvi.init(sourceCopy, testInput.getIteratorOptions(), new SimpleIteratorEnvironment()); - // The new range, resume where we left off (non-inclusive) + // The new range, resume where we left off (non-inclusive), with same families filter final Range newRange = new Range(reSeekStartKey, false, origRange.getEndKey(), origRange.isEndKeyInclusive()); log.debug("Re-seeking to {}", newRange); // Seek there - skvi.seek(newRange, Collections. emptySet(), false); + skvi.seek(newRange, origFamilies, origInclusive); } else { // Every other time, it's a simple call to next() skvi.next();