Java Code Examples for org.apache.hadoop.hbase.util.Bytes.toBoolean()

The following are Jave code examples for showing how to use toBoolean() of the org.apache.hadoop.hbase.util.Bytes class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ditb   File: HRegion.java   View Source Code Vote up 6 votes
@Override public long getOldestHfileTs(boolean majorCompactioOnly) throws IOException {
  long result = Long.MAX_VALUE;
  for (Store store : getStores()) {
    Collection<StoreFile> storeFiles = store.getStorefiles();
    if (storeFiles == null) continue;
    for (StoreFile file : storeFiles) {
      StoreFile.Reader sfReader = file.getReader();
      if (sfReader == null) continue;
      HFile.Reader reader = sfReader.getHFileReader();
      if (reader == null) continue;
      if (majorCompactioOnly) {
        byte[] val = reader.loadFileInfo().get(StoreFile.MAJOR_COMPACTION_KEY);
        if (val == null) continue;
        if (val == null || !Bytes.toBoolean(val)) {
          continue;
        }
      }
      result = Math.min(result, reader.getFileContext().getFileCreateTime());
    }
  }
  return result == Long.MAX_VALUE ? 0 : result;
}
 
Example 2
Project: ditb   File: ScanRange.java   View Source Code Vote up 6 votes
@Override public void readFields(DataInput in) throws IOException {
  family = Bytes.readByteArray(in);
  qualifier = Bytes.readByteArray(in);
  boolean startNull = Bytes.toBoolean(Bytes.readByteArray(in));
  if (startNull) {
    start = null;
    startOp = CompareFilter.CompareOp.NO_OP;
  } else {
    start = Bytes.readByteArray(in);
    startOp = CompareFilter.CompareOp.valueOf(Bytes.toString(Bytes.readByteArray(in)));
  }
  boolean stopNull = Bytes.toBoolean(Bytes.readByteArray(in));
  if (stopNull) {
    stop = null;
    stopOp = CompareFilter.CompareOp.NO_OP;
  } else {
    stop = Bytes.readByteArray(in);
    stopOp = CompareFilter.CompareOp.valueOf(Bytes.toString(Bytes.readByteArray(in)));
  }
  startTs = in.readLong();
  stopTs = in.readLong();
  dataType = DataType.valueOf(Bytes.toString(Bytes.readByteArray(in)));
}
 
Example 3
Project: ditb   File: Mutation.java   View Source Code Vote up 5 votes
/**
 * @return current value for returnResults
 */
// Used by Increment and Append only.
@InterfaceAudience.Private
protected boolean isReturnResults() {
  byte[] v = getAttribute(RETURN_RESULTS);
  return v == null ? true : Bytes.toBoolean(v);
}
 
Example 4
Project: ditb   File: HFileReaderV3.java   View Source Code Vote up 4 votes
/**
 * Opens a HFile. You must load the index before you can use it by calling
 * {@link #loadFileInfo()}.
 * @param path
 *          Path to HFile.
 * @param trailer
 *          File trailer.
 * @param fsdis
 *          input stream.
 * @param size
 *          Length of the stream.
 * @param cacheConf
 *          Cache configuration.
 * @param hfs
 *          The file system.
 * @param conf
 *          Configuration
 */
public HFileReaderV3(final Path path, FixedFileTrailer trailer,
    final FSDataInputStreamWrapper fsdis,
    final long size, final CacheConfig cacheConf, final HFileSystem hfs,
    final Configuration conf) throws IOException {
  super(path, trailer, fsdis, size, cacheConf, hfs, conf);
  byte[] tmp = fileInfo.get(FileInfo.MAX_TAGS_LEN);
  // max tag length is not present in the HFile means tags were not at all written to file.
  if (tmp != null) {
    hfileContext.setIncludesTags(true);
    tmp = fileInfo.get(FileInfo.TAGS_COMPRESSED);
    if (tmp != null && Bytes.toBoolean(tmp)) {
      hfileContext.setCompressTags(true);
    }
  }
}
 
Example 5
Project: ditb   File: Scan.java   View Source Code Vote up 4 votes
/**
 * @return True if this Scan is in "raw" mode.
 */
public boolean isRaw() {
  byte[] attr = getAttribute(RAW_ATTR);
  return attr == null ? false : Bytes.toBoolean(attr);
}
 
Example 6
Project: ditb   File: Scan.java   View Source Code Vote up 4 votes
/**
 * @return True if collection of scan metrics is enabled. For advanced users.
 */
public boolean isScanMetricsEnabled() {
  byte[] attr = getAttribute(Scan.SCAN_ATTRIBUTES_METRICS_ENABLE);
  return attr == null ? false : Bytes.toBoolean(attr);
}