Package org.apache.hadoop.hbase.util

Examples of org.apache.hadoop.hbase.util.ByteRange


      }
    }
    RegionScanner scanner = getRegion(e).getScanner(new Scan(get));
    List<Cell> cells = Lists.newArrayList();
    Cell prevCell = null;
    ByteRange curFam = new SimpleMutableByteRange();
    boolean curColAllVersions = (request == OpType.DELETE);
    long curColCheckTs = opTs;
    boolean foundColumn = false;
    try {
      boolean more = false;
      do {
        cells.clear();
        // scan with limit as 1 to hold down memory use on wide rows
        more = scanner.next(cells, 1);
        for (Cell cell: cells) {
          if (LOG.isTraceEnabled()) {
            LOG.trace("Found cell " + cell);
          }
          boolean colChange = prevCell == null || !CellUtil.matchingColumn(prevCell, cell);
          if (colChange) foundColumn = false;
          prevCell = cell;
          if (!curColAllVersions && foundColumn) {
            continue;
          }
          if (colChange && considerCellTs) {
            curFam.set(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength());
            List<Cell> cols = familyMap1.get(curFam);
            for (Cell col : cols) {
              // null/empty qualifier is used to denote a Family delete. The TS and delete type
              // associated with this is applicable for all columns within the family. That is
              // why the below (col.getQualifierLength() == 0) check.
View Full Code Here


    // 100K iterations by 0-1K alloc -> 50MB expected
    // should be reasonable for unit test and also cover wraparound
    // behavior
    for (int i = 0; i < 100000; i++) {
      int size = rand.nextInt(1000);
      ByteRange alloc = mslab.allocateBytes(size);
     
      if (alloc.getBytes() != lastBuffer) {
        expectedOff = 0;
        lastBuffer = alloc.getBytes();
      }
      assertEquals(expectedOff, alloc.getOffset());
      assertTrue("Allocation overruns buffer",
          alloc.getOffset() + size <= alloc.getBytes().length);
      expectedOff += size;
    }
  }
View Full Code Here

  }

  @Test
  public void testLABLargeAllocation() {
    MemStoreLAB mslab = new HeapMemStoreLAB();
    ByteRange alloc = mslab.allocateBytes(2*1024*1024);
    assertNull("2MB allocation shouldn't be satisfied by LAB.",
      alloc);
  }
View Full Code Here

      TestThread t = new MultithreadedTestUtil.RepeatingTestThread(ctx) {
        private Random r = new Random();
        @Override
        public void doAnAction() throws Exception {
          int size = r.nextInt(1000);
          ByteRange alloc = mslab.allocateBytes(size);
          totalAllocated.addAndGet(size);
          allocsByThisThread.add(new AllocRecord(alloc, size));
        }
      };
      ctx.addThread(t);
View Full Code Here

@Category({MiscTests.class, SmallTests.class})
public class TestByteRange {

  @Test
  public void testConstructor() {
    ByteRange b = new SimpleMutableByteRange(new byte[] { 0, 1, 2 });
    Assert.assertEquals(3, b.getLength());
  }
View Full Code Here

public class TestByteRange {

  @Test
  public void testConstructor() {
    ByteRange b = new SimpleByteRange(new byte[] { 0, 1, 2 });
    Assert.assertEquals(3, b.getLength());
  }
View Full Code Here

  public TestColumnDataRandom(int numColumns) {
    RedundantKVGenerator generator = new RedundantKVGenerator();
    ByteRangeSet sortedColumns = new ByteRangeTreeSet();
    List<KeyValue> d = generator.generateTestKeyValues(numColumns);
    for (KeyValue col : d) {
      ByteRange colRange = new SimpleByteRange(col.getQualifier());
      inputs.add(colRange);
      sortedColumns.add(colRange);
    }
    for (ByteRange col : sortedColumns.compile().getSortedRanges()) {
      outputs.add(col);
View Full Code Here

  /************* methods ********************************/

  @Test
  public void testReaderRoundTrip() throws IOException {
    for (int i = 0; i < sortedUniqueColumns.size(); ++i) {
      ByteRange column = sortedUniqueColumns.get(i);
      builder.addSorted(column);
    }
    List<byte[]> builderOutputArrays = builder.getArrays();
    for (int i = 0; i < builderOutputArrays.size(); ++i) {
      byte[] inputArray = sortedUniqueColumns.get(i).deepCopyToNewArray();
View Full Code Here

  protected int store(ByteRange bytes) {
    int indexOfNewElement = numUniqueRanges;
    if (uniqueRanges.size() <= numUniqueRanges) {
      uniqueRanges.add(new SimpleByteRange());
    }
    ByteRange storedRange = uniqueRanges.get(numUniqueRanges);
    int neededBytes = numBytes + bytes.getLength();
    byteAppender = ArrayUtils.growIfNecessary(byteAppender, neededBytes, 2 * neededBytes);
    bytes.deepCopyTo(byteAppender, numBytes);
    storedRange.set(byteAppender, numBytes, bytes.getLength());// this isn't valid yet
    numBytes += bytes.getLength();
    uniqueIndexByUniqueRange.put(storedRange, indexOfNewElement);
    int newestUniqueIndex = numUniqueRanges;
    ++numUniqueRanges;
    return newestUniqueIndex;
View Full Code Here

  /***************** building *************************/

  public void addAll(ArrayList<ByteRange> sortedByteRanges) {
    for (int i = 0; i < sortedByteRanges.size(); ++i) {
      ByteRange byteRange = sortedByteRanges.get(i);
      addSorted(byteRange);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.util.ByteRange

Copyright © 2018 www.massapicom. 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.