Examples of MByteSequence


Examples of org.apache.accumulo.core.file.rfile.RelativeKey.MByteSequence

          // because if only forward seeks are being done, then there is no benefit to building
          // and index for the block... could consider using the index if it exist but not
          // causing the build of an index... doing this could slow down some use cases and
          // and speed up others.

          MByteSequence valbs = new MByteSequence(new byte[64], 0, 0);
          SkippR skippr = RelativeKey.fastSkip(currBlock, startKey, valbs, prevKey, getTopKey());
          if (skippr.skipped > 0) {
            entriesLeft -= skippr.skipped;
            val = new Value(valbs.toArray());
            prevKey = skippr.prevKey;
            rk = skippr.rk;
          }
         
          reseek = false;
        }
       
        if (iiter.previousIndex() == 0 && getTopKey().equals(firstKey) && startKey.compareTo(firstKey) <= 0) {
          // seeking before the beginning of the file, and already positioned at the first key in the file
          // so there is nothing to do
          reseek = false;
        }
      }
     
      if (reseek) {
        iiter = index.lookup(startKey);
       
        reset();
       
        if (!iiter.hasNext()) {
          // past the last key
        } else {
         
          // if the index contains the same key multiple times, then go to the
          // earliest index entry containing the key
          while (iiter.hasPrevious() && iiter.peekPrevious().getKey().equals(iiter.peek().getKey())) {
            iiter.previous();
          }
         
          if (iiter.hasPrevious())
            prevKey = new Key(iiter.peekPrevious().getKey()); // initially prevKey is the last key of the prev block
          else
            prevKey = new Key(); // first block in the file, so set prev key to minimal key
           
          IndexEntry indexEntry = iiter.next();
          entriesLeft = indexEntry.getNumEntries();
          currBlock = getDataBlock(indexEntry);

          checkRange = range.afterEndKey(indexEntry.getKey());
          if (!checkRange)
            hasTop = true;

          MByteSequence valbs = new MByteSequence(new byte[64], 0, 0);

          Key currKey = null;

          if (currBlock.isIndexable()) {
            BlockIndex blockIndex = BlockIndex.getIndex(currBlock, indexEntry);
            if (blockIndex != null) {
              BlockIndexEntry bie = blockIndex.seekBlock(startKey, currBlock);
              if (bie != null) {
                // we are seeked to the current position of the key in the index
                // need to prime the read process and read this key from the block
                RelativeKey tmpRk = new RelativeKey();
                tmpRk.setPrevKey(bie.getPrevKey());
                tmpRk.readFields(currBlock);
                val = new Value();

                val.readFields(currBlock);
                valbs = new MByteSequence(val.get(), 0, val.getSize());
               
                // just consumed one key from the input stream, so subtract one from entries left
                entriesLeft = bie.getEntriesLeft() - 1;
                prevKey = new Key(bie.getPrevKey());
                currKey = tmpRk.getKey();
              }
            }
          }

          SkippR skippr = RelativeKey.fastSkip(currBlock, startKey, valbs, prevKey, currKey);
          prevKey = skippr.prevKey;
          entriesLeft -= skippr.skipped;
          val = new Value(valbs.toArray());
          // set rk when everything above is successful, if exception
          // occurs rk will not be set
          rk = skippr.rk;
        }
      }
View Full Code Here

Examples of org.apache.accumulo.core.file.rfile.RelativeKey.MByteSequence

        }
       
        if (startKey.compareTo(getTopKey()) >= 0 && startKey.compareTo(iiter.peekPrevious().getKey()) <= 0) {
          // start key is within the unconsumed portion of the current block
         
          MByteSequence valbs = new MByteSequence(new byte[64], 0, 0);
          RelativeKey tmpRk = new RelativeKey();
          Key pKey = new Key(getTopKey());
          int fastSkipped = tmpRk.fastSkip(currBlock, startKey, valbs, pKey, getTopKey());
          if (fastSkipped > 0) {
            entriesLeft -= fastSkipped;
            val = new Value(valbs.toArray());
            prevKey = pKey;
            rk = tmpRk;
          }
         
          reseek = false;
        }
       
        if (iiter.previousIndex() == 0 && getTopKey().equals(firstKey) && startKey.compareTo(firstKey) <= 0) {
          // seeking before the beginning of the file, and already positioned at the first key in the file
          // so there is nothing to do
          reseek = false;
        }
      }
     
      int fastSkipped = -1;
     
      if (reseek) {
        iiter = index.lookup(startKey);
       
        reset();
       
        if (!iiter.hasNext()) {
          // past the last key
        } else {
         
          // if the index contains the same key multiple times, then go to the
          // earliest index entry containing the key
          while (iiter.hasPrevious() && iiter.peekPrevious().getKey().equals(iiter.peek().getKey())) {
            iiter.previous();
          }
         
          if (iiter.hasPrevious())
            prevKey = new Key(iiter.peekPrevious().getKey()); // initially prevKey is the last key of the prev block
          else
            prevKey = new Key(); // first block in the file, so set prev key to minimal key
           
          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);
          entriesLeft -= fastSkipped;
          val = new Value(valbs.toArray());
          // set rk when everything above is successful, if exception
          // occurs rk will not be set
          rk = tmpRk;
        }
      }
