public class P2JQueryStatistics
extends java.lang.Object
CompoundQuery and RandomAccessQuery support this type
of storing statistics.| Modifier and Type | Class and Description |
|---|---|
private static class |
P2JQueryStatistics.Key
A hashable key comprised of both location information and an FQL string.
|
private static class |
P2JQueryStatistics.Location
Helper class which stores location information regarding the construction of a P2J query.
|
| Modifier and Type | Field and Description |
|---|---|
private static java.util.Map<P2JQuery,P2JQueryStatistics.Location> |
locations
Map that stores the location of queries.
|
private static java.util.Map<P2JQueryStatistics.Key,P2JQueryStatistics> |
statistics
Transient map of query instances to information about where they were constructed.
|
private double |
time
The execution time of this query until this moment.
|
private long |
useCount
Number of times query was executed at this location (across query instances).
|
| Modifier | Constructor and Description |
|---|---|
private |
P2JQueryStatistics()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
private static P2JQueryStatistics.Location |
gatherQueryDetails()
Function that navigates the stack trace, identifies details of a query (such as file name, method name,
line number) and creates a
Location based on those findings. |
static java.lang.String |
getLocationFormattedOutput(P2JQuery query)
Function that returns the location of a query (if one exists), in a ready to be printed format.
|
static P2JQueryStatistics |
getStatistics(P2JQuery query,
java.lang.String fql)
Function that retrieves/creates the statistics of a query.
|
double |
getTime()
Getter for the
time field. |
long |
getUseCount()
Get the number of times the FQL query was executed at this location, across all query
instances constructed at the same location.
|
void |
increaseTime(double time)
Method for increasing the total time of this query by a specified amount.
|
void |
incrementUseCount()
Increment by one the number of times the FQL query was executed at this location, across
all query instances constructed at the same location.
|
private static final java.util.Map<P2JQueryStatistics.Key,P2JQueryStatistics> statistics
private static final java.util.Map<P2JQuery,P2JQueryStatistics.Location> locations
private long useCount
private double time
public static P2JQueryStatistics getStatistics(P2JQuery query, java.lang.String fql)
query - The query in use.fql - The FQL of the query.P2JQueryStatistics denoting the statistics of the given query.public static java.lang.String getLocationFormattedOutput(P2JQuery query)
query - The given query.null if no such
location exists.public long getUseCount()
public void incrementUseCount()
public double getTime()
time field.public void increaseTime(double time)
time - The time that will be added to the total time.private static P2JQueryStatistics.Location gatherQueryDetails()
Location based on those findings.