Permalink
Browse files

Small fixes and initial work for load tests

  • Loading branch information...
1 parent b16862b commit 8f221713b51b4cfd74c09591d8e3dc023c3b4562 antoniogarrote committed Jun 14, 2011
View
Oops, something went wrong.
View
@@ -0,0 +1,52 @@
+@prefix dc: <http://purl.org/dc/elements/1.1/> .
+@prefix dcterms: <http://purl.org/dc/terms/> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix swrc: <http://swrc.ontoware.org/ontology#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix bench: <http://localhost/vocabulary/bench/> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+@prefix person: <http://localhost/persons/> .
+bench:Journal rdfs:subClassOf foaf:Document.
+bench:Proceedings rdfs:subClassOf foaf:Document.
+bench:Inproceedings rdfs:subClassOf foaf:Document.
+bench:Article rdfs:subClassOf foaf:Document.
+bench:Www rdfs:subClassOf foaf:Document.
+bench:MastersThesis rdfs:subClassOf foaf:Document.
+bench:PhDThesis rdfs:subClassOf foaf:Document.
+bench:Incollection rdfs:subClassOf foaf:Document.
+bench:Book rdfs:subClassOf foaf:Document.
+<http://localhost/persons/Paul_Erdoes> rdf:type foaf:Person.
+<http://localhost/persons/Paul_Erdoes> foaf:name "Paul Erdoes"^^xsd:string.
+<http://localhost/misc/UnknownDocument> rdf:type foaf:Document.
+<http://localhost/publications/journals/Journal1/1940> rdf:type bench:Journal.
+<http://localhost/publications/journals/Journal1/1940> swrc:number "1"^^xsd:integer.
+<http://localhost/publications/journals/Journal1/1940> dc:title "Journal 1 (1940)"^^xsd:string.
+<http://localhost/publications/journals/Journal1/1940> swrc:volume "1"^^xsd:integer.
+<http://localhost/publications/journals/Journal1/1940> dcterms:issued "1940"^^xsd:integer.
+<http://localhost/publications/articles/Journal1/1940/Article1> rdf:type bench:Article.
+<http://localhost/publications/articles/Journal1/1940/Article1> bench:abstract "unmuzzling measles decentralizing hogfishes gantleted richer succories dwelling scrapped prat islanded burlily thanklessly swiveled polers oinked apnea maxillary dumpers bering evasiveness toto teashop reaccepts gunneries exorcises pirog desexes summable heliocentricity excretions recelebrating dually plateauing reoccupations embossers cerebrum gloves mohairs admiralties bewigged playgoers cheques batting waspishly stilbestrol villainousness miscalling firefanged skeins equalled sandwiching bewitchment cheaters riffled kerneling napoleons rifer splinting surmisers satisfying undamped sharpers forbearer anesthetization undermentioned outflanking funnyman commuted lachrymation floweret arcadian acridities unrealistic substituting surges preheats loggias reconciliating photocatalyst lenity tautological jambing sodality outcrop slipcases phenylketonuria grunts venturers valiantly unremorsefully extradites stollens ponderers conditione loathly cancels debiting parrots paraguayans resonates"^^xsd:string.
+<http://localhost/publications/articles/Journal1/1940/Article1> bench:cdrom "http://www.hogfishes.tld/richer/succories.html"^^xsd:string.
+<http://localhost/publications/articles/Journal1/1940/Article1> rdfs:seeAlso "http://www.gantleted.tld/succories/dwelling.html"^^xsd:string.
+<http://localhost/publications/articles/Journal1/1940/Article1> swrc:month "4"^^xsd:integer.
+<http://localhost/publications/articles/Journal1/1940/Article1> swrc:note "overbites terminals giros podgy vagus kinkiest xix recollected"^^xsd:string.
+<http://localhost/publications/articles/Journal1/1940/Article1> swrc:pages "110"^^xsd:integer.
+<http://localhost/publications/articles/Journal1/1940/Article1> dc:title "richer dwelling scrapped"^^xsd:string.
+<http://localhost/publications/articles/Journal1/1940/Article1> foaf:homepage "http://www.succories.tld/scrapped/prat.html"^^xsd:string.
+<http://localhost/publications/articles/Journal1/1940/Article1> swrc:journal <http://localhost/publications/journals/Journal1/1940>.
+_:Adamanta_Schlitt rdf:type foaf:Person.
+_:Adamanta_Schlitt foaf:name "Adamanta Schlitt"^^xsd:string.
+<http://localhost/publications/articles/Journal1/1940/Article1> dc:creator _:Adamanta_Schlitt.
+<http://localhost/publications/articles/Journal1/1940/Article1> dc:creator <http://localhost/persons/Paul_Erdoes>.
+<http://localhost/publications/articles/Journal1/1940/Article1> dcterms:references _:references1.
+_:references1 rdf:type rdf:Bag.
+_:references1 rdf:_1 <http://localhost/misc/UnknownDocument>.
+_:references1 rdf:_2 <http://localhost/misc/UnknownDocument>.
+_:references1 rdf:_3 <http://localhost/misc/UnknownDocument>.
+_:references1 rdf:_4 <http://localhost/misc/UnknownDocument>.
+<http://localhost/publications/articles/Journal1/1940/Article2> rdf:type bench:Article.
+<http://localhost/publications/articles/Journal1/1940/Article2> bench:abstract "householder overeducated objurgate treaties preprocessor despising loftily yabber reprovingly blungers dwarflike effulgences coreless tuberculoses environs hulled preexamination oralogy tibetans slavishly hipless prs bluejays cuppier nonsurgical skimpiest outpoured dissociated heartier petitionee brill neologic intermuscular fobbed transcribed swifters redigesting ostinato recalculation safest signiory latchets inflecting trephines hops exec junketeers isolators reducing nethermost nonfiction retrogressions eliminates unknowns mongoloids danker raunchiness perspicuously disjoined nigglings midmonths labium peeped daydreams permuting immediately canzona interrelated cooked reformers goodwife technicolor plenishes nippy bounden occulters blubberer amenities desecrated tetrachlorides loutish polygony malines cliffhanger entailments reindexed bedstraws thoughtless elation swampland earings circumscribed paralyzingly pouchy surrejoinders chestiest measurage tonsils pasturage thurifer teazle"^^xsd:string.
+<http://localhost/publications/articles/Journal1/1940/Article2> bench:cdrom "http://www.dwelling.tld/prat/islanded.html"^^xsd:string.
+<http://localhost/publications/articles/Journal1/1940/Article2> rdfs:seeAlso "http://www.scrapped.tld/islanded/burlily.html"^^xsd:string.
+<http://localhost/publications/articles/Journal1/1940/Article2> swrc:month "8"^^xsd:integer.
+<http://localhost/publications/articles/Journal1/1940/Article2> swrc:note "fringier rhythmical wastebaskets powderer immigrates inserter plights corollaries"^^xsd:string.
View
@@ -0,0 +1,14 @@
+var Store = require('./src/js-store/src/store.js');
+
+Store.Store.create(function(store) {
+
+ store.load('text/n3', 'file://Users/antonio/Development/Projects/js/rdfstore-js/data/sp2b_10k.n3', 'test_file', function(success, result) {
+ console.log('Finished!');
+ console.log(result);
+
+ store.execute("SELECT DISTINCT ?s FROM <test_file> { ?s ?p ?o }", function(succes,result) {
+ console.log(result.count);
+ });
+ });
+
+});
@@ -96,6 +96,20 @@ RDFLoader.RDFLoader.prototype.load = function(uri, graph, callback) {
}});
};
+RDFLoader.RDFLoader.prototype.loadFromFile = function(parser, graph, uri, callback) {
+ try {
+ var that = this;
+ fs = require('fs');
+ fs.readFile(uri.split("file:/")[1], function(err, data) {
+ if(err) throw err;
+ var data = data.toString('utf8');
+ that.tryToParse(parser, graph, data, callback);
+ });
+ } catch(e) {
+ callback(false, e);
+ }
+};
+
RDFLoader.RDFLoader.prototype.tryToParse = function(parser, graph, input, callback) {
try {
if(typeof(input) === 'string') {
@@ -2,6 +2,14 @@
exports.TurtleParser = {};
var TurtleParser = exports.TurtleParser;
+var statementCounter = 0;
+var timer = new Date().getTime();
+var printTime = function() {
+ var newTimer = new Date().getTime();
+ console.log("ellapsed: "+((newTimer-timer)/1000)+" secs");
+ timer = newTimer;
+};
+
// imports
var Utils = require("./../../js-trees/src/utils").Utils;
@@ -190,6 +198,11 @@ TurtleParser.parser = (function(){
}
function parse_statement() {
+ statementCounter++;
+ if(statementCounter % 1000 == 0) {
+ console.log(""+statementCounter);
+ printTime();
+ }
var cacheKey = 'statement@' + pos;
var cachedResult = cache[cacheKey];
if (cachedResult) {
@@ -5175,7 +5188,7 @@ TurtleParser.parser = (function(){
}
var savedReportMatchFailures = reportMatchFailures;
- reportMatchFailures = false;
+ reportMatchFailures = false
if (input.substr(pos).match(/^[ ]/) !== null) {
var result5 = input.charAt(pos);
pos++;
@@ -6253,8 +6266,10 @@ TurtleParser.parser.parse = function(data, graph) {
var result = TurtleParser.parser.innerParse(data);
var namespaces = {};
- var env = {namespaces: namespaces, base:''};
-
+ var env = {namespaces: namespaces, base:'', blankCounter: 0};
+
+ statementCounter = 0;
+
for(var i=0; i<result.length; i++) {
var unit = result[i];
if(unit.token === 'base') {
@@ -0,0 +1,17 @@
+var TurtleParser = require("./../src/turtle_parser.js").TurtleParser;
+
+
+exports.testParsing1 = function(test) {
+
+ fs = require('fs');
+ fs.readFile("./data/sp2b_10k.n3", function(err, data) {
+ if(err) throw err;
+ var data = data.toString('utf8')
+ console.log("DATA:"+data.length);
+ var result = TurtleParser.parser.parse(data)
+ console.log(result.length+" triples parsed");
+
+ test.done();
+ });
+
+}
@@ -271,6 +271,20 @@ Store.Store.prototype.load = function(){
var query = "LOAD <"+data.valueOf()+"> INTO GRAPH <"+graph.valueOf()+">";
this.engine.execute(query, callback);
+ } else if(data.indexOf('file://')=== 0) {
+ var parser = this.engine.rdfLoader.parsers[mediaType];
+
+ var that = this;
+
+ this.engine.rdfLoader.loadFromFile(parser, {'token':'uri', 'value':graph.valueOf()}, data, function(success, quads) {
+ if(success) {
+ that.engine.batchLoad(quads,callback);
+ } else {
+ callback(success, quads);
+ }
+ });
+
+
} else {
var parser = this.engine.rdfLoader.parsers[mediaType];
@@ -31,14 +31,30 @@ Utils.include = function(a,v) {
return false;
};
+Utils.repeatNew = function(c,max,floop,env) {
+try{
+ if(arguments.length===3) { env = {}; }
+ env._i = c;
+ env._success = true;
+ var result;
+ while(env._i<max && result != 'break') {
+ result = floop(env);
+ env._i++;
+ }
+ return env;
+} catch(e) {
+ console.log("ERROR");
+}
+};
+
Utils.repeat = function(c,max,floop,fend,env) {
if(arguments.length===4) { env = {}; }
if(c<max) {
env._i = c;
floop(function(floop,env){
// avoid stack overflow
// deadly hack
- if(c % 40 == 39) {
+ if(c % 5 == 4) {
setTimeout(function(){ Utils.repeat(c+1, max, floop, fend, env); }, 0);
} else {
Utils.repeat(c+1, max, floop, fend, env);
@@ -342,6 +358,8 @@ Utils.lexicalFormTerm = function(term, ns) {
} else if(term.token === 'literal') {
return {'literal': Utils.lexicalFormLiteral(term, ns)};
} else if(term.token === 'blank') {
+ var label = '_:'+ns.blank;
+ ns.blank = ns.blank+1;
return {'blank': label};
} else {
callback(false, 'Token of kind '+term.token+' cannot transformed into its lexical form');

0 comments on commit 8f22171

Please sign in to comment.