Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.HStoreKey$HStoreKeyComparator


            // NOTE: We used to do results.putAll(resultSets[i]);
            // but this had the effect of overwriting newer
            // values with older ones. So now we only insert
            // a result if the map does not contain the key.
            HStoreKey hsk = new HStoreKey(key.getRow(),
              HConstants.EMPTY_BYTE_ARRAY,
              key.getTimestamp(), this.store.getHRegionInfo());
            for (Map.Entry<byte [], Cell> e : resultSets[i].entrySet()) {
              hsk.setColumn(e.getKey());
              if (HLogEdit.isDeleted(e.getValue().getValue())) {
                // Only first key encountered is added; deletes is a Set.
                deletes.add(new HStoreKey(hsk));
              } else if (!deletes.contains(hsk) &&
                  !filtered &&
                  moreToFollow &&
                  !results.containsKey(e.getKey())) {
                if (dataFilter != null) {
View Full Code Here


    this.encodedRegionName = Integer.parseInt(in.readUTF());
    fileid = in.readLong();
    boolean tmp = in.readBoolean();
    // If true, set region to top.
    region = tmp? Range.top: Range.bottom;
    midkey = new HStoreKey();
    midkey.readFields(in);
  }
View Full Code Here

    this.keys = new HStoreKey[readers.length];
    this.vals = new byte[readers.length][];

    // Advance the readers to the first pos.
    for (int i = 0; i < readers.length; i++) {
      keys[i] = new HStoreKey(HConstants.EMPTY_BYTE_ARRAY, this.store
          .getHRegionInfo());
      if (firstRow != null && firstRow.length != 0) {
        if (findFirstRow(i, firstRow)) {
          continue;
        }
View Full Code Here

   * @param firstRow seek to this row
   * @return true if this is the first row or if the row was not found
   */
  private boolean findFirstRow(int i, final byte [] firstRow) throws IOException {
    ImmutableBytesWritable ibw = new ImmutableBytesWritable();
    HStoreKey firstKey
      = (HStoreKey)readers[i].getClosest(new HStoreKey(firstRow, this.store.getHRegionInfo()), ibw);
    if (firstKey == null) {
      // Didn't find it. Close the scanner and return TRUE
      closeSubScanner(i);
      return true;
    }
    long now = System.currentTimeMillis();
    long ttl = store.ttl;
    if (ttl != HConstants.FOREVER && now >= firstKey.getTimestamp() + ttl) {
      // Didn't find it. Close the scanner and return TRUE
      closeSubScanner(i);
      return true;
    }
    this.vals[i] = ibw.get();
    keys[i].setRow(firstKey.getRow());
    keys[i].setColumn(firstKey.getColumn());
    keys[i].setVersion(firstKey.getTimestamp());
    return columnMatch(i);
  }
View Full Code Here

      final long timestamp) throws IOException {
    TransactionState state = getTransactionState(transactionId);
    long now = System.currentTimeMillis();

    for (HStore store : super.stores.values()) {
      List<HStoreKey> keys = store.getKeys(new HStoreKey(row, timestamp),
          ALL_VERSIONS, now, null);
      BatchUpdate deleteUpdate = new BatchUpdate(row, timestamp);

      for (HStoreKey key : keys) {
        deleteUpdate.delete(key.getColumn());
View Full Code Here

      // Split each store file.
      for(HStoreFile h: hstoreFilesToSplit) {
        // A reference to the bottom half of the hsf store file.
        Reference aReference = new Reference(
            this.regionInfo.getEncodedName(), h.getFileId(),
            new HStoreKey(midKey, this.regionInfo), Reference.Range.bottom);
        HStoreFile a = new HStoreFile(this.conf, fs, splits,
            regionAInfo, h.getColFamily(), -1, aReference);
        // Reference to top half of the hsf store file.
        Reference bReference = new Reference(
            this.regionInfo.getEncodedName(), h.getFileId(),
            new HStoreKey(midKey, this.regionInfo), Reference.Range.top);
        HStoreFile b = new HStoreFile(this.conf, fs, splits,
            regionBInfo, h.getColFamily(), -1, bReference);
        h.splitStoreFile(a, b, this.fs);
      }
View Full Code Here

      }
      // Make sure this is a valid row and valid column
      checkRow(row);
      checkColumn(column);
      // Don't need a row lock for a simple get
      HStoreKey key = new HStoreKey(row, column, timestamp, this.regionInfo);
      Cell[] result = getStore(column).get(key, numVersions);
      // Guarantee that we return null instead of a zero-length array,
      // if there are no results to return.
      return (result == null || result.length == 0)? null : result;
    } finally {
View Full Code Here

    if (columns != null) {
      for (byte [] column: columns) {
        checkColumn(column);
      }
    }
    HStoreKey key = new HStoreKey(row, ts, this.regionInfo);
    Integer lid = getLock(lockid,row);
    HashSet<HStore> storeSet = new HashSet<HStore>();
    try {
      HbaseMapWritable<byte [], Cell> result =
        new HbaseMapWritable<byte [], Cell>();
View Full Code Here

  public RowResult getClosestRowBefore(final byte [] row,
      final byte [] columnFamily)
  throws IOException{
    // look across all the HStores for this region and determine what the
    // closest key is across all column families, since the data may be sparse
    HStoreKey key = null;
    checkRow(row);
    splitsAndClosesLock.readLock().lock();
    try {
      HStore store = getStore(columnFamily);
      // get the closest key. (HStore.getRowKeyAtOrBefore can return null)
      byte [] closestKey = store.getRowKeyAtOrBefore(row);
      // If it happens to be an exact match, we can stop.
      // Otherwise, we need to check if it's the max and move to the next
      if (closestKey != null) {
        if (HStoreKey.equalsTwoRowKeys(regionInfo, row, closestKey)) {
          key = new HStoreKey(closestKey, this.regionInfo);
        }
        if (key == null) {
          key = new HStoreKey(closestKey, this.regionInfo);
        }
      }
      if (key == null) {
        return null;
      }

      // Now that we've found our key, get the values
      HbaseMapWritable<byte [], Cell> cells =
        new HbaseMapWritable<byte [], Cell>();
      // This will get all results for this store.
      store.getFull(key, null, 1, cells);
      return new RowResult(key.getRow(), cells);
    } finally {
      splitsAndClosesLock.readLock().unlock();
    }
  }
View Full Code Here

      long commitTime = (b.getTimestamp() == LATEST_TIMESTAMP) ?
          System.currentTimeMillis() : b.getTimestamp();
      try {
        List<byte []> deletes = null;
        for (BatchOperation op: b) {
          HStoreKey key = new HStoreKey(row, op.getColumn(), commitTime,
              this.regionInfo);
          byte[] val = null;
          if (op.isPut()) {
            val = op.getValue();
            if (HLogEdit.isDeleted(val)) {
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.HStoreKey$HStoreKeyComparator

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.