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  @Override
525  public boolean isCacheIndexesOnWrite() {
526    return delegatee.isCacheIndexesOnWrite();
527  }
528
529  /**
530   * @param value true if we should cache index blocks on write
531   * @return this (for chained invocation)
532   */
533  public HColumnDescriptor setCacheIndexesOnWrite(boolean value) {
534    getDelegateeForModification().setCacheIndexesOnWrite(value);
535    return this;
536  }
537
538  @Override
539  public boolean isCacheBloomsOnWrite() {
540    return delegatee.isCacheBloomsOnWrite();
541  }
542
543  /**
544   * @param value true if we should cache bloomfilter blocks on write
545   * @return this (for chained invocation)
546   */
547  public HColumnDescriptor setCacheBloomsOnWrite(boolean value) {
548    getDelegateeForModification().setCacheBloomsOnWrite(value);
549    return this;
550  }
551
552  @Override
553  public boolean isEvictBlocksOnClose() {
554    return delegatee.isEvictBlocksOnClose();
555  }
556
557  /**
558   * @param value true if we should evict cached blocks from the blockcache on
559   * close
560   * @return this (for chained invocation)
561   */
562  public HColumnDescriptor setEvictBlocksOnClose(boolean value) {
563    getDelegateeForModification().setEvictBlocksOnClose(value);
564    return this;
565  }
566
567  @Override
568  public boolean isPrefetchBlocksOnOpen() {
569    return delegatee.isPrefetchBlocksOnOpen();
570  }
571
572  /**
573   * @param value true if we should prefetch blocks into the blockcache on open
574   * @return this (for chained invocation)
575   */
576  public HColumnDescriptor setPrefetchBlocksOnOpen(boolean value) {
577    getDelegateeForModification().setPrefetchBlocksOnOpen(value);
578    return this;
579  }
580
581  /**
582   * @see java.lang.Object#toString()
583   */
584  @Override
585  public String toString() {
586    return delegatee.toString();
587  }
588
589  /**
590   * @return Column family descriptor with only the customized attributes.
591   */
592  @Override
593  public String toStringCustomizedValues() {
594    return delegatee.toStringCustomizedValues();
595  }
596
597  public static Unit getUnit(String key) {
598    return ColumnFamilyDescriptorBuilder.getUnit(key);
599  }
600
601  public static Map<String, String> getDefaultValues() {
602    return ColumnFamilyDescriptorBuilder.getDefaultValues();
603  }
604
605  /**
606   * @see java.lang.Object#equals(java.lang.Object)
607   */
608  @Override
609  public boolean equals(Object obj) {
610    if (this == obj) {
611      return true;
612    }
613    if (obj instanceof HColumnDescriptor) {
614      return delegatee.equals(((HColumnDescriptor) obj).delegatee);
615    }
616    return false;
617  }
618
619  /**
620   * @see java.lang.Object#hashCode()
621   */
622  @Override
623  public int hashCode() {
624    return delegatee.hashCode();
625  }
626
627  @Override
628  public int compareTo(HColumnDescriptor other) {
629    return COMPARATOR.compare(this, other);
630  }
631
632  /**
633   * @return This instance serialized with pb with pb magic prefix
634   * @see #parseFrom(byte[])
635   */
636  public byte[] toByteArray() {
637    return ColumnFamilyDescriptorBuilder.toByteArray(delegatee);
638  }
639
640  /**
641   * @param bytes A pb serialized {@link HColumnDescriptor} instance with pb magic prefix
642   * @return An instance of {@link HColumnDescriptor} made from <code>bytes</code>
643   * @throws DeserializationException
644   * @see #toByteArray()
645   */
646  public static HColumnDescriptor parseFrom(final byte [] bytes) throws DeserializationException {
647    ColumnFamilyDescriptor desc = ColumnFamilyDescriptorBuilder.parseFrom(bytes);
648    if (desc instanceof ModifyableColumnFamilyDescriptor) {
649      return new HColumnDescriptor((ModifyableColumnFamilyDescriptor) desc);
650    } else {
651      return new HColumnDescriptor(new ModifyableColumnFamilyDescriptor(desc));
652    }
653  }
654
655  @Override
656  public String getConfigurationValue(String key) {
657    return delegatee.getConfigurationValue(key);
658  }
659
660  @Override
661  public Map<String, String> getConfiguration() {
662    return delegatee.getConfiguration();
663  }
664
665  /**
666   * Setter for storing a configuration setting.
667   * @param key Config key. Same as XML config key e.g. hbase.something.or.other.
668   * @param value String value. If null, removes the configuration.
669   */
670  public HColumnDescriptor setConfiguration(String key, String value) {
671    getDelegateeForModification().setConfiguration(key, value);
672    return this;
673  }
674
675  /**
676   * Remove a configuration setting represented by the key.
677   */
678  public void removeConfiguration(final String key) {
679    getDelegateeForModification().removeConfiguration(key);
680  }
681
682  @Override
683  public String getEncryptionType() {
684    return delegatee.getEncryptionType();
685  }
686
687  /**
688   * Set the encryption algorithm for use with this family
689   * @param value
690   */
691  public HColumnDescriptor setEncryptionType(String value) {
692    getDelegateeForModification().setEncryptionType(value);
693    return this;
694  }
695
696  @Override
697  public byte[] getEncryptionKey() {
698    return delegatee.getEncryptionKey();
699  }
700
701  /** Set the raw crypto key attribute for the family */
702  public HColumnDescriptor setEncryptionKey(byte[] value) {
703    getDelegateeForModification().setEncryptionKey(value);
704    return this;
705  }
706
707  @Override
708  public long getMobThreshold() {
709    return delegatee.getMobThreshold();
710  }
711
712  /**
713   * Sets the mob threshold of the family.
714   * @param value The mob threshold.
715   * @return this (for chained invocation)
716   */
717  public HColumnDescriptor setMobThreshold(long value) {
718    getDelegateeForModification().setMobThreshold(value);
719    return this;
720  }
721
722  @Override
723  public boolean isMobEnabled() {
724    return delegatee.isMobEnabled();
725  }
726
727  /**
728   * Enables the mob for the family.
729   * @param value Whether to enable the mob for the family.
730   * @return this (for chained invocation)
731   */
732  public HColumnDescriptor setMobEnabled(boolean value) {
733    getDelegateeForModification().setMobEnabled(value);
734    return this;
735  }
736
737  @Override
738  public MobCompactPartitionPolicy getMobCompactPartitionPolicy() {
739    return delegatee.getMobCompactPartitionPolicy();
740  }
741
742  /**
743   * Set the mob compact partition policy for the family.
744   * @param value policy type
745   * @return this (for chained invocation)
746   */
747  public HColumnDescriptor setMobCompactPartitionPolicy(MobCompactPartitionPolicy value) {
748    getDelegateeForModification().setMobCompactPartitionPolicy(value);
749    return this;
750  }
751
752  @Override
753  public short getDFSReplication() {
754    return delegatee.getDFSReplication();
755  }
756
757  /**
758   * Set the replication factor to hfile(s) belonging to this family
759   * @param value number of replicas the blocks(s) belonging to this CF should have, or
760   *          {@link #DEFAULT_DFS_REPLICATION} for the default replication factor set in the
761   *          filesystem
762   * @return this (for chained invocation)
763   */
764  public HColumnDescriptor setDFSReplication(short value) {
765    getDelegateeForModification().setDFSReplication(value);
766    return this;
767  }
768
769  @Override
770  public String getStoragePolicy() {
771    return delegatee.getStoragePolicy();
772  }
773
774  /**
775   * Set the storage policy for use with this family
776   * @param value the policy to set, valid setting includes: <i>"LAZY_PERSIST"</i>,
777   *          <i>"ALL_SSD"</i>, <i>"ONE_SSD"</i>, <i>"HOT"</i>, <i>"WARM"</i>, <i>"COLD"</i>
778   */
779  public HColumnDescriptor setStoragePolicy(String value) {
780    getDelegateeForModification().setStoragePolicy(value);
781    return this;
782  }
783
784  @Override
785  public Bytes getValue(Bytes key) {
786    return delegatee.getValue(key);
787  }
788
789  protected ModifyableColumnFamilyDescriptor getDelegateeForModification() {
790    return delegatee;
791  }
792}