private static final int CHUNK_SIZE = 300_000;
private static void addResultsToRepository(final ResultSet results,
final Connection stardog_connection)
throws SQLException {
System.out.println("Processing RDBMS " + CHUNK_SIZE +
" rows at a time.");
IRI context = Values.iri(CONTEXT);
IRI fname = Values.iri(NAMESPACE, "fname");
IRI lname = Values.iri(NAMESPACE, "lname");
IRI dob = Values.iri(NAMESPACE, "dob");
int count = 0;
stardog_connection.begin();
try {
Adder adder = stardog_connection.add();
while (results.next()) {
IRI person = Values.iri(NAMESPACE,
"Person" + results.getString(1));
addToTransaction(adder, person, fname, results, 2, context);
addToTransaction(adder, person, lname, results, 3, context);
addToTransaction(adder, person, dob, results, 4, context);
count++;
if (0 == count % CHUNK_SIZE) {
String timeStamp = new SimpleDateFormat(
"yyyyMMdd_HHmmss").format(
Calendar.getInstance().getTime());
System.out.print(count + " rows so far. " + timeStamp +
"...");
stardog_connection.commit();
System.out.println("Committed.");
stardog_connection.begin();
adder = stardog_connection.add();
System.out.println("Starting next batch.");
}
}
} finally {
stardog_connection.commit();
}
System.out.println("# of results processed: " + count);
}
private static void addToTransaction(Adder adder, IRI person, IRI predicate,
final ResultSet results, int column, IRI context) throws SQLException {
adder.statement(person, predicate,
Values.literal(results.getString(column)), context);
}
Exception in thread "main" com.complexible.stardog.StardogException: Unable to complete operation, a transaction has not been initiated.
at com.complexible.stardog.api.impl.AbstractConnection.assertInTransaction(AbstractConnection.java:266)
at com.complexible.stardog.api.impl.AbstractConnection.commit(AbstractConnection.java:197)
at ida.org.stardogtimer.Sql2Stardog.addResultsToRepository(Sql2Stardog.java:128)
at ida.org.stardogtimer.Sql2Stardog.run(Sql2Stardog.java:81)
at ida.org.stardogtimer.Sql2Stardog.main(Sql2Stardog.java:142)
--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.
Thank you. After reading your assessment, I made sure to catch and log SqlException, and for good measure catch and log StardogException, too. I also realized that the sample code seems to recommend "one call per adder", i.e., always call connection.add().statement(...) instead of repeated calls to the same Adder instance like I was doing. (For all I know, it was giving the same reference...I didn't check.) Long story short, the real issue was my Stardog server runs out of heap space around 7.2M triples. Right now I'm running with CHUNK_SIZE reduced to 300k to test if this helps.
Does anyone know if there is a Stardog native store size to Java heap requirements correlation, i.e., as my store grows beyond 7M statements, do I actually need to give the Stardog server more heap space beyond the default 2 GB?
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+unsubscribe@clarkparsia.com.
$ stardog-admin virtual add lots_of_users.properties lots_of_users.ttl
Unknown or unsupported command type 'Add', cannot execute.
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+unsubscribe@clarkparsia.com.