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.util.function.Consumer;
021import org.apache.hadoop.fs.Path;
022import org.apache.hadoop.hbase.HConstants;
023import org.apache.hadoop.hbase.io.compress.Compression;
024import org.apache.yetus.audience.InterfaceAudience;
025
026@InterfaceAudience.Private
027public final class CreateStoreFileWriterParams {
028
029  private long maxKeyCount;
030
031  private Compression.Algorithm compression;
032
033  private boolean isCompaction;
034
035  private boolean includeMVCCReadpoint;
036
037  private boolean includesTag;
038
039  private boolean shouldDropBehind;
040
041  private long totalCompactedFilesSize = -1;
042
043  private String fileStoragePolicy = HConstants.EMPTY_STRING;
044
045  private Consumer<Path> writerCreationTracker;
046
047  private CreateStoreFileWriterParams() {
048  }
049
050  public long maxKeyCount() {
051    return maxKeyCount;
052  }
053
054  public CreateStoreFileWriterParams maxKeyCount(long maxKeyCount) {
055    this.maxKeyCount = maxKeyCount;
056    return this;
057  }
058
059  public Compression.Algorithm compression() {
060    return compression;
061  }
062
063  /**
064   * Set the compression algorithm to use
065   */
066  public CreateStoreFileWriterParams compression(Compression.Algorithm compression) {
067    this.compression = compression;
068    return this;
069  }
070
071  public boolean isCompaction() {
072    return isCompaction;
073  }
074
075  /**
076   * Whether we are creating a new file in a compaction
077   */
078  public CreateStoreFileWriterParams isCompaction(boolean isCompaction) {
079    this.isCompaction = isCompaction;
080    return this;
081  }
082
083  public boolean includeMVCCReadpoint() {
084    return includeMVCCReadpoint;
085  }
086
087  /**
088   * Whether to include MVCC or not
089   */
090  public CreateStoreFileWriterParams includeMVCCReadpoint(boolean includeMVCCReadpoint) {
091    this.includeMVCCReadpoint = includeMVCCReadpoint;
092    return this;
093  }
094
095  public boolean includesTag() {
096    return includesTag;
097  }
098
099  /**
100   * Whether to includesTag or not
101   */
102  public CreateStoreFileWriterParams includesTag(boolean includesTag) {
103    this.includesTag = includesTag;
104    return this;
105  }
106
107  public boolean shouldDropBehind() {
108    return shouldDropBehind;
109  }
110
111  public CreateStoreFileWriterParams shouldDropBehind(boolean shouldDropBehind) {
112    this.shouldDropBehind = shouldDropBehind;
113    return this;
114  }
115
116  public long totalCompactedFilesSize() {
117    return totalCompactedFilesSize;
118  }
119
120  public CreateStoreFileWriterParams totalCompactedFilesSize(long totalCompactedFilesSize) {
121    this.totalCompactedFilesSize = totalCompactedFilesSize;
122    return this;
123  }
124
125  public String fileStoragePolicy() {
126    return fileStoragePolicy;
127  }
128
129  public CreateStoreFileWriterParams fileStoragePolicy(String fileStoragePolicy) {
130    this.fileStoragePolicy = fileStoragePolicy;
131    return this;
132  }
133
134  public Consumer<Path> writerCreationTracker() {
135    return writerCreationTracker;
136  }
137
138  public CreateStoreFileWriterParams writerCreationTracker(Consumer<Path> writerCreationTracker) {
139    this.writerCreationTracker = writerCreationTracker;
140    return this;
141  }
142
143  public static CreateStoreFileWriterParams create() {
144    return new CreateStoreFileWriterParams();
145  }
146}