001package gudusoft.gsqlparser.resolver2.model;
002
003/**
004 * Statistics about resolution results.
005 * Used for monitoring and reporting resolution quality.
006 */
007public class ResolutionStatistics {
008    private final int totalReferences;
009    private final int exactMatches;
010    private final int ambiguousMatches;
011    private final int unresolvedReferences;
012    private final int referencedTableCount;
013
014    public ResolutionStatistics(int total, int exact, int ambiguous,
015                               int unresolved, int tableCount) {
016        this.totalReferences = total;
017        this.exactMatches = exact;
018        this.ambiguousMatches = ambiguous;
019        this.unresolvedReferences = unresolved;
020        this.referencedTableCount = tableCount;
021    }
022
023    public int getTotalReferences() {
024        return totalReferences;
025    }
026
027    public int getExactMatches() {
028        return exactMatches;
029    }
030
031    public int getAmbiguousMatches() {
032        return ambiguousMatches;
033    }
034
035    public int getUnresolvedReferences() {
036        return unresolvedReferences;
037    }
038
039    public int getReferencedTableCount() {
040        return referencedTableCount;
041    }
042
043    /**
044     * Calculate resolution success rate (exact matches / total)
045     */
046    public double getSuccessRate() {
047        return totalReferences > 0
048            ? (double) exactMatches / totalReferences
049            : 0.0;
050    }
051
052    /**
053     * Calculate resolution coverage (resolved / total)
054     * Includes both exact and ambiguous matches
055     */
056    public double getCoverageRate() {
057        return totalReferences > 0
058            ? (double) (exactMatches + ambiguousMatches) / totalReferences
059            : 0.0;
060    }
061
062    @Override
063    public String toString() {
064        return String.format(
065            "Total: %d, Exact: %d (%.1f%%), Ambiguous: %d, Unresolved: %d, Tables: %d",
066            totalReferences,
067            exactMatches,
068            getSuccessRate() * 100,
069            ambiguousMatches,
070            unresolvedReferences,
071            referencedTableCount
072        );
073    }
074}