Java 类org.apache.hadoop.hbase.codec.prefixtree.scanner.CellSearcher 实例源码

项目:ditb    文件:TestPrefixTreeSearcher.java   
@Test
public void testScanForwards() throws IOException {
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);

    int i = -1;
    while (searcher.advance()) {
      ++i;
      KeyValue inputCell = rows.getInputs().get(i);
      Cell outputCell = searcher.current();

      // check all 3 permutations of equals()
      Assert.assertEquals(inputCell, outputCell);
      Assert.assertEquals(outputCell, inputCell);
      Assert.assertTrue(CellComparator.equals(inputCell, outputCell));
    }
    Assert.assertEquals(rows.getInputs().size(), i + 1);
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:ditb    文件:TestPrefixTreeSearcher.java   
@Test
public void testScanBackwards() throws IOException {
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);
    searcher.positionAfterLastCell();
    int i = -1;
    while (searcher.previous()) {
      ++i;
      int oppositeIndex = rows.getInputs().size() - i - 1;
      KeyValue inputKv = rows.getInputs().get(oppositeIndex);
      KeyValue outputKv = KeyValueUtil.copyToNewKeyValue(searcher.current());
      Assert.assertEquals(inputKv, outputKv);
    }
    Assert.assertEquals(rows.getInputs().size(), i + 1);
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:ditb    文件:TestPrefixTreeSearcher.java   
@Test
public void testSeekWithPrefix() throws IOException {
  if (!(rows instanceof TestRowDataSearchWithPrefix)) {
    return;
  }
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);
    // seek with half bytes of second row key, should return second row
    KeyValue kv = rows.getInputs().get(1);
    KeyValue firstKVOnRow = KeyValueUtil.createFirstOnRow(Arrays.copyOfRange(
        kv.getRowArray(), kv.getRowOffset(),
        kv.getRowOffset() + kv.getRowLength() / 2));
    CellScannerPosition position = searcher.positionAtOrAfter(firstKVOnRow);
    Assert.assertEquals(CellScannerPosition.AFTER, position);
    Assert.assertEquals(kv, searcher.current());
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:ditb    文件:TestRowDataSearcherRowMiss.java   
@Override
public void individualSearcherAssertions(CellSearcher searcher) {
  assertRowOffsetsCorrect();

  searcher.resetToBeforeFirstEntry();

  //test first cell
  try {
    searcher.advance();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  Cell first = searcher.current();
  Assert.assertTrue(CellComparator.equals(d.get(0), first));

  //test first cell in second row
  Assert.assertTrue(searcher.positionAt(d.get(1)));
  Assert.assertTrue(CellComparator.equals(d.get(1), searcher.current()));

  testBetween1and2(searcher);
  testBetween2and3(searcher);
}
项目:ditb    文件:TestRowDataSearcherRowMiss.java   
private void testBetween1and2(CellSearcher searcher){
  CellScannerPosition p;//reuse
  Cell betweenAAndAAA = new KeyValue(AA, cf, cq, ts-2, v);

  //test exact
  Assert.assertFalse(searcher.positionAt(betweenAAndAAA));

  //test atOrBefore
  p = searcher.positionAtOrBefore(betweenAAndAAA);
  Assert.assertEquals(CellScannerPosition.BEFORE, p);
  Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(1)));

  //test atOrAfter
  p = searcher.positionAtOrAfter(betweenAAndAAA);
  Assert.assertEquals(CellScannerPosition.AFTER, p);
  Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(2)));
}
项目:ditb    文件:TestRowDataSearcherRowMiss.java   
private void testBetween2and3(CellSearcher searcher){
  CellScannerPosition p;//reuse
  Cell betweenAAAndB = new KeyValue(AAA, cf, cq, ts-2, v);

  //test exact
  Assert.assertFalse(searcher.positionAt(betweenAAAndB));

  //test atOrBefore
  p = searcher.positionAtOrBefore(betweenAAAndB);
  Assert.assertEquals(CellScannerPosition.BEFORE, p);
  Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(2)));

  //test atOrAfter
  p = searcher.positionAtOrAfter(betweenAAAndB);
  Assert.assertEquals(CellScannerPosition.AFTER, p);
  Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(3)));
}
项目:pbase    文件:TestPrefixTreeSearcher.java   
@Test
public void testScanForwards() throws IOException {
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);

    int i = -1;
    while (searcher.advance()) {
      ++i;
      KeyValue inputCell = rows.getInputs().get(i);
      Cell outputCell = searcher.current();

      // check all 3 permutations of equals()
      Assert.assertEquals(inputCell, outputCell);
      Assert.assertEquals(outputCell, inputCell);
      Assert.assertTrue(CellComparator.equals(inputCell, outputCell));
    }
    Assert.assertEquals(rows.getInputs().size(), i + 1);
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:pbase    文件:TestPrefixTreeSearcher.java   
@Test
public void testScanBackwards() throws IOException {
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);
    searcher.positionAfterLastCell();
    int i = -1;
    while (searcher.previous()) {
      ++i;
      int oppositeIndex = rows.getInputs().size() - i - 1;
      KeyValue inputKv = rows.getInputs().get(oppositeIndex);
      KeyValue outputKv = KeyValueUtil.copyToNewKeyValue(searcher.current());
      Assert.assertEquals(inputKv, outputKv);
    }
    Assert.assertEquals(rows.getInputs().size(), i + 1);
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:pbase    文件:TestPrefixTreeSearcher.java   
@Test
public void testSeekWithPrefix() throws IOException {
  if (!(rows instanceof TestRowDataSearchWithPrefix)) {
    return;
  }
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);
    // seek with half bytes of second row key, should return second row
    KeyValue kv = rows.getInputs().get(1);
    KeyValue firstKVOnRow = KeyValueUtil.createFirstOnRow(Arrays.copyOfRange(
        kv.getRowArray(), kv.getRowOffset(),
        kv.getRowOffset() + kv.getRowLength() / 2));
    CellScannerPosition position = searcher.positionAtOrAfter(firstKVOnRow);
    Assert.assertEquals(CellScannerPosition.AFTER, position);
    Assert.assertEquals(kv, searcher.current());
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:pbase    文件:TestRowDataSearcherRowMiss.java   
@Override
public void individualSearcherAssertions(CellSearcher searcher) {
  assertRowOffsetsCorrect();

  searcher.resetToBeforeFirstEntry();

  //test first cell
  try {
    searcher.advance();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  Cell first = searcher.current();
  Assert.assertTrue(CellComparator.equals(d.get(0), first));

  //test first cell in second row
  Assert.assertTrue(searcher.positionAt(d.get(1)));
  Assert.assertTrue(CellComparator.equals(d.get(1), searcher.current()));

  testBetween1and2(searcher);
  testBetween2and3(searcher);
}
项目:pbase    文件:TestRowDataSearcherRowMiss.java   
private void testBetween1and2(CellSearcher searcher){
  CellScannerPosition p;//reuse
  Cell betweenAAndAAA = new KeyValue(AA, cf, cq, ts-2, v);

  //test exact
  Assert.assertFalse(searcher.positionAt(betweenAAndAAA));

  //test atOrBefore
  p = searcher.positionAtOrBefore(betweenAAndAAA);
  Assert.assertEquals(CellScannerPosition.BEFORE, p);
  Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(1)));

  //test atOrAfter
  p = searcher.positionAtOrAfter(betweenAAndAAA);
  Assert.assertEquals(CellScannerPosition.AFTER, p);
  Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(2)));
}
项目:pbase    文件:TestRowDataSearcherRowMiss.java   
private void testBetween2and3(CellSearcher searcher){
  CellScannerPosition p;//reuse
  Cell betweenAAAndB = new KeyValue(AAA, cf, cq, ts-2, v);

  //test exact
  Assert.assertFalse(searcher.positionAt(betweenAAAndB));

  //test atOrBefore
  p = searcher.positionAtOrBefore(betweenAAAndB);
  Assert.assertEquals(CellScannerPosition.BEFORE, p);
  Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(2)));

  //test atOrAfter
  p = searcher.positionAtOrAfter(betweenAAAndB);
  Assert.assertEquals(CellScannerPosition.AFTER, p);
  Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(3)));
}
项目:HIndex    文件:TestPrefixTreeSearcher.java   
@Test
public void testScanForwards() throws IOException {
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);

    int i = -1;
    while (searcher.advance()) {
      ++i;
      KeyValue inputCell = rows.getInputs().get(i);
      Cell outputCell = searcher.current();

      // check all 3 permutations of equals()
      Assert.assertEquals(inputCell, outputCell);
      Assert.assertEquals(outputCell, inputCell);
      Assert.assertTrue(CellComparator.equals(inputCell, outputCell));
    }
    Assert.assertEquals(rows.getInputs().size(), i + 1);
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:HIndex    文件:TestPrefixTreeSearcher.java   
@Test
public void testScanBackwards() throws IOException {
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);
    searcher.positionAfterLastCell();
    int i = -1;
    while (searcher.previous()) {
      ++i;
      int oppositeIndex = rows.getInputs().size() - i - 1;
      KeyValue inputKv = rows.getInputs().get(oppositeIndex);
      KeyValue outputKv = KeyValueUtil.copyToNewKeyValue(searcher.current());
      Assert.assertEquals(inputKv, outputKv);
    }
    Assert.assertEquals(rows.getInputs().size(), i + 1);
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:HIndex    文件:TestRowDataSearcherRowMiss.java   
@Override
public void individualSearcherAssertions(CellSearcher searcher) {
   assertRowOffsetsCorrect();

   searcher.resetToBeforeFirstEntry();

   //test first cell
   try {
     searcher.advance();
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
   Cell first = searcher.current();
   Assert.assertTrue(CellComparator.equals(d.get(0), first));

   //test first cell in second row
   Assert.assertTrue(searcher.positionAt(d.get(1)));
   Assert.assertTrue(CellComparator.equals(d.get(1), searcher.current()));

   testBetween1and2(searcher);
   testBetween2and3(searcher);
 }
项目:HIndex    文件:TestRowDataSearcherRowMiss.java   
private void testBetween1and2(CellSearcher searcher){
   CellScannerPosition p;//reuse
   Cell betweenAAndAAA = new KeyValue(AA, cf, cq, ts-2, v);

   //test exact
   Assert.assertFalse(searcher.positionAt(betweenAAndAAA));

   //test atOrBefore
   p = searcher.positionAtOrBefore(betweenAAndAAA);
   Assert.assertEquals(CellScannerPosition.BEFORE, p);
   Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(1)));

   //test atOrAfter
   p = searcher.positionAtOrAfter(betweenAAndAAA);
   Assert.assertEquals(CellScannerPosition.AFTER, p);
   Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(2)));
}
项目:HIndex    文件:TestRowDataSearcherRowMiss.java   
private void testBetween2and3(CellSearcher searcher){
  CellScannerPosition p;//reuse
  Cell betweenAAAndB = new KeyValue(AAA, cf, cq, ts-2, v);

  //test exact
  Assert.assertFalse(searcher.positionAt(betweenAAAndB));

  //test atOrBefore
  p = searcher.positionAtOrBefore(betweenAAAndB);
  Assert.assertEquals(CellScannerPosition.BEFORE, p);
  Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(2)));

  //test atOrAfter
  p = searcher.positionAtOrAfter(betweenAAAndB);
  Assert.assertEquals(CellScannerPosition.AFTER, p);
  Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(3)));
}
项目:PyroDB    文件:TestPrefixTreeSearcher.java   
@Test
public void testScanForwards() throws IOException {
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);

    int i = -1;
    while (searcher.advance()) {
      ++i;
      KeyValue inputCell = rows.getInputs().get(i);
      Cell outputCell = searcher.current();

      // check all 3 permutations of equals()
      Assert.assertEquals(inputCell, outputCell);
      Assert.assertEquals(outputCell, inputCell);
      Assert.assertTrue(CellComparator.equals(inputCell, outputCell));
    }
    Assert.assertEquals(rows.getInputs().size(), i + 1);
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:PyroDB    文件:TestPrefixTreeSearcher.java   
@Test
public void testScanBackwards() throws IOException {
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);
    searcher.positionAfterLastCell();
    int i = -1;
    while (searcher.previous()) {
      ++i;
      int oppositeIndex = rows.getInputs().size() - i - 1;
      KeyValue inputKv = rows.getInputs().get(oppositeIndex);
      KeyValue outputKv = KeyValueUtil.copyToNewKeyValue(searcher.current());
      Assert.assertEquals(inputKv, outputKv);
    }
    Assert.assertEquals(rows.getInputs().size(), i + 1);
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:PyroDB    文件:TestRowDataSearcherRowMiss.java   
@Override
public void individualSearcherAssertions(CellSearcher searcher) {
   assertRowOffsetsCorrect();

   searcher.resetToBeforeFirstEntry();

   //test first cell
   try {
     searcher.advance();
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
   Cell first = searcher.current();
   Assert.assertTrue(CellComparator.equals(d.get(0), first));

   //test first cell in second row
   Assert.assertTrue(searcher.positionAt(d.get(1)));
   Assert.assertTrue(CellComparator.equals(d.get(1), searcher.current()));

   testBetween1and2(searcher);
   testBetween2and3(searcher);
 }
项目:PyroDB    文件:TestRowDataSearcherRowMiss.java   
private void testBetween1and2(CellSearcher searcher){
   CellScannerPosition p;//reuse
   Cell betweenAAndAAA = new KeyValue(AA, cf, cq, ts-2, v);

   //test exact
   Assert.assertFalse(searcher.positionAt(betweenAAndAAA));

   //test atOrBefore
   p = searcher.positionAtOrBefore(betweenAAndAAA);
   Assert.assertEquals(CellScannerPosition.BEFORE, p);
   Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(1)));

   //test atOrAfter
   p = searcher.positionAtOrAfter(betweenAAndAAA);
   Assert.assertEquals(CellScannerPosition.AFTER, p);
   Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(2)));
}
项目:PyroDB    文件:TestRowDataSearcherRowMiss.java   
private void testBetween2and3(CellSearcher searcher){
  CellScannerPosition p;//reuse
  Cell betweenAAAndB = new KeyValue(AAA, cf, cq, ts-2, v);

  //test exact
  Assert.assertFalse(searcher.positionAt(betweenAAAndB));

  //test atOrBefore
  p = searcher.positionAtOrBefore(betweenAAAndB);
  Assert.assertEquals(CellScannerPosition.BEFORE, p);
  Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(2)));

  //test atOrAfter
  p = searcher.positionAtOrAfter(betweenAAAndB);
  Assert.assertEquals(CellScannerPosition.AFTER, p);
  Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(3)));
}
项目:c5    文件:TestPrefixTreeSearcher.java   
@Test
public void testScanForwards() throws IOException {
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);

    int i = -1;
    while (searcher.advance()) {
      ++i;
      KeyValue inputCell = rows.getInputs().get(i);
      Cell outputCell = searcher.current();

      // check all 3 permutations of equals()
      Assert.assertEquals(inputCell, outputCell);
      Assert.assertEquals(outputCell, inputCell);
      Assert.assertTrue(CellComparator.equals(inputCell, outputCell));
    }
    Assert.assertEquals(rows.getInputs().size(), i + 1);
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:c5    文件:TestPrefixTreeSearcher.java   
@Test
public void testScanBackwards() throws IOException {
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);
    searcher.positionAfterLastCell();
    int i = -1;
    while (searcher.previous()) {
      ++i;
      int oppositeIndex = rows.getInputs().size() - i - 1;
      KeyValue inputKv = rows.getInputs().get(oppositeIndex);
      KeyValue outputKv = KeyValueUtil.copyToNewKeyValue(searcher.current());
      Assert.assertEquals(inputKv, outputKv);
    }
    Assert.assertEquals(rows.getInputs().size(), i + 1);
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:c5    文件:TestRowDataSearcherRowMiss.java   
@Override
public void individualSearcherAssertions(CellSearcher searcher) {
   assertRowOffsetsCorrect();

   searcher.resetToBeforeFirstEntry();

   //test first cell
   try {
     searcher.advance();
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
   Cell first = searcher.current();
   Assert.assertTrue(CellComparator.equals(d.get(0), first));

   //test first cell in second row
   Assert.assertTrue(searcher.positionAt(d.get(1)));
   Assert.assertTrue(CellComparator.equals(d.get(1), searcher.current()));

   testBetween1and2(searcher);
   testBetween2and3(searcher);
 }
项目:c5    文件:TestRowDataSearcherRowMiss.java   
private void testBetween1and2(CellSearcher searcher){
   CellScannerPosition p;//reuse
   Cell betweenAAndAAA = new KeyValue(AA, cf, cq, ts-2, v);

   //test exact
   Assert.assertFalse(searcher.positionAt(betweenAAndAAA));

   //test atOrBefore
   p = searcher.positionAtOrBefore(betweenAAndAAA);
   Assert.assertEquals(CellScannerPosition.BEFORE, p);
   Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(1)));

   //test atOrAfter
   p = searcher.positionAtOrAfter(betweenAAndAAA);
   Assert.assertEquals(CellScannerPosition.AFTER, p);
   Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(2)));
}
项目:c5    文件:TestRowDataSearcherRowMiss.java   
private void testBetween2and3(CellSearcher searcher){
  CellScannerPosition p;//reuse
  Cell betweenAAAndB = new KeyValue(AAA, cf, cq, ts-2, v);

  //test exact
  Assert.assertFalse(searcher.positionAt(betweenAAAndB));

  //test atOrBefore
  p = searcher.positionAtOrBefore(betweenAAAndB);
  Assert.assertEquals(CellScannerPosition.BEFORE, p);
  Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(2)));

  //test atOrAfter
  p = searcher.positionAtOrAfter(betweenAAAndB);
  Assert.assertEquals(CellScannerPosition.AFTER, p);
  Assert.assertTrue(CellComparator.equals(searcher.current(), d.get(3)));
}
项目:ditb    文件:PrefixTreeCodec.java   
/**
 * I don't think this method is called during normal HBase operation, so efficiency is not
 * important.
 */
