Java 类org.apache.hadoop.hbase.io.hfile.InvalidHFileException 实例源码

项目:ditb    文件:HStore.java   
@Override public void assertBulkLoadHFileOk(Path srcPath) throws IOException {
  HFile.Reader reader = null;
  try {
    LOG.info(
        "Validating hfile at " + srcPath + " for inclusion in " + "store " + this + " region "
            + this.getRegionInfo().getRegionNameAsString());
    reader = HFile.createReader(srcPath.getFileSystem(conf), srcPath, cacheConf, conf);
    reader.loadFileInfo();

    byte[] firstKey = reader.getFirstRowKey();
    Preconditions.checkState(firstKey != null, "First key can not be null");
    byte[] lk = reader.getLastKey();
    Preconditions.checkState(lk != null, "Last key can not be null");
    byte[] lastKey = KeyValue.createKeyValueFromKey(lk).getRow();

    LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey) + " last=" + Bytes
        .toStringBinary(lastKey));
    LOG.debug(
        "Region bounds: first=" + Bytes.toStringBinary(getRegionInfo().getStartKey()) + " last="
            + Bytes.toStringBinary(getRegionInfo().getEndKey()));

    if (!this.getRegionInfo().containsRange(firstKey, lastKey)) {
      throw new WrongRegionException(
          "Bulk load file " + srcPath.toString() + " does not fit inside region " + this
              .getRegionInfo().getRegionNameAsString());
    }

    if (reader.length() > conf
        .getLong(HConstants.HREGION_MAX_FILESIZE, HConstants.DEFAULT_MAX_FILE_SIZE)) {
      LOG.warn(
          "Trying to bulk load hfile " + srcPath.toString() + " with size: " + reader.length()
              + " bytes can be problematic as it may lead to oversplitting.");
    }

    if (verifyBulkLoads) {
      long verificationStartTime = EnvironmentEdgeManager.currentTime();
      LOG.info("Full verification started for bulk load hfile: " + srcPath.toString());
      Cell prevCell = null;
      HFileScanner scanner = reader.getScanner(false, false, false);
      scanner.seekTo();
      do {
        Cell cell = scanner.getKeyValue();
        if (prevCell != null) {
          if (CellComparator.compareRows(prevCell, cell) > 0) {
            throw new InvalidHFileException(
                "Previous row is greater than" + " current row: path=" + srcPath + " previous="
                    + CellUtil.getCellKeyAsString(prevCell) + " current=" + CellUtil
                    .getCellKeyAsString(cell));
          }
          if (CellComparator.compareFamilies(prevCell, cell) != 0) {
            throw new InvalidHFileException(
                "Previous key had different" + " family compared to current key: path=" + srcPath
                    + " previous=" + Bytes
                    .toStringBinary(prevCell.getFamilyArray(), prevCell.getFamilyOffset(),
                        prevCell.getFamilyLength()) + " current=" + Bytes
                    .toStringBinary(cell.getFamilyArray(), cell.getFamilyOffset(),
                        cell.getFamilyLength()));
          }
        }
        prevCell = cell;
      } while (scanner.next());
      LOG.info(
          "Full verification complete for bulk load hfile: " + srcPath.toString() + " took " + (
              EnvironmentEdgeManager.currentTime() - verificationStartTime) + " ms");
    }
  } finally {
    if (reader != null) reader.close();
  }
}
项目:LCIndex-HBase-0.94.16    文件:Store.java   
/**
 * This throws a WrongRegionException if the HFile does not fit in this region, or an
 * InvalidHFileException if the HFile is not valid.
 */
