當前位置: 首頁>>代碼示例>>Java>>正文


Java Model.removeAll方法代碼示例

本文整理匯總了Java中com.hp.hpl.jena.rdf.model.Model.removeAll方法的典型用法代碼示例。如果您正苦於以下問題:Java Model.removeAll方法的具體用法?Java Model.removeAll怎麽用?Java Model.removeAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hp.hpl.jena.rdf.model.Model的用法示例。


在下文中一共展示了Model.removeAll方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: bulkUpdate

import com.hp.hpl.jena.rdf.model.Model; //導入方法依賴的package包/類
/**
 * Method called to Chunk the triples into N-Sized batches and post to VIVO.
 * This is designed to work around / handle errors when posting sets of triples
 * over 10,000 to the API.
 *
 * @param namedGraph String with named graph.
 * @param changeModel Jena model with set of changes to sync to store.
 * @param changeType Either add or remove.
 * @return Boolean true if update was successful.
 * @throws IOException
 */
private Boolean bulkUpdate(String namedGraph, Model changeModel, String changeType) throws IOException {
    // Temporary model to hold
    Model tmpModel = ModelFactory.createDefaultModel();
    Integer bSize = Integer.parseInt(batchSize);
    // Use an integer to count triples rather than calling size on the model
    // during each loop.
    Integer size = 0;
    StmtIterator iter = changeModel.listStatements();
    while (iter.hasNext()) {
        Statement stmt = iter.nextStatement();  // get next statement
        tmpModel.add(stmt);
        size++;
        if (size >= bSize) {
            // Submit
            log.info("Submitting " + size + " triples to " + namedGraph);
            submitBatch(tmpModel, namedGraph, changeType);
            // Reset the tmp model.
            tmpModel.removeAll();
            // Reset the counter.
            size = 0;
        }
    }
    log.info("model size:" + tmpModel.size());
    // Submit the remaining statements, if any.
    if (tmpModel.size() > 0) {
        submitBatch(tmpModel, namedGraph, changeType);
    }
    return true;
}
 
開發者ID:lawlesst,項目名稱:karma2vivo,代碼行數:41,代碼來源:VIVOSPARQLClient.java

示例2: collapseAnnotations

import com.hp.hpl.jena.rdf.model.Model; //導入方法依賴的package包/類
private List<Statement> collapseAnnotations(Property property, Model model){
	
	List<Statement> stmts = new ArrayList<Statement>();
	
	Map<String, Map<String,Statement>> literalMap = new HashMap<String, Map<String,Statement>>();
	StmtIterator stmtIt = model.listStatements(null, property, (RDFNode) null);
	stmtIt.forEachRemaining(stmt -> {
		RDFNode obj = stmt.getObject();
		if(obj.isLiteral()){
			Literal lit = obj.asLiteral();
			String lang = lit.getLanguage();
			if(lang == null){
				lang = "null";
			}
			Map<String, Statement> stmtMap = literalMap.get(lang);
			if(stmtMap == null) {
				stmtMap = new HashMap<String, Statement>();
				literalMap.put(lang, stmtMap);
			}
			
			Statement statement = stmtMap.get(lang);
			boolean insert = false;
			if(statement == null) insert = true;
			else{
				String statementLF = ((Literal)statement.getObject()).getLexicalForm();
				String lexicalForm = lit.getLexicalForm();
				if(lexicalForm.length() > statementLF.length()) insert = true;
			}
				
				
			if(insert) stmtMap.put(lang, statement);
		}
		
	});
	
	model.removeAll(null, property, (RDFNode) null);
	
	literalMap.forEach((subject, stmtMap) -> {
		stmtMap.forEach((lang, stmt) -> {
			model.add(stmt);
		});
	});
	
	return stmts;
	
}
 
開發者ID:teamdigitale,項目名稱:ontonethub,代碼行數:47,代碼來源:IndexingJob.java

示例3: keepMaxLengthAnnotationsOnly

import com.hp.hpl.jena.rdf.model.Model; //導入方法依賴的package包/類
private List<Statement> keepMaxLengthAnnotationsOnly(Property property, Model model){
	
	List<Statement> stmts = new ArrayList<Statement>();
	
	Map<Resource, Map<String,Statement>> literalMap = new HashMap<Resource, Map<String,Statement>>();
	StmtIterator stmtIt = model.listStatements(null, property, (RDFNode) null);
	stmtIt.forEachRemaining(stmt -> {
		Resource subj = stmt.getSubject();
		RDFNode obj = stmt.getObject();
		if(obj.isLiteral()){
			Literal lit = obj.asLiteral();
			String lang = lit.getLanguage();
			if(lang == null){
				lang = "null";
			}
			Map<String, Statement> stmtMap = literalMap.get(subj);
			if(stmtMap == null) {
				stmtMap = new HashMap<String, Statement>();
				literalMap.put(subj, stmtMap);
			}
			
			Statement statement = stmtMap.get(lang);
			boolean insert = false;
			if(statement == null) insert = true;
			else{
				String statementLF = ((Literal)statement.getObject()).getLexicalForm();
				String lexicalForm = lit.getLexicalForm();
				if(lexicalForm.length() > statementLF.length()) insert = true;
			}
				
				
			if(insert) stmtMap.put(lang, stmt);
		}
		
	});
	
	model.removeAll(null, property, (RDFNode) null);
	
	literalMap.forEach((subject, stmtMap) -> {
		stmtMap.forEach((lang, stmt) -> {
			model.add(stmt);
		});
	});
	
	return stmts;
	
}
 
開發者ID:teamdigitale,項目名稱:ontonethub,代碼行數:48,代碼來源:IndexingJob.java


注:本文中的com.hp.hpl.jena.rdf.model.Model.removeAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。