1212import org .variantsync .diffdetective .variation .diff .Projection ;
1313import org .variantsync .diffdetective .variation .diff .Time ;
1414import org .variantsync .diffdetective .variation .diff .view .DiffView ;
15- import org .variantsync .diffdetective .variation .tree .view .query . ArtifactQuery ;
16- import org .variantsync .diffdetective .variation .tree .view .query . FeatureQuery ;
17- import org .variantsync .diffdetective .variation .tree .view .query . Query ;
18- import org .variantsync .diffdetective .variation .tree .view .query . VariantQuery ;
15+ import org .variantsync .diffdetective .variation .tree .view .relevance . Search ;
16+ import org .variantsync .diffdetective .variation .tree .view .relevance . Trace ;
17+ import org .variantsync .diffdetective .variation .tree .view .relevance . Relevance ;
18+ import org .variantsync .diffdetective .variation .tree .view .relevance . Configure ;
1919
2020import java .io .IOException ;
2121import java .util .*;
@@ -40,36 +40,36 @@ public void initializeResults(Analysis analysis) {
4040 csv .append (ViewEvaluation .makeHeader (CSV .DEFAULT_CSV_DELIMITER )).append (StringUtils .LINEBREAK );
4141 }
4242
43- private void runQueryExperiment (Analysis analysis , final DiffTree d , final Query q ) {
43+ private void runRelevanceExperiment (Analysis analysis , final DiffTree d , final Relevance rho ) {
4444 final long preprocessingTime , naiveTime , optimizedTime ;
4545
4646 //Show.diff(d, "D").showAndAwait();
4747
4848 final Clock c = new Clock ();
4949
50- final BiPredicate <Time , Projection > inV = DiffView .computeWhenNodesAreRelevant (d , q );
50+ final BiPredicate <Time , Projection > inV = DiffView .computeWhenNodesAreRelevant (d , rho );
5151
5252 preprocessingTime = c .getPassedMilliseconds ();
5353
5454 // measure naive view generation
5555 try {
5656 c .start ();
57- DiffView .naive (d , q , inV );
57+ DiffView .naive (d , rho , inV );
5858 naiveTime = c .getPassedMilliseconds ();
5959 } catch (IOException | DiffParseException e ) {
6060 throw new RuntimeException (e );
6161 }
6262
6363 // measure optimized view generation
6464 c .start ();
65- final DiffTree view = DiffView .optimized (d , q , inV );
65+ final DiffTree view = DiffView .optimized (d , rho , inV );
6666 optimizedTime = c .getPassedMilliseconds ();
6767
6868 // export results
6969 final ViewEvaluation e = new ViewEvaluation (
7070 analysis .getCurrentCommitDiff ().getAbbreviatedCommitHash (),
7171 analysis .getCurrentPatch ().getFileName (),
72- q ,
72+ rho ,
7373 preprocessingTime + naiveTime ,
7474 preprocessingTime + optimizedTime ,
7575 ViewEvaluation .DiffStatistics .of (d ),
@@ -86,17 +86,17 @@ private void runQueryExperiment(Analysis analysis, final DiffTree d, final Query
8686
8787 @ Override
8888 public boolean analyzeDiffTree (Analysis analysis ) throws Exception {
89- final DiffTree d = analysis .getCurrentDiffTree ();
90- final Collection <Query > queries = generateRandomQueries (d );
89+ final DiffTree d = analysis .getCurrentDiffTree ();
90+ final Collection <Relevance > queries = generateRandomRelevances (d );
9191
92- for (final Query q : queries ) {
93- runQueryExperiment (analysis , d , q );
92+ for (final Relevance r : queries ) {
93+ runRelevanceExperiment (analysis , d , r );
9494 }
9595
9696 return Analysis .Hooks .super .analyzeDiffTree (analysis );
9797 }
9898
99- private List <Query > generateRandomQueries (final DiffTree d ) {
99+ private List <Relevance > generateRandomRelevances (final DiffTree d ) {
100100 final List <Node > deselectedPCs = new ArrayList <>();
101101 final Set <String > features = new HashSet <>();
102102 final Set <String > artifacts = new HashSet <>();
@@ -121,61 +121,61 @@ else if (a.isConditionalAnnotation()) {
121121 features .remove (FixTrueFalse .True .var .toString ());
122122 features .remove (FixTrueFalse .False .var .toString ());
123123
124- final List <Query > queries = new ArrayList <>(3 );
125- addRandomQuery (deselectedPCs , this ::randomVariantQuery , queries );
126- addRandomQuery (features , this ::randomFeatureQuery , queries );
127- addRandomQuery (artifacts , this ::randomArtifactQuery , queries );
124+ final List <Relevance > relevances = new ArrayList <>(3 );
125+ addRandomRelevance (deselectedPCs , this ::randomConfigure , relevances );
126+ addRandomRelevance (features , this ::randomTrace , relevances );
127+ addRandomRelevance (artifacts , this ::randomSearch , relevances );
128128
129129 // For debugging:
130130// addAll(deselectedPCs, this::allVariantQueries, queries);
131131// addAll(features, this::allFeatureQueries, queries);
132132// addAll(artifacts, this::allArtifactQueries, queries);
133133
134- return queries ;
134+ return relevances ;
135135 }
136136
137- private static <QueryData , QueryCandidates extends Collection <QueryData >> void addRandomQuery (
138- QueryCandidates source ,
139- Function <QueryCandidates , Query > pick ,
140- Collection <Query > target
137+ private static <RelevanceParams , RelevanceCandidates extends Collection <RelevanceParams >> void addRandomRelevance (
138+ RelevanceCandidates source ,
139+ Function <RelevanceCandidates , Relevance > pick ,
140+ Collection <Relevance > target
141141 ) {
142142 if (!source .isEmpty ()) {
143- final Query e = pick .apply (source );
143+ final Relevance e = pick .apply (source );
144144 if (e != null ) {
145145 target .add (e );
146146 }
147147 }
148148 }
149149
150- private static <QueryData , QueryCandidates extends Collection <? extends QueryData >> void addAll (
151- QueryCandidates source ,
152- Function <? super QueryCandidates , ? extends Collection <? extends Query >> prepare ,
153- Collection <Query > target
150+ private static <RelevanceParams , RelevanceCandidates extends Collection <? extends RelevanceParams >> void addAll (
151+ RelevanceCandidates source ,
152+ Function <? super RelevanceCandidates , ? extends Collection <? extends Relevance >> prepare ,
153+ Collection <Relevance > target
154154 ) {
155155 if (!source .isEmpty ()) {
156156 target .addAll (prepare .apply (source ));
157157 }
158158 }
159159
160- private List <VariantQuery > allVariantQueries (final List <Node > deselectedPCs ) {
160+ private List <Configure > allConfigureRelevances (final List <Node > deselectedPCs ) {
161161 /*
162162 * Select a random satisfiable configuration (i.e., a non-false config).
163163 * Unsatisfiable configs cause empty views which
164164 * (1) we suspect to be rather useless and thus unused in practice
165165 * (2) cause a crash in view generation because everything is removed, even the mandatory root.
166166 */
167- final List <VariantQuery > all = new ArrayList <>();
167+ final List <Configure > all = new ArrayList <>();
168168 for (final Node deselectedPC : deselectedPCs ) {
169169 final FixTrueFalse .Formula p = FixTrueFalse .EliminateTrueAndFalseInplace (deselectedPC );
170170 if (SAT .isSatisfiable (p )) {
171- all .add (new VariantQuery (p ));
171+ all .add (new Configure (p ));
172172 }
173173 }
174174
175175 return all ;
176176 }
177177
178- private Query randomVariantQuery (final List <Node > deselectedPCs ) {
178+ private Configure randomConfigure (final List <Node > deselectedPCs ) {
179179 /*
180180 Do we need this?
181181 I think for our feasibility study, we can ignore this.
@@ -207,33 +207,33 @@ private Query randomVariantQuery(final List<Node> deselectedPCs) {
207207 return null ;
208208 }
209209
210- return new VariantQuery (winner );
210+ return new Configure (winner );
211211 }
212212
213- private List <FeatureQuery > allFeatureQueries (final Set <String > features ) {
214- return features .stream ().map (FeatureQuery ::new ).toList ();
213+ private List <Trace > allTraceRelevances (final Set <String > features ) {
214+ return features .stream ().map (Trace ::new ).toList ();
215215 }
216216
217- private Query randomFeatureQuery (final Set <String > features ) {
217+ private Trace randomTrace (final Set <String > features ) {
218218 /*
219- Pick a random feature for our query .
219+ Pick a random feature for our relevance .
220220 Since we actually just need a single random value, we could also just pick the first element
221221 but I don't know if there is any hidden sorting within the set that would bias this choice.
222222 */
223- return new FeatureQuery (CollectionUtils .getRandomElement (random , features ));
223+ return new Trace (CollectionUtils .getRandomElement (random , features ));
224224 }
225225
226- private List <ArtifactQuery > allArtifactQueries (final Set <String > artifacts ) {
227- return artifacts .stream ().map (ArtifactQuery ::new ).toList ();
226+ private List <Search > allSearchRelevances (final Set <String > artifacts ) {
227+ return artifacts .stream ().map (Search ::new ).toList ();
228228 }
229229
230- private Query randomArtifactQuery (final Set <String > artifacts ) {
230+ private Search randomSearch (final Set <String > artifacts ) {
231231 /*
232- Pick a random artifact for our query .
232+ Pick a random artifact for our relevance .
233233 Since we actually just need a single random value, we could also just pick the first element
234234 but I don't know if there is any hidden sorting within the set that would bias this choice.
235235 */
236- return new ArtifactQuery (CollectionUtils .getRandomElement (random , artifacts ));
236+ return new Search (CollectionUtils .getRandomElement (random , artifacts ));
237237 }
238238
239239 @ Override
0 commit comments