void assertBulkLoadHFileOk(Path srcPath) throws IOException {
  HFile.Reader reader = null;
  try {
    LOG.info("Validating hfile at " + srcPath + " for inclusion in " + "store " + this
        + " region " + this.region);
    reader = HFile.createReader(srcPath.getFileSystem(conf), srcPath, cacheConf);
    reader.loadFileInfo();

    byte[] firstKey = reader.getFirstRowKey();
    byte[] lk = reader.getLastKey();
    byte[] lastKey = (lk == null) ? null : KeyValue.createKeyValueFromKey(lk).getRow();

    LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey) + " last="
        + Bytes.toStringBinary(lastKey));
    LOG.debug("Region bounds: first=" + Bytes.toStringBinary(region.getStartKey()) + " last="
        + Bytes.toStringBinary(region.getEndKey()));

    HRegionInfo hri = region.getRegionInfo();
    if (!hri.containsRange(firstKey, lastKey)) {
      throw new WrongRegionException("Bulk load file " + srcPath.toString()
          + " does not fit inside region " + this.region);
    }

    if (verifyBulkLoads) {
      KeyValue prevKV = null;
      HFileScanner scanner = reader.getScanner(false, false, false);
      scanner.seekTo();
      do {
        KeyValue kv = scanner.getKeyValue();
        if (prevKV != null) {
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getRowOffset(), prevKV.getRowLength(),
            kv.getBuffer(), kv.getRowOffset(), kv.getRowLength()) > 0) {
            throw new InvalidHFileException("Previous row is greater than"
                + " current row: path=" + srcPath + " previous="
                + Bytes.toStringBinary(prevKV.getKey()) + " current="
                + Bytes.toStringBinary(kv.getKey()));
          }
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getFamilyOffset(),
            prevKV.getFamilyLength(), kv.getBuffer(), kv.getFamilyOffset(), kv.getFamilyLength()) != 0) {
            throw new InvalidHFileException("Previous key had different"
                + " family compared to current key: path=" + srcPath + " previous="
                + Bytes.toStringBinary(prevKV.getFamily()) + " current="
                + Bytes.toStringBinary(kv.getFamily()));
          }
        }
        prevKV = kv;
      } while (scanner.next());
    }
  } finally {
    if (reader != null) reader.close();
  }
}
项目:pbase    文件:HStore.java   
@Override
public void assertBulkLoadHFileOk(Path srcPath) throws IOException {
    HFile.Reader reader = null;
    try {
        LOG.info("Validating hfile at " + srcPath + " for inclusion in "
                + "store " + this + " region " + this.getRegionInfo().getRegionNameAsString());
        reader = HFile.createReader(srcPath.getFileSystem(conf),
                srcPath, cacheConf, conf);
        reader.loadFileInfo();

        byte[] firstKey = reader.getFirstRowKey();
        Preconditions.checkState(firstKey != null, "First key can not be null");
        byte[] lk = reader.getLastKey();
        Preconditions.checkState(lk != null, "Last key can not be null");
        byte[] lastKey = KeyValue.createKeyValueFromKey(lk).getRow();

        LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey) +
                " last=" + Bytes.toStringBinary(lastKey));
        LOG.debug("Region bounds: first=" +
                Bytes.toStringBinary(getRegionInfo().getStartKey()) +
                " last=" + Bytes.toStringBinary(getRegionInfo().getEndKey()));

        if (!this.getRegionInfo().containsRange(firstKey, lastKey)) {
            throw new WrongRegionException(
                    "Bulk load file " + srcPath.toString() + " does not fit inside region "
                            + this.getRegionInfo().getRegionNameAsString());
        }

        if (reader.length() > conf.getLong(HConstants.HREGION_MAX_FILESIZE,
                HConstants.DEFAULT_MAX_FILE_SIZE)) {
            LOG.warn("Trying to bulk load hfile " + srcPath.toString() + " with size: " +
                    reader.length() + " bytes can be problematic as it may lead to oversplitting.");
        }

        if (verifyBulkLoads) {
            long verificationStartTime = EnvironmentEdgeManager.currentTime();
            LOG.info("Full verification started for bulk load hfile: " + srcPath.toString());
            Cell prevCell = null;
            HFileScanner scanner = reader.getScanner(false, false, false);
            scanner.seekTo();
            do {
                Cell cell = scanner.getKeyValue();
                if (prevCell != null) {
                    if (CellComparator.compareRows(prevCell, cell) > 0) {
                        throw new InvalidHFileException("Previous row is greater than"
                                + " current row: path=" + srcPath + " previous="
                                + CellUtil.getCellKeyAsString(prevCell) + " current="
                                + CellUtil.getCellKeyAsString(cell));
                    }
                    if (CellComparator.compareFamilies(prevCell, cell) != 0) {
                        throw new InvalidHFileException("Previous key had different"
                                + " family compared to current key: path=" + srcPath
                                + " previous="
                                + Bytes.toStringBinary(prevCell.getFamilyArray(), prevCell.getFamilyOffset(),
                                prevCell.getFamilyLength())
                                + " current="
                                + Bytes.toStringBinary(cell.getFamilyArray(), cell.getFamilyOffset(),
                                cell.getFamilyLength()));
                    }
                }
                prevCell = cell;
            } while (scanner.next());
            LOG.info("Full verification complete for bulk load hfile: " + srcPath.toString()
                    + " took " + (EnvironmentEdgeManager.currentTime() - verificationStartTime)
                    + " ms");
        }
    } finally {
        if (reader != null) reader.close();
    }
}
项目:HIndex    文件:HStore.java   
@Override
public void assertBulkLoadHFileOk(Path srcPath) throws IOException {
  HFile.Reader reader  = null;
  try {
    LOG.info("Validating hfile at " + srcPath + " for inclusion in "
        + "store " + this + " region " + this.getRegionInfo().getRegionNameAsString());
    reader = HFile.createReader(srcPath.getFileSystem(conf),
        srcPath, cacheConf, conf);
    reader.loadFileInfo();

    byte[] firstKey = reader.getFirstRowKey();
    Preconditions.checkState(firstKey != null, "First key can not be null");
    byte[] lk = reader.getLastKey();
    Preconditions.checkState(lk != null, "Last key can not be null");
    byte[] lastKey =  KeyValue.createKeyValueFromKey(lk).getRow();

    LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey) +
        " last=" + Bytes.toStringBinary(lastKey));
    LOG.debug("Region bounds: first=" +
        Bytes.toStringBinary(getRegionInfo().getStartKey()) +
        " last=" + Bytes.toStringBinary(getRegionInfo().getEndKey()));

    if (!this.getRegionInfo().containsRange(firstKey, lastKey)) {
      throw new WrongRegionException(
          "Bulk load file " + srcPath.toString() + " does not fit inside region "
          + this.getRegionInfo().getRegionNameAsString());
    }

    if (verifyBulkLoads) {
      KeyValue prevKV = null;
      HFileScanner scanner = reader.getScanner(false, false, false);
      scanner.seekTo();
      do {
        KeyValue kv = scanner.getKeyValue();
        if (prevKV != null) {
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getRowOffset(),
              prevKV.getRowLength(), kv.getBuffer(), kv.getRowOffset(),
              kv.getRowLength()) > 0) {
            throw new InvalidHFileException("Previous row is greater than"
                + " current row: path=" + srcPath + " previous="
                + Bytes.toStringBinary(prevKV.getKey()) + " current="
                + Bytes.toStringBinary(kv.getKey()));
          }
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getFamilyOffset(),
              prevKV.getFamilyLength(), kv.getBuffer(), kv.getFamilyOffset(),
              kv.getFamilyLength()) != 0) {
            throw new InvalidHFileException("Previous key had different"
                + " family compared to current key: path=" + srcPath
                + " previous=" + Bytes.toStringBinary(prevKV.getFamily())
                + " current=" + Bytes.toStringBinary(kv.getFamily()));
          }
        }
        prevKV = kv;
      } while (scanner.next());
    }
  } finally {
    if (reader != null) reader.close();
  }
}
项目:IRIndex    文件:Store.java   
/**
 * This throws a WrongRegionException if the HFile does not fit in this
 * region, or an InvalidHFileException if the HFile is not valid.
 */
