Package dev.roanh.gmark.lang.cpq
Class QueryGraphCPQ.Row
java.lang.Object
dev.roanh.gmark.lang.cpq.QueryGraphCPQ.Row
- Enclosing class:
- QueryGraphCPQ
A row instance represents a single potential homomorphism mapping
for a partial map. A row also tracks information about past attributes
that are required to construct a complete homomorphism mapping.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprivate BitSet
The best (smallest) complete mapping as represented by this row.private int
The cost of the smallest complete mapping for this row.private QueryGraphCPQ.QueryGraphComponent[]
The targets that this row maps the attributes from the partial map to.private List<QueryGraphCPQ.OptionSet>
A list of option sets that complete the entire homomorphism mapping when combined with thematch
for this row.private int
Current write index inmatch
, this is the next position that a query graph component will be written to byadd(QueryGraphComponent)
. -
Constructor Summary
ModifierConstructorDescriptionprivate
Row
(int size) Constructs a new row with space for the given number of mapping targets. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new match component to this row.private void
computeBestUsage
(int size) Computes the best usage for this row.private void
computeBestUsage
(int offset, BitSet workSet, int size) Computes the best usage for this row.get
(int idx) Gets the match component at the given index.toString()
private void
updateBest
(BitSet used) Updates best mapping candidate for this row with the given candidate if this candidate has a lower cost than the current best candidate.
-
Field Details
-
match
The targets that this row maps the attributes from the partial map to. -
other
A list of option sets that complete the entire homomorphism mapping when combined with thematch
for this row. When constructing the complete mapping exactly one option from each option set has to be used. -
write
private int writeCurrent write index inmatch
, this is the next position that a query graph component will be written to byadd(QueryGraphComponent)
. -
best
The best (smallest) complete mapping as represented by this row. This bitset can be seen as a map fromQueryGraphCPQ.QueryGraphComponent.getID()
to a boolean, where true means the component was used in the mapping. The cost of this mapping is given bycost
and both are computed bycomputeBestUsage(int)
.- See Also:
-
cost
private int costThe cost of the smallest complete mapping for this row. This value is computed bycomputeBestUsage(int)
and isInteger.MAX_VALUE
before that.- See Also:
-
-
Constructor Details
-
Row
private Row(int size) Constructs a new row with space for the given number of mapping targets.- Parameters:
size
- The number of mapping targets to allocate space for.
-
-
Method Details
-
computeBestUsage
private void computeBestUsage(int size) Computes the best usage for this row. This is the selection of options from the option sets inother
that together withmatch
results in the mapping with the smallest number of distinct targets. For this computation exactly one option from each option set has to be used. The result of this computation is stored in #best and its cost in #cost.- Parameters:
size
- The size of the entire original query graph as the combined count of vertices and edges.
-
computeBestUsage
Computes the best usage for this row. This is the selection of options from the option sets inother
that together withmatch
results in the mapping with the smallest number of distinct targets. For this computation exactly one option from each option set has to be used. The result of this computation is stored in #best and its cost in #cost.- Parameters:
offset
- The current option set to pick from.workSet
- The set of picked mappings so far encoded as a bit set with bits set based on component IDs.size
- The size of the entire original query graph as the combined count of vertices and edges.
-
updateBest
Updates best mapping candidate for this row with the given candidate if this candidate has a lower cost than the current best candidate. The cost is evaluated as the total number of distinct mapping targets.- Parameters:
used
- A set of picked mappings that together form the complete candidate encoded as a bit set with bits set based on component IDs.
-
get
Gets the match component at the given index.- Parameters:
idx
- The index to get.- Returns:
- The match component at the given index.
-
add
Adds a new match component to this row.- Parameters:
comp
- The component to append.
-
toString
-