Skip to content

Commit

Permalink
Changed the DataLoaderService API to get IDataLoaderStatistics back a…
Browse files Browse the repository at this point in the history
…fter a load.
  • Loading branch information
chenson42 committed Jun 23, 2008
1 parent 72e2a23 commit 1cbf542
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
Expand Up @@ -119,8 +119,8 @@ public void load() throws IOException {
BinaryEncoding encoding = BinaryEncoding.NONE;
while (csvReader.readRecord()) {
String[] tokens = csvReader.getValues();
if (tokens != null && tokens.length > 0 && tokens[0] != null) {
stats.incrementLineCount();
stats.incrementLineCount();
if (tokens != null && tokens.length > 0 && tokens[0] != null) {
stats.incrementByteCount(csvReader.getRawRecord().length());

if (tokens[0].equals(CsvConstants.INSERT)) {
Expand Down
Expand Up @@ -31,6 +31,7 @@
import org.jumpmind.symmetric.load.IColumnFilter;
import org.jumpmind.symmetric.load.IDataLoader;
import org.jumpmind.symmetric.load.IDataLoaderFilter;
import org.jumpmind.symmetric.load.IDataLoaderStatistics;
import org.jumpmind.symmetric.load.csv.CsvLoader;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.transport.IIncomingTransport;
Expand Down Expand Up @@ -58,7 +59,7 @@ public interface IDataLoaderService {
* @throws IOException
*/
@Transactional
public void loadDataBatch(String batchData) throws IOException;
public IDataLoaderStatistics loadDataBatch(String batchData) throws IOException;

public void addDataLoaderFilter(IDataLoaderFilter filter);

Expand Down
Expand Up @@ -46,6 +46,7 @@
import org.jumpmind.symmetric.load.IColumnFilter;
import org.jumpmind.symmetric.load.IDataLoader;
import org.jumpmind.symmetric.load.IDataLoaderFilter;
import org.jumpmind.symmetric.load.IDataLoaderStatistics;
import org.jumpmind.symmetric.model.IncomingBatch;
import org.jumpmind.symmetric.model.IncomingBatchHistory;
import org.jumpmind.symmetric.model.Node;
Expand Down Expand Up @@ -156,14 +157,19 @@ public IDataLoader openDataLoader(BufferedReader reader) throws IOException {
return dataLoader;
}

public void loadDataBatch(String batchData) throws IOException {
public IDataLoaderStatistics loadDataBatch(String batchData) throws IOException {
BufferedReader reader = new BufferedReader(new StringReader(batchData));
IDataLoader dataLoader = openDataLoader(reader);
IDataLoaderStatistics stats = null;
try {
dataLoader.load();
while (dataLoader.hasNext()) {
dataLoader.load();
}
} finally {
dataLoader.close();
stats = dataLoader.getStatistics();
dataLoader.close();
}
return stats;
}

/**
Expand Down
Expand Up @@ -30,6 +30,7 @@
import org.jumpmind.symmetric.load.IColumnFilter;
import org.jumpmind.symmetric.load.IDataLoader;
import org.jumpmind.symmetric.load.IDataLoaderFilter;
import org.jumpmind.symmetric.load.IDataLoaderStatistics;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.service.IDataLoaderService;
import org.jumpmind.symmetric.transport.IIncomingTransport;
Expand All @@ -41,7 +42,8 @@ public void addColumnFilter(String tableName, IColumnFilter filter) {

}

public void loadDataBatch(String batchData) throws IOException {
public IDataLoaderStatistics loadDataBatch(String batchData) throws IOException {
return null;
}

public IDataLoader openDataLoader(BufferedReader reader) throws IOException {
Expand Down

0 comments on commit 1cbf542

Please sign in to comment.