void assertBulkLoadHFileOk(Path srcPath) throws IOException {
  HFile.Reader reader  = null;
  try {
    LOG.info("Validating hfile at " + srcPath + " for inclusion in "
        + "store " + this + " region " + this.region);
    reader = HFile.createReader(srcPath.getFileSystem(conf),
        srcPath, cacheConf);
    reader.loadFileInfo();

    byte[] firstKey = reader.getFirstRowKey();
    byte[] lk = reader.getLastKey();
    byte[] lastKey =
        (lk == null) ? null :
            KeyValue.createKeyValueFromKey(lk).getRow();

    LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey) +
        " last=" + Bytes.toStringBinary(lastKey));
    LOG.debug("Region bounds: first=" +
        Bytes.toStringBinary(region.getStartKey()) +
        " last=" + Bytes.toStringBinary(region.getEndKey()));

    HRegionInfo hri = region.getRegionInfo();
    if (!hri.containsRange(firstKey, lastKey)) {
      throw new WrongRegionException(
          "Bulk load file " + srcPath.toString() + " does not fit inside region "
          + this.region);
    }

    if (verifyBulkLoads) {
      KeyValue prevKV = null;
      HFileScanner scanner = reader.getScanner(false, false, false);
      scanner.seekTo();
      do {
        KeyValue kv = scanner.getKeyValue();
        if (prevKV != null) {
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getRowOffset(),
              prevKV.getRowLength(), kv.getBuffer(), kv.getRowOffset(),
              kv.getRowLength()) > 0) {
            throw new InvalidHFileException("Previous row is greater than"
                + " current row: path=" + srcPath + " previous="
                + Bytes.toStringBinary(prevKV.getKey()) + " current="
                + Bytes.toStringBinary(kv.getKey()));
          }
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getFamilyOffset(),
              prevKV.getFamilyLength(), kv.getBuffer(), kv.getFamilyOffset(),
              kv.getFamilyLength()) != 0) {
            throw new InvalidHFileException("Previous key had different"
                + " family compared to current key: path=" + srcPath
                + " previous=" + Bytes.toStringBinary(prevKV.getFamily())
                + " current=" + Bytes.toStringBinary(kv.getFamily()));
          }
        }
        prevKV = kv;
      } while (scanner.next());
    }
  } finally {
    if (reader != null) reader.close();
  }
}
项目:hbase    文件:HStore.java   
/**
 * This throws a WrongRegionException if the HFile does not fit in this region, or an
 * InvalidHFileException if the HFile is not valid.
 */
