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(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   * @param b Family name.
160   * @return <code>b</code>
161   * @throws IllegalArgumentException If not null and not a legitimate family
162   * name: i.e. 'printable' and ends in a ':' (Null passes are allowed because
163   * <code>b</code> can be null when deserializing).  Cannot start with a '.'
164   * either. Also Family can not be an empty value or equal "recovered.edits".
165   * @deprecated Use {@link ColumnFamilyDescriptorBuilder#isLegalColumnFamilyName(byte[])}.
166   */
167  @Deprecated
168  public static byte [] isLegalFamilyName(final byte [] b) {
169    return ColumnFamilyDescriptorBuilder.isLegalColumnFamilyName(b);
170  }
171
172  /**
173   * @return Name of this column family
174   */
175  @Override
176  public byte [] getName() {
177    return delegatee.getName();
178  }
179
180  /**
181   * @return The name string of this column family
182   */
183  @Override
184  public String getNameAsString() {
185    return delegatee.getNameAsString();
186  }
187
188  /**
189   * @param key The key.
190   * @return The value.
191   */
192  @Override
193  public byte[] getValue(byte[] key) {
194    return delegatee.getValue(key);
195  }
196
197  /**
198   * @param key The key.
199   * @return The value as a string.
200   */
201  public String getValue(String key) {
202    byte[] value = getValue(Bytes.toBytes(key));
203    return value == null ? null : Bytes.toString(value);
204  }
205
206  @Override
207  public Map<Bytes, Bytes> getValues() {
208    return delegatee.getValues();
209  }
210
211  /**
212   * @param key The key.
213   * @param value The value.
214   * @return this (for chained invocation)
215   */
216  public HColumnDescriptor setValue(byte[] key, byte[] value) {
217    getDelegateeForModification().setValue(key, value);
218    return this;
219  }
220
221  /**
222   * @param key Key whose key and value we're to remove from HCD parameters.
223   */
224  public void remove(final byte [] key) {
225    getDelegateeForModification().removeValue(new Bytes(key));
226  }
227
228  /**
229   * @param key The key.
230   * @param value The value.
231   * @return this (for chained invocation)
232   */
233  public HColumnDescriptor setValue(String key, String value) {
234    getDelegateeForModification().setValue(key, value);
235    return this;
236  }
237
238  /**
239   * @return compression type being used for the column family
240   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
241   *             (<a href="https://issues.apache.org/jira/browse/HBASE-13655">HBASE-13655</a>).
242   *             Use {@link #getCompressionType()}.
243   */
244  @Deprecated
245  public Compression.Algorithm getCompression() {
246    return getCompressionType();
247  }
248
249  /**
250   *  @return compression type being used for the column family for major compaction
251   *  @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
252   *             (<a href="https://issues.apache.org/jira/browse/HBASE-13655">HBASE-13655</a>).
253   *             Use {@link #getCompactionCompressionType()}.
254   */
255  @Deprecated
256  public Compression.Algorithm getCompactionCompression() {
257    return getCompactionCompressionType();
258  }
259
260  @Override
261  public int getMaxVersions() {
262    return delegatee.getMaxVersions();
263  }
264
265  /**
266   * @param value maximum number of versions
267   * @return this (for chained invocation)
268   */
269  public HColumnDescriptor setMaxVersions(int value) {
270    getDelegateeForModification().setMaxVersions(value);
271    return this;
272  }
273
274  /**
275   * Set minimum and maximum versions to keep
276   *
277   * @param minVersions minimal number of versions
278   * @param maxVersions maximum number of versions
279   * @return this (for chained invocation)
280   */
281  public HColumnDescriptor setVersions(int minVersions, int maxVersions) {
282    if (minVersions <= 0) {
283      // TODO: Allow minVersion and maxVersion of 0 to be the way you say "Keep all versions".
284      // Until there is support, consider 0 or < 0 -- a configuration error.
285      throw new IllegalArgumentException("Minimum versions must be positive");
286    }
287
288    if (maxVersions < minVersions) {
289      throw new IllegalArgumentException("Unable to set MaxVersion to " + maxVersions
290        + " and set MinVersion to " + minVersions
291        + ", as maximum versions must be >= minimum versions.");
292    }
293    setMinVersions(minVersions);
294    setMaxVersions(maxVersions);
295    return this;
296  }
297
298  @Override
299  public int getBlocksize() {
300    return delegatee.getBlocksize();
301  }
302
303  /**
304   * @param value Blocksize to use when writing out storefiles/hfiles on this
305   * column family.
306   * @return this (for chained invocation)
307   */
308  public HColumnDescriptor setBlocksize(int value) {
309    getDelegateeForModification().setBlocksize(value);
310    return this;
311  }
312
313  @Override
314  public Compression.Algorithm getCompressionType() {
315    return delegatee.getCompressionType();
316  }
317
318  /**
319   * Compression types supported in hbase.
320   * LZO is not bundled as part of the hbase distribution.
321   * See <a href="http://wiki.apache.org/hadoop/UsingLzoCompression">LZO Compression</a>
322   * for how to enable it.
323   * @param value Compression type setting.
324   * @return this (for chained invocation)
325   */
326  public HColumnDescriptor setCompressionType(Compression.Algorithm value) {
327    getDelegateeForModification().setCompressionType(value);
328    return this;
329  }
330
331  @Override
332  public DataBlockEncoding getDataBlockEncoding() {
333    return delegatee.getDataBlockEncoding();
334  }
335
336  /**
337   * Set data block encoding algorithm used in block cache.
338   * @param value What kind of data block encoding will be used.
339   * @return this (for chained invocation)
340   */
341  public HColumnDescriptor setDataBlockEncoding(DataBlockEncoding value) {
342    getDelegateeForModification().setDataBlockEncoding(value);
343    return this;
344  }
345
346  /**
347   * Set whether the tags should be compressed along with DataBlockEncoding. When no
348   * DataBlockEncoding is been used, this is having no effect.
349   *
350   * @param value
351   * @return this (for chained invocation)
352   */
353  public HColumnDescriptor setCompressTags(boolean value) {
354    getDelegateeForModification().setCompressTags(value);
355    return this;
356  }
357
358  @Override
359  public boolean isCompressTags() {
360    return delegatee.isCompressTags();
361  }
362
363  @Override
364  public Compression.Algorithm getCompactionCompressionType() {
365    return delegatee.getCompactionCompressionType();
366  }
367
368  /**
369   * Compression types supported in hbase.
370   * LZO is not bundled as part of the hbase distribution.
371   * See <a href="http://wiki.apache.org/hadoop/UsingLzoCompression">LZO Compression</a>
372   * for how to enable it.
373   * @param value Compression type setting.
374   * @return this (for chained invocation)
375   */
376  public HColumnDescriptor setCompactionCompressionType(Compression.Algorithm value) {
377    getDelegateeForModification().setCompactionCompressionType(value);
378    return this;
379  }
380
381  @Override
382  public boolean isInMemory() {
383    return delegatee.isInMemory();
384  }
385
386  /**
387   * @param value True if we are to favor keeping all values for this column family in the
388   * HRegionServer cache
389   * @return this (for chained invocation)
390   */
391  public HColumnDescriptor setInMemory(boolean value) {
392    getDelegateeForModification().setInMemory(value);
393    return this;
394  }
395
396  @Override
397  public MemoryCompactionPolicy getInMemoryCompaction() {
398    return delegatee.getInMemoryCompaction();
399  }
400
401  /**
402   * @param value the prefered in-memory compaction policy
403   *                  for this column family
404   * @return this (for chained invocation)
405   */
406  public HColumnDescriptor setInMemoryCompaction(MemoryCompactionPolicy value) {
407    getDelegateeForModification().setInMemoryCompaction(value);
408    return this;
409  }
410
411  @Override
412  public KeepDeletedCells getKeepDeletedCells() {
413    return delegatee.getKeepDeletedCells();
414  }
415
416  /**
417   * @param value True if deleted rows should not be collected
418   * immediately.
419   * @return this (for chained invocation)
420   */
421  public HColumnDescriptor setKeepDeletedCells(KeepDeletedCells value) {
422    getDelegateeForModification().setKeepDeletedCells(value);
423    return this;
424  }
425
426  /**
427   * By default, HBase only consider timestamp in versions. So a previous Delete with higher ts
428   * will mask a later Put with lower ts. Set this to true to enable new semantics of versions.
429   * We will also consider mvcc in versions. See HBASE-15968 for details.
430   */
431  @Override
432  public boolean isNewVersionBehavior() {
433    return delegatee.isNewVersionBehavior();
434  }
435
436  public HColumnDescriptor setNewVersionBehavior(boolean newVersionBehavior) {
437    getDelegateeForModification().setNewVersionBehavior(newVersionBehavior);
438    return this;
439  }
440
441
442  @Override
443  public int getTimeToLive() {
444    return delegatee.getTimeToLive();
445  }
446
447  /**
448   * @param value Time-to-live of cell contents, in seconds.
449   * @return this (for chained invocation)
450   */
451  public HColumnDescriptor setTimeToLive(int value) {
452    getDelegateeForModification().setTimeToLive(value);
453    return this;
454  }
455
456  /**
457   * @param value Time to live of cell contents, in human readable format
458   *                   @see org.apache.hadoop.hbase.util.PrettyPrinter#format(String, Unit)
459   * @return this (for chained invocation)
460   */
461  public HColumnDescriptor setTimeToLive(String value) throws HBaseException {
462    getDelegateeForModification().setTimeToLive(value);
463    return this;
464  }
465
466  @Override
467  public int getMinVersions() {
468    return delegatee.getMinVersions();
469  }
470
471  /**
472   * @param value The minimum number of versions to keep.
473   * (used when timeToLive is set)
474   * @return this (for chained invocation)
475   */
476  public HColumnDescriptor setMinVersions(int value) {
477    getDelegateeForModification().setMinVersions(value);
478    return this;
479  }
480
481  @Override
482  public boolean isBlockCacheEnabled() {
483    return delegatee.isBlockCacheEnabled();
484  }
485
486  /**
487   * @param value True if hfile DATA type blocks should be cached (We always cache
488   * INDEX and BLOOM blocks; you cannot turn this off).
489   * @return this (for chained invocation)
490   */
491  public HColumnDescriptor setBlockCacheEnabled(boolean value) {
492    getDelegateeForModification().setBlockCacheEnabled(value);
493    return this;
494  }
495
496  @Override
497  public BloomType getBloomFilterType() {
498    return delegatee.getBloomFilterType();
499  }
500
501  /**
502   * @param value bloom filter type
503   * @return this (for chained invocation)
504   */
505  public HColumnDescriptor setBloomFilterType(final BloomType value) {
506    getDelegateeForModification().setBloomFilterType(value);
507    return this;
508  }
509
510  @Override
511  public int getScope() {
512    return delegatee.getScope();
513  }
514
515 /**
516  * @param value the scope tag
517  * @return this (for chained invocation)
518  */
519  public HColumnDescriptor setScope(int value) {
520    getDelegateeForModification().setScope(value);
521    return this;
522  }
523
524  @Override
525  public boolean isCacheDataOnWrite() {
526    return delegatee.isCacheDataOnWrite();
527  }
528
529  /**
530   * @param value true if we should cache data blocks on write
531   * @return this (for chained invocation)
532   */
533  public HColumnDescriptor setCacheDataOnWrite(boolean value) {
534    getDelegateeForModification().setCacheDataOnWrite(value);
535    return this;
536  }
537
538  /**
539   * This is a noop call from HBase 2.0 onwards
540   *
541   * @return this (for chained invocation)
542   * @deprecated Since 2.0 and will be removed in 3.0 with out any replacement. Caching data in on
543   *             heap Cache, when there are both on heap LRU Cache and Bucket Cache will no longer
544   *             be supported from 2.0.
545   */
546  @Deprecated
547  public HColumnDescriptor setCacheDataInL1(boolean value) {
548    return this;
549  }
550
551  @Override
552  public boolean isCacheIndexesOnWrite() {
553    return delegatee.isCacheIndexesOnWrite();
554  }
555
556  /**
557   * @param value true if we should cache index blocks on write
558   * @return this (for chained invocation)
559   */
560  public HColumnDescriptor setCacheIndexesOnWrite(boolean value) {
561    getDelegateeForModification().setCacheIndexesOnWrite(value);
562    return this;
563  }
564
565  @Override
566  public boolean isCacheBloomsOnWrite() {
567    return delegatee.isCacheBloomsOnWrite();
568  }
569
570  /**
571   * @param value true if we should cache bloomfilter blocks on write
572   * @return this (for chained invocation)
573   */
574  public HColumnDescriptor setCacheBloomsOnWrite(boolean value) {
575    getDelegateeForModification().setCacheBloomsOnWrite(value);
576    return this;
577  }
578
579  @Override
580  public boolean isEvictBlocksOnClose() {
581    return delegatee.isEvictBlocksOnClose();
582  }
583
584  /**
585   * @param value true if we should evict cached blocks from the blockcache on
586   * close
587   * @return this (for chained invocation)
588   */
589  public HColumnDescriptor setEvictBlocksOnClose(boolean value) {
590    getDelegateeForModification().setEvictBlocksOnClose(value);
591    return this;
592  }
593
594  @Override
595  public boolean isPrefetchBlocksOnOpen() {
596    return delegatee.isPrefetchBlocksOnOpen();
597  }
598
599  /**
600   * @param value true if we should prefetch blocks into the blockcache on open
601   * @return this (for chained invocation)
602   */
603  public HColumnDescriptor setPrefetchBlocksOnOpen(boolean value) {
604    getDelegateeForModification().setPrefetchBlocksOnOpen(value);
605    return this;
606  }
607
608  /**
609   * @see java.lang.Object#toString()
610   */
611  @Override
612  public String toString() {
613    return delegatee.toString();
614  }
615
616  /**
617   * @return Column family descriptor with only the customized attributes.
618   */
619  @Override
620  public String toStringCustomizedValues() {
621    return delegatee.toStringCustomizedValues();
622  }
623
624  public static Unit getUnit(String key) {
625    return ColumnFamilyDescriptorBuilder.getUnit(key);
626  }
627
628  public static Map<String, String> getDefaultValues() {
629    return ColumnFamilyDescriptorBuilder.getDefaultValues();
630  }
631
632  /**
633   * @see java.lang.Object#equals(java.lang.Object)
634   */
635  @Override
636  public boolean equals(Object obj) {
637    if (this == obj) {
638      return true;
639    }
640    if (obj instanceof HColumnDescriptor) {
641      return delegatee.equals(((HColumnDescriptor) obj).delegatee);
642    }
643    return false;
644  }
645
646  /**
647   * @see java.lang.Object#hashCode()
648   */
649  @Override
650  public int hashCode() {
651    return delegatee.hashCode();
652  }
653
654  @Override
655  public int compareTo(HColumnDescriptor other) {
656    return COMPARATOR.compare(this, other);
657  }
658
659  /**
660   * @return This instance serialized with pb with pb magic prefix
661   * @see #parseFrom(byte[])
662   */
663  public byte[] toByteArray() {
664    return ColumnFamilyDescriptorBuilder.toByteArray(delegatee);
665  }
666
667  /**
668   * @param bytes A pb serialized {@link HColumnDescriptor} instance with pb magic prefix
669   * @return An instance of {@link HColumnDescriptor} made from <code>bytes</code>
670   * @throws DeserializationException
671   * @see #toByteArray()
672   */
673  public static HColumnDescriptor parseFrom(final byte [] bytes) throws DeserializationException {
674    ColumnFamilyDescriptor desc = ColumnFamilyDescriptorBuilder.parseFrom(bytes);
675    if (desc instanceof ModifyableColumnFamilyDescriptor) {
676      return new HColumnDescriptor((ModifyableColumnFamilyDescriptor) desc);
677    } else {
678      return new HColumnDescriptor(new ModifyableColumnFamilyDescriptor(desc));
679    }
680  }
681
682  @Override
683  public String getConfigurationValue(String key) {
684    return delegatee.getConfigurationValue(key);
685  }
686
687  @Override
688  public Map<String, String> getConfiguration() {
689    return delegatee.getConfiguration();
690  }
691
692  /**
693   * Setter for storing a configuration setting.
694   * @param key Config key. Same as XML config key e.g. hbase.something.or.other.
695   * @param value String value. If null, removes the configuration.
696   */
697  public HColumnDescriptor setConfiguration(String key, String value) {
698    getDelegateeForModification().setConfiguration(key, value);
699    return this;
700  }
701
702  /**
703   * Remove a configuration setting represented by the key.
704   */
705  public void removeConfiguration(final String key) {
706    getDelegateeForModification().removeConfiguration(key);
707  }
708
709  @Override
710  public String getEncryptionType() {
711    return delegatee.getEncryptionType();
712  }
713
714  /**
715   * Set the encryption algorithm for use with this family
716   * @param value
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}