public class HTreeUtil extends Object
HTree
.Constructor and Description |
---|
HTreeUtil() |
Modifier and Type | Method and Description |
---|---|
static int |
getBuddyOffset(int hashBits,
int globalDepth,
int localDepth)
Find the offset of the buddy hash table or buddy bucket in the child.
|
static int |
getLocalDepth(int addressBits,
int globalDepth,
int npointers)
Return the local depth of a child page having npointers to that
page in the parent node.
|
static int |
getSlotsOnPage(int globalDepth,
int localDepth)
Return the #of entries in the address map for a page having the given
local depth.
|
static boolean |
isPowerOf2(int v)
Return
true if the argument is a power of TWO (2). |
public static boolean isPowerOf2(int v)
true
if the argument is a power of TWO (2).v
- The argument.true
if the argument is a power of TWO (2).public static int getSlotsOnPage(int globalDepth, int localDepth)
2^(globalHashBits - localHashBits)
. The
following table shows the relationship between the global hash bits (gb),
the local hash bits (lb) for a page, and the #of directory entries for
that page (nentries).
gb lb nentries 1 0 2 1 1 1 2 0 4 2 1 2 2 2 1 3 0 8 3 1 4 3 2 2 3 3 1 4 0 16 4 1 8 4 2 4 4 3 2 4 4 1
globalDepth
- The global depth of the parent.localDepth
- The local depth of the child.IllegalArgumentException
- if either argument is less than ZERO (0).IllegalArgumentException
- if localHashBits is greater than
globalHashBits.public static int getLocalDepth(int addressBits, int globalDepth, int npointers)
2^(n-i) = npointers
where n is the global depth of
the parent and i is the local depth of the child. The value of
i is the MSB of (npointers / (2^n))
. That equation
always evaluates to a power of two since npointers is a power of two. The
MSB is the index of the highest (and only) ONE (1) bit in the result for
that equation.addressBits
- The #of address bits for the hash tree. This is set when the
tree is configured and is immutable. addressBits is not
required for the computation, but is used to validate the
other arguments.globalDepth
- The global depth of the parent node.npointers
- The #of pointers to that child in the parent node. All of
those pointers will be within a single buddy hash table in the
parent. The maximum value for npointers is
2^globalDepth
for a given globalDepth.
(The maximum value of globalDepth is the configured
value of addressBits for the hash tree.)IllegalArgumentException
- if addressBits is LT ONE (1).IllegalArgumentException
- if globalDepth is LT ZERO (0).IllegalArgumentException
- if globalDepth is GT 2^addressBits
.IllegalArgumentException
- if npointers is LT ONE (1).IllegalArgumentException
- if npointers is greater than
2^globalDepth
.IllegalArgumentException
- if npointers is not a power of 2.public static int getBuddyOffset(int hashBits, int globalDepth, int localDepth)
hashBits
- The relevant bits of the hash code used to lookup the child
within the parent.globalDepth
- The global depth of the parent.localDepth
- The local depth of the child page within the parent.IllegalArgumentException
- if the globalDepth is negative.IllegalArgumentException
- if the localDepth is greater than the
globalDepth.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.