public void assertBulkLoadHFileOk(Path srcPath) throws IOException {
  HFile.Reader reader  = null;
  try {
    LOG.info("Validating hfile at " + srcPath + " for inclusion in "
        + "store " + this + " region " + this.getRegionInfo().getRegionNameAsString());
    reader = HFile.createReader(srcPath.getFileSystem(conf), srcPath, cacheConf,
      isPrimaryReplicaStore(), conf);
    reader.loadFileInfo();

    Optional<byte[]> firstKey = reader.getFirstRowKey();
    Preconditions.checkState(firstKey.isPresent(), "First key can not be null");
    Optional<Cell> lk = reader.getLastKey();
    Preconditions.checkState(lk.isPresent(), "Last key can not be null");
    byte[] lastKey =  CellUtil.cloneRow(lk.get());

    if (LOG.isDebugEnabled()) {
      LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey.get()) +
          " last=" + Bytes.toStringBinary(lastKey));
      LOG.debug("Region bounds: first=" +
          Bytes.toStringBinary(getRegionInfo().getStartKey()) +
          " last=" + Bytes.toStringBinary(getRegionInfo().getEndKey()));
    }

    if (!this.getRegionInfo().containsRange(firstKey.get(), lastKey)) {
      throw new WrongRegionException(
          "Bulk load file " + srcPath.toString() + " does not fit inside region "
          + this.getRegionInfo().getRegionNameAsString());
    }

    if(reader.length() > conf.getLong(HConstants.HREGION_MAX_FILESIZE,
        HConstants.DEFAULT_MAX_FILE_SIZE)) {
      LOG.warn("Trying to bulk load hfile " + srcPath + " with size: " +
          reader.length() + " bytes can be problematic as it may lead to oversplitting.");
    }

    if (verifyBulkLoads) {
      long verificationStartTime = EnvironmentEdgeManager.currentTime();
      LOG.info("Full verification started for bulk load hfile: {}", srcPath);
      Cell prevCell = null;
      HFileScanner scanner = reader.getScanner(false, false, false);
      scanner.seekTo();
      do {
        Cell cell = scanner.getCell();
        if (prevCell != null) {
          if (comparator.compareRows(prevCell, cell) > 0) {
            throw new InvalidHFileException("Previous row is greater than"
                + " current row: path=" + srcPath + " previous="
                + CellUtil.getCellKeyAsString(prevCell) + " current="
                + CellUtil.getCellKeyAsString(cell));
          }
          if (CellComparator.getInstance().compareFamilies(prevCell, cell) != 0) {
            throw new InvalidHFileException("Previous key had different"
                + " family compared to current key: path=" + srcPath
                + " previous="
                + Bytes.toStringBinary(prevCell.getFamilyArray(), prevCell.getFamilyOffset(),
                    prevCell.getFamilyLength())
                + " current="
                + Bytes.toStringBinary(cell.getFamilyArray(), cell.getFamilyOffset(),
                    cell.getFamilyLength()));
          }
        }
        prevCell = cell;
      } while (scanner.next());
    LOG.info("Full verification complete for bulk load hfile: " + srcPath.toString()
       + " took " + (EnvironmentEdgeManager.currentTime() - verificationStartTime)
       + " ms");
    }
  } finally {
    if (reader != null) reader.close();
  }
}
项目:RStore    文件:Store.java   
/**
 * This throws a WrongRegionException if the HFile does not fit in this
 * region, or an InvalidHFileException if the HFile is not valid.
 */
