Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.HStoreKey


   */
  private void rowAtOrBeforeFromMapFile(final MapFile.Reader map,
    final byte [] row, final SortedMap<HStoreKey, Long> candidateKeys,
    final Set<HStoreKey> deletes)
  throws IOException {
    HStoreKey startKey = new HStoreKey();
    ImmutableBytesWritable startValue = new ImmutableBytesWritable();
    synchronized(map) {
      // Don't bother with the rest of this if the file is empty
      map.reset();
      if (!map.next(startKey, startValue)) {
        return;
      }
      startKey.setHRegionInfo(this.info);
      // If start row for this file is beyond passed in row, return; nothing
      // in here is of use to us.
      if (HStoreKey.compareTwoRowKeys(this.info, startKey.getRow(), row) > 0) {
        return;
      }
      long now = System.currentTimeMillis();
      // if there aren't any candidate keys yet, we'll do some things different
      if (candidateKeys.isEmpty()) {
View Full Code Here


    final Set<HStoreKey> deletes, final long now)
  throws IOException {
    // if the row we're looking for is past the end of this mapfile, set the
    // search key to be the last key.  If its a deleted key, then we'll back
    // up to the row before and return that.
    HStoreKey finalKey = getFinalKey(map);
    HStoreKey searchKey = null;
    if (HStoreKey.compareTwoRowKeys(info,finalKey.getRow(), row) < 0) {
      searchKey = finalKey;
    } else {
      searchKey = new HStoreKey(row, this.info);
      if (searchKey.compareTo(startKey) < 0) {
        searchKey = startKey;
      }
    }
    rowAtOrBeforeCandidate(map, searchKey, candidateKeys, deletes, now);
  }
View Full Code Here

   */
  private void rowAtOrBeforeCandidate(final MapFile.Reader map,
    final HStoreKey sk, final SortedMap<HStoreKey, Long> candidateKeys,
    final Set<HStoreKey> deletes, final long now)
  throws IOException {
    HStoreKey searchKey = sk;
    if (searchKey.getHRegionInfo() == null) {
      searchKey.setHRegionInfo(this.info);
    }
    HStoreKey readkey = null;
    ImmutableBytesWritable readval = new ImmutableBytesWritable();
    HStoreKey knownNoGoodKey = null;
    for (boolean foundCandidate = false; !foundCandidate;) {
      // Seek to the exact row, or the one that would be immediately before it
      readkey = (HStoreKey)map.getClosest(searchKey, readval, true);
      if (readkey == null) {
        // If null, we are at the start or end of the file.
        break;
      }
      HStoreKey deletedOrExpiredRow = null;
      do {
        // Set this region into the readkey.
        readkey.setHRegionInfo(this.info);
        // If we have an exact match on row, and it's not a delete, save this
        // as a candidate key
        if (HStoreKey.equalsTwoRowKeys(this.info, readkey.getRow(),
            searchKey.getRow())) {
          if (!HLogEdit.isDeleted(readval.get())) {
            if (handleNonDelete(readkey, now, deletes, candidateKeys)) {
              foundCandidate = true;
              // NOTE! Continue.
              continue;
            }
          }
          HStoreKey copy = addCopyToDeletes(readkey, deletes);
          if (deletedOrExpiredRow == null) {
            deletedOrExpiredRow = copy;
          }
        } else if (HStoreKey.compareTwoRowKeys(this.info, readkey.getRow(),
            searchKey.getRow()) > 0) {
          // if the row key we just read is beyond the key we're searching for,
          // then we're done.
          break;
        } else {
          // So, the row key doesn't match, but we haven't gone past the row
          // we're seeking yet, so this row is a candidate for closest
          // (assuming that it isn't a delete).
          if (!HLogEdit.isDeleted(readval.get())) {
            if (handleNonDelete(readkey, now, deletes, candidateKeys)) {
              foundCandidate = true;
              // NOTE: Continue
              continue;
            }
          }
          HStoreKey copy = addCopyToDeletes(readkey, deletes);
          if (deletedOrExpiredRow == null) {
            deletedOrExpiredRow = copy;
          }
        }
      } while(map.next(readkey, readval) && (knownNoGoodKey == null ||
View Full Code Here

   * @param deletes
   * @return Instance of the copy added to <code>deletes</code>
   */
  private HStoreKey addCopyToDeletes(final HStoreKey key,
      final Set<HStoreKey> deletes) {
    HStoreKey copy = new HStoreKey(key);
    deletes.add(copy);
    return copy;
  }
View Full Code Here

  private void rowAtOrBeforeWithCandidates(final HStoreKey startKey,
    final MapFile.Reader map, final byte[] row,
    final SortedMap<HStoreKey, Long> candidateKeys,
    final Set<HStoreKey> deletes, final long now)
  throws IOException {
    HStoreKey readkey = null;
    ImmutableBytesWritable readval = new ImmutableBytesWritable();

    // if there are already candidate keys, we need to start our search
    // at the earliest possible key so that we can discover any possible
    // deletes for keys between the start and the search key.  Back up to start
    // of the row in case there are deletes for this candidate in this mapfile
    // BUT do not backup before the first key in the mapfile else getClosest
    // will return null
    HStoreKey searchKey = new HStoreKey(candidateKeys.firstKey().getRow(), this.info);
    if (searchKey.compareTo(startKey) < 0) {
      searchKey = startKey;
    }

    // Seek to the exact row, or the one that would be immediately before it
    readkey = (HStoreKey)map.getClosest(searchKey, readval, true);
View Full Code Here

      final SortedMap<HStoreKey, Long> candidateKeys) {
    if (!HLogEdit.isDeleted(value)) {
      handleNonDelete(readkey, now, deletes, candidateKeys);
    } else {
      // Pass copy because readkey will change next time next is called.
      handleDeleted(new HStoreKey(readkey), candidateKeys, deletes);
    }
  }
View Full Code Here

   */
  static void handleDeleted(final HStoreKey k,
      final SortedMap<HStoreKey, Long> candidateKeys,
      final Set<HStoreKey> deletes) {
    deletes.add(k);
    HStoreKey strippedKey = stripTimestamp(k);
    if (candidateKeys.containsKey(strippedKey)) {
      long bestCandidateTs =
        candidateKeys.get(strippedKey).longValue();
      if (bestCandidateTs <= k.getTimestamp()) {
        candidateKeys.remove(strippedKey);
View Full Code Here

   * @param mf MapFile to dig in.
   * @return Final key from passed <code>mf</code>
   * @throws IOException
   */
  private HStoreKey getFinalKey(final MapFile.Reader mf) throws IOException {
    HStoreKey finalKey = new HStoreKey();
    mf.finalKey(finalKey);
    finalKey.setHRegionInfo(this.info);
    return finalKey;
  }
View Full Code Here

      if (!this.lastSeqWritten.containsKey(regionName)) {
        this.lastSeqWritten.put(regionName, Long.valueOf(seqNum[0]));
      }
      int counter = 0;
      for (Map.Entry<HStoreKey, byte[]> es : edits.entrySet()) {
        HStoreKey key = es.getKey();
        HLogKey logKey =
          new HLogKey(regionName, tableName, key.getRow(), seqNum[counter++]);
        HLogEdit logEdit =
          new HLogEdit(key.getColumn(), es.getValue(), key.getTimestamp());
       doWrite(logKey, logEdit, sync);

        this.numEntries++;
      }
      updateLock.notifyAll();
View Full Code Here

    // This is not actual midkey for this half-file; its just border
    // around which we split top and bottom.  Have to look in files to find
    // actual last and first keys for bottom and top halves.  Half-files don't
    // have an actual midkey themselves. No midkey is how we indicate file is
    // not splittable.
    this.midkey = new HStoreKey((HStoreKey)mk);
    this.midkey.setHRegionInfo(hri);
    // Is it top or bottom half?
    this.top = Reference.isTopFileRegion(r);
  }
View Full Code Here

TOP

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

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.