01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.sail.rdbms.schema;
07:
08: import java.sql.SQLException;
09:
10: import org.openrdf.sail.helpers.DefaultSailChangedEvent;
11:
12: /**
13: *
14: * @author James Leigh
15: */
16: public class TripleBatch extends Batch {
17:
18: public static int total_rows;
19:
20: public static int total_st;
21:
22: public static int total_wait;
23:
24: private TripleTable table;
25:
26: private DefaultSailChangedEvent sailChangedEvent;
27:
28: public void setTable(TripleTable table) {
29: assert table != null;
30: this .table = table;
31: }
32:
33: public void setSailChangedEvent(
34: DefaultSailChangedEvent sailChangedEvent) {
35: this .sailChangedEvent = sailChangedEvent;
36: }
37:
38: public boolean isReady() {
39: return table.isReady();
40: }
41:
42: public synchronized int flush() throws SQLException {
43: table.blockUntilReady();
44: long start = System.currentTimeMillis();
45: int count = super .flush();
46: long end = System.currentTimeMillis();
47: total_rows += count;
48: total_st += 2;
49: total_wait += end - start;
50: if (count > 0) {
51: sailChangedEvent.setStatementsAdded(true);
52: }
53: return count;
54: }
55:
56: }
|