void assertBulkLoadHFileOk(Path srcPath) throws IOException {
  HFile.Reader reader  = null;
  try {
    LOG.info("Validating hfile at " + srcPath + " for inclusion in "
        + "store " + this + " region " + this.region);
    reader = HFile.createReader(srcPath.getFileSystem(conf),
        srcPath, cacheConf);
    reader.loadFileInfo();

    byte[] firstKey = reader.getFirstRowKey();
    byte[] lk = reader.getLastKey();
    byte[] lastKey =
        (lk == null) ? null :
            KeyValue.createKeyValueFromKey(lk).getRow();

    LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey) +
        " last=" + Bytes.toStringBinary(lastKey));
    LOG.debug("Region bounds: first=" +
        Bytes.toStringBinary(region.getStartKey()) +
        " last=" + Bytes.toStringBinary(region.getEndKey()));

    HRegionInfo hri = region.getRegionInfo();
    if (!hri.containsRange(firstKey, lastKey)) {
      throw new WrongRegionException(
          "Bulk load file " + srcPath.toString() + " does not fit inside region "
          + this.region);
    }

    if (verifyBulkLoads) {
      KeyValue prevKV = null;
      HFileScanner scanner = reader.getScanner(false, false, false);
      scanner.seekTo();
      do {
        KeyValue kv = scanner.getKeyValue();
        if (prevKV != null) {
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getRowOffset(),
              prevKV.getRowLength(), kv.getBuffer(), kv.getRowOffset(),
              kv.getRowLength()) > 0) {
            throw new InvalidHFileException("Previous row is greater than"
                + " current row: path=" + srcPath + " previous="
                + Bytes.toStringBinary(prevKV.getKey()) + " current="
                + Bytes.toStringBinary(kv.getKey()));
          }
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getFamilyOffset(),
              prevKV.getFamilyLength(), kv.getBuffer(), kv.getFamilyOffset(),
              kv.getFamilyLength()) != 0) {
            throw new InvalidHFileException("Previous key had different"
                + " family compared to current key: path=" + srcPath
                + " previous=" + Bytes.toStringBinary(prevKV.getFamily())
                + " current=" + Bytes.toStringBinary(kv.getFamily()));
          }
        }
        prevKV = kv;
      } while (scanner.next());
    }
  } finally {
    if (reader != null) reader.close();
  }
}
项目:PyroDB    文件:HStore.java   
@Override
public void assertBulkLoadHFileOk(Path srcPath) throws IOException {
  HFile.Reader reader  = null;
  try {
    LOG.info("Validating hfile at " + srcPath + " for inclusion in "
        + "store " + this + " region " + this.getRegionInfo().getRegionNameAsString());
    reader = HFile.createReader(srcPath.getFileSystem(conf),
        srcPath, cacheConf, conf);
    reader.loadFileInfo();

    byte[] firstKey = reader.getFirstRowKey();
    Preconditions.checkState(firstKey != null, "First key can not be null");
    byte[] lk = reader.getLastKey();
    Preconditions.checkState(lk != null, "Last key can not be null");
    byte[] lastKey =  KeyValue.createKeyValueFromKey(lk).getRow();

    LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey) +
        " last=" + Bytes.toStringBinary(lastKey));
    LOG.debug("Region bounds: first=" +
        Bytes.toStringBinary(getRegionInfo().getStartKey()) +
        " last=" + Bytes.toStringBinary(getRegionInfo().getEndKey()));

    if (!this.getRegionInfo().containsRange(firstKey, lastKey)) {
      throw new WrongRegionException(
          "Bulk load file " + srcPath.toString() + " does not fit inside region "
          + this.getRegionInfo().getRegionNameAsString());
    }

    if (verifyBulkLoads) {
      Cell prevKV = null;
      HFileScanner scanner = reader.getScanner(false, false, false);
      scanner.seekTo();
      do {
        Cell kv = scanner.getKeyValue();
        if (prevKV != null) {
          if (Bytes.compareTo(prevKV.getRowArray(), prevKV.getRowOffset(),
              prevKV.getRowLength(), kv.getRowArray(), kv.getRowOffset(),
              kv.getRowLength()) > 0) {
            throw new InvalidHFileException("Previous row is greater than"
                + " current row: path=" + srcPath + " previous="
                + Bytes.toStringBinary(KeyValueUtil.ensureKeyValue(prevKV).getKey()) + " current="
                + Bytes.toStringBinary(KeyValueUtil.ensureKeyValue(kv).getKey()));
          }
          if (Bytes.compareTo(prevKV.getFamilyArray(), prevKV.getFamilyOffset(),
              prevKV.getFamilyLength(), kv.getFamilyArray(), kv.getFamilyOffset(),
              kv.getFamilyLength()) != 0) {
            throw new InvalidHFileException("Previous key had different"
                + " family compared to current key: path=" + srcPath
                + " previous=" + Bytes.toStringBinary(prevKV.getFamily())
                + " current=" + Bytes.toStringBinary(kv.getFamily()));
          }
        }
        prevKV = kv;
      } while (scanner.next());
    }
  } finally {
    if (reader != null) reader.close();
  }
}
项目:c5    文件:HStore.java   
@Override
public void assertBulkLoadHFileOk(Path srcPath) throws IOException {
  HFile.Reader reader  = null;
  try {
    LOG.info("Validating hfile at " + srcPath + " for inclusion in "
        + "store " + this + " region " + this.getRegionInfo().getRegionNameAsString());
    reader = HFile.createReader(srcPath.getFileSystem(conf),
        srcPath, cacheConf);
    reader.loadFileInfo();

    byte[] firstKey = reader.getFirstRowKey();
    Preconditions.checkState(firstKey != null, "First key can not be null");
    byte[] lk = reader.getLastKey();
    Preconditions.checkState(lk != null, "Last key can not be null");
    byte[] lastKey =  KeyValue.createKeyValueFromKey(lk).getRow();

    LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey) +
        " last=" + Bytes.toStringBinary(lastKey));
    LOG.debug("Region bounds: first=" +
        Bytes.toStringBinary(getRegionInfo().getStartKey()) +
        " last=" + Bytes.toStringBinary(getRegionInfo().getEndKey()));

    if (!this.getRegionInfo().containsRange(firstKey, lastKey)) {
      throw new WrongRegionException(
          "Bulk load file " + srcPath.toString() + " does not fit inside region "
          + this.getRegionInfo().getRegionNameAsString());
    }

    if (verifyBulkLoads) {
      KeyValue prevKV = null;
      HFileScanner scanner = reader.getScanner(false, false, false);
      scanner.seekTo();
      do {
        KeyValue kv = scanner.getKeyValue();
        if (prevKV != null) {
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getRowOffset(),
              prevKV.getRowLength(), kv.getBuffer(), kv.getRowOffset(),
              kv.getRowLength()) > 0) {
            throw new InvalidHFileException("Previous row is greater than"
                + " current row: path=" + srcPath + " previous="
                + Bytes.toStringBinary(prevKV.getKey()) + " current="
                + Bytes.toStringBinary(kv.getKey()));
          }
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getFamilyOffset(),
              prevKV.getFamilyLength(), kv.getBuffer(), kv.getFamilyOffset(),
              kv.getFamilyLength()) != 0) {
            throw new InvalidHFileException("Previous key had different"
                + " family compared to current key: path=" + srcPath
                + " previous=" + Bytes.toStringBinary(prevKV.getFamily())
                + " current=" + Bytes.toStringBinary(kv.getFamily()));
          }
        }
        prevKV = kv;
      } while (scanner.next());
    }
  } finally {
    if (reader != null) reader.close();
  }
}
项目:HBase-Research    文件:Store.java   
/**
 * This throws a WrongRegionException if the HFile does not fit in this
 * region, or an InvalidHFileException if the HFile is not valid.
 */
