You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by bi...@apache.org on 2011/11/28 20:30:28 UTC

svn commit: r1207529 [2/2] - in /incubator/accumulo/branches/1.4/src/core/src: main/java/org/apache/accumulo/core/client/mock/ main/java/org/apache/accumulo/core/iterators/ main/java/org/apache/accumulo/core/iterators/system/ main/java/org/apache/accum...

Copied: incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java (from r1204997, incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/RegExFilterTest.java)
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java?p2=incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java&p1=incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/RegExFilterTest.java&r1=1204997&r2=1207529&rev=1207529&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/RegExFilterTest.java (original)
+++ incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java Mon Nov 28 19:30:20 2011
@@ -14,24 +14,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.accumulo.core.iterators;
+package org.apache.accumulo.core.iterators.user;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.TreeMap;
 
+import junit.framework.TestCase;
+
+import org.apache.accumulo.core.client.IteratorSetting;
 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;
+import org.apache.accumulo.core.iterators.DefaultIteratorEnvironment;
 import org.apache.accumulo.core.iterators.SortedMapIterator;
-import org.apache.accumulo.core.iterators.user.RegExFilter;
 import org.apache.hadoop.io.Text;
 
-import junit.framework.TestCase;
-
 public class RegExFilterTest extends TestCase {
   
   private static final Collection<ByteSequence> EMPTY_COL_FAMS = new ArrayList<ByteSequence>();
@@ -53,14 +53,14 @@ public class RegExFilterTest extends Tes
     Key k2 = nkv(tm, "boo1", "yap", "20080202", "cat");
     Key k3 = nkv(tm, "boo2", "yip", "20080203", "hamster");
     
-    RegExFilter rei = new RegExFilter(new SortedMapIterator(tm));
+    RegExFilter rei = new RegExFilter();
     rei.describeOptions();
     
-    HashMap<String,String> options = new HashMap<String,String>();
+    IteratorSetting is = new IteratorSetting(1, RegExFilter.class);
+    RegExFilter.setRegexs(is, ".*2", null, null, null, false);
     
-    options.put(RegExFilter.ROW_REGEX, ".*2");
-    rei.validateOptions(options);
-    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
+    rei.validateOptions(is.getProperties());
+    rei.init(new SortedMapIterator(tm), is.getProperties(), new DefaultIteratorEnvironment());
     rei.seek(new Range(), EMPTY_COL_FAMS, false);
     
     assertTrue(rei.hasTop());
@@ -69,11 +69,11 @@ public class RegExFilterTest extends Tes
     assertFalse(rei.hasTop());
     
     // -----------------------------------------------------
-    options.clear();
+    is.clearOptions();
     
-    options.put(RegExFilter.COLF_REGEX, "ya.*");
-    rei.validateOptions(options);
-    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
+    RegExFilter.setRegexs(is, null, "ya.*", null, null, false);
+    rei.validateOptions(is.getProperties());
+    rei.init(new SortedMapIterator(tm), is.getProperties(), new DefaultIteratorEnvironment());
     rei.seek(new Range(), EMPTY_COL_FAMS, false);
     
     assertTrue(rei.hasTop());
@@ -82,11 +82,11 @@ public class RegExFilterTest extends Tes
     assertFalse(rei.hasTop());
     
     // -----------------------------------------------------
-    options.clear();
+    is.clearOptions();
     
-    options.put(RegExFilter.COLQ_REGEX, ".*01");
-    rei.validateOptions(options);
-    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
+    RegExFilter.setRegexs(is, null, null, ".*01", null, false);
+    rei.validateOptions(is.getProperties());
+    rei.init(new SortedMapIterator(tm), is.getProperties(), new DefaultIteratorEnvironment());
     rei.seek(new Range(), EMPTY_COL_FAMS, false);
     
     assertTrue(rei.hasTop());
@@ -95,11 +95,11 @@ public class RegExFilterTest extends Tes
     assertFalse(rei.hasTop());
     
     // -----------------------------------------------------
-    options.clear();
+    is.clearOptions();
     
-    options.put(RegExFilter.VALUE_REGEX, ".*at");
-    rei.validateOptions(options);
-    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
+    RegExFilter.setRegexs(is, null, null, null, ".*at", false);
+    rei.validateOptions(is.getProperties());
+    rei.init(new SortedMapIterator(tm), is.getProperties(), new DefaultIteratorEnvironment());
     rei.seek(new Range(), EMPTY_COL_FAMS, false);
     
     assertTrue(rei.hasTop());
@@ -108,20 +108,19 @@ public class RegExFilterTest extends Tes
     assertFalse(rei.hasTop());
     
     // -----------------------------------------------------
-    options.clear();
+    is.clearOptions();
     
-    options.put(RegExFilter.VALUE_REGEX, ".*ap");
-    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
+    RegExFilter.setRegexs(is, null, null, null, ".*ap", false);
+    rei.init(new SortedMapIterator(tm), is.getProperties(), new DefaultIteratorEnvironment());
     rei.seek(new Range(), EMPTY_COL_FAMS, false);
     
     assertFalse(rei.hasTop());
     
     // -----------------------------------------------------
-    options.clear();
+    is.clearOptions();
     
-    options.put(RegExFilter.COLF_REGEX, "ya.*");
-    options.put(RegExFilter.VALUE_REGEX, ".*at");
-    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
+    RegExFilter.setRegexs(is, null, "ya.*", null, ".*at", false);
+    rei.init(new SortedMapIterator(tm), is.getProperties(), new DefaultIteratorEnvironment());
     rei.seek(new Range(), EMPTY_COL_FAMS, false);
     
     assertTrue(rei.hasTop());
@@ -130,20 +129,19 @@ public class RegExFilterTest extends Tes
     assertFalse(rei.hasTop());
     
     // -----------------------------------------------------
-    options.clear();
+    is.clearOptions();
     
-    options.put(RegExFilter.COLF_REGEX, "ya.*");
-    options.put(RegExFilter.VALUE_REGEX, ".*ap");
-    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
+    RegExFilter.setRegexs(is, null, "ya.*", null, ".*ap", false);
+    rei.init(new SortedMapIterator(tm), is.getProperties(), new DefaultIteratorEnvironment());
     rei.seek(new Range(), EMPTY_COL_FAMS, false);
     
     assertFalse(rei.hasTop());
     
     // -----------------------------------------------------
-    options.clear();
+    is.clearOptions();
     
-    options.put(RegExFilter.ROW_REGEX, "boo1");
-    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
+    RegExFilter.setRegexs(is, "boo1", null, null, null, false);
+    rei.init(new SortedMapIterator(tm), is.getProperties(), new DefaultIteratorEnvironment());
     rei.seek(new Range(), EMPTY_COL_FAMS, false);
     
     assertTrue(rei.hasTop());
@@ -155,9 +153,9 @@ public class RegExFilterTest extends Tes
     assertFalse(rei.hasTop());
     
     // -----------------------------------------------------
-    options.clear();
+    is.clearOptions();
     
-    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
+    rei.init(new SortedMapIterator(tm), is.getProperties(), new DefaultIteratorEnvironment());
     rei.seek(new Range(), EMPTY_COL_FAMS, false);
     
     assertTrue(rei.hasTop());
@@ -172,13 +170,10 @@ public class RegExFilterTest extends Tes
     assertFalse(rei.hasTop());
     
     // -----------------------------------------------------
-    options.clear();
+    is.clearOptions();
     
-    options.put(RegExFilter.ROW_REGEX, "hamster");
-    options.put(RegExFilter.COLQ_REGEX, "hamster");
-    options.put(RegExFilter.VALUE_REGEX, "hamster");
-    options.put(RegExFilter.OR_FIELDS, "true");
-    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
+    RegExFilter.setRegexs(is, "hamster", null, "hamster", "hamster", true);
+    rei.init(new SortedMapIterator(tm), is.getProperties(), new DefaultIteratorEnvironment());
     rei.seek(new Range(), EMPTY_COL_FAMS, false);
     
     assertTrue(rei.hasTop());
@@ -187,12 +182,10 @@ public class RegExFilterTest extends Tes
     assertFalse(rei.hasTop());
     
     // -----------------------------------------------------
-    options.clear();
+    is.clearOptions();
     
-    options.put(RegExFilter.COLF_REGEX, "ya.*");
-    options.put(RegExFilter.COLQ_REGEX, "hamster");
-    options.put(RegExFilter.OR_FIELDS, "true");
-    rei.init(new SortedMapIterator(tm), options, new DefaultIteratorEnvironment());
+    RegExFilter.setRegexs(is, null, "ya.*", "hamster", null, true);
+    rei.init(new SortedMapIterator(tm), is.getProperties(), new DefaultIteratorEnvironment());
     rei.seek(new Range(), EMPTY_COL_FAMS, false);
     
     assertTrue(rei.hasTop());

Copied: incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/VersioningIteratorTest.java (from r1205055, incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/VersioningIteratorTest.java)
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/VersioningIteratorTest.java?p2=incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/VersioningIteratorTest.java&p1=incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/VersioningIteratorTest.java&r1=1205055&r2=1207529&rev=1207529&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/VersioningIteratorTest.java (original)
+++ incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/VersioningIteratorTest.java Mon Nov 28 19:30:20 2011
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.accumulo.core.iterators;
+package org.apache.accumulo.core.iterators.user;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -24,12 +24,14 @@ import java.util.TreeMap;
 
 import junit.framework.TestCase;
 
+import org.apache.accumulo.core.client.IteratorSetting;
 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;
+import org.apache.accumulo.core.iterators.LongCombiner;
+import org.apache.accumulo.core.iterators.SortedMapIterator;
 import org.apache.accumulo.core.iterators.TypedValueCombiner.Encoder;
-import org.apache.accumulo.core.iterators.user.VersioningIterator;
 import org.apache.hadoop.io.Text;
 
 public class VersioningIteratorTest extends TestCase {
@@ -67,7 +69,10 @@ public class VersioningIteratorTest exte
     createTestData(tm, colf, colq);
     
     try {
-      VersioningIterator it = new VersioningIterator(new SortedMapIterator(tm), 3);
+      VersioningIterator it = new VersioningIterator();
+      IteratorSetting is = new IteratorSetting(1, VersioningIterator.class);
+      VersioningIterator.setMaxVersions(is, 3);
+      it.init(new SortedMapIterator(tm), is.getProperties(), null);
       it.seek(new Range(), EMPTY_COL_FAMS, false);
       
       TreeMap<Key,Value> tmOut = iteratorOverTestData(it);
@@ -126,7 +131,10 @@ public class VersioningIteratorTest exte
     createTestData(tm, colf, colq);
     
     try {
-      VersioningIterator it = new VersioningIterator(new SortedMapIterator(tm), 3);
+      VersioningIterator it = new VersioningIterator();
+      IteratorSetting is = new IteratorSetting(1, VersioningIterator.class);
+      VersioningIterator.setMaxVersions(is, 3);
+      it.init(new SortedMapIterator(tm), is.getProperties(), null);
       
       // after doing this seek, should get zero keys for row 1
       Key seekKey = new Key(new Text(String.format("%03d", 1)), colf, colq, 15);
@@ -172,7 +180,10 @@ public class VersioningIteratorTest exte
     
     for (int i = 1; i <= 30; i++) {
       try {
-        VersioningIterator it = new VersioningIterator(new SortedMapIterator(tm), i);
+        VersioningIterator it = new VersioningIterator();
+        IteratorSetting is = new IteratorSetting(1, VersioningIterator.class);
+        VersioningIterator.setMaxVersions(is, i);
+        it.init(new SortedMapIterator(tm), is.getProperties(), null);
         it.seek(new Range(), EMPTY_COL_FAMS, false);
         
         TreeMap<Key,Value> tmOut = iteratorOverTestData(it);
@@ -195,7 +206,10 @@ public class VersioningIteratorTest exte
     
     createTestData(tm, colf, colq);
     
-    VersioningIterator it = new VersioningIterator(new SortedMapIterator(tm), 3);
+    VersioningIterator it = new VersioningIterator();
+    IteratorSetting is = new IteratorSetting(1, VersioningIterator.class);
+    VersioningIterator.setMaxVersions(is, 3);
+    it.init(new SortedMapIterator(tm), is.getProperties(), null);
     
     Key seekKey = new Key(new Text(String.format("%03d", 1)), colf, colq, 19);
     it.seek(new Range(seekKey, false, null, true), EMPTY_COL_FAMS, false);