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