use of com.vaticle.typedb.core.TypeDB in project grakn by graknlabs.
the class DataExporter method run.
public void run() {
LOG.info("Exporting {} from TypeDB {}", database, version);
try (OutputStream outputStream = new BufferedOutputStream(Files.newOutputStream(filename))) {
export(outputStream, header());
try (TypeDB.Session session = databaseMgr.session(database, Arguments.Session.Type.DATA);
TypeDB.Transaction tx = session.transaction(Arguments.Transaction.Type.READ)) {
totalEntityCount = tx.concepts().getRootEntityType().getInstancesCount();
totalAttributeCount = tx.concepts().getRootAttributeType().getInstancesCount();
totalRelationCount = tx.concepts().getRootRelationType().getInstancesCount();
List<Runnable> exporters = Arrays.asList(() -> exportEntities(tx, outputStream), () -> exportRelations(tx, outputStream), () -> exportAttributes(tx, outputStream));
exporters.parallelStream().forEach(Runnable::run);
export(outputStream, checksums());
}
} catch (IOException e) {
throw TypeDBException.of(FILE_NOT_WRITABLE, filename.toString());
}
LOG.info("Exported " + status.toString());
}
Aggregations