void assertBulkLoadHFileOk(Path srcPath) throws IOException {
  HFile.Reader reader  = null;
  try {
    LOG.info("Validating hfile at " + srcPath + " for inclusion in "
        + "store " + this + " region " + this.region);
    reader = HFile.createReader(srcPath.getFileSystem(conf),
        srcPath, cacheConf);
    reader.loadFileInfo();

    byte[] firstKey = reader.getFirstRowKey();
    byte[] lk = reader.getLastKey();
    byte[] lastKey =
        (lk == null) ? null :
            KeyValue.createKeyValueFromKey(lk).getRow();

    LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey) +
        " last=" + Bytes.toStringBinary(lastKey));
    LOG.debug("Region bounds: first=" +
        Bytes.toStringBinary(region.getStartKey()) +
        " last=" + Bytes.toStringBinary(region.getEndKey()));

    HRegionInfo hri = region.getRegionInfo();
    if (!hri.containsRange(firstKey, lastKey)) {
      throw new WrongRegionException(
          "Bulk load file " + srcPath.toString() + " does not fit inside region "
          + this.region);
    }

    if (verifyBulkLoads) {
      KeyValue prevKV = null;
      HFileScanner scanner = reader.getScanner(false, false, false);
      scanner.seekTo();
      do {
        KeyValue kv = scanner.getKeyValue();
        if (prevKV != null) {
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getRowOffset(),
              prevKV.getRowLength(), kv.getBuffer(), kv.getRowOffset(),
              kv.getRowLength()) > 0) {
            throw new InvalidHFileException("Previous row is greater than"
                + " current row: path=" + srcPath + " previous="
                + Bytes.toStringBinary(prevKV.getKey()) + " current="
                + Bytes.toStringBinary(kv.getKey()));
          }
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getFamilyOffset(),
              prevKV.getFamilyLength(), kv.getBuffer(), kv.getFamilyOffset(),
              kv.getFamilyLength()) != 0) {
            throw new InvalidHFileException("Previous key had different"
                + " family compared to current key: path=" + srcPath
                + " previous=" + Bytes.toStringBinary(prevKV.getFamily())
                + " current=" + Bytes.toStringBinary(kv.getFamily()));
          }
        }
        prevKV = kv;
      } while (scanner.next());
    }
  } finally {
    if (reader != null) reader.close();
  }
}
项目:hbase-0.94.8-qod    文件:Store.java   
/**
 * This throws a WrongRegionException if the HFile does not fit in this
 * region, or an InvalidHFileException if the HFile is not valid.
 */
