Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.HStoreKey


        HScannerInterface rootScanner = rootRegion.getScanner(
            HConstants.COL_REGIONINFO_ARRAY, HConstants.EMPTY_START_ROW,
            HConstants.LATEST_TIMESTAMP, null);

        try {
          HStoreKey key = new HStoreKey();
          SortedMap<Text, byte[]> results = new TreeMap<Text, byte[]>();
          while (rootScanner.next(key, results)) {
            HRegionInfo info = Writables.getHRegionInfoOrNull(
                results.get(HConstants.COL_REGIONINFO));
            if (info == null) {
              LOG.warn("region info is null for row " + key.getRow() +
                  " in table " + HConstants.ROOT_TABLE_NAME);
              continue;
            }

            // First move the meta region to where it should be and rename
View Full Code Here


      HScannerInterface metaScanner = metaRegion.getScanner(
          HConstants.COL_REGIONINFO_ARRAY, HConstants.EMPTY_START_ROW,
          HConstants.LATEST_TIMESTAMP, null);

      try {
        HStoreKey key = new HStoreKey();
        SortedMap<Text, byte[]> results = new TreeMap<Text, byte[]>();
        while (metaScanner.next(key, results)) {
          HRegionInfo region = Writables.getHRegionInfoOrNull(
              results.get(HConstants.COL_REGIONINFO));
          if (region == null) {
            LOG.warn("region info is null for row " + key.getRow() +
                " in table " + HConstants.META_TABLE_NAME);
            continue;
          }

          // Move the region to where it should be and rename
View Full Code Here

      this.leases.renewLease(scannerName);

      // Collect values to be returned here
      HbaseMapWritable<byte [], Cell> values
        = new HbaseMapWritable<byte [], Cell>();
      HStoreKey key = new HStoreKey();
      TreeMap<byte [], Cell> results =
        new TreeMap<byte [], Cell>(Bytes.BYTES_COMPARATOR);
      while (s.next(key, results)) {
        values.putAll(results);
        if (values.size() > 0) {
          // Row has something in it. Return the value.
          break;
        }

        // No data for this row, go get another.
        results.clear();
      }
      return values.size() == 0 ? null : new RowResult(key.getRow(), values);
    } catch (IOException e) {
      checkFileSystem();
      throw e;
    }
  }
View Full Code Here

    InternalScanner rootScanner = rootRegion.getScanner(
        HConstants.COL_REGIONINFO_ARRAY, HConstants.EMPTY_START_ROW,
        HConstants.LATEST_TIMESTAMP, null);

    try {
      HStoreKey key = new HStoreKey();
      SortedMap<byte [], Cell> results =
        new TreeMap<byte [], Cell>(Bytes.BYTES_COMPARATOR);
      while (rootScanner.next(key, results)) {
        HRegionInfo info = Writables.getHRegionInfoOrNull(
            results.get(HConstants.COL_REGIONINFO).getValue());
        if (info == null) {
          LOG.warn("region info is null for row " + key.getRow() +
              " in table " + HConstants.ROOT_TABLE_NAME);
          continue;
        }
        if (!listener.processRow(info)) {
          break;
View Full Code Here

  public void scanMetaRegion(final HRegion m, final ScannerListener listener)
  throws IOException {
    InternalScanner metaScanner = m.getScanner(HConstants.COL_REGIONINFO_ARRAY,
      HConstants.EMPTY_START_ROW, HConstants.LATEST_TIMESTAMP, null);
    try {
      HStoreKey key = new HStoreKey();
      SortedMap<byte[], Cell> results =
        new TreeMap<byte[], Cell>(Bytes.BYTES_COMPARATOR);
      while (metaScanner.next(key, results)) {
        HRegionInfo info = Writables.getHRegionInfoOrNull(
            results.get(HConstants.COL_REGIONINFO).getValue());
        if (info == null) {
          LOG.warn("regioninfo null for row " + key.getRow() + " in table " +
            Bytes.toString(m.getTableDesc().getName()));
          continue;
        }
        if (!listener.processRow(info)) {
          break;
View Full Code Here

      // Split each store file.
      for(HStoreFile h: hstoreFilesToSplit) {
        // A reference to the bottom half of the hsf store file.
        HStoreFile.Reference aReference = new HStoreFile.Reference(
            this.regionInfo.getEncodedName(), h.getFileId(),
            new HStoreKey(midKey), HStoreFile.Range.bottom);
        HStoreFile a = new HStoreFile(this.conf, fs, splits,
            regionAInfo.getEncodedName(), h.getColFamily(), -1, aReference);
        // Reference to top half of the hsf store file.
        HStoreFile.Reference bReference = new HStoreFile.Reference(
            this.regionInfo.getEncodedName(), h.getFileId(),
            new HStoreKey(midKey), HStoreFile.Range.top);
        HStoreFile b = new HStoreFile(this.conf, fs, splits,
            regionBInfo.getEncodedName(), 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);
    return getStore(column).get(key, numVersions);
  }
View Full Code Here

    if (columns != null) {
      for (byte [] column: columns) {
        checkColumn(column);
      }
    }
    HStoreKey key = new HStoreKey(row, ts);
    Integer lid = obtainRowLock(row);
    try {
      TreeMap<byte [], Cell> result =
        new TreeMap<byte [], Cell>(Bytes.BYTES_COMPARATOR);
      for (HStore targetStore: stores.values()) {
View Full Code Here

   */
  public RowResult getClosestRowBefore(final byte [] row)
  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 {
      // examine each column family for the preceeding or matching key
      for (HStore store : stores.values()) {
        // get the closest key
        byte [] closestKey = store.getRowKeyAtOrBefore(row);
        // if it happens to be an exact match, we can stop looping
        if (Bytes.equals(row, closestKey)) {
          key = new HStoreKey(closestKey);
          break;
        }
        // otherwise, we need to check if it's the max and move to the next
        if (closestKey != null
          && (key == null || Bytes.compareTo(closestKey, key.getRow()) > 0) ) {
          key = new HStoreKey(closestKey);
        }
      }
      if (key == null) {
        return null;
      }
     
      // now that we've found our key, get the values
      HbaseMapWritable<byte [], Cell> cells =
        new HbaseMapWritable<byte [], Cell>();
      for (HStore s: stores.values()) {
        s.getFull(key, null, 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);
        byte[] val = null;
        if (op.isPut()) {
          val = op.getValue();
          if (HLogEdit.isDeleted(val)) {
            throw new IOException("Cannot insert value: " + val);
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.