Class Index.Block

java.lang.Object
dev.roanh.cpqindex.Index.Block
Enclosing class:
Index

public final class Index.Block extends Object
Representation of a single block in the index containing the paths, labels and cores of the partition it represents.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Index.Block
    The block from the previous layer that the paths in this block were stored at.
    Hashes for the cores in this index block.
    private List<BlockPair>
    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.
    A list of all label sequences that map to this block.
    private final List<Pair>
    A list of all paths stored at this block.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    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 Type
    Method
    Description
    private final void
    addCore(CanonForm canon, boolean noSave)
    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.
    Gets the hashes of the cores that map to this block.
    final List<dev.roanh.gmark.conjunct.cpq.CPQ>
    Gets the cores that map to this block.
    final int
    Gets the ID of this block.
    Gets the label sequences that map to this block.
    final List<Pair>
    Gets the paths stored at this block.
    final boolean
    Checks if this block represents a loop, this means that all paths in this block have the same source and target vertex.
     
    private final void
    write(DataOutputStream out, boolean full)
    Writes this block to the given stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • id

      private final int id
      The ID of this block.
    • k

      private final int k
      The value of k for the index layer this core belongs to.
    • paths

      private final List<Pair> paths
      A list of all paths stored at this block.
    • labels

      private List<LabelSequence> 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 setting Index.computeLabels to true.
    • cores

      private List<dev.roanh.gmark.conjunct.cpq.CPQ> 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

      private Set<CanonForm.CoreHash> canonCores
      Hashes for the cores in this index block. Explicit forms are optionally stored in cores.
    • combinations

      private List<BlockPair> combinations
      Blocks from previous layers that were combined to form this layer.
    • ancestor

      private Index.Block ancestor
      The block from the previous layer that the paths in this block were stored at.
      See Also:
  • Constructor Details

    • Block

      private Block(int k, List<LabelledPath> slice)
      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

      private final void write(DataOutputStream out, boolean full) throws IOException
      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

      public final List<Pair> getPaths()
      Gets the paths stored at this block.
      Returns:
      The paths for this block.
    • getLabels

      public final List<LabelSequence> 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

      public final Set<CanonForm.CoreHash> 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

      public final List<dev.roanh.gmark.conjunct.cpq.CPQ> 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

      private final void addCore(CanonForm canon, boolean noSave)
      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 to cores.
    • 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 to cores.
    • 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 range 0...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 to cores.
      id - True if this block is a loop so all computed cores also need to be intersected with identity.
    • toString

      public String toString()
      Overrides:
      toString in class Object