Package org.apache.hadoop.hbase.regionserver

Examples of org.apache.hadoop.hbase.regionserver.InternalScanner


        kvs.length, idx);
  }

  private void verifyScanFullNoValues(Scan s, KeyValue [] kvs, boolean useLen)
  throws IOException {
    InternalScanner scanner = this.region.getScanner(s);
    List<KeyValue> results = new ArrayList<KeyValue>();
    int row = 0;
    int idx = 0;
    for (boolean more = true; more; row++) {
      more = scanner.next(results);
      Arrays.sort(results.toArray(new KeyValue[results.size()]),
          KeyValue.COMPARATOR);
      if(results.isEmpty()) break;
      assertTrue("Scanned too many keys! Only expected " + kvs.length +
          " total but already scanned " + (results.size() + idx) +
View Full Code Here


    CacheConfig cacheConf = new CacheConfig(conf);
    LruBlockCache cache = (LruBlockCache) cacheConf.getBlockCache();
    cache.clearCache();
    Map<String, Long> metricsBefore = SchemaMetrics.getMetricsSnapshot();
    SchemaMetrics.validateMetricChanges(metricsBefore);
    InternalScanner scanner = region.getScanner(scan);
    List<KeyValue> results = new ArrayList<KeyValue>();
    while (scanner.next(results)) {
    }
    scanner.close();
    assertEquals(0, results.size());
    Set<String> accessedFiles = cache.getCachedFileNamesForTest();
    assertEquals(accessedFiles.size(), 0);
    //assertEquals(cache.getBlockCount(), 0);
    Map<String, Long> diffMetrics = SchemaMetrics.diffMetrics(metricsBefore,
View Full Code Here

    }
    super.getRequestCount().incrementAndGet();
    try {
      TransactionalRegion r = getTransactionalRegion(regionName);
      long scannerId = -1L;
      InternalScanner s = r.getScanner(transactionId, cols, firstRow,
          timestamp, filter);
      scannerId = super.addScanner(s);
      return scannerId;
    } catch (IOException e) {
      LOG.error("Error opening scanner (fsOk: " + this.fsOk + ")",
View Full Code Here

    // Open root region so we can scan it
    if (this.rootRegion == null) {
      openRootRegion();
    }

    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;
        }
        results.clear();
      }
    } finally {
      rootScanner.close();
    }
  }
View Full Code Here

   * @param listener
   * @throws IOException
   */
  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;
        }
        results.clear();
      }
    } finally {
      metaScanner.close();
    }
  }
View Full Code Here

   * has no actual methods of querying itself, and relies on StoreScanner.
   */
  public static List<Cell> getFromStoreFile(HStore store,
                                                Get get) throws IOException {
    Scan scan = new Scan(get);
    InternalScanner scanner = (InternalScanner) store.getScanner(scan,
        scan.getFamilyMap().get(store.getFamily().getName()),
        // originally MultiVersionConsistencyControl.resetThreadReadPoint() was called to set
        // readpoint 0.
        0);

    List<Cell> result = new ArrayList<Cell>();
    scanner.next(result);
    if (!result.isEmpty()) {
      // verify that we are on the row we want:
      Cell kv = result.get(0);
      if (!CellUtil.matchingRow(kv, get.getRow())) {
        result.clear();
      }
    }
    scanner.close();
    return result;
  }
View Full Code Here

   
  }
 
  private void verifyScan(Scan s, long expectedRows, long expectedKeys)
  throws IOException {
    InternalScanner scanner = this.region.getScanner(s);
    List<KeyValue> results = new ArrayList<KeyValue>();
    int i = 0;
    for (boolean done = true; done; i++) {
      done = scanner.next(results);
      Arrays.sort(results.toArray(new KeyValue[results.size()]),
          KeyValue.COMPARATOR);
      LOG.info("counter=" + i + ", " + results);
      assertTrue("Scanned too many rows! Only expected " + expectedRows +
          " total but already scanned " + (i+1), expectedRows > i);
View Full Code Here

 
  private void verifyScanNoEarlyOut(Scan s, long expectedRows,
      long expectedKeys)
  throws IOException {
    InternalScanner scanner = this.region.getScanner(s);
    List<KeyValue> results = new ArrayList<KeyValue>();
    int i = 0;
    for (boolean done = true; done; i++) {
      done = scanner.next(results);
      Arrays.sort(results.toArray(new KeyValue[results.size()]),
          KeyValue.COMPARATOR);
      LOG.info("counter=" + i + ", " + results);
      if(results.isEmpty()) break;
      assertTrue("Scanned too many rows! Only expected " + expectedRows +
View Full Code Here

        " rows", expectedRows, i);
  }

  private void verifyScanFull(Scan s, KeyValue [] kvs)
  throws IOException {
    InternalScanner scanner = this.region.getScanner(s);
    List<KeyValue> results = new ArrayList<KeyValue>();
    int row = 0;
    int idx = 0;
    for (boolean done = true; done; row++) {
      done = scanner.next(results);
      Arrays.sort(results.toArray(new KeyValue[results.size()]),
          KeyValue.COMPARATOR);
      if(results.isEmpty()) break;
      assertTrue("Scanned too many keys! Only expected " + kvs.length +
          " total but already scanned " + (results.size() + idx) +
View Full Code Here

    // Open root region so we can scan it
    if (this.rootRegion == null) {
      openRootRegion();
    }

    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;
        }
        results.clear();
      }
    } finally {
      rootScanner.close();
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.regionserver.InternalScanner

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.