Skip to content

Commit e4b9994

Browse files
committed
Remove extraneous preinit from no-key reads
1 parent ff9b1ff commit e4b9994

8 files changed

Lines changed: 8 additions & 51 deletions

File tree

API/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<parent>
3232
<groupId>org.ohnlp.backbone</groupId>
3333
<artifactId>backbone-parent</artifactId>
34-
<version>3.0.17</version>
34+
<version>3.0.18</version>
3535
</parent>
3636

3737
<artifactId>api</artifactId>

Core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.ohnlp.backbone</groupId>
99
<artifactId>backbone-parent</artifactId>
10-
<version>3.0.17</version>
10+
<version>3.0.18</version>
1111
</parent>
1212

1313
<artifactId>core</artifactId>

Example-Backbone-Configs/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.ohnlp.backbone</groupId>
99
<artifactId>backbone-parent</artifactId>
10-
<version>3.0.17</version>
10+
<version>3.0.18</version>
1111
</parent>
1212

1313
<artifactId>example-backbone-configs</artifactId>

IO/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.ohnlp.backbone</groupId>
99
<artifactId>backbone-parent</artifactId>
10-
<version>3.0.17</version>
10+
<version>3.0.18</version>
1111
</parent>
1212

1313
<groupId>org.ohnlp.backbone.io</groupId>

IO/src/main/java/org/ohnlp/backbone/io/jdbc/JDBCExtract.java

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,8 @@ public class JDBCExtract extends ExtractToOne {
8282
private int idleTimeout = 0;
8383

8484
private JdbcIO.DataSourceConfiguration datasourceConfig;
85-
private long numBatches;
8685
private ComboPooledDataSource initializationDS;
87-
private String[] orderByCols;
8886
private String viewName;
89-
private String orderedQuery;
9087
private Schema schema;
9188
private String keyValueQuery;
9289
private Schema keyValueSchema;
@@ -135,43 +132,7 @@ public void init() throws ComponentInitializationException {
135132
// of batches
136133
String runId = UUID.randomUUID().toString().replaceAll("-", "_");
137134
this.viewName = "backbone_jdbcextract_" + runId;
138-
if (this.identifierCol == null) {
139-
// No identifier column provided so we can only do a full-form sort.
140-
// TODO find a better solution for this
141-
//noinspection SqlResolve
142-
String countQuery = "SELECT COUNT(*) FROM (" + query + ") bckbone_preflight_query_" + runId;
143-
// Find appropriate columns to order by so that pagination results are consistent
144-
this.orderByCols = findPaginationOrderingColumns(this.query);
145-
// Get record count so that we know how many batches are going to be needed
146-
try (Connection conn = initializationDS.getConnection()) {
147-
ResultSet rs = conn.createStatement().executeQuery(countQuery);
148-
rs.next();
149-
int resultCount = rs.getInt(1);
150-
this.numBatches = Math.round(Math.ceil((double) resultCount / this.batchSize));
151-
}
152-
// Normally I would say use Strings.join for the below, but this was causing cross-jvm issues
153-
// so we use the more portable stringbuilder instead...
154-
StringBuilder sB = new StringBuilder();
155-
boolean flag = false;
156-
for (String s : this.orderByCols) {
157-
if (flag) {
158-
sB.append(", ");
159-
}
160-
sB.append(s);
161-
flag = true;
162-
}
163-
this.orderedQuery = "SELECT * FROM (" + this.query + ") " + this.viewName
164-
+ " ORDER BY " + sB.toString() + " ";
165-
// Now we have to add the offset/fetch in the dialect local format..
166-
// Specifically, postgres and MySQL are special in that they do not conform to the
167-
// SQL:2011 standard syntax
168-
if (driver.equals("org.postgresql.Driver") || driver.equals("com.mysql.jdbc.Driver")
169-
|| driver.equals("com.mysql.cj.jdbc.Driver") || driver.equals("org.sqlite.JDBC")) {
170-
this.orderedQuery += "LIMIT " + batchSize + " OFFSET ?";
171-
} else { // This is the SQL:2011 standard definition of an offset...fetch syntax
172-
this.orderedQuery += "OFFSET ? ROWS FETCH NEXT " + batchSize + " ROWS ONLY";
173-
}
174-
} else {
135+
if (this.identifierCol != null) {
175136
this.keyValueQuery = "SELECT DISTINCT " + identifierCol + " FROM (" + query + ") " + viewName;
176137
this.keyValueSchema = getIdentifierColumnsSchema();
177138
}
@@ -201,10 +162,6 @@ public Schema calculateOutputSchema() {
201162
@Override
202163
public PCollection<Row> begin(PBegin input) {
203164
if (this.identifierCol == null) {
204-
List<Integer> offsets = new ArrayList<>();
205-
for (int i = 0; i < numBatches; i++) {
206-
offsets.add(i * batchSize); // Create a sequence of batches at the appropriate offset
207-
}
208165
return input.apply(
209166
"Read from JDBC",
210167
JdbcIO.<Row>read()

Plugin-Manager/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.ohnlp.backbone</groupId>
99
<artifactId>backbone-parent</artifactId>
10-
<version>3.0.17</version>
10+
<version>3.0.18</version>
1111
</parent>
1212

1313
<artifactId>plugin-manager</artifactId>

Transforms/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.ohnlp.backbone</groupId>
99
<artifactId>backbone-parent</artifactId>
10-
<version>3.0.17</version>
10+
<version>3.0.18</version>
1111
</parent>
1212

1313
<groupId>org.ohnlp.backbone.transforms</groupId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.ohnlp.backbone</groupId>
88
<artifactId>backbone-parent</artifactId>
9-
<version>3.0.17</version>
9+
<version>3.0.18</version>
1010

1111

1212
<properties>

0 commit comments

Comments
 (0)