View Full Code Here

Examples of org.apache.accumulo.core.file.rfile.RelativeKey.MByteSequence

  @Test
  public void testSeekBeforeEverything() throws IOException {
    Key seekKey = new Key();
    Key prevKey = new Key();
    Key currKey = null;
    MByteSequence value = new MByteSequence(new byte[64], 0, 0);
   
    RelativeKey.SkippR skippr = RelativeKey.fastSkip(in, seekKey, value, prevKey, currKey);
    assertEquals(1, skippr.skipped);
    assertEquals(new Key(), skippr.prevKey);
    assertEquals(expectedKeys.get(0), skippr.rk.getKey());
    assertEquals(expectedValues.get(0).toString(), value.toString());
   
    // ensure we can advance after fastskip
    skippr.rk.readFields(in);
    assertEquals(expectedKeys.get(1), skippr.rk.getKey());
   
    in.reset();
   
    seekKey = new Key("a", "b", "c", "d", 1);
    seekKey.setDeleted(true);
    skippr = RelativeKey.fastSkip(in, seekKey, value, prevKey, currKey);
    assertEquals(1, skippr.skipped);
    assertEquals(new Key(), skippr.prevKey);
    assertEquals(expectedKeys.get(0), skippr.rk.getKey());
    assertEquals(expectedValues.get(0).toString(), value.toString());
   
    skippr.rk.readFields(in);
    assertEquals(expectedKeys.get(1), skippr.rk.getKey());
  }
View Full Code Here

Examples of org.apache.accumulo.core.file.rfile.RelativeKey.MByteSequence

  @Test(expected = EOFException.class)
  public void testSeekAfterEverything() throws IOException {
    Key seekKey = new Key("s", "t", "u", "v", 1);
    Key prevKey = new Key();
    Key currKey = null;
    MByteSequence value = new MByteSequence(new byte[64], 0, 0);
   
    RelativeKey.fastSkip(in, seekKey, value, prevKey, currKey);
  }
View Full Code Here

Examples of org.apache.accumulo.core.file.rfile.RelativeKey.MByteSequence

  public void testSeekMiddle() throws IOException {
    int seekIndex = expectedKeys.size() / 2;
    Key seekKey = expectedKeys.get(seekIndex);
    Key prevKey = new Key();
    Key currKey = null;
    MByteSequence value = new MByteSequence(new byte[64], 0, 0);
   
    RelativeKey.SkippR skippr = RelativeKey.fastSkip(in, seekKey, value, prevKey, currKey);
   
    assertEquals(seekIndex + 1, skippr.skipped);
    assertEquals(expectedKeys.get(seekIndex - 1), skippr.prevKey);
    assertEquals(expectedKeys.get(seekIndex), skippr.rk.getKey());
    assertEquals(expectedValues.get(seekIndex).toString(), value.toString());
   
    skippr.rk.readFields(in);
    assertEquals(expectedValues.get(seekIndex + 1).toString(), value.toString());
   
    // try fast skipping to a key that does not exist
    in.reset();
    Key fKey = expectedKeys.get(seekIndex).followingKey(PartialKey.ROW_COLFAM_COLQUAL);
    int i;
    for (i = seekIndex; expectedKeys.get(i).compareTo(fKey) < 0; i++) {}
   
    skippr = RelativeKey.fastSkip(in, expectedKeys.get(i), value, prevKey, currKey);
    assertEquals(i + 1, skippr.skipped);
    assertEquals(expectedKeys.get(i - 1), skippr.prevKey);
    assertEquals(expectedKeys.get(i), skippr.rk.getKey());
    assertEquals(expectedValues.get(i).toString(), value.toString());
   
    // try fast skipping to our current location
    skippr = RelativeKey.fastSkip(in, expectedKeys.get(i), value, expectedKeys.get(i - 1), expectedKeys.get(i));
    assertEquals(0, skippr.skipped);
    assertEquals(expectedKeys.get(i - 1), skippr.prevKey);
    assertEquals(expectedKeys.get(i), skippr.rk.getKey());
    assertEquals(expectedValues.get(i).toString(), value.toString());
   
    // try fast skipping 1 column family ahead from our current location, testing fastskip from middle of block as opposed to stating at beginning of block
    fKey = expectedKeys.get(i).followingKey(PartialKey.ROW_COLFAM);
    int j;
    for (j = i; expectedKeys.get(j).compareTo(fKey) < 0; j++) {}
    skippr = RelativeKey.fastSkip(in, fKey, value, expectedKeys.get(i - 1), expectedKeys.get(i));
    assertEquals(j - i, skippr.skipped);
    assertEquals(expectedKeys.get(j - 1), skippr.prevKey);
    assertEquals(expectedKeys.get(j), skippr.rk.getKey());
    assertEquals(expectedValues.get(j).toString(), value.toString());
   
  }
