use of com.torodb.backend.InternalField in project torodb by torodb.
the class PostgreSqlWriteInterface method copyInsertDocPartData.
private void copyInsertDocPartData(PGConnection connection, String schemaName, DocPartData docPartData) throws SQLException, IOException {
final int maxBatchSize = 1024;
final CopyManager copyManager = connection.getCopyAPI();
final MetaDocPart metaDocPart = docPartData.getMetaDocPart();
Collection<InternalField<?>> internalFields = postgreSqlMetaDataReadInterface.getInternalFields(metaDocPart);
final StringBuilder sb = new StringBuilder(65536);
final String copyStatement = getCopyInsertDocPartDataStatement(schemaName, docPartData, metaDocPart, internalFields);
Iterator<DocPartRow> docPartRowIterator = docPartData.iterator();
int docCounter = 0;
while (docPartRowIterator.hasNext()) {
DocPartRow tableRow = docPartRowIterator.next();
docCounter++;
addValuesToCopy(sb, tableRow, internalFields);
assert sb.length() != 0;
if (docCounter % maxBatchSize == 0 || !docPartRowIterator.hasNext()) {
executeCopy(copyManager, copyStatement, sb);
sb.setLength(0);
}
}
}
Aggregations