1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.io.hfile;
19
20 import org.apache.hadoop.hbase.classification.InterfaceAudience;
21 import org.apache.hadoop.hbase.HConstants;
22 import org.apache.hadoop.hbase.io.compress.Compression.Algorithm;
23 import org.apache.hadoop.hbase.io.crypto.Encryption;
24 import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
25 import org.apache.hadoop.hbase.util.ChecksumType;
26
27
28
29
30 @InterfaceAudience.Private
31 public class HFileContextBuilder {
32
33 public static final int DEFAULT_BYTES_PER_CHECKSUM = 16 * 1024;
34
35
36 private boolean usesHBaseChecksum = true;
37
38 private boolean includesMvcc = true;
39
40 private boolean includesTags = false;
41
42 private Algorithm compression = Algorithm.NONE;
43
44 private boolean compressTags = false;
45
46 private ChecksumType checksumType = ChecksumType.getDefaultChecksumType();
47
48 private int bytesPerChecksum = DEFAULT_BYTES_PER_CHECKSUM;
49
50 private int blocksize = HConstants.DEFAULT_BLOCKSIZE;
51 private DataBlockEncoding encoding = DataBlockEncoding.NONE;
52
53 private Encryption.Context cryptoContext = Encryption.Context.NONE;
54 private long fileCreateTime = 0;
55
56 public HFileContextBuilder withHBaseCheckSum(boolean useHBaseCheckSum) {
57 this.usesHBaseChecksum = useHBaseCheckSum;
58 return this;
59 }
60
61 public HFileContextBuilder withIncludesMvcc(boolean includesMvcc) {
62 this.includesMvcc = includesMvcc;
63 return this;
64 }
65
66 public HFileContextBuilder withIncludesTags(boolean includesTags) {
67 this.includesTags = includesTags;
68 return this;
69 }
70
71 public HFileContextBuilder withCompression(Algorithm compression) {
72 this.compression = compression;
73 return this;
74 }
75
76 public HFileContextBuilder withCompressTags(boolean compressTags) {
77 this.compressTags = compressTags;
78 return this;
79 }
80
81 public HFileContextBuilder withChecksumType(ChecksumType checkSumType) {
82 this.checksumType = checkSumType;
83 return this;
84 }
85
86 public HFileContextBuilder withBytesPerCheckSum(int bytesPerChecksum) {
87 this.bytesPerChecksum = bytesPerChecksum;
88 return this;
89 }
90
91 public HFileContextBuilder withBlockSize(int blockSize) {
92 this.blocksize = blockSize;
93 return this;
94 }
95
96 public HFileContextBuilder withDataBlockEncoding(DataBlockEncoding encoding) {
97 this.encoding = encoding;
98 return this;
99 }
100
101 public HFileContextBuilder withEncryptionContext(Encryption.Context cryptoContext) {
102 this.cryptoContext = cryptoContext;
103 return this;
104 }
105
106 public HFileContextBuilder withCreateTime(long fileCreateTime) {
107 this.fileCreateTime = fileCreateTime;
108 return this;
109 }
110
111 public HFileContext build() {
112 return new HFileContext(usesHBaseChecksum, includesMvcc, includesTags, compression,
113 compressTags, checksumType, bytesPerChecksum, blocksize, encoding, cryptoContext,
114 fileCreateTime);
115 }
116 }