Class ViewAnalysis
java.lang.Object
org.variantsync.diffdetective.experiments.views.ViewAnalysis
- All Implemented Interfaces:
Analysis.Hooks
Implementation of the feasibility study from Section 6 of our paper
Views on Edits to Variational Software
at SPLC'23.
This Analysis is run on a batch of commits of a single repository.
For the whole feasibility study, multiple analysis are run in parallel, each
processing a part of a repositories history.
-
Field Summary
Modifier and TypeFieldDescriptionprivate StringBuilder
StringBuilder that is used to iteratively create a csv file with this analysis' results.private Random
Random instance to generate random numbers.static final String
File extension for csv files created by this analysis. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static <RelevanceParams,
RelevanceCandidates extends Collection<? extends RelevanceParams>>
voidaddAll
(RelevanceCandidates source, Function<? super RelevanceCandidates, ? extends Collection<? extends Relevance>> prepare, Collection<Relevance> target) This is a convenience method for creating relevance predicates from their parameters.private static <RelevanceParams,
RelevanceCandidates extends Collection<RelevanceParams>>
voidaddRandomRelevance
(RelevanceCandidates source, Function<RelevanceCandidates, Relevance> pick, Collection<Relevance> target) This is a convenience method for creating a random relevance predicate from a collection of potential parameterisations.allConfigureRelevances
(List<org.prop4j.Node> deselectedPCs) Generates allConfigure
relevance predicates that can be generated from the given list of deselected presence conditions.allSearchRelevances
(Set<String> artifacts) Generates aSearch
relevance predicate for each artifact in the given set.allTraceRelevances
(Set<String> features) Generates aTrace
relevance predicate for each feature in the given set of feature names.boolean
analyzeVariationDiff
(Analysis analysis) Runs the feasibility study on the current variation diff.void
Writes the results of this analysis to disk as CSV file.Generates random relevance predicates for creating random views on the given variation diff d, as explained in Section 6.1 in our paper.void
initializeResults
(Analysis analysis) Initialization hook forAnalysis.getResult()
.private Configure
randomConfigure
(List<org.prop4j.Node> deselectedPCs) Creates a randomConfigure
relevance predicate from the given list of deselected presence conditions.private Search
randomSearch
(Set<String> artifacts) Creates a randomSearch
relevance predicate from the given set of artifacts.private Trace
randomTrace
(Set<String> features) Creates a randomTrace
relevance predicate from the given set of feature names.private void
runRelevanceExperiment
(Analysis analysis, VariationDiff<DiffLinesLabel> d, Relevance rho) Benchmark for view generation on the given variation diff with the given relevance.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.variantsync.diffdetective.analysis.Analysis.Hooks
beginBatch, beginCommit, beginPatch, endCommit, endPatch, onFailedCommit, onFailedParse, onParsedCommit
-
Field Details
-
VIEW_CSV_EXTENSION
File extension for csv files created by this analysis.- See Also:
-
csv
StringBuilder that is used to iteratively create a csv file with this analysis' results. -
random
Random instance to generate random numbers. Used to generate random relevance predicates.
-
-
Constructor Details
-
ViewAnalysis
public ViewAnalysis()
-
-
Method Details
-
initializeResults
Description copied from interface:Analysis.Hooks
Initialization hook forAnalysis.getResult()
. All result types should be appended with a neutral value usingAnalysis.append(org.variantsync.diffdetective.analysis.AnalysisResult.ResultKey<T>, T)
. No other side effects should be performed during this methods as it might be called an arbitrary amount of times.- Specified by:
initializeResults
in interfaceAnalysis.Hooks
-
runRelevanceExperiment
private void runRelevanceExperiment(Analysis analysis, VariationDiff<DiffLinesLabel> d, Relevance rho) Benchmark for view generation on the given variation diff with the given relevance. This method generates a view once with each algorithm: - once with thenaive algorithm
view_naive (Equation 8 from our paper), - and once with theoptimized algorithm
view_smart (Equation 10 in our paper). This method measures both algorithms runtimes and stores the runtimes and metadata in terms of aViewEvaluation
in this objectscsv
field.- Parameters:
analysis
- The current instance of the analysis that is run. Used to access metadata of the current commit that is processed.d
- The variation diff to benchmark view generation on.rho
- A relevance predicate that determines which nodes should be contained in the view.
-
analyzeVariationDiff
Runs the feasibility study on the current variation diff. Creates random relevance predicates as explained in Section 6 of our paper. Then runsrunRelevanceExperiment(Analysis, VariationDiff, Relevance)
for each relevance on the current variation diff.- Specified by:
analyzeVariationDiff
in interfaceAnalysis.Hooks
- Parameters:
analysis
- The current instance of the analysis that is run. Used to access metadata of the current commit that is processed.- Returns:
Analysis.Hooks.analyzeVariationDiff(Analysis)
- Throws:
Exception
-
generateRandomRelevances
Generates random relevance predicates for creating random views on the given variation diff d, as explained in Section 6.1 in our paper. If possible, this method will generate one relevance of each type ofConfigure
,Trace
, andSearch
.- Parameters:
d
- The variation diff to generate relevance predicates for.- Returns:
- A list of three random relevance predicates.
-
addRandomRelevance
private static <RelevanceParams,RelevanceCandidates extends Collection<RelevanceParams>> void addRandomRelevance(RelevanceCandidates source, Function<RelevanceCandidates, Relevance> pick, Collection<Relevance> target) This is a convenience method for creating a random relevance predicate from a collection of potential parameterisations.If the given collection
source
of parameters for relevance predicates is not empty, this method picks a random parameterization and creates a relevance predicate from it. The created predicate is added to the given target collection.- Type Parameters:
RelevanceParams
- The type of the parameters for the relevance predicates.RelevanceCandidates
- The type of collection of the parameters.- Parameters:
source
- A potentially empty collection of arguments for relevance predicates.pick
- A function that picks a parameterisation at random and creates a relevance predicate from it.target
- A collection to which the randomly created relevance predicate will be added to.
-
addAll
private static <RelevanceParams,RelevanceCandidates extends Collection<? extends RelevanceParams>> void addAll(RelevanceCandidates source, Function<? super RelevanceCandidates, ? extends Collection<? extends Relevance>> prepare, Collection<Relevance> target) This is a convenience method for creating relevance predicates from their parameters.If the given collection of parameters for relevance predicates is not empty, this method generates corresponding relevance predicates for all those predicates and adds them to the given target collection.
- Type Parameters:
RelevanceParams
- The type of the parameters for the relevance predicates.RelevanceCandidates
- The type of collection of the parameters.- Parameters:
source
- A potentially empty collection of arguments for relevance predicates.prepare
- A function that creates a relevance predicate from suitable arguments.target
- A collection to which all relevance predicates will be added to.
-
allConfigureRelevances
Generates allConfigure
relevance predicates that can be generated from the given list of deselected presence conditions. The returned list of predicates is complete: For every (partial) variant of the variation tree or diff the deselected presence conditions come from, a corresponding relevance predicate is within the returned list.- Parameters:
deselectedPCs
- A list of negations of all presence conditions that occur in a variation tree or diff.- Returns:
- A complete list of
Configure
predicates.
-
randomConfigure
Creates a randomConfigure
relevance predicate from the given list of deselected presence conditions. This method picks a random satisfiable formula from the given list and returns it as a relevance predicate for configuration.- Returns:
- A random, satisfiable
Configure
predicate, created from the given presence conditions. Null if the given list is empty or if it does not contain a satisfiable formula.
-
allTraceRelevances
Generates aTrace
relevance predicate for each feature in the given set of feature names.- Parameters:
features
- A set of feature names to trace.- Returns:
- A
Trace
predicate for each feature name in the given set.
-
randomTrace
Creates a randomTrace
relevance predicate from the given set of feature names.- Parameters:
features
- A set of feature names.- Returns:
- A
Trace
predicate for a feature name randomly picked from the given set.
-
allSearchRelevances
Generates aSearch
relevance predicate for each artifact in the given set.- Parameters:
artifacts
- A list of text-based artifacts.- Returns:
- A
Search
predicate for each artifact.
-
randomSearch
Creates a randomSearch
relevance predicate from the given set of artifacts.- Parameters:
artifacts
- A set of text-based artifacts (e.g., lines of code).- Returns:
- A
Search
predicate for an artifact randomly picked from the given set.
-
endBatch
Writes the results of this analysis to disk as CSV file.- Specified by:
endBatch
in interfaceAnalysis.Hooks
- Parameters:
analysis
- The current state of the analysis.- Throws:
IOException
- When the file cannot be created or written.
-