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