void assertBulkLoadHFileOk(Path srcPath) throws IOException {
  HFile.Reader reader  = null;
  try {
    LOG.info("Validating hfile at " + srcPath + " for inclusion in "
        + "store " + this + " region " + this.region);
    reader = HFile.createReader(srcPath.getFileSystem(conf),
        srcPath, cacheConf);
    reader.loadFileInfo();

    byte[] firstKey = reader.getFirstRowKey();
    byte[] lk = reader.getLastKey();
    byte[] lastKey =
        (lk == null) ? null :
            KeyValue.createKeyValueFromKey(lk).getRow();

    LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey) +
        " last=" + Bytes.toStringBinary(lastKey));
    LOG.debug("Region bounds: first=" +
        Bytes.toStringBinary(region.getStartKey()) +
        " last=" + Bytes.toStringBinary(region.getEndKey()));

    HRegionInfo hri = region.getRegionInfo();
    if (!hri.containsRange(firstKey, lastKey)) {
      throw new WrongRegionException(
          "Bulk load file " + srcPath.toString() + " does not fit inside region "
          + this.region);
    }

    if (verifyBulkLoads) {
      KeyValue prevKV = null;
      HFileScanner scanner = reader.getScanner(false, false, false);
      scanner.seekTo();
      do {
        KeyValue kv = scanner.getKeyValue();
        if (prevKV != null) {
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getRowOffset(),
              prevKV.getRowLength(), kv.getBuffer(), kv.getRowOffset(),
              kv.getRowLength()) > 0) {
            throw new InvalidHFileException("Previous row is greater than"
                + " current row: path=" + srcPath + " previous="
                + Bytes.toStringBinary(prevKV.getKey()) + " current="
                + Bytes.toStringBinary(kv.getKey()));
          }
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getFamilyOffset(),
              prevKV.getFamilyLength(), kv.getBuffer(), kv.getFamilyOffset(),
              kv.getFamilyLength()) != 0) {
            throw new InvalidHFileException("Previous key had different"
                + " family compared to current key: path=" + srcPath
                + " previous=" + Bytes.toStringBinary(prevKV.getFamily())
                + " current=" + Bytes.toStringBinary(kv.getFamily()));
          }
        }
        prevKV = kv;
      } while (scanner.next());
    }
  } finally {
    if (reader != null) reader.close();
  }
}
项目:hbase-0.94.8-qod    文件:Store.java   
/**
 * This throws a WrongRegionException if the HFile does not fit in this
 * region, or an InvalidHFileException if the HFile is not valid.
 */
void assertBulkLoadHFileOk(Path srcPath) throws IOException {
  HFile.Reader reader  = null;
  try {
    LOG.info("Validating hfile at " + srcPath + " for inclusion in "
        + "store " + this + " region " + this.region);
    reader = HFile.createReader(srcPath.getFileSystem(conf),
        srcPath, cacheConf);
    reader.loadFileInfo();

    byte[] firstKey = reader.getFirstRowKey();
    byte[] lk = reader.getLastKey();
    byte[] lastKey =
        (lk == null) ? null :
            KeyValue.createKeyValueFromKey(lk).getRow();

    LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey) +
        " last=" + Bytes.toStringBinary(lastKey));
    LOG.debug("Region bounds: first=" +
        Bytes.toStringBinary(region.getStartKey()) +
        " last=" + Bytes.toStringBinary(region.getEndKey()));

    HRegionInfo hri = region.getRegionInfo();
    if (!hri.containsRange(firstKey, lastKey)) {
      throw new WrongRegionException(
          "Bulk load file " + srcPath.toString() + " does not fit inside region "
          + this.region);
    }

    if (verifyBulkLoads) {
      KeyValue prevKV = null;
      HFileScanner scanner = reader.getScanner(false, false, false);
      scanner.seekTo();
      do {
        KeyValue kv = scanner.getKeyValue();
        if (prevKV != null) {
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getRowOffset(),
              prevKV.getRowLength(), kv.getBuffer(), kv.getRowOffset(),
              kv.getRowLength()) > 0) {
            throw new InvalidHFileException("Previous row is greater than"
                + " current row: path=" + srcPath + " previous="
                + Bytes.toStringBinary(prevKV.getKey()) + " current="
                + Bytes.toStringBinary(kv.getKey()));
          }
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getFamilyOffset(),
              prevKV.getFamilyLength(), kv.getBuffer(), kv.getFamilyOffset(),
              kv.getFamilyLength()) != 0) {
            throw new InvalidHFileException("Previous key had different"
                + " family compared to current key: path=" + srcPath
                + " previous=" + Bytes.toStringBinary(prevKV.getFamily())
                + " current=" + Bytes.toStringBinary(kv.getFamily()));
          }
        }
        prevKV = kv;
      } while (scanner.next());
    }
  } finally {
    if (reader != null) reader.close();
  }
}
项目:DominoHBase    文件:HStore.java   
@Override
public void assertBulkLoadHFileOk(Path srcPath) throws IOException {
  HFile.Reader reader  = null;
  try {
    LOG.info("Validating hfile at " + srcPath + " for inclusion in "
        + "store " + this + " region " + this.region);
    reader = HFile.createReader(srcPath.getFileSystem(conf),
        srcPath, cacheConf);
    reader.loadFileInfo();

    byte[] firstKey = reader.getFirstRowKey();
    Preconditions.checkState(firstKey != null, "First key can not be null");
    byte[] lk = reader.getLastKey();
    Preconditions.checkState(lk != null, "Last key can not be null");
    byte[] lastKey =  KeyValue.createKeyValueFromKey(lk).getRow();

    LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey) +
        " last=" + Bytes.toStringBinary(lastKey));
    LOG.debug("Region bounds: first=" +
        Bytes.toStringBinary(region.getStartKey()) +
        " last=" + Bytes.toStringBinary(region.getEndKey()));

    HRegionInfo hri = region.getRegionInfo();
    if (!hri.containsRange(firstKey, lastKey)) {
      throw new WrongRegionException(
          "Bulk load file " + srcPath.toString() + " does not fit inside region "
          + this.region);
    }

    if (verifyBulkLoads) {
      KeyValue prevKV = null;
      HFileScanner scanner = reader.getScanner(false, false, false);
      scanner.seekTo();
      do {
        KeyValue kv = scanner.getKeyValue();
        if (prevKV != null) {
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getRowOffset(),
              prevKV.getRowLength(), kv.getBuffer(), kv.getRowOffset(),
              kv.getRowLength()) > 0) {
            throw new InvalidHFileException("Previous row is greater than"
                + " current row: path=" + srcPath + " previous="
                + Bytes.toStringBinary(prevKV.getKey()) + " current="
                + Bytes.toStringBinary(kv.getKey()));
          }
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getFamilyOffset(),
              prevKV.getFamilyLength(), kv.getBuffer(), kv.getFamilyOffset(),
              kv.getFamilyLength()) != 0) {
            throw new InvalidHFileException("Previous key had different"
                + " family compared to current key: path=" + srcPath
                + " previous=" + Bytes.toStringBinary(prevKV.getFamily())
                + " current=" + Bytes.toStringBinary(kv.getFamily()));
          }
        }
        prevKV = kv;
      } while (scanner.next());
    }
  } finally {
    if (reader != null) reader.close();
  }
}
项目:hindex    文件:Store.java   
/**
 * This throws a WrongRegionException if the HFile does not fit in this
 * region, or an InvalidHFileException if the HFile is not valid.
 */
