Как я могу хранить несколько онтологий в TDB

Я работаю над проектом, в котором необходимо сохранить несколько онтологий в одной БТ. Я пытался сделать это по-своему, но не получилось. Помогите мне, пожалуйста.. Если вы знаете, как использовать TDB, не могли бы вы опубликовать код, примененный к моему коду?

String directory = "./111";
Dataset dataset = TDBFactory.createDataset(directory);
Model tdb = dataset.getNamedModel("test1");
String source = "file:///e:/Course.rdf";
System.out.println(tdb.toString());
tdb.commit();
tdb.close();
String source2 = "file:///e:/lyx/resouces/Course1.rdf";
Model tdb2 = dataset.getNamedModel("test2");//see error1 information
FileManager.get().readModel( tdb2, source2);
System.out.println(tdb2.toString());//see error2 information
tdb2.commit();
tdb2.close();
dataset.close();

Но я получил сообщение об ошибке: Error1 imformation:

ERROR [main] (ObjectFileStorage.java:345) - ObjectFileStorage.read[nodes](25148)[filesize=30366][file.size()=30366]: Impossibly large object : 879060026 bytes > filesize-(loc+SizeOfInt)=5214

Информация об ошибке 2:

Exception in thread "main" com.hp.hpl.jena.tdb.base.file.FileException: ObjectFileStorage.read[nodes](30397)[filesize=33022][file.size()=33022]: Impossibly large object : 1711276032 bytes > filesize-(loc+SizeOfInt)=2621
at com.hp.hpl.jena.tdb.base.objectfile.ObjectFileStorage.read(ObjectFileStorage.java:346)
at com.hp.hpl.jena.tdb.lib.NodeLib.fetchDecode(NodeLib.java:78)
at com.hp.hpl.jena.tdb.nodetable.NodeTableNative.readNodeFromTable(NodeTableNative.java:178)
at com.hp.hpl.jena.tdb.nodetable.NodeTableNative._retrieveNodeByNodeId(NodeTableNative.java:103)
at com.hp.hpl.jena.tdb.nodetable.NodeTableNative.getNodeForNodeId(NodeTableNative.java:74)
at com.hp.hpl.jena.tdb.nodetable.NodeTableCache._retrieveNodeByNodeId(NodeTableCache.java:103)
at com.hp.hpl.jena.tdb.nodetable.NodeTableCache.getNodeForNodeId(NodeTableCache.java:74)
at com.hp.hpl.jena.tdb.nodetable.NodeTableWrapper.getNodeForNodeId(NodeTableWrapper.java:55)
at com.hp.hpl.jena.tdb.nodetable.NodeTableInline.getNodeForNodeId(NodeTableInline.java:67)
at com.hp.hpl.jena.tdb.lib.TupleLib.quad(TupleLib.java:161)
at com.hp.hpl.jena.tdb.lib.TupleLib.quad(TupleLib.java:153)
at com.hp.hpl.jena.tdb.lib.TupleLib.access$100(TupleLib.java:45)
at com.hp.hpl.jena.tdb.lib.TupleLib$4.convert(TupleLib.java:87)
at com.hp.hpl.jena.tdb.lib.TupleLib$4.convert(TupleLib.java:83)
at org.apache.jena.atlas.iterator.Iter$4.next(Iter.java:317)
at org.apache.jena.atlas.iterator.Iter$4.next(Iter.java:317)
at org.apache.jena.atlas.iterator.Iter.next(Iter.java:915)
at com.hp.hpl.jena.util.iterator.WrappedIterator.next(WrappedIterator.java:94)
at com.hp.hpl.jena.graph.impl.GraphBase.toString(GraphBase.java:422)
at com.hp.hpl.jena.graph.impl.GraphBase.toString(GraphBase.java:391)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at com.hp.hpl.jena.rdf.model.impl.ModelCom.toString(ModelCom.java:1498)
at CreateTDB.main(CreateTDB.java:60)

person user3194152    schedule 14.01.2014    source источник


Ответы (2)


Какая версия Йены?

Попробуйте поместить транзакцию в набор данных.

dataset.begin(ReadWrite.WRITE) ;

см. http://jena.apache.org/documentation/tdb/tdb_transactions.html

person AndyS    schedule 14.01.2014
comment
AndyS, спасибо за быстрый ответ, моя версия jena 2.11.0, я пытался сделать это с транзакциями jena, но это не сработало. код, информация об ошибке: Exception in thread "main" com.hp.hpl.jena.tdb.transaction.TDBTransactionException: Not in a transaction - person user3194152; 15.01.2014
comment
AndyS, спасибо за быстрый ответ, моя версия jena 2.11.0, я пытался сделать это с транзакциями jena. не работает. информация об ошибке:Exception in thread "main" com.hp.hpl.jena.tdb.transaction.TDBTransactionException: Not in a transaction - person user3194152; 15.01.2014

Эти вспомогательные функции работают для меня:

  /**
   * get a model for the given directory
   * 
   * @param directory
   * @return
   */
  public Model getModel(String directory) {
    // Make a TDB-backed dataset
    dataset = TDBFactory.createDataset(directory);

    // open write transaction 
    // see http://jena.apache.org/documentation/tdb/tdb_transactions.html
    dataset.begin(ReadWrite.WRITE);
    Model model = dataset.getDefaultModel();
    return model;
  }

  /**
   * save the given model
   * @param model
   */
  public void saveModel(Model model) {
    if (model != null && dataset != null) {
      model.commit();
      model.close();
      dataset.close();
    }
  }
person Wolfgang Fahl    schedule 23.02.2015