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 org.apache.hadoop.hbase.HBaseInterfaceAudience;
021import org.apache.hadoop.hbase.KeepDeletedCells;
022import org.apache.hadoop.hbase.client.Scan;
023import org.apache.yetus.audience.InterfaceAudience;
024import org.apache.yetus.audience.InterfaceStability;
025
026/**
027 * This class gives you the ability to change the max versions and TTL options before opening a
028 * scanner for a Store. And also gives you some information for the scan.
029 * <p>
030 * Changing max versions, min versins, KeepDeletedCells, and TTL are usually safe even
031 * for flush/compaction, so here we provide a way to do it for you. If you want to do other
032 * complicated operations such as filtering, please wrap
033 * the {@link InternalScanner} in the {@code preCompact} and {@code preFlush} methods in
034 * {@link org.apache.hadoop.hbase.coprocessor.RegionObserver}.
035 * <p>
036 * For user scans, we also provide this class as a parameter in the {@code preStoreScannerOpen}
037 * method in {@link org.apache.hadoop.hbase.coprocessor.RegionObserver}. You can use it to change
038 * the inherent properties for a Store. For example, even if you use {@code Scan.readAllVersions},
039 * you still can not read two versions if the max versions property of the Store is one. You need to
040 * set the max versions to a value greater than two in {@code preStoreScannerOpen}.
041 * @see org.apache.hadoop.hbase.coprocessor.RegionObserver#preFlushScannerOpen(org.apache.hadoop.hbase.coprocessor.ObserverContext,
042 *      Store, ScanOptions, FlushLifeCycleTracker)
043 * @see org.apache.hadoop.hbase.coprocessor.RegionObserver#preCompactScannerOpen(org.apache.hadoop.hbase.coprocessor.ObserverContext,
044 *      Store, ScanType, ScanOptions,
045 *      org.apache.hadoop.hbase.regionserver.compactions.CompactionLifeCycleTracker,
046 *      org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest)
047 * @see org.apache.hadoop.hbase.coprocessor.RegionObserver#preStoreScannerOpen(org.apache.hadoop.hbase.coprocessor.ObserverContext,
048 *      Store, ScanOptions)
049 */
050@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
051@InterfaceStability.Evolving
052public interface ScanOptions {
053
054  int getMaxVersions();
055
056  void setMaxVersions(int maxVersions);
057
058  default void readAllVersions() {
059    setMaxVersions(Integer.MAX_VALUE);
060  }
061
062  long getTTL();
063
064  void setTTL(long ttl);
065
066  void setKeepDeletedCells(KeepDeletedCells keepDeletedCells);
067
068  KeepDeletedCells getKeepDeletedCells();
069
070  int getMinVersions();
071
072  void setMinVersions(int minVersions);
073
074  /**
075   * Returns a copy of the Scan object. Modifying it will have no effect.
076   */
077  Scan getScan();
078}