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