Skip to content

Commit 13e38c3

Browse files
committed
Use Collection instead of List, use common code path
1 parent 48514d5 commit 13e38c3

2 files changed

Lines changed: 18 additions & 22 deletions

File tree

src/main/org/firebirdsql/management/FBStatisticsManager.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020

2121
import java.sql.Connection;
2222
import java.sql.SQLException;
23-
import java.util.List;
23+
import java.util.Collection;
2424

2525
import static org.firebirdsql.gds.ISCConstants.*;
2626
import static org.firebirdsql.gds.VaxEncoding.iscVaxInteger2;
2727
import static org.firebirdsql.gds.VaxEncoding.iscVaxLong;
2828

2929
/**
30-
* The <code>FBStatisticsManager</code> class is responsible for replicating the functionality of
31-
* the <code>gstat</code> command-line tool.
30+
* The {@code FBStatisticsManager} class is responsible for replicating the functionality of
31+
* the {@code gstat} command-line tool.
3232
* <p>
3333
* This functionality includes:
3434
* <ul>
@@ -49,16 +49,13 @@ public class FBStatisticsManager extends FBServiceManager implements StatisticsM
4949
RECORD_VERSION_STATISTICS;
5050

5151
/**
52-
* Create a new instance of <code>FBMaintenanceManager</code> based on
53-
* the default GDSType.
52+
* Create a new instance of {@code FBMaintenanceManager} based on the default GDSType.
5453
*/
5554
public FBStatisticsManager() {
56-
super();
5755
}
5856

5957
/**
60-
* Create a new instance of <code>FBMaintenanceManager</code> based on
61-
* a given GDSType.
58+
* Create a new instance of {@code FBMaintenanceManager} based on a given GDSType.
6259
*
6360
* @param gdsType
6461
* type must be PURE_JAVA, EMBEDDED, or NATIVE
@@ -69,8 +66,7 @@ public FBStatisticsManager(String gdsType) {
6966
}
7067

7168
/**
72-
* Create a new instance of <code>FBMaintenanceManager</code> based on
73-
* a given GDSType.
69+
* Create a new instance of {@code FBMaintenanceManager} based on a given GDSType.
7470
*
7571
* @param gdsType
7672
* The GDS implementation type to use
@@ -107,19 +103,18 @@ public void getDatabaseStatistics(int options) throws SQLException {
107103
}
108104

109105
@Override
110-
public void getTableStatistics(List<String> schemas, List<String> tableNames) throws SQLException {
106+
public void getTableStatistics(Collection<String> schemas, Collection<String> tableNames) throws SQLException {
111107
try (FbService service = attachServiceManager()) {
112108
ServiceRequestBuffer srb;
113109
GDSServerVersion serverVersion = service.getServerVersion();
114-
if (serverVersion.isEqualOrAbove(3)) {
115-
srb = createStatsSRB(service, 0);
110+
if (serverVersion.isEqualOrAbove(3) || tableNames.isEmpty()) {
111+
srb = createDefaultStatsSRB(service);
116112
if (serverVersion.isEqualOrAbove(6)) {
117113
schemas.forEach(schema -> srb.addArgument(isc_spb_sts_schema, schema));
118114
}
119115
tableNames.forEach(tableName -> srb.addArgument(isc_spb_sts_table, tableName));
120-
} else if (tableNames.isEmpty()) {
121-
srb = createStatsSRB(service, 0);
122116
} else {
117+
// Handling of table list is different on older (unsupported) Firebird versions
123118
srb = createStatsSRB(service, isc_spb_sts_table);
124119
srb.addArgument(SpbItems.isc_spb_command_line, String.join(" ", tableNames));
125120
}

src/main/org/firebirdsql/management/StatisticsManager.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import java.sql.SQLException;
1010
import java.util.Arrays;
11+
import java.util.Collection;
1112
import java.util.List;
1213

1314
/**
@@ -114,15 +115,15 @@ public interface StatisticsManager extends ServiceManager {
114115
/**
115116
* Get the table statistics.
116117
* <p>
117-
* For a more detailed description, see {@link #getTableStatistics(List, List)}.
118+
* For a more detailed description, see {@link #getTableStatistics(Collection, Collection)}.
118119
* </p>
119120
*
120121
* @param tableNames
121122
* table names to analyze
122123
* @throws SQLException
123124
* if something went wrong
124-
* @see #getTableStatistics(List)
125-
* @see #getTableStatistics(List, List)
125+
* @see #getTableStatistics(Collection)
126+
* @see #getTableStatistics(Collection, Collection)
126127
*/
127128
default void getTableStatistics(String... tableNames) throws SQLException {
128129
getTableStatistics(Arrays.asList(tableNames));
@@ -131,17 +132,17 @@ default void getTableStatistics(String... tableNames) throws SQLException {
131132
/**
132133
* Get the table statistics.
133134
* <p>
134-
* For a more detailed description, see {@link #getTableStatistics(List, List)}.
135+
* For a more detailed description, see {@link #getTableStatistics(Collection, Collection)}.
135136
* </p>
136137
*
137138
* @param tableNames
138139
* table names to analyze
139140
* @throws SQLException
140141
* if something went wrong
141-
* @see #getTableStatistics(List, List)
142+
* @see #getTableStatistics(Collection, Collection)
142143
* @since 7
143144
*/
144-
default void getTableStatistics(List<String> tableNames) throws SQLException {
145+
default void getTableStatistics(Collection<String> tableNames) throws SQLException {
145146
getTableStatistics(List.of(), tableNames);
146147
}
147148

@@ -174,7 +175,7 @@ default void getTableStatistics(List<String> tableNames) throws SQLException {
174175
* found)
175176
* @since 7
176177
*/
177-
void getTableStatistics(List<String> schemaNames, List<String> tableNames) throws SQLException;
178+
void getTableStatistics(Collection<String> schemaNames, Collection<String> tableNames) throws SQLException;
178179

179180
/**
180181
* Get transaction information of the database specified in {@code database}.

0 commit comments

Comments
 (0)