Package dev.roanh.cpqindex
Class Index.Block
java.lang.Object
dev.roanh.cpqindex.Index.Block
- Enclosing class:
- Index
Representation of a single block in the index containing
the paths, labels and cores of the partition it represents.
-
Field Summary
Modifier and TypeFieldDescriptionprivate Index.Block
The block from the previous layer that the paths in this block were stored at.private Set<CanonForm.CoreHash>
Hashes for the cores in this index block.Blocks from previous layers that were combined to form this layer.private List<dev.roanh.gmark.conjunct.cpq.CPQ>
Explicit core informations for cores stored in this block.private final int
The ID of this block.private final int
The value of k for the index layer this core belongs to.private List<LabelSequence>
A list of all label sequences that map to this block.A list of all paths stored at this block. -
Constructor Summary
ModifierConstructorDescriptionprivate
Block
(int k, List<LabelledPath> slice) Constructs a new index block for the given diameter and with the given paths.private
Block
(DataInputStream in, boolean full, dev.roanh.gmark.util.RangeList<Index.Block> blockMap) Reads a previously saved block from the given input stream. -
Method Summary
Modifier and TypeMethodDescriptionprivate final void
Adds a new core to this index.private final void
addCore
(dev.roanh.gmark.conjunct.cpq.CPQ q, boolean noSave) Adds a new core to this index.private final void
Computes all the CPQ cores for this block.private final void
computeIntersectionCores
(List<dev.roanh.gmark.conjunct.cpq.CPQ> items, int offset, int restricted, int max, List<dev.roanh.gmark.conjunct.cpq.CPQ> set, BitSet selected, BitSet[] conflicts, boolean noSave, boolean id) Computes intersection derived CPQ for this index.final Set<CanonForm.CoreHash>
Gets the hashes of the cores that map to this block.final List<dev.roanh.gmark.conjunct.cpq.CPQ>
getCores()
Gets the cores that map to this block.final int
getId()
Gets the ID of this block.final List<LabelSequence>
Gets the label sequences that map to this block.getPaths()
Gets the paths stored at this block.final boolean
isLoop()
Checks if this block represents a loop, this means that all paths in this block have the same source and target vertex.toString()
private final void
write
(DataOutputStream out, boolean full) Writes this block to the given stream.
-
Field Details
-
id
private final int idThe ID of this block. -
k
private final int kThe value of k for the index layer this core belongs to. -
paths
A list of all paths stored at this block. -
labels
A list of all label sequences that map to this block. This is the same set of label sequences as computed in the original paper on language aware indexing. This list may also be set to null if its computation is not explicitly requested by settingIndex.computeLabels
to true. -
cores
Explicit core informations for cores stored in this block. This list is never restored for an index that was saved and read back and is also cleared after core computation unless saving labels is enabled.- See Also:
-
canonCores
Hashes for the cores in this index block. Explicit forms are optionally stored incores
. -
combinations
Blocks from previous layers that were combined to form this layer. -
ancestor
The block from the previous layer that the paths in this block were stored at.- See Also:
-
-
Constructor Details
-
Block
Constructs a new index block for the given diameter and with the given paths.- Parameters:
k
- The diameter this block is for, corresponds to the index layer.slice
- The paths to store at this block.
-
Block
private Block(DataInputStream in, boolean full, dev.roanh.gmark.util.RangeList<Index.Block> blockMap) throws IOException Reads a previously saved block from the given input stream.- Parameters:
in
- The stream to read from.full
- True if extra information has to be read.blockMap
- A map of already read blocks indexed by ID.- Throws:
IOException
- When an IOException occurs.
-
-
Method Details
-
write
Writes this block to the given stream.- Parameters:
out
- The stream to write to.full
- True to write extended information required to later compute cores.- Throws:
IOException
- When an IOException occurs.
-
getId
public final int getId()Gets the ID of this block. This is equal to the ID of the segments this block was built from.- Returns:
- The ID of this block.
-
getPaths
Gets the paths stored at this block.- Returns:
- The paths for this block.
-
getLabels
Gets the label sequences that map to this block.- Returns:
- The label sequences that map to this block.
This value may be null unless label computation
was explicitly requested via
Index.computeLabels
.
-
getCanonCores
Gets the hashes of the cores that map to this block.- Returns:
- The cores for this block.
This value may be null unless label computation
was explicitly requested via
Index.computeLabels
.
-
getCores
Gets the cores that map to this block.- Returns:
- The cores that map to this block.
This value may be null unless label computation
was explicitly requested via
Index.computeLabels
.
-
isLoop
public final boolean isLoop()Checks if this block represents a loop, this means that all paths in this block have the same source and target vertex.- Returns:
- True if this block represents a loop.
-
addCore
Adds a new core to this index.- Parameters:
canon
- The canonical form of the core to add.noSave
- True if the explicit form of this core does not need to be saved tocores
.
-
addCore
private final void addCore(dev.roanh.gmark.conjunct.cpq.CPQ q, boolean noSave) Adds a new core to this index.- Parameters:
q
- The CPQ to add, the core of this CPQ is always computed first before adding.noSave
- True if the explicit form of this core does not need to be saved tocores
.
-
computeCores
private final void computeCores()Computes all the CPQ cores for this block. -
computeIntersectionCores
private final void computeIntersectionCores(List<dev.roanh.gmark.conjunct.cpq.CPQ> items, int offset, int restricted, int max, List<dev.roanh.gmark.conjunct.cpq.CPQ> set, BitSet selected, BitSet[] conflicts, boolean noSave, boolean id) Computes intersection derived CPQ for this index. All sub sets of the given list of CPQs need to be intersected and added as a potential core.- Parameters:
items
- The list of CPQs to intersect all sub sets of.offset
- The current CPQ in the list of CPQs to pick of skip for the subset currently being constructed.restricted
- End of restricted range of CPQs. At most one CPQ from the range0...restricted
is allowed to to be included in an intersection as this range includes already computed intersections from a previous layer.max
- The maximum index in the list of items to pick, higher indices are not considered.set
- The set of CPQs picked for the current subset.selected
- Bit set indicating by index which CPQs are picked for the current subset.conflicts
- Bit set array indicating which CPQs are subsets of each other and thus would never be a core if intersected.noSave
- Whether explicit cores should be saved tocores
.id
- True if this block is a loop so all computed cores also need to be intersected with identity.
-
toString
-