Examples of CellSearcher


Examples of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellSearcher

    sourceAsBuffer.rewind();
    int numV1BytesWithHeader = allocateHeaderLength + blockMeta.getNumKeyValueBytes();
    byte[] keyValueBytesWithHeader = new byte[numV1BytesWithHeader];
    ByteBuffer result = ByteBuffer.wrap(keyValueBytesWithHeader);
    result.rewind();
    CellSearcher searcher = null;
    try {
      searcher = DecoderFactory.checkOut(sourceAsBuffer, includesMvccVersion);
      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();
        KeyValueUtil.appendToByteArray(currentCell, result.array(), offset);
        int keyValueLength = KeyValueUtil.length(currentCell);
View Full Code Here

Examples of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellSearcher

    sourceAsBuffer.rewind();
    int numV1BytesWithHeader = allocateHeaderLength + blockMeta.getNumKeyValueBytes();
    byte[] keyValueBytesWithHeader = new byte[numV1BytesWithHeader];
    ByteBuffer result = ByteBuffer.wrap(keyValueBytesWithHeader);
    result.rewind();
    CellSearcher searcher = null;
    try {
      searcher = DecoderFactory.checkOut(sourceAsBuffer, includesMvccVersion);
      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();
        KeyValueUtil.appendToByteArray(currentCell, result.array(), offset);
        int keyValueLength = KeyValueUtil.length(currentCell);
View Full Code Here

Examples of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellSearcher

    sourceAsBuffer.rewind();
    int numV1BytesWithHeader = allocateHeaderLength + blockMeta.getNumKeyValueBytes();
    byte[] keyValueBytesWithHeader = new byte[numV1BytesWithHeader];
    ByteBuffer result = ByteBuffer.wrap(keyValueBytesWithHeader);
    result.rewind();
    CellSearcher searcher = null;
    try {
      searcher = DecoderFactory.checkOut(sourceAsBuffer, includesMvccVersion);
      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();
        KeyValueUtil.appendToByteArray(currentCell, result.array(), offset);
        int keyValueLength = KeyValueUtil.length(currentCell);
View Full Code Here

Examples of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellSearcher

  }


  @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));
View Full Code Here

Examples of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellSearcher

  }


  @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);
View Full Code Here

Examples of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellSearcher

  }


  @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);
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellSearcher

  /**
   * very hard to test nubs with this thing since the a nextRowKey function will usually skip them
   */
  @Test
  public void testRandomSeekMisses() throws IOException {
    CellSearcher searcher = null;
    List<Integer> rowStartIndexes = rows.getRowStartIndexes();
    try {
      searcher = DecoderFactory.checkOut(block, true);
      for (int i=0; i < rows.getInputs().size(); ++i) {
        KeyValue kv = rows.getInputs().get(i);

        //nextRow
        KeyValue inputNextRow = KeyValueUtil.createFirstKeyInNextRow(kv);

        CellScannerPosition position = searcher.positionAtOrBefore(inputNextRow);
        boolean isFirstInRow = rowStartIndexes.contains(i);
        if(isFirstInRow){
          int rowIndex = rowStartIndexes.indexOf(i);
          if(rowIndex < rowStartIndexes.size() - 1){
//            int lastKvInRowI = rowStartIndexes.get(rowIndex + 1) - 1;
            Assert.assertEquals(CellScannerPosition.BEFORE, position);
            /*
             * Can't get this to work between nubs like rowB\x00 <-> rowBB
             *
             * No reason to doubt that it works, but will have to come up with a smarter test.
             */
//            Assert.assertEquals(rows.getInputs().get(lastKvInRowI), searcher.getCurrentCell());
          }
        }

        //previous KV
        KeyValue inputPreviousKv = KeyValueUtil.previousKey(kv);
        boolean hit = searcher.positionAt(inputPreviousKv);
        Assert.assertFalse(hit);
        position = searcher.positionAtOrAfter(inputPreviousKv);
        if(CollectionUtils.isLastIndex(rows.getInputs(), i)){
          Assert.assertTrue(CellScannerPosition.AFTER_LAST == position);
        }else{
          Assert.assertTrue(CellScannerPosition.AFTER == position);
          /*
           * TODO: why i+1 instead of i?
           */
          Assert.assertEquals(rows.getInputs().get(i+1), searcher.current());
        }
      }
    } finally {
      DecoderFactory.checkIn(searcher);
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellSearcher

  }


  @Test
  public void testRandomSeekIndividualAssertions() throws IOException {
    CellSearcher searcher = null;
    try {
      searcher = DecoderFactory.checkOut(block, true);
      rows.individualSearcherAssertions(searcher);
    } finally {
      DecoderFactory.checkIn(searcher);
View Full Code Here

Examples of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellSearcher

    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());
View Full Code Here

Examples of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellSearcher

    this.block = ByteBuffer.wrap(outputBytes);
  }

  @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));
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.