This is an automated email from the ASF dual-hosted git repository.
andy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jena.git
The following commit(s) were added to refs/heads/master by this push:
new 4cdcfce JENA-1802: Flag --count for riot
new a7ed77b Merge pull request #655 from afs/riot-count
4cdcfce is described below
commit 4cdcfcefb9c71d86b76a671eb5da0a8fa9bdf89f
Author: Andy Seaborne <[email protected]>
AuthorDate: Mon Dec 16 11:44:59 2019 +0000
JENA-1802: Flag --count for riot
---
.../src/main/java/arq/cmdline/ModLangParse.java | 12 ++++++++++++
jena-cmds/src/main/java/riotcmd/CmdLangParse.java | 22 +++++++++++++++-------
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/jena-cmds/src/main/java/arq/cmdline/ModLangParse.java
b/jena-cmds/src/main/java/arq/cmdline/ModLangParse.java
index 527fae6..2c38039 100644
--- a/jena-cmds/src/main/java/arq/cmdline/ModLangParse.java
+++ b/jena-cmds/src/main/java/arq/cmdline/ModLangParse.java
@@ -37,6 +37,7 @@ public class ModLangParse extends ModBase
private ArgDecl argCheck = new ArgDecl(ArgDecl.NoValue, "check") ;
private ArgDecl argNoCheck = new ArgDecl(ArgDecl.NoValue, "nocheck",
"noCheck") ;
private ArgDecl argSink = new ArgDecl(ArgDecl.NoValue, "sink", "null")
;
+ private ArgDecl argCount = new ArgDecl(ArgDecl.NoValue, "count") ;
private ArgDecl argStrict = new ArgDecl(ArgDecl.NoValue, "strict") ;
private ArgDecl argValidate = new ArgDecl(ArgDecl.NoValue, "validate") ;
@@ -63,6 +64,7 @@ public class ModLangParse extends ModBase
private boolean bitbucket = false ;
private boolean strict = false ;
private boolean validate = false ;
+ private boolean outputCount = false ;
private Lang lang = null ;
@Override
@@ -74,6 +76,7 @@ public class ModLangParse extends ModBase
cmdLine.add(argCheck, "--check", "Addition checking of RDF
terms") ; // (default: off for N-triples, N-Quads, on for Turtle and TriG)") ;
cmdLine.add(argStrict, "--strict", "Run with in strict mode")
;
cmdLine.add(argValidate,"--validate", "Same as --sink --check
--strict") ;
+ cmdLine.add(argCount, "--count", "Count triples/quads
parsed, not output them") ;
cmdLine.add(argRDFS, "--rdfs=file", "Apply some RDFS inference
using the vocabulary in the file") ;
cmdLine.add(argNoCheck, "--nocheck", "Turn off checking of RDF
terms") ;
@@ -131,6 +134,11 @@ public class ModLangParse extends ModBase
if ( cmdLine.contains(argSink) )
bitbucket = true ;
+
+ if ( cmdLine.contains(argCount) ) {
+ bitbucket = true ;
+ outputCount = true ;
+ }
if ( cmdLine.contains(argRDFS) ) {
try {
@@ -160,6 +168,10 @@ public class ModLangParse extends ModBase
return validate ;
}
+ public boolean outputCount() {
+ return outputCount ;
+ }
+
public boolean skipOnBadTerm() {
return skipOnBadTerm ;
}
diff --git a/jena-cmds/src/main/java/riotcmd/CmdLangParse.java
b/jena-cmds/src/main/java/riotcmd/CmdLangParse.java
index c696315..777ee31 100644
--- a/jena-cmds/src/main/java/riotcmd/CmdLangParse.java
+++ b/jena-cmds/src/main/java/riotcmd/CmdLangParse.java
@@ -82,7 +82,7 @@ public abstract class CmdLangParse extends CmdGeneral
@Override
protected String getSummary() {
- return getCommandName()+" [--time] [--check|--noCheck] [--sink]
[--base=IRI] [--out=FORMAT] [--compress] file ..." ;
+ return getCommandName()+" [--help] [--time] [--base=IRI]
[-syntax=FORMAT] [--out=FORMAT] [--count] file ..." ;
}
protected List<ParseRecord> outcomes = new ArrayList<>();
@@ -170,7 +170,7 @@ public abstract class CmdLangParse extends CmdGeneral
postParse.postParse();
// Post parse information.
// Total if more than one file.
- if ( super.getPositional().size() > 1 && modTime.timingEnabled() )
{
+ if ( super.getPositional().size() > 1 && ( modTime.timingEnabled()
|| modLangParse.outputCount() ) ) {
long totalMillis = 0;
long totalTriples = 0;
long totalQuads = 0;
@@ -207,6 +207,14 @@ public abstract class CmdLangParse extends CmdGeneral
}
public void outcome(ParseRecord rtn) {
+ if ( modLangParse.outputCount() ) {
+ System.err.printf("%-15s", rtn.filename);
+ if ( rtn.triples > 0 )
+ System.err.printf(" : Triples = %,d", rtn.triples);
+ if ( rtn.quads > 0 )
+ System.err.printf(" : Quads = %,d", rtn.quads);
+ System.err.println();
+ }
outcomes.add(rtn);
if ( modTime.timingEnabled() )
output(rtn);
@@ -235,6 +243,7 @@ public abstract class CmdLangParse extends CmdGeneral
baseURI = "http://base/";
builder.base(baseURI);
}
+ filename = "stdin";
builder.source(System.in);
} else {
builder.source(filename);
@@ -246,7 +255,7 @@ public abstract class CmdLangParse extends CmdGeneral
// Contrast with --syntax=.. which forces the language.
protected abstract Lang dftLang() ;
- protected ParseRecord parseRIOT(RDFParserBuilder builder, /*Info for the
ProcessOutcome*/ String filename) {
+ protected ParseRecord parseRIOT(RDFParserBuilder builder, String filename)
{
boolean checking = true ;
if ( modLangParse.explicitChecking() )
checking = true;
@@ -303,7 +312,6 @@ public abstract class CmdLangParse extends CmdGeneral
}
sink.finish() ;
long x = modTime.endTimer() ;
- // TEMP
ParseRecord outcome = new ParseRecord(filename, successful, x,
sink.countTriples(), sink.countQuads(), errHandler);
return outcome;
}
@@ -362,14 +370,14 @@ public abstract class CmdLangParse extends CmdGeneral
long total = numberTriples + numberQuads + numberTuples;
StringBuilder sb = new StringBuilder();
if ( total > 0 ) {
- sb.append(label);
+ sb.append(String.format("%-15s", label));
if ( success )
- appendFmt(sb, " : %,5.2f sec", timeSec);
+ appendFmt(sb, " : %,4.2f sec", timeSec);
appendCount(sb, numberTriples, "Triple", "Triples", "TPS");
appendCount(sb, numberQuads, "Quad", "Quads", "QPS");
appendCount(sb, numberTuples, "Tuple", "Tuples", "TPS");
if ( success && timeMillis > 0 )
- appendFmt(sb," : %,.2f %s", numberTriples/timeSec, "per
second");
+ appendFmt(sb," : %,.2f %s", total/timeSec, "per second");
} else {
appendFmt(sb, "%s : (No Output)", label) ;
}