View Full Code Here

Examples of org.apache.accumulo.core.file.rfile.RelativeKey.MByteSequence

        }
       
        if (startKey.compareTo(getTopKey()) >= 0 && startKey.compareTo(iiter.peekPrevious().getKey()) <= 0) {
          // start key is within the unconsumed portion of the current block
         
          MByteSequence valbs = new MByteSequence(new byte[64], 0, 0);
          RelativeKey tmpRk = new RelativeKey();
          Key pKey = new Key(getTopKey());
          int fastSkipped = tmpRk.fastSkip(currBlock, startKey, valbs, pKey, getTopKey());
          if (fastSkipped > 0) {
            entriesLeft -= fastSkipped;
            val = new Value(valbs.toArray());
            prevKey = pKey;
            rk = tmpRk;
          }
         
          reseek = false;
        }
       
        if (iiter.previousIndex() == 0 && getTopKey().equals(firstKey) && startKey.compareTo(firstKey) <= 0) {
          // seeking before the beginning of the file, and already positioned at the first key in the file
          // so there is nothing to do
          reseek = false;
        }
      }
     
      int fastSkipped = -1;
     
      if (reseek) {
        iiter = index.lookup(startKey);
       
        reset();
       
        if (!iiter.hasNext()) {
          // past the last key
        } else {
         
          // if the index contains the same key multiple times, then go to the
          // earliest index entry containing the key
          while (iiter.hasPrevious() && iiter.peekPrevious().getKey().equals(iiter.peek().getKey())) {
            iiter.previous();
          }
         
          if (iiter.hasPrevious())
            prevKey = new Key(iiter.peekPrevious().getKey()); // initially prevKey is the last key of the prev block
          else
            prevKey = new Key(); // first block in the file, so set prev key to minimal key
           
          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);
          entriesLeft -= fastSkipped;
          val = new Value(valbs.toArray());
          // set rk when everything above is successful, if exception
          // occurs rk will not be set
          rk = tmpRk;
        }
      }
View Full Code Here

Examples of org.apache.accumulo.core.file.rfile.RelativeKey.MByteSequence

        }
       
        if (startKey.compareTo(index.get(block).getKey()) <= 0 && startKey.compareTo(getTopKey()) >= 0) {
          // start key is within the unconsumed portion of the current block
         
          MByteSequence valbs = new MByteSequence(new byte[64], 0, 0);
          RelativeKey tmpRk = new RelativeKey();
          Key pKey = new Key(getTopKey());
          int fastSkipped = tmpRk.fastSkip(currBlock, startKey, valbs, pKey, getTopKey());
          if (fastSkipped > 0) {
            entriesLeft -= fastSkipped;
            val = new Value(valbs.toArray());
            prevKey = pKey;
            rk = tmpRk;
          }
         
          reseek = false;
        }
       
        if (block == 0 && getTopKey().equals(firstKey) && startKey.compareTo(firstKey) <= 0) {
          // seeking before the beginning of the file, and already positioned at the first key in the file
          // so there is nothing to do
          reseek = false;
        }
      }
     
      int fastSkipped = -1;
     
      if (reseek) {
        int pos = Collections.binarySearch(index, new IndexEntry(startKey, 0), new Comparator<IndexEntry>() {
          @Override
          public int compare(IndexEntry o1, IndexEntry o2) {
            return o1.getKey().compareTo(o2.getKey());
          }
        });
       
        if (pos >= 0) {
          block = pos;
        } else {
          block = (pos * -1) - 1;
        }
       
        reset();
       
        if (block == index.size()) {
          // past the last key
        } else {
         
          // if the index contains the same key multiple times, then go to the
          // earliest index entry containing the key
          while (block > 0 && index.get(block - 1).getKey().equals(index.get(block).getKey())) {
            block--;
          }
         
          currBlock = getDataBlock();
          entriesLeft = index.get(block).entries;
         
          val = new Value();
         
          if (block > 0)
            prevKey = new Key(index.get(block - 1).getKey()); // initially prevKey is the last key of the prev block
          else
            prevKey = new Key(); // first block in the file, so set prev key to minimal key
           
          MByteSequence valbs = new MByteSequence(new byte[64], 0, 0);
          RelativeKey tmpRk = new RelativeKey();
          fastSkipped = tmpRk.fastSkip(currBlock, startKey, valbs, prevKey, null);
          entriesLeft -= fastSkipped;
          val = new Value(valbs.toArray());
          // set rk when everything above is successful, if exception
          // occurs rk will not be set
          rk = tmpRk;
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.