Package dev.roanh.gmark.conjunct.cpq
Class GeneratorCPQ
java.lang.Object
dev.roanh.gmark.conjunct.cpq.GeneratorCPQ
 All Implemented Interfaces:
ConjunctGenerator
Generator for CPQs (Conjunctive Path Queries).

Field Summary
Modifier and TypeFieldDescriptionprivate SchemaGraph
The schema graph to use to generate CPQs.private WorkloadCPQ
The workload specifying what CPQs to generate. 
Constructor Summary
ConstructorDescriptionConstructs a new CPQ generator using the given workload. 
Method Summary
Modifier and TypeMethodDescriptiongenerateConjunct
(SelectivityGraph gSel, SelectivityType start, SelectivityType end, Variable source, Variable target, boolean star) Generates a single conjunct using the given selectivity graph and with the start of the conjunct being the given start selectivity type and the end of the conjunct the given end selectivity type.private static CPQ
generatePlainCPQ
(int ruleApplications, boolean allowId, List<Predicate> labels) Generates a random CPQ created by applying the intersection (conjunction) and concatenation steps from the CPQ grammar the given number of times.static CPQ
generatePlainCPQ
(int ruleApplications, int labels) Generates a random CPQ created by applying the intersection (conjunction) and concatenation steps from the CPQ grammar the given number of times.static CPQ
generatePlainCPQ
(int ruleApplications, List<Predicate> labels) Generates a random CPQ created by applying the intersection (conjunction) and concatenation steps from the CPQ grammar the given number of times.static CPQ
Parses the given CPQ in string form to a CPQ instance.static CPQ
Parses the given CPQ in string form to a CPQ instance.static CPQ
Parses the given CPQ in string form to a CPQ instance.Splits the given string into parts on the given character.

Field Details

gs
The schema graph to use to generate CPQs. 
workload
The workload specifying what CPQs to generate.


Constructor Details

GeneratorCPQ
Constructs a new CPQ generator using the given workload. Parameters:
wl
 The workload specification. See Also:


Method Details

generatePlainCPQ
public static CPQ generatePlainCPQ(int ruleApplications, int labels) throws IllegalArgumentException Generates a random CPQ created by applying the intersection (conjunction) and concatenation steps from the CPQ grammar the given number of times. A set of labels of the given size is automatically generated together with corresponding inverse labels for each label. Three relatively meaningless but technically valid patterns are intentionally never generated: Concatenation with identity.
 Intersection of identity with identity.
 The query consisting of only identity and nothing else.
 Parameters:
ruleApplications
 The number of times the intersection and concatenation steps are allowed to be applied.labels
 The number of distinct labels to use (upper limit). Returns:
 The randomly generated CPQ.
 Throws:
IllegalArgumentException
 When the list of labels is empty. See Also:

generatePlainCPQ
public static CPQ generatePlainCPQ(int ruleApplications, List<Predicate> labels) throws IllegalArgumentException Generates a random CPQ created by applying the intersection (conjunction) and concatenation steps from the CPQ grammar the given number of times. Labels and inverse labels are drawn from the given set of labels. Three relatively meaningless but technically valid patterns are intentionally never generated: Concatenation with identity.
 Intersection of identity with identity.
 The query consisting of only identity and nothing else.
 Parameters:
ruleApplications
 The number of times the intersection and concatenation steps are allowed to be applied.labels
 The set of labels to draw from. Returns:
 The randomly generated CPQ.
 Throws:
IllegalArgumentException
 When the list of labels is empty. See Also:

generatePlainCPQ
Generates a random CPQ created by applying the intersection (conjunction) and concatenation steps from the CPQ grammar the given number of times. Labels and inverse labels are drawn from the given set of labels. Two relatively meaningless but technically valid patterns are intentionally never generated: Concatenation with identity.
 Intersection of identity with identity.
 Parameters:
ruleApplications
 The number of times the intersection and concatenation steps are allowed to be applied.allowId
 Whether the result of this call is allowed to be the identity CPQ.labels
 The set of labels to draw from. Returns:
 The randomly generated CPQ.

parse
Parses the given CPQ in string form to a CPQ instance. The input is assumed to use brackets where possible and to use the 'id
', ''\u25e6'', ''\u2229'' and ''\u207b'' symbols to denote operations. Example input:(0◦(((1◦0) ∩ (1◦1))◦1⁻))
. Parameters:
query
 The CPQ to parse. Returns:
 The parsed CPQ.
 Throws:
IllegalArgumentException
 When the given string is not a valid CPQ. See Also:

parse
public static CPQ parse(String query, char join, char intersect, char inverse) throws IllegalArgumentException Parses the given CPQ in string form to a CPQ instance. Unlikeparse(String)
this subroutine allows custom symbols to be used to input the CPQ. Parameters:
query
 The CPQ to parse.join
 The symbol to use for the join/concatenation operation.intersect
 The symbol to use for the intersection/conjunction operation.inverse
 The symbol to use for the inverse edge label operation. Returns:
 The parsed CPQ.
 Throws:
IllegalArgumentException
 When the given string is not a valid CPQ. See Also:

parse
public static CPQ parse(String query, Map<String, Predicate> labels, char join, char intersect, char inverse) throws IllegalArgumentExceptionParses the given CPQ in string form to a CPQ instance. Unlikeparse(String)
this subroutine allows custom symbols to be used to input the CPQ. Parameters:
query
 The CPQ to parse.labels
 A map with predicates found so far.join
 The symbol to use for the join/concatenation operation.intersect
 The symbol to use for the intersection/conjunction operation.inverse
 The symbol to use for the inverse edge label operation. Returns:
 The parsed CPQ.
 Throws:
IllegalArgumentException
 When the given string is not a valid CPQ.

split
Splits the given string into parts on the given character. The given character will not be returned in any parts and the found parts will be trimmed of leading and trailing whitespace. This method will ignore any regions of the input string that are enclosed in (nested) round brackets. Parameters:
str
 The string to split.symbol
 The character to split on. Returns:
 The input string split on the given character.
 Throws:
IllegalArgumentException
 When brackets are present in the given string, but not balanced properly.

generateConjunct
public Conjunct generateConjunct(SelectivityGraph gSel, SelectivityType start, SelectivityType end, Variable source, Variable target, boolean star) throws GenerationException Description copied from interface:ConjunctGenerator
Generates a single conjunct using the given selectivity graph and with the start of the conjunct being the given start selectivity type and the end of the conjunct the given end selectivity type. Specified by:
generateConjunct
in interfaceConjunctGenerator
 Parameters:
gSel
 The selectivity graph to use (if required).start
 The starting selectivity type of the conjunct to generate.end
 The end selectivity type of the conjunct to generate.source
 The source variable of the conjunct.target
 The target variable of the conjunct.star
 True if the conjunct should have a Kleene star above it. Returns:
 The randomly generated conjunct.
 Throws:
GenerationException
 When some exception occurred that prevented a conjunct from begin generated.
