@@ -106,6 +106,7 @@ public void setReadOnly(final Boolean readOnly) throws DbException {
106
106
@ Override
107
107
public void tupleBatchInsert (final RelationKey relationKey , final Schema schema , final TupleBatch tupleBatch )
108
108
throws DbException {
109
+ LOGGER .debug ("Inserting batch of size {}" , tupleBatch .numTuples ());
109
110
Objects .requireNonNull (jdbcConnection );
110
111
if (jdbcInfo .getDbms ().equals (MyriaConstants .STORAGE_SYSTEM_POSTGRESQL )) {
111
112
// Use the postgres COPY command which is much faster
@@ -118,8 +119,11 @@ public void tupleBatchInsert(final RelationKey relationKey, final Schema schema,
118
119
tw .done ();
119
120
120
121
Reader reader = new InputStreamReader (new ByteArrayInputStream (baos .toByteArray ()));
121
- cpManager .copyIn ("COPY " + relationKey .toString (MyriaConstants .STORAGE_SYSTEM_POSTGRESQL )
122
- + " FROM STDIN WITH CSV" , reader );
122
+ long inserted =
123
+ cpManager .copyIn ("COPY " + relationKey .toString (MyriaConstants .STORAGE_SYSTEM_POSTGRESQL )
124
+ + " FROM STDIN WITH CSV" , reader );
125
+ Preconditions .checkState (inserted == tupleBatch .numTuples (),
126
+ "Error: inserted a batch of size %s but only actually inserted %s rows" , tupleBatch .numTuples (), inserted );
123
127
} catch (final SQLException | IOException e ) {
124
128
LOGGER .error (e .getMessage (), e );
125
129
throw new DbException (e );
@@ -139,6 +143,7 @@ public void tupleBatchInsert(final RelationKey relationKey, final Schema schema,
139
143
throw new DbException (e );
140
144
}
141
145
}
146
+ LOGGER .debug (".. done inserting batch of size {}" , tupleBatch .numTuples ());
142
147
}
143
148
144
149
@ Override
@@ -209,6 +214,7 @@ public void init() throws DbException {
209
214
@ Override
210
215
public void execute (final String ddlCommand ) throws DbException {
211
216
Objects .requireNonNull (jdbcConnection );
217
+ LOGGER .debug ("Executing command {}" , ddlCommand );
212
218
Statement statement ;
213
219
try {
214
220
statement = jdbcConnection .createStatement ();
@@ -549,7 +555,6 @@ private TupleBatch getNextTB() throws SQLException {
549
555
return new TupleBatch (schema , columns , numTuples );
550
556
} else {
551
557
return null ;
552
-
553
558
}
554
559
}
555
560
0 commit comments