All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bigdata.rdf.load.RDFVerifyTaskFactory Maven / Gradle / Ivy

package com.bigdata.rdf.load;

import org.openrdf.model.Statement;
import org.openrdf.rio.RDFFormat;

import com.bigdata.rdf.rio.RDFParserOptions;
import com.bigdata.rdf.store.AbstractTripleStore;

/**
 * Factory for tasks for verifying a database against RDF resources.
 * 
 * @author Bryan Thompson
 * @version $Id$
 */
public class RDFVerifyTaskFactory extends
        AbstractRDFTaskFactory {

    public RDFVerifyTaskFactory(AbstractTripleStore db, int bufferCapacity,
            RDFParserOptions parserOptions, boolean deleteAfter, RDFFormat fallback) {

        super(db, parserOptions, deleteAfter, fallback, new VerifyStatementBufferFactory(
                db, bufferCapacity));

    }

    public long getTermCount() {
        
        return ((VerifyStatementBufferFactory)bufferFactory).nterms.get();
        
    }
    
    public long getTermNotFoundCount() {
        
        return ((VerifyStatementBufferFactory)bufferFactory).ntermsNotFound.get();
        
    }
    
    public long getTripleCount() {
        
        return ((VerifyStatementBufferFactory)bufferFactory).ntriples.get();
        
    }
    
    public long getTripleNotFoundCount() {
        
        return ((VerifyStatementBufferFactory)bufferFactory).ntriplesNotFound.get();
        
    }
    
    /**
     * Report on #terms and #stmts not found as well as #triples processed
     * and found.
     */
    public String reportTotals() {

        // total run time.
        final long elapsed = elapsed();

        final long tripleCount = getTripleCount();

        final double tps = (long) (((double) tripleCount) / ((double) elapsed) * 1000d);

        return "Processed: #terms=" + getTermCount() + " ("
                + getTermNotFoundCount() + " not found), #stmts="
                + tripleCount + " (" + getTripleNotFoundCount()
                + " not found)" + ", rate=" + tps + " in " + elapsed
                + " ms.";
            
    }
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy