From: <tho...@us...> - 2010-08-02 00:49:46
|
Revision: 3383 http://bigdata.svn.sourceforge.net/bigdata/?rev=3383&view=rev Author: thompsonbry Date: 2010-08-02 00:49:40 +0000 (Mon, 02 Aug 2010) Log Message: ----------- Added logic to NanoSparqlServer to optionally include the namespace for all triple stores when the URL query parameter "showNamespaces" is specified. Added logic to NanoSparqlServer to show all properties for the specified namespace. Conditional logging in TPS. Modified Paths: -------------- trunk/bigdata/src/java/com/bigdata/sparse/TPS.java trunk/bigdata-sails/src/java/com/bigdata/rdf/sail/bench/NanoSparqlServer.java Modified: trunk/bigdata/src/java/com/bigdata/sparse/TPS.java =================================================================== --- trunk/bigdata/src/java/com/bigdata/sparse/TPS.java 2010-08-01 18:53:21 UTC (rev 3382) +++ trunk/bigdata/src/java/com/bigdata/sparse/TPS.java 2010-08-02 00:49:40 UTC (rev 3383) @@ -53,9 +53,9 @@ protected static final transient Logger log = Logger.getLogger(TPS.class); - protected static final transient boolean INFO = log.isInfoEnabled(); - - protected static final transient boolean DEBUG = log.isDebugEnabled(); +// protected static final transient boolean INFO = log.isInfoEnabled(); +// +// protected static final transient boolean DEBUG = log.isDebugEnabled(); /** * @@ -220,7 +220,7 @@ if (tpv != null) { - if (INFO) + if (log.isInfoEnabled()) log.info("Exact timestamp match: name=" + name + (timestamp == Long.MAX_VALUE ? ", current value" @@ -271,14 +271,14 @@ * encountered by the iterator. */ - if (INFO) + if (log.isInfoEnabled()) log.info("No match: name=" + name); return new TPV(schema, name, 0L, null); } - if (INFO) + if (log.isInfoEnabled()) log.info("Most recent match: name=" + name + ", value=" + last.value + ", timestamp=" + last.timestamp); @@ -335,7 +335,7 @@ */ public TPS currentRow(final INameFilter filter) { - if(DEBUG) { + if(log.isDebugEnabled()) { log.debug("filter=" + filter + ", preFilter=" + this); @@ -352,7 +352,7 @@ if (filter != null && !filter.accept(tpv.name)) { - if(DEBUG) { + if(log.isDebugEnabled()) { log.debug("rejecting on filter: "+tpv); @@ -367,7 +367,7 @@ // remove binding. final TPV old = m.remove(tpv.name); - if (DEBUG && old != null) { + if (log.isDebugEnabled() && old != null) { log.debug("removed binding: " + old); @@ -378,7 +378,7 @@ // (over)write binding. final TPV old = m.put(tpv.name, tpv); - if (DEBUG && old != null) { + if (log.isDebugEnabled() && old != null) { log.debug("overwrote: \nold=" + old + "\nnew=" + tpv); @@ -408,7 +408,7 @@ } - if(DEBUG) { + if(log.isDebugEnabled()) { log.debug("postFilter: "+tps); @@ -453,7 +453,7 @@ if (toTime <= fromTime) throw new IllegalArgumentException(); - if(DEBUG) { + if(log.isDebugEnabled()) { log.debug("fromTime=" + fromTime + ", toTime=" + toTime + ", filter=" + filter + ", preFilter=" + this); @@ -479,7 +479,7 @@ // Outside of the half-open range. - if (DEBUG) { + if (log.isDebugEnabled()) { log.debug("rejecting on timestamp: " + tp); @@ -491,7 +491,7 @@ if (filter != null && !filter.accept(tp.name)) { - if (DEBUG) { + if (log.isDebugEnabled()) { log.debug("rejecting on filter: " + tp); @@ -506,7 +506,7 @@ } - if(DEBUG) { + if(log.isDebugEnabled()) { log.debug("postFilter: "+tps); @@ -736,7 +736,7 @@ // #of tuples. final int n = in.readInt(); - if (INFO) + if (log.isDebugEnabled()) log.info("n=" + n + ", schema=" + schema); for (int i = 0; i < n; i++) { @@ -761,7 +761,7 @@ tuples.put(new TP(name, timestamp), tpv); - if (INFO) + if (log.isDebugEnabled()) log.info("tuple: name=" + name + ", timestamp=" + timestamp + ", value=" + value); @@ -899,7 +899,7 @@ public String toString() { - return "TPS{name="+name+",timestamp="+timestamp+",value="+value+"}"; + return "TPV{name="+name+",timestamp="+timestamp+",value="+value+"}"; } Modified: trunk/bigdata-sails/src/java/com/bigdata/rdf/sail/bench/NanoSparqlServer.java =================================================================== --- trunk/bigdata-sails/src/java/com/bigdata/rdf/sail/bench/NanoSparqlServer.java 2010-08-01 18:53:21 UTC (rev 3382) +++ trunk/bigdata-sails/src/java/com/bigdata/rdf/sail/bench/NanoSparqlServer.java 2010-08-02 00:49:40 UTC (rev 3383) @@ -43,6 +43,9 @@ import java.util.Date; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import java.util.Properties; import java.util.TreeMap; import java.util.Vector; @@ -84,8 +87,10 @@ import com.bigdata.rdf.sail.bench.NanoSparqlClient.QueryType; import com.bigdata.rdf.store.AbstractTripleStore; import com.bigdata.relation.AbstractResource; +import com.bigdata.relation.RelationSchema; import com.bigdata.service.IBigdataFederation; import com.bigdata.service.jini.JiniClient; +import com.bigdata.sparse.ITPS; import com.bigdata.util.concurrent.DaemonThreadFactory; import com.bigdata.util.httpd.AbstractHTTPD; import com.bigdata.util.httpd.NanoHTTPD; @@ -226,6 +231,52 @@ } + /** + * Return a list of the registered {@link AbstractTripleStore}s. + */ + protected List<String> getNamespaces() { + + // the triple store namespaces. + final List<String> namespaces = new LinkedList<String>(); + + // scan the relation schema in the global row store. + final Iterator<ITPS> itr = (Iterator<ITPS>) indexManager + .getGlobalRowStore().rangeIterator(RelationSchema.INSTANCE); + + while (itr.hasNext()) { + + // A timestamped property value set is a logical row with + // timestamped property values. + final ITPS tps = itr.next(); + + // If you want to see what is in the TPS, uncomment this. +// System.err.println(tps.toString()); + + // The namespace is the primary key of the logical row for the + // relation schema. + final String namespace = (String) tps.getPrimaryKey(); + + // Get the name of the implementation class + // (AbstractTripleStore, SPORelation, LexiconRelation, etc.) + final String className = (String) tps.get(RelationSchema.CLASS) + .getValue(); + + try { + final Class cls = Class.forName(className); + if (AbstractTripleStore.class.isAssignableFrom(cls)) { + // this is a triple store (vs something else). + namespaces.add(namespace); + } + } catch (ClassNotFoundException e) { + log.error(e,e); + } + + } + + return namespaces; + + } + /** * Return various interesting metadata about the KB state. * @@ -296,6 +347,18 @@ sb.append(AbstractResource.Options.MAX_PARALLEL_SUBQUERIES + "=" + tripleStore.getMaxParallelSubqueries() + "\n"); + sb.append("-- All properties.--\n"); + + // get the triple store's properties from the global row store. + final Map<String, Object> properties = indexManager + .getGlobalRowStore().read(RelationSchema.INSTANCE, + namespace); + + // write them out, + for (String key : properties.keySet()) { + sb.append(key + "=" + properties.get(key)+"\n"); + } + // sb.append(tripleStore.predicateUsage()); } catch (Throwable t) { @@ -553,12 +616,30 @@ final boolean showKBInfo = params.get("showKBInfo") != null; + final boolean showNamespaces = params.get("showNamespaces") != null; + final StringBuilder sb = new StringBuilder(); sb.append("Accepted query count=" + queryIdFactory.get() + "\n"); - sb.append("Running query count=" + queries.size() + "\n"); + sb.append("Running query count=" + queries.size() + "\n"); + if (showNamespaces) { + + final List<String> namespaces = getNamespaces(); + + sb.append("Namespaces: "); + + for (String s : namespaces) { + + sb.append(s); + + } + + sb.append("\n"); + + } + if (showKBInfo) { // General information on the connected kb. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |