Overview | Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.exist.numbering
Class DLNBase

    java.lang.Object
      org.exist.numbering.DLNBase

Direct Known Subclasses:
  DLN

public class DLNBase
extends java.lang.Object

Base class representing a node id in the form of a dynamic level number (DLN). See `DLN`. DLNBase handles the efficient binary encoding of node ids. Level values are stored consecutively, using a fixed prefix free encoding. The number of units to be used for encoding a single level value is dynamically adjusted. We start with one unit and use its n - 1 lower bits. If the number exceeds the lower bits, we add another unit and set the highest bit to 1. This process is repeated for larger numbers. As a result, the first 1 bits of a level id indicate the number of fixed-size units used for encoding a level id. We thus don't need separator bits between the units themselves.

Author:
  wolf

Field Summary
`static int[]` | `BIT_MASK`
`static int` | `BITS_PER_UNIT` The default number of bits used per fixed size unit.

Constructor Summary
`DLNBase()`
`DLNBase(DLNBase dln)`
`DLNBase(int units, byte[] data, int startOffset)`
`DLNBase(short bitCnt, VariableByteInput is)`

Method Summary
`void` | `addLevelId(int levelId, boolean isSubLevel)` Adds a new level to the node id, using levelId as initial value.
`int` | `compareBits(DLNBase other, int bitCount)`
`java.lang.String` | `debug()`
`boolean` | `equals(DLNBase other)`
`static int` | `getLengthInBytes(int units, byte[] data, int startOffset)`
`int` | `getLevelCount(int startOffset)` Returns the number of level in this id, which corresponds to the depth at which the node occurs within the node tree.
`int` | `getLevelId(int startBit)` Returns the id starting at offset.
`int[]` | `getLevelIds()` Return all level ids converted to int.
`int` | `getSubLevelCount(int startOffset)` Returns the number of sub-levels in the id starting at startOffset.
`void` | `incrementLevelId()` Increments the last level id by one.
`boolean` | `isLevelSeparator(int index)`
`int` | `lastLevelOffset()` Find the last level in the id and return its offset.
`void` | `serialize(byte[] data, int offset)`
`void` | `setLevelId(int offset, int levelId)` Set the level id which starts at offset to the given id value.
`int` | `size()` Returns the size of this id by counting the bytes used to encode it.
`boolean` | `startsWith(DLNBase other)` Checks if the current DLN starts with the same bit sequence as other.
`java.lang.String` | `toBitString()`
`static java.lang.String` | `toBitString(byte b)` Returns a string showing the bit representation of the given byte.
`java.lang.String` | `toString()`
`int` | `units()` Returns the number of units currently used to encode the id.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### BITS_PER_UNIT

    public static final int BITS_PER_UNIT

  The default number of bits used per fixed size unit.

  See Also:
    Constant Field Values

### BIT_MASK

    public static final int[] BIT_MASK

Constructor Detail

### DLNBase

    public DLNBase()

### DLNBase

    public DLNBase(DLNBase dln)

### DLNBase

    public DLNBase(int units,
                   byte[] data,
                   int startOffset)

### DLNBase

    public DLNBase(short bitCnt,
                   VariableByteInput is)
            throws java.io.IOException

Method Detail

### setLevelId

    public void setLevelId(int offset,
                           int levelId)

  Set the level id which starts at offset to the given id value.

  Parameters:
    `offset` -
    `levelId` -

### addLevelId

    public void addLevelId(int levelId,
                           boolean isSubLevel)

  Adds a new level to the node id, using levelId as initial value.

  Parameters:
    `levelId` - initial value

### incrementLevelId

    public void incrementLevelId()

  Increments the last level id by one.

### getLevelId

    public int getLevelId(int startBit)

  Returns the id starting at offset.

  Parameters:
    `startBit` -
  Returns:
    the level id

### units

    public int units()

  Returns the number of units currently used to encode the id. The size of a single unit is given by `BITS_PER_UNIT`.

  Returns:
    the number of units

### size

    public int size()

  Returns the size of this id by counting the bytes used to encode it.

  Returns:
    the size in bytes

### isLevelSeparator

    public boolean isLevelSeparator(int index)

### getLevelCount

    public int getLevelCount(int startOffset)

  Returns the number of level in this id, which corresponds to the depth at which the node occurs within the node tree.

  Returns:
    the number of levels in this id

### getSubLevelCount

    public int getSubLevelCount(int startOffset)

  Returns the number of sub-levels in the id starting at startOffset. This is required to determine where a node can be inserted.

  Parameters:
    `startOffset` -
  Returns:
    number of sub-levels

### getLevelIds

    public int[] getLevelIds()

  Return all level ids converted to int.

  Returns:
    all level ids in this node id.

### lastLevelOffset

    public int lastLevelOffset()

  Find the last level in the id and return its offset.

  Returns:
    start-offset of the last level id.

### serialize

    public void serialize(byte[] data,
                          int offset)

### getLengthInBytes

    public static int getLengthInBytes(int units,
                                       byte[] data,
                                       int startOffset)

### equals

    public boolean equals(DLNBase other)

### compareBits

    public int compareBits(DLNBase other,
                           int bitCount)

### startsWith

    public boolean startsWith(DLNBase other)

  Checks if the current DLN starts with the same bit sequence as other. This is used to test ancestor-descendant relationships.

  Parameters:
    `other` -

### debug

    public java.lang.String debug()

### toString

    public java.lang.String toString()

### toBitString

    public java.lang.String toBitString()

### toBitString

    public static final java.lang.String toBitString(byte b)

  Returns a string showing the bit representation of the given byte.

  Parameters:
    `b` - the byte to display
  Returns:
    string representation

Overview | Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) Wolfgang Meier. All rights reserved.