org.apache.hadoop.hbase.io.hfile
Enum BlockType

java.lang.Object
  extended by java.lang.Enum<BlockType>
      extended by org.apache.hadoop.hbase.io.hfile.BlockType
All Implemented Interfaces:
Serializable, Comparable<BlockType>

@InterfaceAudience.Private
public enum BlockType
extends Enum<BlockType>

Various types of HFile blocks. Ordinal values of these enum constants must not be relied upon. The values in the enum appear in the order they appear in a version 2 HFile.


Nested Class Summary
static class BlockType.BlockCategory
           
 
Enum Constant Summary
BLOOM_CHUNK
          Bloom filter block, version 2
DATA
          Data block, both versions
DELETE_FAMILY_BLOOM_META
          Delete Family Bloom filter metadata, version 2
ENCODED_DATA
          An encoded data block (e.g.
FILE_INFO
          File info, version 2
GENERAL_BLOOM_META
          General Bloom filter metadata, version 2
INDEX_V1
          Block index magic string in version 1
INTERMEDIATE_INDEX
          Intermediate-level version 2 index in the non-data block section
LEAF_INDEX
          Version 2 leaf index block.
META
          Meta blocks
ROOT_INDEX
          Root index block, also used for the single-level meta index, version 2
TRAILER
          Fixed file trailer, both versions (always just a magic string)
 
Field Summary
static int MAGIC_LENGTH
           
 
Method Summary
 BlockType.BlockCategory getCategory()
           
 int getId()
          Use this instead of Enum.ordinal().
 boolean isData()
           
static BlockType parse(byte[] buf, int offset, int length)
           
 int put(byte[] bytes, int offset)
          Put the magic record out to the specified byte array position.
static BlockType read(ByteBuffer buf)
           
static BlockType read(DataInputStream in)
           
 void readAndCheck(ByteBuffer in)
          Reads a magic record of the length MAGIC_LENGTH from the given byte buffer and expects it to match this block type.
 void readAndCheck(DataInputStream in)
          Reads a magic record of the length MAGIC_LENGTH from the given stream and expects it to match this block type.
static BlockType valueOf(String name)
          Returns the enum constant of this type with the specified name.
static BlockType[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 void write(ByteBuffer buf)
           
 void write(DataOutput out)
           
 void writeToStream(OutputStream out)
           
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

DATA

public static final BlockType DATA
Data block, both versions


ENCODED_DATA

public static final BlockType ENCODED_DATA
An encoded data block (e.g. with prefix compression), version 2


LEAF_INDEX

public static final BlockType LEAF_INDEX
Version 2 leaf index block. Appears in the data block section


BLOOM_CHUNK

public static final BlockType BLOOM_CHUNK
Bloom filter block, version 2


META

public static final BlockType META
Meta blocks


INTERMEDIATE_INDEX

public static final BlockType INTERMEDIATE_INDEX
Intermediate-level version 2 index in the non-data block section


ROOT_INDEX

public static final BlockType ROOT_INDEX
Root index block, also used for the single-level meta index, version 2


FILE_INFO

public static final BlockType FILE_INFO
File info, version 2


GENERAL_BLOOM_META

public static final BlockType GENERAL_BLOOM_META
General Bloom filter metadata, version 2


DELETE_FAMILY_BLOOM_META

public static final BlockType DELETE_FAMILY_BLOOM_META
Delete Family Bloom filter metadata, version 2


TRAILER

public static final BlockType TRAILER
Fixed file trailer, both versions (always just a magic string)


INDEX_V1

public static final BlockType INDEX_V1
Block index magic string in version 1

Field Detail

MAGIC_LENGTH

public static final int MAGIC_LENGTH
See Also:
Constant Field Values
Method Detail

values

public static BlockType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (BlockType c : BlockType.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static BlockType valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

getId

public int getId()
Use this instead of Enum.ordinal(). They work exactly the same, except DATA and ENCODED_DATA get the same id using this method (overridden for ENCODED_DATA).

Returns:
block type id from 0 to the number of block types - 1

writeToStream

public void writeToStream(OutputStream out)
                   throws IOException
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Throws:
IOException

write

public void write(ByteBuffer buf)

getCategory

public BlockType.BlockCategory getCategory()

parse

public static BlockType parse(byte[] buf,
                              int offset,
                              int length)
                       throws IOException
Throws:
IOException

read

public static BlockType read(DataInputStream in)
                      throws IOException
Throws:
IOException

read

public static BlockType read(ByteBuffer buf)
                      throws IOException
Throws:
IOException

put

public int put(byte[] bytes,
               int offset)
Put the magic record out to the specified byte array position.

Parameters:
bytes - the byte array
offset - position in the array
Returns:
incremented offset

readAndCheck

public void readAndCheck(DataInputStream in)
                  throws IOException
Reads a magic record of the length MAGIC_LENGTH from the given stream and expects it to match this block type.

Throws:
IOException

readAndCheck

public void readAndCheck(ByteBuffer in)
                  throws IOException
Reads a magic record of the length MAGIC_LENGTH from the given byte buffer and expects it to match this block type.

Throws:
IOException

isData

public final boolean isData()
Returns:
whether this block type is encoded or unencoded data block


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.