001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.regionserver;
019
020import java.io.IOException;
021import java.util.Optional;
022import java.util.OptionalLong;
023import org.apache.hadoop.fs.Path;
024import org.apache.hadoop.hbase.Cell;
025import org.apache.hadoop.hbase.CellComparator;
026import org.apache.hadoop.hbase.HBaseInterfaceAudience;
027import org.apache.yetus.audience.InterfaceAudience;
028import org.apache.yetus.audience.InterfaceStability;
029
030/**
031 * An interface to describe a store data file.
032 * <p>
033 * <strong>NOTICE: </strong>this interface is mainly designed for coprocessor, so it will not expose
034 * all the internal APIs for a 'store file'. If you are implementing something inside HBase, i.e,
035 * not a coprocessor hook, usually you should use {@link HStoreFile} directly as it is the only
036 * implementation of this interface.
037 */
038@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
039@InterfaceStability.Evolving
040public interface StoreFile {
041
042  /**
043   * Get the first key in this store file.
044   */
045  Optional<Cell> getFirstKey();
046
047  /**
048   * Get the last key in this store file.
049   */
050  Optional<Cell> getLastKey();
051
052  /**
053   * Get the comparator for comparing two cells.
054   */
055  CellComparator getComparator();
056
057  /**
058   * Get max of the MemstoreTS in the KV's in this store file.
059   */
060  long getMaxMemStoreTS();
061
062  /** Returns Path or null if this StoreFile was made with a Stream. */
063  Path getPath();
064
065  /** Returns Encoded Path if this StoreFile was made with a Stream. */
066  Path getEncodedPath();
067
068  /** Returns Returns the qualified path of this StoreFile */
069  Path getQualifiedPath();
070
071  /** Returns True if this is a StoreFile Reference. */
072  boolean isReference();
073
074  /** Returns True if this is HFile. */
075  boolean isHFile();
076
077  /** Returns True if this file was made by a major compaction. */
078  boolean isMajorCompactionResult();
079
080  /** Returns True if this file should not be part of a minor compaction. */
081  boolean excludeFromMinorCompaction();
082
083  /** Returns This files maximum edit sequence id. */
084  long getMaxSequenceId();
085
086  /**
087   * Get the modification time of this store file. Usually will access the file system so throws
088   * IOException.
089   */
090  long getModificationTimestamp() throws IOException;
091
092  /**
093   * Check if this storefile was created by bulk load. When a hfile is bulk loaded into HBase, we
094   * append {@code '_SeqId_<id-when-loaded>'} to the hfile name, unless
095   * "hbase.mapreduce.bulkload.assign.sequenceNumbers" is explicitly turned off. If
096   * "hbase.mapreduce.bulkload.assign.sequenceNumbers" is turned off, fall back to
097   * BULKLOAD_TIME_KEY.
098   * @return true if this storefile was created by bulk load.
099   */
100  boolean isBulkLoadResult();
101
102  /**
103   * Return the timestamp at which this bulk load file was generated.
104   */
105  OptionalLong getBulkLoadTimestamp();
106
107  /** Returns a length description of this StoreFile, suitable for debug output */
108  String toStringDetailed();
109
110  /**
111   * Get the min timestamp of all the cells in the store file.
112   */
113  OptionalLong getMinimumTimestamp();
114
115  /**
116   * Get the max timestamp of all the cells in the store file.
117   */
118  OptionalLong getMaximumTimestamp();
119}