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;
019
020import java.util.Map;
021import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
022import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
023import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor;
024import org.apache.hadoop.hbase.client.MobCompactPartitionPolicy;
025import org.apache.hadoop.hbase.exceptions.DeserializationException;
026import org.apache.hadoop.hbase.exceptions.HBaseException;
027import org.apache.hadoop.hbase.io.compress.Compression;
028import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
029import org.apache.hadoop.hbase.regionserver.BloomType;
030import org.apache.hadoop.hbase.util.Bytes;
031import org.apache.hadoop.hbase.util.PrettyPrinter.Unit;
032import org.apache.yetus.audience.InterfaceAudience;
033
034/**
035 * An HColumnDescriptor contains information about a column family such as the number of versions,
036 * compression settings, etc. It is used as input when creating a table or adding a column.
037 */
038@InterfaceAudience.Public
039@Deprecated // remove it in 3.0
040public class HColumnDescriptor implements ColumnFamilyDescriptor, Comparable<HColumnDescriptor> {
041  public static final String IN_MEMORY_COMPACTION =
042    ColumnFamilyDescriptorBuilder.IN_MEMORY_COMPACTION;
043  public static final String COMPRESSION = ColumnFamilyDescriptorBuilder.COMPRESSION;
044  public static final String COMPRESSION_COMPACT =
045    ColumnFamilyDescriptorBuilder.COMPRESSION_COMPACT;
046  public static final String COMPRESSION_COMPACT_MAJOR =
047    ColumnFamilyDescriptorBuilder.COMPRESSION_COMPACT_MAJOR;
048  public static final String COMPRESSION_COMPACT_MINOR =
049    ColumnFamilyDescriptorBuilder.COMPRESSION_COMPACT_MINOR;
050  public static final String ENCODE_ON_DISK = "ENCODE_ON_DISK";
051  public static final String DATA_BLOCK_ENCODING =
052    ColumnFamilyDescriptorBuilder.DATA_BLOCK_ENCODING;
053  public static final String BLOCKCACHE = ColumnFamilyDescriptorBuilder.BLOCKCACHE;
054  public static final String CACHE_DATA_ON_WRITE =
055    ColumnFamilyDescriptorBuilder.CACHE_DATA_ON_WRITE;
056  public static final String CACHE_INDEX_ON_WRITE =
057    ColumnFamilyDescriptorBuilder.CACHE_INDEX_ON_WRITE;
058  public static final String CACHE_BLOOMS_ON_WRITE =
059    ColumnFamilyDescriptorBuilder.CACHE_BLOOMS_ON_WRITE;
060  public static final String EVICT_BLOCKS_ON_CLOSE =
061    ColumnFamilyDescriptorBuilder.EVICT_BLOCKS_ON_CLOSE;
062  public static final String CACHE_DATA_IN_L1 = "CACHE_DATA_IN_L1";
063  public static final String PREFETCH_BLOCKS_ON_OPEN =
064    ColumnFamilyDescriptorBuilder.PREFETCH_BLOCKS_ON_OPEN;
065  public static final String BLOCKSIZE = ColumnFamilyDescriptorBuilder.BLOCKSIZE;
066  public static final String LENGTH = "LENGTH";
067  public static final String TTL = ColumnFamilyDescriptorBuilder.TTL;
068  public static final String BLOOMFILTER = ColumnFamilyDescriptorBuilder.BLOOMFILTER;
069  public static final String FOREVER = "FOREVER";
070  public static final String REPLICATION_SCOPE = ColumnFamilyDescriptorBuilder.REPLICATION_SCOPE;
071  public static final byte[] REPLICATION_SCOPE_BYTES = Bytes.toBytes(REPLICATION_SCOPE);
072  public static final String MIN_VERSIONS = ColumnFamilyDescriptorBuilder.MIN_VERSIONS;
073  public static final String KEEP_DELETED_CELLS = ColumnFamilyDescriptorBuilder.KEEP_DELETED_CELLS;
074  public static final String COMPRESS_TAGS = ColumnFamilyDescriptorBuilder.COMPRESS_TAGS;
075  public static final String ENCRYPTION = ColumnFamilyDescriptorBuilder.ENCRYPTION;
076  public static final String ENCRYPTION_KEY = ColumnFamilyDescriptorBuilder.ENCRYPTION_KEY;
077  public static final String IS_MOB = ColumnFamilyDescriptorBuilder.IS_MOB;
078  public static final byte[] IS_MOB_BYTES = Bytes.toBytes(IS_MOB);
079  public static final String MOB_THRESHOLD = ColumnFamilyDescriptorBuilder.MOB_THRESHOLD;
080  public static final byte[] MOB_THRESHOLD_BYTES = Bytes.toBytes(MOB_THRESHOLD);
081  public static final long DEFAULT_MOB_THRESHOLD =
082    ColumnFamilyDescriptorBuilder.DEFAULT_MOB_THRESHOLD;
083  public static final String MOB_COMPACT_PARTITION_POLICY =
084    ColumnFamilyDescriptorBuilder.MOB_COMPACT_PARTITION_POLICY;
085  public static final byte[] MOB_COMPACT_PARTITION_POLICY_BYTES =
086    Bytes.toBytes(MOB_COMPACT_PARTITION_POLICY);
087  public static final MobCompactPartitionPolicy DEFAULT_MOB_COMPACT_PARTITION_POLICY =
088    ColumnFamilyDescriptorBuilder.DEFAULT_MOB_COMPACT_PARTITION_POLICY;
089  public static final String DFS_REPLICATION = ColumnFamilyDescriptorBuilder.DFS_REPLICATION;
090  public static final short DEFAULT_DFS_REPLICATION =
091    ColumnFamilyDescriptorBuilder.DEFAULT_DFS_REPLICATION;
092  public static final String STORAGE_POLICY = ColumnFamilyDescriptorBuilder.STORAGE_POLICY;
093  public static final String DEFAULT_COMPRESSION =
094    ColumnFamilyDescriptorBuilder.DEFAULT_COMPRESSION.name();
095  public static final boolean DEFAULT_ENCODE_ON_DISK = true;
096  public static final String DEFAULT_DATA_BLOCK_ENCODING =
097    ColumnFamilyDescriptorBuilder.DEFAULT_DATA_BLOCK_ENCODING.name();
098  public static final int DEFAULT_VERSIONS = ColumnFamilyDescriptorBuilder.DEFAULT_MAX_VERSIONS;
099  public static final int DEFAULT_MIN_VERSIONS = ColumnFamilyDescriptorBuilder.DEFAULT_MIN_VERSIONS;
100  public static final boolean DEFAULT_IN_MEMORY = ColumnFamilyDescriptorBuilder.DEFAULT_IN_MEMORY;
101  public static final KeepDeletedCells DEFAULT_KEEP_DELETED =
102    ColumnFamilyDescriptorBuilder.DEFAULT_KEEP_DELETED;
103  public static final boolean DEFAULT_BLOCKCACHE = ColumnFamilyDescriptorBuilder.DEFAULT_BLOCKCACHE;
104  public static final boolean DEFAULT_CACHE_DATA_ON_WRITE =
105    ColumnFamilyDescriptorBuilder.DEFAULT_CACHE_DATA_ON_WRITE;
106  public static final boolean DEFAULT_CACHE_DATA_IN_L1 = false;
107  public static final boolean DEFAULT_CACHE_INDEX_ON_WRITE =
108    ColumnFamilyDescriptorBuilder.DEFAULT_CACHE_INDEX_ON_WRITE;
109  public static final int DEFAULT_BLOCKSIZE = ColumnFamilyDescriptorBuilder.DEFAULT_BLOCKSIZE;
110  public static final String DEFAULT_BLOOMFILTER =
111    ColumnFamilyDescriptorBuilder.DEFAULT_BLOOMFILTER.name();
112  public static final boolean DEFAULT_CACHE_BLOOMS_ON_WRITE =
113    ColumnFamilyDescriptorBuilder.DEFAULT_CACHE_BLOOMS_ON_WRITE;
114  public static final int DEFAULT_TTL = ColumnFamilyDescriptorBuilder.DEFAULT_TTL;
115  public static final int DEFAULT_REPLICATION_SCOPE =
116    ColumnFamilyDescriptorBuilder.DEFAULT_REPLICATION_SCOPE;
117  public static final boolean DEFAULT_EVICT_BLOCKS_ON_CLOSE =
118    ColumnFamilyDescriptorBuilder.DEFAULT_EVICT_BLOCKS_ON_CLOSE;
119  public static final boolean DEFAULT_COMPRESS_TAGS =
120    ColumnFamilyDescriptorBuilder.DEFAULT_COMPRESS_TAGS;
121  public static final boolean DEFAULT_PREFETCH_BLOCKS_ON_OPEN =
122    ColumnFamilyDescriptorBuilder.DEFAULT_PREFETCH_BLOCKS_ON_OPEN;
123  public static final String NEW_VERSION_BEHAVIOR =
124    ColumnFamilyDescriptorBuilder.NEW_VERSION_BEHAVIOR;
125  public static final boolean DEFAULT_NEW_VERSION_BEHAVIOR =
126    ColumnFamilyDescriptorBuilder.DEFAULT_NEW_VERSION_BEHAVIOR;
127  protected final ModifyableColumnFamilyDescriptor delegatee;
128
129  /**
130   * Construct a column descriptor specifying only the family name The other attributes are
131   * defaulted.
132   * @param familyName Column family name. Must be 'printable' -- digit or letter -- and may not
133   *                   contain a <code>:</code>
134   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
135   *             (<a href="https://issues.apache.org/jira/browse/HBASE-18433">HBASE-18433</a>). Use
136   *             {@link ColumnFamilyDescriptorBuilder#of(String)}.
137   */
138  @Deprecated
139  public HColumnDescriptor(final String familyName) {
140    this(Bytes.toBytes(familyName));
141  }
142
143  /**
144   * Construct a column descriptor specifying only the family name The other attributes are
145   * defaulted.
146   * @param familyName Column family name. Must be 'printable' -- digit or letter -- and may not
147   *                   contain a <code>:</code>
148   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
149   *             (<a href="https://issues.apache.org/jira/browse/HBASE-18433">HBASE-18433</a>). Use
150   *             {@link ColumnFamilyDescriptorBuilder#of(byte[])}.
151   */
152  @Deprecated
153  public HColumnDescriptor(final byte[] familyName) {
154    this(new ModifyableColumnFamilyDescriptor(familyName));
155  }
156
157  /**
158   * Constructor. Makes a deep copy of the supplied descriptor. Can make a modifiable descriptor
159   * from an UnmodifyableHColumnDescriptor.
160   * @param desc The descriptor.
161   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
162   *             (<a href="https://issues.apache.org/jira/browse/HBASE-18433">HBASE-18433</a>). Use
163   *             {@link ColumnFamilyDescriptorBuilder#copy(ColumnFamilyDescriptor)}.
164   */
165  @Deprecated
166  public HColumnDescriptor(HColumnDescriptor desc) {
167    this(desc, true);
168  }
169
170  protected HColumnDescriptor(HColumnDescriptor desc, boolean deepClone) {
171    this(deepClone ? new ModifyableColumnFamilyDescriptor(desc) : desc.delegatee);
172  }
173
174  protected HColumnDescriptor(ModifyableColumnFamilyDescriptor delegate) {
175    this.delegatee = delegate;
176  }
177
178  /**
179   * Check if a given family name is allowed.
180   * @param b Family name.
181   * @return <code>b</code>
182   * @throws IllegalArgumentException If not null and not a legitimate family name: i.e. 'printable'
183   *                                  and ends in a ':' (Null passes are allowed because
184   *                                  <code>b</code> can be null when deserializing). Cannot start
185   *                                  with a '.' either. Also Family can not be an empty value or
186   *                                  equal "recovered.edits".
187   * @deprecated since 2.0.0 and will be removed in 3.0.0. Use
188   *             {@link ColumnFamilyDescriptorBuilder#isLegalColumnFamilyName(byte[])} instead.
189   * @see ColumnFamilyDescriptorBuilder#isLegalColumnFamilyName(byte[])
190   * @see <a href="https://issues.apache.org/jira/browse/HBASE-18008">HBASE-18008</a>
191   */
192  @Deprecated
193  public static byte[] isLegalFamilyName(final byte[] b) {
194    return ColumnFamilyDescriptorBuilder.isLegalColumnFamilyName(b);
195  }
196
197  /** Returns Name of this column family */
198  @Override
199  public byte[] getName() {
200    return delegatee.getName();
201  }
202
203  /** Returns The name string of this column family */
204  @Override
205  public String getNameAsString() {
206    return delegatee.getNameAsString();
207  }
208
209  @Override
210  public byte[] getValue(byte[] key) {
211    return delegatee.getValue(key);
212  }
213
214  @Override
215  public String getValue(String key) {
216    byte[] value = getValue(Bytes.toBytes(key));
217    return value == null ? null : Bytes.toString(value);
218  }
219
220  @Override
221  public Map<Bytes, Bytes> getValues() {
222    return delegatee.getValues();
223  }
224
225  public HColumnDescriptor setValue(byte[] key, byte[] value) {
226    getDelegateeForModification().setValue(key, value);
227    return this;
228  }
229
230  public void remove(final byte[] key) {
231    getDelegateeForModification().removeValue(new Bytes(key));
232  }
233
234  public HColumnDescriptor setValue(String key, String value) {
235    getDelegateeForModification().setValue(key, value);
236    return this;
237  }
238
239  /**
240   * Returns compression type being used for the column family
241   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
242   *             (<a href="https://issues.apache.org/jira/browse/HBASE-13655">HBASE-13655</a>). Use
243   *             {@link #getCompressionType()}.
244   */
245  @Deprecated
246  public Compression.Algorithm getCompression() {
247    return getCompressionType();
248  }
249
250  /**
251   * Returns compression type being used for the column family for major compaction
252   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
253   *             (<a href="https://issues.apache.org/jira/browse/HBASE-13655">HBASE-13655</a>). Use
254   *             {@link #getCompactionCompressionType()}.
255   */
256  @Deprecated
257  public Compression.Algorithm getCompactionCompression() {
258    return getCompactionCompressionType();
259  }
260
261  @Override
262  public int getMaxVersions() {
263    return delegatee.getMaxVersions();
264  }
265
266  /**
267   * Set maximum versions to keep
268   * @param value maximum number of versions
269   * @return this (for chained invocation)
270   */
271  public HColumnDescriptor setMaxVersions(int value) {
272    getDelegateeForModification().setMaxVersions(value);
273    return this;
274  }
275
276  /**
277   * Set minimum and maximum versions to keep
278   * @param minVersions minimal number of versions
279   * @param maxVersions maximum number of versions
280   * @return this (for chained invocation)
281   */
282  public HColumnDescriptor setVersions(int minVersions, int maxVersions) {
283    if (minVersions <= 0) {
284      // TODO: Allow minVersion and maxVersion of 0 to be the way you say "Keep all versions".
285      // Until there is support, consider 0 or < 0 -- a configuration error.
286      throw new IllegalArgumentException("Minimum versions must be positive");
287    }
288
289    if (maxVersions < minVersions) {
290      throw new IllegalArgumentException(
291        "Unable to set MaxVersion to " + maxVersions + " and set MinVersion to " + minVersions
292          + ", as maximum versions must be >= minimum versions.");
293    }
294    setMinVersions(minVersions);
295    setMaxVersions(maxVersions);
296    return this;
297  }
298
299  @Override
300  public int getBlocksize() {
301    return delegatee.getBlocksize();
302  }
303
304  /**
305   * Set block size to use when writing
306   * @param value Blocksize to use when writing out storefiles/hfiles on this column family.
307   * @return this (for chained invocation)
308   */
309  public HColumnDescriptor setBlocksize(int value) {
310    getDelegateeForModification().setBlocksize(value);
311    return this;
312  }
313
314  public HColumnDescriptor setBlocksize(String value) throws HBaseException {
315    getDelegateeForModification().setBlocksize(value);
316    return this;
317  }
318
319  @Override
320  public Compression.Algorithm getCompressionType() {
321    return delegatee.getCompressionType();
322  }
323
324  /**
325   * Compression types supported in hbase. LZO is not bundled as part of the hbase distribution. See
326   * <a href="http://wiki.apache.org/hadoop/UsingLzoCompression">LZO Compression</a> for how to
327   * enable it.
328   * @param value Compression type setting.
329   * @return this (for chained invocation)
330   */
331  public HColumnDescriptor setCompressionType(Compression.Algorithm value) {
332    getDelegateeForModification().setCompressionType(value);
333    return this;
334  }
335
336  @Override
337  public DataBlockEncoding getDataBlockEncoding() {
338    return delegatee.getDataBlockEncoding();
339  }
340
341  /**
342   * Set data block encoding algorithm used in block cache.
343   * @param value What kind of data block encoding will be used.
344   * @return this (for chained invocation)
345   */
346  public HColumnDescriptor setDataBlockEncoding(DataBlockEncoding value) {
347    getDelegateeForModification().setDataBlockEncoding(value);
348    return this;
349  }
350
351  /**
352   * Set whether the tags should be compressed along with DataBlockEncoding. When no
353   * DataBlockEncoding is been used, this is having no effect. n * @return this (for chained
354   * invocation)
355   */
356  public HColumnDescriptor setCompressTags(boolean value) {
357    getDelegateeForModification().setCompressTags(value);
358    return this;
359  }
360
361  @Override
362  public boolean isCompressTags() {
363    return delegatee.isCompressTags();
364  }
365
366  @Override
367  public Compression.Algorithm getCompactionCompressionType() {
368    return delegatee.getCompactionCompressionType();
369  }
370
371  @Override
372  public Compression.Algorithm getMajorCompactionCompressionType() {
373    return delegatee.getMajorCompactionCompressionType();
374  }
375
376  @Override
377  public Compression.Algorithm getMinorCompactionCompressionType() {
378    return delegatee.getMinorCompactionCompressionType();
379  }
380
381  /**
382   * Compression types supported in hbase. LZO is not bundled as part of the hbase distribution. See
383   * <a href="http://wiki.apache.org/hadoop/UsingLzoCompression">LZO Compression</a> for how to
384   * enable it.
385   * @param value Compression type setting.
386   * @return this (for chained invocation)
387   */
388  public HColumnDescriptor setCompactionCompressionType(Compression.Algorithm value) {
389    getDelegateeForModification().setCompactionCompressionType(value);
390    return this;
391  }
392
393  public HColumnDescriptor setMajorCompactionCompressionType(Compression.Algorithm value) {
394    getDelegateeForModification().setMajorCompactionCompressionType(value);
395    return this;
396  }
397
398  public HColumnDescriptor setMinorCompactionCompressionType(Compression.Algorithm value) {
399    getDelegateeForModification().setMinorCompactionCompressionType(value);
400    return this;
401  }
402
403  @Override
404  public boolean isInMemory() {
405    return delegatee.isInMemory();
406  }
407
408  /**
409   * Set or clear the in memory flag.
410   * @param value True if we are to favor keeping all values for this column family in the
411   *              HRegionServer cache
412   * @return this (for chained invocation)
413   */
414  public HColumnDescriptor setInMemory(boolean value) {
415    getDelegateeForModification().setInMemory(value);
416    return this;
417  }
418
419  @Override
420  public MemoryCompactionPolicy getInMemoryCompaction() {
421    return delegatee.getInMemoryCompaction();
422  }
423
424  /**
425   * Set the in memory compaction policy.
426   * @param value the prefered in-memory compaction policy for this column family
427   * @return this (for chained invocation)
428   */
429  public HColumnDescriptor setInMemoryCompaction(MemoryCompactionPolicy value) {
430    getDelegateeForModification().setInMemoryCompaction(value);
431    return this;
432  }
433
434  @Override
435  public KeepDeletedCells getKeepDeletedCells() {
436    return delegatee.getKeepDeletedCells();
437  }
438
439  /**
440   * Set the keep deleted cells policy.
441   * @param value True if deleted rows should not be collected immediately.
442   * @return this (for chained invocation)
443   */
444  public HColumnDescriptor setKeepDeletedCells(KeepDeletedCells value) {
445    getDelegateeForModification().setKeepDeletedCells(value);
446    return this;
447  }
448
449  /**
450   * By default, HBase only consider timestamp in versions. So a previous Delete with higher ts will
451   * mask a later Put with lower ts. Set this to true to enable new semantics of versions. We will
452   * also consider mvcc in versions. See HBASE-15968 for details.
453   */
454  @Override
455  public boolean isNewVersionBehavior() {
456    return delegatee.isNewVersionBehavior();
457  }
458
459  public HColumnDescriptor setNewVersionBehavior(boolean newVersionBehavior) {
460    getDelegateeForModification().setNewVersionBehavior(newVersionBehavior);
461    return this;
462  }
463
464  @Override
465  public int getTimeToLive() {
466    return delegatee.getTimeToLive();
467  }
468
469  /**
470   * Set the time to live of cell contents
471   * @param value Time-to-live of cell contents, in seconds.
472   * @return this (for chained invocation)
473   */
474  public HColumnDescriptor setTimeToLive(int value) {
475    getDelegateeForModification().setTimeToLive(value);
476    return this;
477  }
478
479  /**
480   * Set the time to live of cell contents
481   * @param value Time to live of cell contents, in human readable format
482   * @see org.apache.hadoop.hbase.util.PrettyPrinter#format(String, Unit)
483   * @return this (for chained invocation)
484   */
485  public HColumnDescriptor setTimeToLive(String value) throws HBaseException {
486    getDelegateeForModification().setTimeToLive(value);
487    return this;
488  }
489
490  @Override
491  public int getMinVersions() {
492    return delegatee.getMinVersions();
493  }
494
495  /**
496   * Set the minimum number of versions to keep.
497   * @param value The minimum number of versions to keep. (used when timeToLive is set)
498   * @return this (for chained invocation)
499   */
500  public HColumnDescriptor setMinVersions(int value) {
501    getDelegateeForModification().setMinVersions(value);
502    return this;
503  }
504
505  @Override
506  public boolean isBlockCacheEnabled() {
507    return delegatee.isBlockCacheEnabled();
508  }
509
510  /**
511   * Set or clear the block cache enabled flag.
512   * @param value True if hfile DATA type blocks should be cached (We always cache INDEX and BLOOM
513   *              blocks; you cannot turn this off).
514   * @return this (for chained invocation)
515   */
516  public HColumnDescriptor setBlockCacheEnabled(boolean value) {
517    getDelegateeForModification().setBlockCacheEnabled(value);
518    return this;
519  }
520
521  @Override
522  public BloomType getBloomFilterType() {
523    return delegatee.getBloomFilterType();
524  }
525
526  /**
527   * Set the bloom filter type.
528   * @param value bloom filter type
529   * @return this (for chained invocation)
530   */
531  public HColumnDescriptor setBloomFilterType(final BloomType value) {
532    getDelegateeForModification().setBloomFilterType(value);
533    return this;
534  }
535
536  @Override
537  public int getScope() {
538    return delegatee.getScope();
539  }
540
541  public HColumnDescriptor setScope(int value) {
542    getDelegateeForModification().setScope(value);
543    return this;
544  }
545
546  @Override
547  public boolean isCacheDataOnWrite() {
548    return delegatee.isCacheDataOnWrite();
549  }
550
551  /**
552   * Set or clear the cache data on write flag.
553   * @param value true if we should cache data blocks on write
554   * @return this (for chained invocation)
555   */
556  public HColumnDescriptor setCacheDataOnWrite(boolean value) {
557    getDelegateeForModification().setCacheDataOnWrite(value);
558    return this;
559  }
560
561  /**
562   * Set or clear the cache in L1 flag. This is a noop call from HBase 2.0 onwards
563   * @return this (for chained invocation)
564   * @deprecated Since 2.0 and will be removed in 3.0 with out any replacement. Caching data in on
565   *             heap Cache, when there are both on heap LRU Cache and Bucket Cache will no longer
566   *             be supported from 2.0.
567   */
568  @Deprecated
569  public HColumnDescriptor setCacheDataInL1(boolean value) {
570    return this;
571  }
572
573  @Override
574  public boolean isCacheIndexesOnWrite() {
575    return delegatee.isCacheIndexesOnWrite();
576  }
577
578  /**
579   * Set or clear the cache indexes on write flag.
580   * @param value true if we should cache index blocks on write
581   * @return this (for chained invocation)
582   */
583  public HColumnDescriptor setCacheIndexesOnWrite(boolean value) {
584    getDelegateeForModification().setCacheIndexesOnWrite(value);
585    return this;
586  }
587
588  @Override
589  public boolean isCacheBloomsOnWrite() {
590    return delegatee.isCacheBloomsOnWrite();
591  }
592
593  /**
594   * Set or clear the cache bloom filters on write flag.
595   * @param value true if we should cache bloomfilter blocks on write
596   * @return this (for chained invocation)
597   */
598  public HColumnDescriptor setCacheBloomsOnWrite(boolean value) {
599    getDelegateeForModification().setCacheBloomsOnWrite(value);
600    return this;
601  }
602
603  @Override
604  public boolean isEvictBlocksOnClose() {
605    return delegatee.isEvictBlocksOnClose();
606  }
607
608  /**
609   * Set or clear the evict bloom filters on close flag.
610   * @param value true if we should evict cached blocks from the blockcache on close
611   * @return this (for chained invocation)
612   */
613  public HColumnDescriptor setEvictBlocksOnClose(boolean value) {
614    getDelegateeForModification().setEvictBlocksOnClose(value);
615    return this;
616  }
617
618  @Override
619  public boolean isPrefetchBlocksOnOpen() {
620    return delegatee.isPrefetchBlocksOnOpen();
621  }
622
623  /**
624   * Set or clear the prefetch on open flag.
625   * @param value true if we should prefetch blocks into the blockcache on open
626   * @return this (for chained invocation)
627   */
628  public HColumnDescriptor setPrefetchBlocksOnOpen(boolean value) {
629    getDelegateeForModification().setPrefetchBlocksOnOpen(value);
630    return this;
631  }
632
633  @Override
634  public String toString() {
635    return delegatee.toString();
636  }
637
638  /** Returns Column family descriptor with only the customized attributes. */
639  @Override
640  public String toStringCustomizedValues() {
641    return delegatee.toStringCustomizedValues();
642  }
643
644  public static Unit getUnit(String key) {
645    return ColumnFamilyDescriptorBuilder.getUnit(key);
646  }
647
648  public static Map<String, String> getDefaultValues() {
649    return ColumnFamilyDescriptorBuilder.getDefaultValues();
650  }
651
652  @Override
653  public boolean equals(Object obj) {
654    if (this == obj) {
655      return true;
656    }
657    if (obj instanceof HColumnDescriptor) {
658      return delegatee.equals(((HColumnDescriptor) obj).delegatee);
659    }
660    return false;
661  }
662
663  @Override
664  public int hashCode() {
665    return delegatee.hashCode();
666  }
667
668  @Override
669  public int compareTo(HColumnDescriptor other) {
670    return COMPARATOR.compare(this, other);
671  }
672
673  /**
674   * Returns This instance serialized with pb with pb magic prefix
675   * @see #parseFrom(byte[])
676   */
677  public byte[] toByteArray() {
678    return ColumnFamilyDescriptorBuilder.toByteArray(delegatee);
679  }
680
681  /**
682   * Parse a serialized representation of a {@link HColumnDescriptor}
683   * @param bytes A pb serialized {@link HColumnDescriptor} instance with pb magic prefix
684   * @return An instance of {@link HColumnDescriptor} made from <code>bytes</code> n * @see
685   *         #toByteArray()
686   */
687  public static HColumnDescriptor parseFrom(final byte[] bytes) throws DeserializationException {
688    ColumnFamilyDescriptor desc = ColumnFamilyDescriptorBuilder.parseFrom(bytes);
689    if (desc instanceof ModifyableColumnFamilyDescriptor) {
690      return new HColumnDescriptor((ModifyableColumnFamilyDescriptor) desc);
691    } else {
692      return new HColumnDescriptor(new ModifyableColumnFamilyDescriptor(desc));
693    }
694  }
695
696  @Override
697  public String getConfigurationValue(String key) {
698    return delegatee.getConfigurationValue(key);
699  }
700
701  @Override
702  public Map<String, String> getConfiguration() {
703    return delegatee.getConfiguration();
704  }
705
706  /**
707   * Setter for storing a configuration setting.
708   * @param key   Config key. Same as XML config key e.g. hbase.something.or.other.
709   * @param value String value. If null, removes the configuration.
710   */
711  public HColumnDescriptor setConfiguration(String key, String value) {
712    getDelegateeForModification().setConfiguration(key, value);
713    return this;
714  }
715
716  /**
717   * Remove a configuration setting represented by the key.
718   */
719  public void removeConfiguration(final String key) {
720    getDelegateeForModification().removeConfiguration(key);
721  }
722
723  @Override
724  public String getEncryptionType() {
725    return delegatee.getEncryptionType();
726  }
727
728  /**
729   * Set the encryption algorithm for use with this family n
730   */
731  public HColumnDescriptor setEncryptionType(String value) {
732    getDelegateeForModification().setEncryptionType(value);
733    return this;
734  }
735
736  @Override
737  public byte[] getEncryptionKey() {
738    return delegatee.getEncryptionKey();
739  }
740
741  /** Set the raw crypto key attribute for the family */
742  public HColumnDescriptor setEncryptionKey(byte[] value) {
743    getDelegateeForModification().setEncryptionKey(value);
744    return this;
745  }
746
747  @Override
748  public long getMobThreshold() {
749    return delegatee.getMobThreshold();
750  }
751
752  /**
753   * Sets the mob threshold of the family.
754   * @param value The mob threshold.
755   * @return this (for chained invocation)
756   */
757  public HColumnDescriptor setMobThreshold(long value) {
758    getDelegateeForModification().setMobThreshold(value);
759    return this;
760  }
761
762  @Override
763  public boolean isMobEnabled() {
764    return delegatee.isMobEnabled();
765  }
766
767  /**
768   * Enables the mob for the family.
769   * @param value Whether to enable the mob for the family.
770   * @return this (for chained invocation)
771   */
772  public HColumnDescriptor setMobEnabled(boolean value) {
773    getDelegateeForModification().setMobEnabled(value);
774    return this;
775  }
776
777  @Override
778  public MobCompactPartitionPolicy getMobCompactPartitionPolicy() {
779    return delegatee.getMobCompactPartitionPolicy();
780  }
781
782  /**
783   * Set the mob compact partition policy for the family.
784   * @param value policy type
785   * @return this (for chained invocation)
786   */
787  public HColumnDescriptor setMobCompactPartitionPolicy(MobCompactPartitionPolicy value) {
788    getDelegateeForModification().setMobCompactPartitionPolicy(value);
789    return this;
790  }
791
792  @Override
793  public short getDFSReplication() {
794    return delegatee.getDFSReplication();
795  }
796
797  /**
798   * Set the replication factor to hfile(s) belonging to this family
799   * @param value number of replicas the blocks(s) belonging to this CF should have, or
800   *              {@link #DEFAULT_DFS_REPLICATION} for the default replication factor set in the
801   *              filesystem
802   * @return this (for chained invocation)
803   */
804  public HColumnDescriptor setDFSReplication(short value) {
805    getDelegateeForModification().setDFSReplication(value);
806    return this;
807  }
808
809  @Override
810  public String getStoragePolicy() {
811    return delegatee.getStoragePolicy();
812  }
813
814  /**
815   * Set the storage policy for use with this family
816   * @param value the policy to set, valid setting includes: <i>"LAZY_PERSIST"</i>,
817   *              <i>"ALL_SSD"</i>, <i>"ONE_SSD"</i>, <i>"HOT"</i>, <i>"WARM"</i>, <i>"COLD"</i>
818   */
819  public HColumnDescriptor setStoragePolicy(String value) {
820    getDelegateeForModification().setStoragePolicy(value);
821    return this;
822  }
823
824  @Override
825  public Bytes getValue(Bytes key) {
826    return delegatee.getValue(key);
827  }
828
829  protected ModifyableColumnFamilyDescriptor getDelegateeForModification() {
830    return delegatee;
831  }
832}