public ByteBuffer decodeKeyValues(DataInputStream source, int allocateHeaderLength,
    int skipLastBytes, HFileBlockDecodingContext decodingCtx) throws IOException {
  ByteBuffer sourceAsBuffer = ByteBufferUtils.drainInputStreamToBuffer(source);// waste
  sourceAsBuffer.mark();
  PrefixTreeBlockMeta blockMeta = new PrefixTreeBlockMeta(sourceAsBuffer);
  sourceAsBuffer.rewind();
  int numV1BytesWithHeader = allocateHeaderLength + blockMeta.getNumKeyValueBytes();
  byte[] keyValueBytesWithHeader = new byte[numV1BytesWithHeader];
  ByteBuffer result = ByteBuffer.wrap(keyValueBytesWithHeader);
  result.rewind();
  CellSearcher searcher = null;
  try {
    boolean includesMvcc = decodingCtx.getHFileContext().isIncludesMvcc();
    searcher = DecoderFactory.checkOut(sourceAsBuffer, includesMvcc);
    while (searcher.advance()) {
      KeyValue currentCell = KeyValueUtil.copyToNewKeyValue(searcher.current());
      // needs to be modified for DirectByteBuffers. no existing methods to
      // write VLongs to byte[]
      int offset = result.arrayOffset() + result.position();
      System.arraycopy(currentCell.getBuffer(), currentCell.getOffset(), result.array(), offset,
          currentCell.getLength());
      int keyValueLength = KeyValueUtil.length(currentCell);
      ByteBufferUtils.skip(result, keyValueLength);
      offset += keyValueLength;
      if (includesMvcc) {
        ByteBufferUtils.writeVLong(result, currentCell.getMvccVersion());
      }
    }
    result.position(result.limit());//make it appear as if we were appending
    return result;
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:ditb    文件:DecoderFactory.java   
public static void checkIn(CellSearcher pSearcher) {
  if (pSearcher == null) {
    return;
  }
  if (! (pSearcher instanceof PrefixTreeArraySearcher)) {
    throw new IllegalArgumentException("Cannot return "+pSearcher.getClass()+" to "
        +DecoderFactory.class);
  }
  PrefixTreeArraySearcher searcher = (PrefixTreeArraySearcher) pSearcher;
  POOL.checkIn(searcher);
}
项目:ditb    文件:TestPrefixTreeSearcher.java   
@Test
public void testRandomSeekHits() throws IOException {
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);
    for (KeyValue kv : rows.getInputs()) {
      boolean hit = searcher.positionAt(kv);
      Assert.assertTrue(hit);
      Cell foundKv = searcher.current();
      Assert.assertTrue(CellComparator.equals(kv, foundKv));
    }
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:ditb    文件:TestPrefixTreeSearcher.java   
@Test
public void testRandomSeekIndividualAssertions() throws IOException {
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);
    rows.individualSearcherAssertions(searcher);
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:ditb    文件:TestRowDataTrivial.java   
@Override
public void individualSearcherAssertions(CellSearcher searcher) {
  /**
   * The searcher should get a token mismatch on the "r" branch. Assert that it skips not only rA,
   * but rB as well.
   */
  KeyValue afterLast = KeyValueUtil.createFirstOnRow(Bytes.toBytes("zzz"));
  CellScannerPosition position = searcher.positionAtOrAfter(afterLast);
  Assert.assertEquals(CellScannerPosition.AFTER_LAST, position);
  Assert.assertNull(searcher.current());
}
项目:ditb    文件:TestRowDataDeeper.java   
@Override
public void individualSearcherAssertions(CellSearcher searcher) {
  /**
   * The searcher should get a token mismatch on the "r" branch.  Assert that it skips not only
   * rA, but rB as well.
   */
  KeyValue cfcRow = KeyValueUtil.createFirstOnRow(Bytes.toBytes("cfc"));
  CellScannerPosition position = searcher.positionAtOrAfter(cfcRow);
  Assert.assertEquals(CellScannerPosition.AFTER, position);
  Assert.assertEquals(d.get(2), searcher.current());
  searcher.previous();
  Assert.assertEquals(d.get(1), searcher.current());
}
项目:ditb    文件:TestRowDataTrivialWithTags.java   
@Override
public void individualSearcherAssertions(CellSearcher searcher) {
  /**
   * The searcher should get a token mismatch on the "r" branch. Assert that
   * it skips not only rA, but rB as well.
   */
  KeyValue afterLast = KeyValueUtil.createFirstOnRow(Bytes.toBytes("zzz"));
  CellScannerPosition position = searcher.positionAtOrAfter(afterLast);
  Assert.assertEquals(CellScannerPosition.AFTER_LAST, position);
  Assert.assertNull(searcher.current());
}
项目:pbase    文件:PrefixTreeCodec.java   
/**
 * I don't think this method is called during normal HBase operation, so efficiency is not
 * important.
 */
public ByteBuffer decodeKeyValues(DataInputStream source, int allocateHeaderLength,
    int skipLastBytes, HFileBlockDecodingContext decodingCtx) throws IOException {
  ByteBuffer sourceAsBuffer = ByteBufferUtils.drainInputStreamToBuffer(source);// waste
  sourceAsBuffer.mark();
  PrefixTreeBlockMeta blockMeta = new PrefixTreeBlockMeta(sourceAsBuffer);
  sourceAsBuffer.rewind();
  int numV1BytesWithHeader = allocateHeaderLength + blockMeta.getNumKeyValueBytes();
  byte[] keyValueBytesWithHeader = new byte[numV1BytesWithHeader];
  ByteBuffer result = ByteBuffer.wrap(keyValueBytesWithHeader);
  result.rewind();
  CellSearcher searcher = null;
  try {
    boolean includesMvcc = decodingCtx.getHFileContext().isIncludesMvcc();
    searcher = DecoderFactory.checkOut(sourceAsBuffer, includesMvcc);
    while (searcher.advance()) {
      KeyValue currentCell = KeyValueUtil.copyToNewKeyValue(searcher.current());
      // needs to be modified for DirectByteBuffers. no existing methods to
      // write VLongs to byte[]
      int offset = result.arrayOffset() + result.position();
      System.arraycopy(currentCell.getBuffer(), currentCell.getOffset(), result.array(), offset,
          currentCell.getLength());
      int keyValueLength = KeyValueUtil.length(currentCell);
      ByteBufferUtils.skip(result, keyValueLength);
      offset += keyValueLength;
      if (includesMvcc) {
        ByteBufferUtils.writeVLong(result, currentCell.getMvccVersion());
      }
    }
    result.position(result.limit());//make it appear as if we were appending
    return result;
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:pbase    文件:DecoderFactory.java   
public static void checkIn(CellSearcher pSearcher) {
  if (pSearcher == null) {
    return;
  }
  if (! (pSearcher instanceof PrefixTreeArraySearcher)) {
    throw new IllegalArgumentException("Cannot return "+pSearcher.getClass()+" to "
        +DecoderFactory.class);
  }
  PrefixTreeArraySearcher searcher = (PrefixTreeArraySearcher) pSearcher;
  POOL.checkIn(searcher);
}
项目:pbase    文件:TestPrefixTreeSearcher.java   
@Test
public void testRandomSeekHits() throws IOException {
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);
    for (KeyValue kv : rows.getInputs()) {
      boolean hit = searcher.positionAt(kv);
      Assert.assertTrue(hit);
      Cell foundKv = searcher.current();
      Assert.assertTrue(CellComparator.equals(kv, foundKv));
    }
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:pbase    文件:TestPrefixTreeSearcher.java   
@Test
public void testRandomSeekIndividualAssertions() throws IOException {
  CellSearcher searcher = null;
  try {
    searcher = DecoderFactory.checkOut(block, true);
    rows.individualSearcherAssertions(searcher);
  } finally {
    DecoderFactory.checkIn(searcher);
  }
}
项目:pbase    文件:TestRowDataTrivial.java   
@Override
public void individualSearcherAssertions(CellSearcher searcher) {
  /**
   * The searcher should get a token mismatch on the "r" branch. Assert that it skips not only rA,
   * but rB as well.
   */
  KeyValue afterLast = KeyValueUtil.createFirstOnRow(Bytes.toBytes("zzz"));
  CellScannerPosition position = searcher.positionAtOrAfter(afterLast);
  Assert.assertEquals(CellScannerPosition.AFTER_LAST, position);
  Assert.assertNull(searcher.current());
}
项目:pbase    文件:TestRowDataDeeper.java   
@Override
public void individualSearcherAssertions(CellSearcher searcher) {
  /**
   * The searcher should get a token mismatch on the "r" branch.  Assert that it skips not only
   * rA, but rB as well.
   */
  KeyValue cfcRow = KeyValueUtil.createFirstOnRow(Bytes.toBytes("cfc"));
  CellScannerPosition position = searcher.positionAtOrAfter(cfcRow);
  Assert.assertEquals(CellScannerPosition.AFTER, position);
  Assert.assertEquals(d.get(2), searcher.current());
  searcher.previous();
  Assert.assertEquals(d.get(1), searcher.current());
}