Package dev.roanh.gmark.lang.cpq
Class QueryGraphCPQ.OptionSet
java.lang.Object
dev.roanh.gmark.lang.cpq.QueryGraphCPQ.OptionSet
- Enclosing class:
- QueryGraphCPQ
Represents a set of possible mappings for attributes that
were processed in the past, but will not be seen again in
future tree nodes. These mappings are essentially part of
complete homomorphism mappings for the graph, but are not
relevant to the homomorphism finding algorithm anymore.
Furthermore, this set automatically filters any elements
that are added, keeping only the smallest candidates.
Note that since the added elements represent attributes
that are never seen again we are free to map them in any
way we like without affecting the correct of the of the
algorithm, so we will only keep those candidates that map
to the fewest distinct targets. The row essentially tracks
all the still relevant attributes, while past attributes
are tracked by this option set.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprivate
Constructs a new empty option set for the given row. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Adds a new attribute mapping to this option set.private void
addAll
(BitSet prefix, List<QueryGraphCPQ.OptionSet> toAdd) Adds new mappings to the option set as constructed from the given prefix and list of option sets to join with.private void
addAll
(List<QueryGraphCPQ.OptionSet> toAdd, int offset, BitSet workSet) Adds new mappings to the option set as constructed from the given prefix and list of option sets to join with.private void
Adds a new attribute mapping to this option set.toString()
-
Field Details
-
options
All smallest past attribute mappings for this option set. Note that while each candidate consists of only query graph components, these are actually mapping from an attribute to this component. However, we do not actually ever need to use left hand side attribute of the map, so we do not store it. -
base
A bit set with the components in the match for the row this option set belongs to set to true. The row this option set belongs to. -
cost
private int costThe current cost of the lowest cost attribute mappings inoptions
. This cost is the number of distinct mapping targets.
-
-
Constructor Details
-
OptionSet
Constructs a new empty option set for the given row.- Parameters:
row
- The row to create an option set for.- See Also:
-
-
Method Details
-
addAll
Adds new mappings to the option set as constructed from the given prefix and list of option sets to join with. This will attempt to add a new entry for each unique combination of attribute mappings in the given list of option sets, essentially computing a Cartesian product. The given prefix targets are added to every candidate generated in this manner.- Parameters:
prefix
- The prefix mapping targets to add to every candidate encoded as a bit set.toAdd
- The option sets to compute combinations of.
-
addAll
Adds new mappings to the option set as constructed from the given prefix and list of option sets to join with. This will attempt to add a new entry for each unique combination of attribute mappings in the given list of option sets, essentially computing a Cartesian product. The work set indicates the components picked so far and the offset indicates the next option set to pick from.- Parameters:
toAdd
- The option sets to compute combinations of.offset
- The next option set to pick from.workSet
- The current set of picked components encoded as a bit set.
-
addDirect
Adds a new attribute mapping to this option set. However, if this mapping has a higher cost than the current options it is discarded. Conversely, if it has a lower cost all current options are discarded instead. The cost is computed as the number of distinct mapping targets when combined with the mappings at the the row for this option set.- Parameters:
maps
- The new mapping to add (complete with the row mapping targets).- See Also:
-
add
Adds a new attribute mapping to this option set. However, if this mapping has a higher cost than the current options it is discarded. Conversely, if it has a lower cost all current options are discarded instead. The cost is computed as the number of distinct mapping targets when combined with the mappings at the the row for this option set.- Parameters:
maps
- The new mapping to add (without the row mapping targets).
-
toString
-