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