本文整理匯總了Java中org.openrdf.query.resultio.text.tsv.SPARQLResultsTSVWriter類的典型用法代碼示例。如果您正苦於以下問題:Java SPARQLResultsTSVWriter類的具體用法?Java SPARQLResultsTSVWriter怎麽用?Java SPARQLResultsTSVWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SPARQLResultsTSVWriter類屬於org.openrdf.query.resultio.text.tsv包,在下文中一共展示了SPARQLResultsTSVWriter類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: querySensorObservations
import org.openrdf.query.resultio.text.tsv.SPARQLResultsTSVWriter; //導入依賴的package包/類
private static void querySensorObservations() {
String sparql = "prefix ssn: <http://purl.oclc.org/NET/ssnx/ssn#>"
+ "prefix time: <http://www.w3.org/2006/time#>"
+ "prefix dul: <http://www.loa-cnr.it/ontologies/DUL.owl#>"
+ "select ?time ?value ?sensor ?property ?feature "
+ "where {"
+ "["
+ "ssn:observedBy ?sensor ;"
+ "ssn:observedProperty ?property ;"
+ "ssn:featureOfInterest ?feature ;"
+ "ssn:observationResultTime [ time:inXSDDateTime ?time ] ;"
+ "ssn:observationResult [ ssn:hasValue [ dul:hasRegionDataValue ?value ] ]"
+ "]"
+ "filter (?time >= \"2015-05-18T00:00:30.000+03:00\"^^xsd:dateTime && ?time < \"2015-05-18T00:00:35.000+03:00\"^^xsd:dateTime)"
+ "} order by ?sensor asc (?time)";
System.out.println("== QUERY SENSOR OBSERVATIONS ==");
long start = System.currentTimeMillis();
// In addition to the SPARQL writer, there are also CSV, JSON, and XML
// writers
e.evaluate(QueryType.SENSOR_OBSERVATION, sparql,
new SPARQLResultsTSVWriter(System.out));
long end = System.currentTimeMillis();
System.out.println("Time (s): " + elapsed(start, end));
}
示例2: queryDatasetObservations
import org.openrdf.query.resultio.text.tsv.SPARQLResultsTSVWriter; //導入依賴的package包/類
private static void queryDatasetObservations() {
String sparql = "prefix qb: <http://purl.org/linked-data/cube#>"
+ "prefix sdmx-dimension: <http://purl.org/linked-data/sdmx/2009/dimension#>"
+ "prefix time: <http://www.w3.org/2006/time#>"
+ "prefix qudt: <http://qudt.org/schema/qudt#>"
+ "prefix ex: <http://example.org#>"
+ "select ?time ?temperature ?temperatureUnit ?humidity ?humidityUnit ?vibration ?vibrationUnit ?carbonDioxide ?carbonDioxideUnit ?waterVapor ?waterVaporUnit "
+ "where {"
+ "["
+ "qb:dataSet ex:d1 ;"
+ "sdmx-dimension:timePeriod [ time:inXSDDateTime ?time ] ;"
+ "ex:temperature [ qudt:numericValue ?temperature; qudt:unit ?temperatureUnit ] ;"
+ "ex:humidity [ qudt:numericValue ?humidity; qudt:unit ?humidityUnit ] ;"
+ "ex:vibration [ qudt:numericValue ?vibration; qudt:unit ?vibrationUnit ] ;"
+ "ex:carbonDioxide [ qudt:numericValue ?carbonDioxide; qudt:unit ?carbonDioxideUnit ] ;"
+ "ex:waterVapor [ qudt:numericValue ?waterVapor; qudt:unit ?waterVaporUnit ]"
+ "]"
+ "filter (?time >= \"2015-05-18T00:00:30.000+03:00\"^^xsd:dateTime && ?time < \"2015-05-18T00:00:35.000+03:00\"^^xsd:dateTime)"
+ "} order by asc (?time)";
System.out.println("== QUERY DATASET OBSERVATIONS ==");
long start = System.currentTimeMillis();
e.evaluate(QueryType.DATASET_OBSERVATION, sparql,
new SPARQLResultsTSVWriter(System.out));
long end = System.currentTimeMillis();
System.out.println("Time (s): " + elapsed(start, end));
}
示例3: main
import org.openrdf.query.resultio.text.tsv.SPARQLResultsTSVWriter; //導入依賴的package包/類
public static void main(String[] args) {
if (args.length == 0)
help();
boolean isSensorQuery = false;
File queryFileName = null;
File knowledgeStoreFile = null;
String dataStoreHost = "localhost";
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-sq")) {
queryFileName = new File(args[++i]);
isSensorQuery = true;
} else if (args[i].equals("-dq")) {
queryFileName = new File(args[++i]);
isSensorQuery = false;
} else if (args[i].equals("-ks")) {
knowledgeStoreFile = new File(args[++i]);
} else if (args[i].equals("-ds")) {
dataStoreHost = args[++i];
}
}
if (queryFileName == null || knowledgeStoreFile == null)
help();
Emrooz e = new Emrooz(new SesameKnowledgeStore(new SailRepository(
new MemoryStore(knowledgeStoreFile))), new CassandraDataStore(
dataStoreHost));
long start = System.currentTimeMillis();
try {
if (isSensorQuery)
e.evaluate(QueryType.SENSOR_OBSERVATION,
FileUtils.readFileToString(queryFileName),
new SPARQLResultsTSVWriter(System.out));
else
e.evaluate(QueryType.DATASET_OBSERVATION,
FileUtils.readFileToString(queryFileName),
new SPARQLResultsTSVWriter(System.out));
} catch (IOException e1) {
e1.printStackTrace();
}
long end = System.currentTimeMillis();
e.close();
summary(start, end);
}