Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0003710: Jdbc Batch bulk data loader
- Loading branch information
1 parent
208106c
commit 8201c38
Showing
9 changed files
with
133 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
symmetric-client/src/main/java/org/jumpmind/symmetric/io/JdbcBatchBulkDatabaseWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.jumpmind.symmetric.io; | ||
|
||
import org.jumpmind.db.platform.IDatabasePlatform; | ||
import org.jumpmind.db.sql.JdbcSqlTemplate; | ||
import org.jumpmind.db.sql.JdbcSqlTransaction; | ||
import org.jumpmind.symmetric.common.ContextConstants; | ||
import org.jumpmind.symmetric.io.data.Batch; | ||
import org.jumpmind.symmetric.io.data.CsvData; | ||
|
||
public class JdbcBatchBulkDatabaseWriter extends AbstractBulkDatabaseWriter { | ||
|
||
public JdbcBatchBulkDatabaseWriter(IDatabasePlatform symmetricPlatform, IDatabasePlatform targetPlatform, String tablePrefix) { | ||
super(symmetricPlatform, targetPlatform, tablePrefix); | ||
} | ||
|
||
@Override | ||
public void start(Batch batch) { | ||
super.start(batch); | ||
if (context.get(ContextConstants.CONTEXT_BULK_WRITER_TO_USE) == null || !context.get(ContextConstants.CONTEXT_BULK_WRITER_TO_USE).equals("default")) { | ||
getTransaction().setInBatchMode(true); | ||
((JdbcSqlTransaction) getTransaction()).setBatchSize(((JdbcSqlTemplate) getPlatform() | ||
.getSqlTemplate()).getSettings().getBatchBulkLoaderSize()); | ||
} | ||
} | ||
|
||
@Override | ||
protected LoadStatus insert(CsvData data) { | ||
LoadStatus loadStatus = super.insert(data); | ||
if (loadStatus == LoadStatus.CONFLICT) { | ||
loadStatus = LoadStatus.SUCCESS; | ||
} | ||
return loadStatus; | ||
} | ||
|
||
@Override | ||
protected LoadStatus update(CsvData data, boolean applyChangesOnly, boolean useConflictDetection) { | ||
LoadStatus loadStatus = super.insert(data); | ||
if (loadStatus == LoadStatus.CONFLICT) { | ||
loadStatus = LoadStatus.SUCCESS; | ||
} | ||
return loadStatus; | ||
} | ||
|
||
@Override | ||
protected void bulkWrite(CsvData data) { | ||
writeDefault(data); | ||
} | ||
|
||
@Override | ||
public void end(Batch batch, boolean inError) { | ||
super.end(batch, inError); | ||
getTransaction().flush(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters