incubator-accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject svn commit: r1226913 - in /incubator/accumulo/trunk/src: core/src/main/java/org/apache/accumulo/core/file/rfile/ server/src/main/java/org/apache/accumulo/server/tabletserver/ server/src/test/java/org/apache/accumulo/server/tabletserver/
Date Tue, 03 Jan 2012 18:56:44 GMT
Author: vines
Date: Tue Jan  3 18:56:44 2012
New Revision: 1226913

URL: http://svn.apache.org/viewvc?rev=1226913&view=rev
Log:
Accumulo-149 - fixed my iterator

Modified:
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
    incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/tabletserver/InMemoryMap.java
    incubator/accumulo/trunk/src/server/src/test/java/org/apache/accumulo/server/tabletserver/InMemoryMapTest.java

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java?rev=1226913&r1=1226912&r2=1226913&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
(original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
Tue Jan  3 18:56:44 2012
@@ -717,9 +717,7 @@ public class RFile {
           IndexEntry indexEntry = iiter.next();
           entriesLeft = indexEntry.getNumEntries();
           currBlock = getDataBlock(indexEntry);
-          
-          val = new Value();
-          
+
           MByteSequence valbs = new MByteSequence(new byte[64], 0, 0);
           RelativeKey tmpRk = new RelativeKey();
           fastSkipped = tmpRk.fastSkip(currBlock, startKey, valbs, prevKey, null);

Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/tabletserver/InMemoryMap.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/tabletserver/InMemoryMap.java?rev=1226913&r1=1226912&r2=1226913&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/tabletserver/InMemoryMap.java
(original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/tabletserver/InMemoryMap.java
Tue Jan  3 18:56:44 2012
@@ -18,6 +18,7 @@ package org.apache.accumulo.server.table
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashSet;
@@ -34,6 +35,7 @@ import java.util.concurrent.atomic.Atomi
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.ByteSequence;
 import org.apache.accumulo.core.data.ColumnUpdate;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -109,7 +111,7 @@ class PartialMutationSkippingIterator ex
   
 }
 
-class MemKeyConversionIterator extends SkippingIterator implements InterruptibleIterator
{
+class MemKeyConversionIterator extends WrappingIterator implements InterruptibleIterator
{
   MemKey currKey = null;
   Value currVal = null;
 
@@ -159,18 +161,20 @@ class MemKeyConversionIterator extends S
   
   public void next() throws IOException {
     super.next();
-    getTopKeyVal();
+    if (hasTop())
+      getTopKeyVal();
   }
 
-  @Override
-  protected void consume() throws IOException {
-    MemKey stopPoint = currKey;
+  public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive)
throws IOException {
+    super.seek(range, columnFamilies, inclusive);
     if (hasTop())
       getTopKeyVal();
-    if (stopPoint == null)
-      return;
-    while (getSource().hasTop() && currKey.compareTo(stopPoint) <= 0)
-      next();
+
+    Key k = range.getStartKey();
+    if (k instanceof MemKey && hasTop()) {
+      while (hasTop() && currKey.compareTo(k) < 0)
+        next();
+    }
   }
 
   @Override
@@ -435,7 +439,7 @@ public class InMemoryMap {
 
           readers.add(reader);
           
-          iter = reader;
+          iter = new MemKeyConversionIterator(reader);
         }
       
       return iter;
@@ -524,7 +528,7 @@ public class InMemoryMap {
     int mc = kvCount.get();
     MemoryDataSource mds = new MemoryDataSource();
     SourceSwitchingIterator ssi = new SourceSwitchingIterator(new MemoryDataSource());
-    MemoryIterator mi = new MemoryIterator(new ColumnFamilySkippingIterator(new PartialMutationSkippingIterator(new
MemKeyConversionIterator(ssi), mc)));
+    MemoryIterator mi = new MemoryIterator(new ColumnFamilySkippingIterator(new PartialMutationSkippingIterator(ssi,
mc)));
     mi.setSSI(ssi);
     mi.setMDS(mds);
     activeIters.add(mi);

Modified: incubator/accumulo/trunk/src/server/src/test/java/org/apache/accumulo/server/tabletserver/InMemoryMapTest.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/test/java/org/apache/accumulo/server/tabletserver/InMemoryMapTest.java?rev=1226913&r1=1226912&r2=1226913&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/test/java/org/apache/accumulo/server/tabletserver/InMemoryMapTest.java
(original)
+++ incubator/accumulo/trunk/src/server/src/test/java/org/apache/accumulo/server/tabletserver/InMemoryMapTest.java
Tue Jan  3 18:56:44 2012
@@ -32,7 +32,6 @@ import org.apache.accumulo.core.iterator
 import org.apache.accumulo.core.util.LocalityGroupUtil;
 import org.apache.accumulo.server.client.HdfsZooInstance;
 import org.apache.accumulo.server.conf.ZooConfiguration;
-import org.apache.accumulo.server.tabletserver.InMemoryMap;
 import org.apache.accumulo.server.tabletserver.InMemoryMap.MemoryIterator;
 import org.apache.hadoop.io.Text;
 import org.apache.log4j.Level;
@@ -258,4 +257,22 @@ public class InMemoryMapTest extends Tes
     
     ski1.close();
   }
+  
+  public void testSeekBackWards() throws Exception {
+    InMemoryMap imm = new InMemoryMap(false, "/tmp");
+    
+    mutate(imm, "r1", "foo:cq1", 3, "bar1");
+    mutate(imm, "r1", "foo:cq2", 3, "bar2");
+    mutate(imm, "r1", "foo:cq3", 3, "bar3");
+    mutate(imm, "r1", "foo:cq4", 3, "bar4");
+    
+    MemoryIterator skvi1 = imm.skvIterator();
+    
+    skvi1.seek(new Range(nk("r1", "foo:cq3", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false);
+    ae(skvi1, "r1", "foo:cq3", 3, "bar3");
+    
+    skvi1.seek(new Range(nk("r1", "foo:cq1", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false);
+    ae(skvi1, "r1", "foo:cq1", 3, "bar1");
+    
+  }
 }



Mime
View raw message