void assertBulkLoadHFileOk(Path srcPath) throws IOException {
  HFile.Reader reader  = null;
  try {
    LOG.info("Validating hfile at " + srcPath + " for inclusion in "
        + "store " + this + " region " + this.region);
    reader = HFile.createReader(srcPath.getFileSystem(conf),
        srcPath, cacheConf);
    reader.loadFileInfo();

    byte[] firstKey = reader.getFirstRowKey();
    byte[] lk = reader.getLastKey();
    byte[] lastKey =
        (lk == null) ? null :
            KeyValue.createKeyValueFromKey(lk).getRow();

    LOG.debug("HFile bounds: first=" + Bytes.toStringBinary(firstKey) +
        " last=" + Bytes.toStringBinary(lastKey));
    LOG.debug("Region bounds: first=" +
        Bytes.toStringBinary(region.getStartKey()) +
        " last=" + Bytes.toStringBinary(region.getEndKey()));

    HRegionInfo hri = region.getRegionInfo();
    if (!hri.containsRange(firstKey, lastKey)) {
      throw new WrongRegionException(
          "Bulk load file " + srcPath.toString() + " does not fit inside region "
          + this.region);
    }

    if (verifyBulkLoads) {
      KeyValue prevKV = null;
      HFileScanner scanner = reader.getScanner(false, false, false);
      scanner.seekTo();
      do {
        KeyValue kv = scanner.getKeyValue();
        if (prevKV != null) {
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getRowOffset(),
              prevKV.getRowLength(), kv.getBuffer(), kv.getRowOffset(),
              kv.getRowLength()) > 0) {
            throw new InvalidHFileException("Previous row is greater than"
                + " current row: path=" + srcPath + " previous="
                + Bytes.toStringBinary(prevKV.getKey()) + " current="
                + Bytes.toStringBinary(kv.getKey()));
          }
          if (Bytes.compareTo(prevKV.getBuffer(), prevKV.getFamilyOffset(),
              prevKV.getFamilyLength(), kv.getBuffer(), kv.getFamilyOffset(),
              kv.getFamilyLength()) != 0) {
            throw new InvalidHFileException("Previous key had different"
                + " family compared to current key: path=" + srcPath
                + " previous=" + Bytes.toStringBinary(prevKV.getFamily())
                + " current=" + Bytes.toStringBinary(kv.getFamily()));
          }
        }
        prevKV = kv;
      } while (scanner.next());
    }
  } finally {
    if (reader != null) reader.close();
  }
}