1

我对 tdb 完全陌生,我想将几​​个 rdf 数据存储到 tdb 中。许多代码如下:

public static final String book = "Ontologies/book.rdf";
public static final String conference = "Ontologies/conference.rdf";
public static final String inproceeding = "Ontologies/inproceeding.rdf";
public static final String journal = "Ontologies/journal.rdf";
public static final String JournalArtical = "Ontologies/JournalArtical.rdf";
public static final String organization = "Ontologies/organization.rdf";
public static final String person = "Ontologies/person.rdf";
public static final String place = "Ontologies/place.rdf";
public static final String proceedings = "Ontologies/proceedings.rdf";
public static final String series = "Ontologies/series.rdf";
public static final String thesis = "Ontologies/thesis.rdf";

static String queryRequest = "select * {?s ?p ?o.}";

/**
 * @param args the command line arguments
 */
public static void main(String[] args) throws IOException {
    ArrayList<String> al = new ArrayList();
   // al.add(book);
    al.add(conference);
   al.add(inproceeding);
    al.add(journal);
   al.add(JournalArtical);
    al.add(organization);
    al.add(person);
   al.add(place);
   al.add(proceedings);
    al.add(series);
   al.add(thesis);

    //create the DataSet   
    Dataset dataset = TDBFactory.createDataset("QA");
    Model model = dataset.getDefaultModel();
    //to fill model  
    Iterator  it=  al.iterator();
    while(it.hasNext()){
    FileManager.get().readModel(model, (String)it.next());
    }

    model.commit();
    dataset.close();
}
}

它抛出一个 ConcurrentModificationException 异常?我不知道为什么?一个模型可以存储许多 rdf 数据吗?

4

1 回答 1

0

TDB 做了很多异步操作,因此您可以尝试TDB.sync(model)在每次读取操作之后添加以强制它等待操作真正完成,然后再继续下一个操作。

于 2014-01-03T17:32:26.037 回答