You are viewing a plain text version of this content. The canonical link for it is here.
Posted to triplesoup-commits@incubator.apache.org by le...@apache.org on 2007/04/13 08:56:16 UTC

svn commit: r528394 [34/35] - in /incubator/triplesoup/donations/TRIPLES-3-RDFStore: ./ dbms/ dbms/client/ dbms/client/t/ dbms/dbmsproxy/ dbms/deamon/ dbms/doc/ dbms/include/ dbms/libdbms/ dbms/utils/ doc/ include/ lib/ lib/DBD/ lib/RDFStore/ lib/RDFSt...

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-6-02
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-6-02?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-6-02 (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-6-02 Fri Apr 13 01:56:01 2007
@@ -0,0 +1,7 @@
+/*
+ * Test 6-02 : Multiple bindiings in one pattern
+ */
+
+SELECT *
+SOURCE <model4.nt>
+WHERE  (?x, ?x, ?x)

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-6-03
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-6-03?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-6-03 (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-6-03 Fri Apr 13 01:56:01 2007
@@ -0,0 +1,7 @@
+/*
+ * Test 6-03 : Multiple bindiings in one pattern
+ */
+
+SELECT *
+SOURCE <model4.nt>
+WHERE  (?z, ?x, ?x)

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-6-04
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-6-04?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-6-04 (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-6-04 Fri Apr 13 01:56:01 2007
@@ -0,0 +1,7 @@
+/*
+ * Test 6-04 : Multiple bindiings in one pattern
+ */
+
+SELECT *
+SOURCE <model4.nt>
+WHERE  (?x, ?z, ?x)

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-7-01
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-7-01?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-7-01 (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/rdql-tests/test-7-01 Fri Apr 13 01:56:01 2007
@@ -0,0 +1,10 @@
+SELECT ?x, ?t, ?c, ?o
+
+WHERE   ( ?x, <dc:title>, ?t),
+	( ?x, <dc:creator>, ?c),
+        ( ?c, <eg:homePage>, <http://purl.org/net/eric/>),
+        ( ?c, <eg:worksFor>, ?o)
+
+USING	dc FOR <http://purl.org/dc/1.1/>,
+	eg FOR <http://example.com/vocab/foaf/>
+

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify.xml
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify.xml?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify.xml (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify.xml Fri Apr 13 01:56:01 2007
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<rdf:RDF
+     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:a="http://description.org/schema/">
+     <rdf:Description>
+       <rdf:subject resource="http://www.w3.org/Home/Lassila" />
+       <rdf:predicate resource="http://description.org/schema/Creator" />
+       <rdf:object>Ora Lassila</rdf:object>
+       <rdf:type resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement" />
+       <a:attributedTo>Ralph Swick</a:attributedTo>
+     </rdf:Description>
+   </rdf:RDF>

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify1.xml
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify1.xml?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify1.xml (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify1.xml Fri Apr 13 01:56:01 2007
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<rdf:RDF
+     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:a="http://description.org/schema/">
+     <rdf:Description bagID="123">
+       <a:attributedTo>Ralph Swick</a:attributedTo>
+     </rdf:Description>
+   </rdf:RDF>

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify2.xml
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify2.xml?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify2.xml (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify2.xml Fri Apr 13 01:56:01 2007
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<rdf:RDF
+     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:s="http://description.org/schema/">
+<rdf:Description rdf:about="http://www.w3.org/Home/Lassila">
+      <s:Creator>Ora Lassila</s:Creator>
+      <s:Title>Ora's Home Page</s:Title>
+    </rdf:Description>
+   </rdf:RDF>

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify3.xml
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify3.xml?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify3.xml (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/t/reify3.xml Fri Apr 13 01:56:01 2007
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<rdf:RDF
+     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:s="http://description.org/schema/">
+<rdf:Description rdf:about="http://www.w3.org/Home/Lassila" bagID="D_001">
+      <s:Creator>Ora Lassila</s:Creator>
+      <s:Title>Ora's Home Page</s:Title>
+    </rdf:Description>
+   </rdf:RDF>

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/.cvsignore
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/.cvsignore?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/.cvsignore (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/.cvsignore Fri Apr 13 01:56:01 2007
@@ -0,0 +1,4 @@
+Makefile
+*.o
+*.core
+*.gmon

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/Makefile
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/Makefile?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/Makefile (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/Makefile Fri Apr 13 01:56:01 2007
@@ -0,0 +1,39 @@
+# *
+# *     Copyright (c) 2000-2006 Alberto Reggiori <ar...@webweaving.org>
+# *                        Dirk-Willem van Gulik <di...@webweaving.org>
+# *
+# * NOTICE
+# *
+# * This product is distributed under a BSD/ASF like license as described in the 'LICENSE'
+# * file you should have received together with this source code. If you did not get a
+# * a copy of such a license agreement you can pick up one at:
+# *
+# *     http://rdfstore.sourceforge.net/LICENSE
+# *
+# * 
+TFILE=`date +%Y-%m-%d`
+
+include ../dbms/arch.conf
+
+OBJS = ../dbms/libdbms/libdbms.o ../rdfstore_flat_store.o ../rdfstore_kernel.o ../rdfstore_bits.o ../rdfstore_utf8.o ../rdfstore_xsd.o ../rdfstore_digest.o ../rdfstore_ap_sha1.o ../rdfstore_compress.o ../rdfstore_log.o ../rdfstore_iterator.o  ../rdfstore_serializer.o ../sflcomp.o ../my_compress.o ../fraenkel_compress.o ../backend_bdb_store.o ../backend_dbms_store.o ../backend_caching_store.o
+
+
+all:	mytest mytest1 myingest
+
+test:	all
+	./mytest || exit 1
+	./mytest1 || exit 1
+	./myingest test.triples || exit 1
+
+clean:
+	rm -f mytest mytest1 myingest myingest.core mytest.core mytest1.core mytest.gmon mytest1.gmon
+
+mytest: Makefile mytest.c
+	$(CC) $(CFLAGS) $(INCLUDES) -I ../dbms/include -I ../dbms/client $(DEFINES) $(LIBS_DIR) $(OBJS)  -o mytest mytest.c
+
+mytest1: Makefile mytest1.c
+	$(CC) $(CFLAGS) $(INCLUDES) -I ../dbms/include -I ../dbms/client $(DEFINES) $(LIBS_DIR) $(OBJS)  -o mytest1 mytest1.c
+
+myingest: Makefile myingest.c
+	$(CC) $(CFLAGS) $(INCLUDES) -I ../dbms/include -I ../dbms/client $(DEFINES) $(LIBS_DIR) $(OBJS)  -o myingest myingest.c
+

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/README
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/README?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/README (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/README Fri Apr 13 01:56:01 2007
@@ -0,0 +1,26 @@
+README
+	This file
+mytest.c
+	Flat store/retrive test either for in-memory, local or remote BDB
+
+	to compile it:
+
+	( cd .. ; make ; cc -I /usr/local/BerkeleyDB-4.0.14/include/ -I /usr/include/ -I /usr/local/include/ -I ../dbms/include -I ../dbms/client -I ../include -g -pipe -pipe -fno-common -no-cpp-precomp -flat_namespace -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing -O3 -DVERSION=\"0.50\" -DXS_VERSION=\"0.50\" -I/System/Library/Perl/darwin/CORE -D_NOT_CORE -DSTATIC_BUFF -DSTATIC_CS_BUFF -DSTATIC_SC_BUFF ../dbms/libdbms/libdbms.o ../rdfstore_flat_store.o ../rdfstore_kernel.o ../rdfstore_bits.o ../rdfstore_utf8.o ../rdfstore_digest.o ../ap_sha1.o ../rdfstore_compress.o ../rdfstore_log.o ../rdfstore_iterator.o -L/usr/local/BerkeleyDB-4.0.14/lib/ -ldb -o mytest mytest.c )
+
+mytest1.c
+	RDF store/retrieve test
+
+	to compile it:
+
+	( cd .. ; make ; cc -I /usr/local/BerkeleyDB-4.0.14/include/ -I /usr/include/ -I /usr/local/include/ -I ../dbms/include -I ../dbms/client -I ../include -g -pipe -pipe -fno-common -no-cpp-precomp -flat_namespace -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing -O3 -DVERSION=\"0.50\" -DXS_VERSION=\"0.50\" -I/System/Library/Perl/darwin/CORE -D_NOT_CORE -DSTATIC_BUFF -DSTATIC_CS_BUFF -DSTATIC_SC_BUFF ../dbms/libdbms/libdbms.o ../rdfstore_flat_store.o ../rdfstore_kernel.o ../rdfstore_bits.o ../rdfstore_utf8.o ../rdfstore_digest.o ../ap_sha1.o ../rdfstore_compress.o ../rdfstore_log.o ../rdfstore_iterator.o ../rdfstore_serializer.o -L/usr/local/BerkeleyDB-4.0.14/lib/ -ldb -o mytest1 mytest1.c )
+
+utftest.c
+	UTF8 case folding test
+bittest.c
+	Test routines used during development.
+	Compile with
+		gcc -o bittest bittest.c ../bits.o
+	Run as
+		./bittest |more
+
+$Id: README,v 1.8 2003/05/05 17:57:46 areggiori Exp $

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/bittest.c
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/bittest.c?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/bittest.c (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/bittest.c Fri Apr 13 01:56:01 2007
@@ -0,0 +1,121 @@
+#include <assert.h>
+
+void printbits( unsigned int size, unsigned char * bits, int type)
+{
+	int k=0,i,j;
+	if (type == 1) {
+	for(i=0;i<size;i++) {
+		for(j=0;j<8;j++)  { if (k % 10 == 0) 
+			printf("%d",k/10); else printf(" ");
+		k++;
+		};
+	};
+	printf("\n");
+	for(k=0,i=0;i<size;i++) {
+		for(j=0;j<8;j++)  {
+			printf("%d",k%10);
+		k++;
+		};
+	};
+	printf("\n");
+	};
+	for(i=0;i<size;i++) {
+		for(j=0;j<8;j++) 
+			printf("%c",(bits[i] & (1<<j)) ? '1' : '0');
+	};
+	printf("\n");
+}
+
+int main(int argc, char ** argv ) {
+	unsigned char bits[] = { 1,229,3,127,12,9,255,0,128 };
+	unsigned char bits2[] = { 12,3,45,123,89,3 };
+	unsigned char bits3[100];
+	int at,l;
+
+	printf("GetFirstSetAfter\n");
+	printbits(sizeof(bits),bits,1);
+	at = 0;
+	while ((at = rdfstore_bits_getfirstsetafter(sizeof(bits),bits,at)) < 8*sizeof(bits)) {
+		int i;
+		for(i=0;i<at;i++) printf(" ");
+		printf("1 @ %d\n",at);
+		at++;
+	};
+
+	printf("getfirstrecord - mask = 1\n");
+	at = 0;
+	while ((at = rdfstore_bits_getfirstrecord(sizeof(bits),bits,at,1)) < sizeof(bits) * 2) {
+		int i;
+		printbits(sizeof(bits),bits,2);
+		for(i=0;i<at*4;i++) printf(" ");
+		printf("1000 @ %d\n",at);
+		at++;
+	};
+
+	printf("getfirstrecord - mask = 10\n");
+	at = 0;
+	while ((at = rdfstore_bits_getfirstrecord(sizeof(bits),bits,at,10)) < sizeof(bits) * 2) {
+		int i;
+		printbits(sizeof(bits),bits,2);
+		for(i=0;i<at*4;i++) printf(" ");
+		printf("0101 @ %d\n\n",at);
+		at++;
+	};
+
+	printf("getfirstrecord - mask = 0xf\n");
+	at = 0;
+	while ((at = rdfstore_bits_getfirstrecord(sizeof(bits),bits,at,0xf)) < sizeof(bits) * 2) {
+		int i;
+		printbits(sizeof(bits),bits,2);
+		for(i=0;i<at*4;i++) printf(" ");
+		printf("1111 @ %d\n",at);
+		at++;
+	};
+
+	printf("isanyset()- mask = 1\n");
+	at = 0;
+	l = sizeof(bits);
+	while (rdfstore_bits_isanyset(&l,bits,&at,1)) {
+		int i;
+		printbits(sizeof(bits),bits,2);
+		for(i=0;i<at;i++) printf(" ");
+		printf("1 @ %d\n\n",at);
+		at++;
+	};
+
+	printf("\nAND\n");
+	printf("A   =");
+	printbits(sizeof(bits),bits,2);
+	printf("B   =");
+	printbits(sizeof(bits2),bits2,2);
+	l = rdfstore_bits_and(sizeof(bits),bits,sizeof(bits2),bits2,bits3);
+	printf("A&B =");
+	printbits(l,bits3,2);
+	l = rdfstore_bits_and(sizeof(bits2),bits2,sizeof(bits),bits,bits3);
+	printf("B&A =");
+	printbits(l,bits3,2);
+	printf("\nOR\n");
+	printf("A   =");
+	printbits(sizeof(bits),bits,2);
+	printf("B   =");
+	printbits(sizeof(bits2),bits2,2);
+	l = rdfstore_bits_or(sizeof(bits),bits,sizeof(bits2),bits2,bits3);
+	printf("A|B =");
+	printbits(l,bits3,2);
+	l = rdfstore_bits_or(sizeof(bits2),bits2,sizeof(bits),bits,bits3);
+	printf("B|A =");
+	printbits(l,bits3,2);
+	printf("\nEXOR\n");
+	printf("A   =");
+	printbits(sizeof(bits),bits,2);
+	printf("B   =");
+	printbits(sizeof(bits2),bits2,2);
+	l = rdfstore_bits_exor(sizeof(bits),bits,sizeof(bits2),bits2,bits3);
+	printf("A^B =");
+	printbits(l,bits3,2);
+	l = rdfstore_bits_exor(sizeof(bits2),bits2,sizeof(bits),bits,bits3);
+	printf("B^A =");
+	printbits(l,bits3,2);
+
+}
+

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/dbstats.c
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/dbstats.c?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/dbstats.c (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/dbstats.c Fri Apr 13 01:56:01 2007
@@ -0,0 +1,34 @@
+#include <sys/types.h>
+#include <db.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+
+int main(int argc, char ** argv) {
+	DB * db;
+	DBT k, v;
+	int i = 0;
+
+	if (argc != 2) {
+		fprintf(stderr,"usage: %s <dbfilename>",argv[0]);
+		exit(1);
+	}
+
+	db = dbopen(argv[1], 0, DB_BTREE, 0, NULL);
+	if(!(db)) {
+		perror("Failed to open db");
+		exit(1);
+	};
+
+	printf("#\tkey\tval\n");
+	while((db->seq)(db,&k, &v, i ? R_FIRST : R_NEXT) == 0) {
+		printf("%06d\t%d\t%d\n", i, k.size, v.size);
+		i++;
+	}
+}

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/myingest.c
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/myingest.c?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/myingest.c (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/myingest.c Fri Apr 13 01:56:01 2007
@@ -0,0 +1,181 @@
+#include <sys/types.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <time.h>
+
+/*#include <sys/syslimits.h>*/
+#if !defined(WIN32)
+#include <sys/param.h>
+#endif
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/errno.h>
+#include <sys/uio.h>
+
+#include "rdfstore.h"
+#include "rdfstore_log.h"
+#include "rdfstore_utf8.h"
+#include "rdfstore_serializer.h"
+
+extern char *optarg;
+
+int main ( int argc, char * * argv ) {
+	rdfstore * me;
+	DBT key, data, data1;
+	int c, ch;
+	char * db = "cooltest";
+	char * host = NULL;
+	long int ttime=0,ltime=0;
+	struct timeval tstart,tnow;
+	int line = 0;
+	int freetext = 0, sync = 0, remote = 0;
+	FILE * f;
+
+	gettimeofday(&tstart,NULL);	
+
+	while ((ch = getopt(argc, argv, "fmd:")) != -1)
+             switch (ch) {
+             case 'f':
+                     freetext = 1;
+                     break;
+             case 'm':
+                     db = NULL;
+                     break;
+             case 'd':
+                     db = optarg;
+                     break;
+             case 'r':
+		     remote = 1; 
+                     host = optarg;
+                     break;
+             case '?':
+             default:
+                     fprintf(stderr,"%s: Usage [-f] [-m] [-d dbase] [-r host]\n",argv[0]);
+     }
+     	argc -= optind;
+     	argv += optind;
+
+	if (argc == 1)
+		f = fopen(argv[0],"r");
+	else
+		f = stdin;
+
+	memset(&key, 0, sizeof(key));
+        memset(&data, 0, sizeof(data));
+        memset(&data1, 0, sizeof(data1));
+
+        if ( rdfstore_connect( &me, db, 0, freetext, sync, remote, host,0,NULL,NULL,NULL,NULL ) != 0 ) {
+		printf("Cannot connect :( \n");
+		return -1;
+	};
+
+	c=0;
+	while(!feof(f)) {
+		char buff[102400];
+		char * v[3], *p;
+		int vi =0;
+		int t0,t1,t2;
+		RDF_Statement statement;
+		RDF_Node subject, object, predicate;
+		
+		/* Assume value <space> value <space> value 
+	 	 * and values can be "-ed. 
+		 */
+		if (fgets(buff,sizeof(buff),f) == NULL) 
+			exit(1);
+		line++;
+		for(p=buff;*p;p++) {
+			char * e;
+
+			if (isspace(*p)) 
+				continue;
+
+			if (*p == '"') {
+				p++;
+				if ((e = index(p,'"'))==NULL) {
+					fprintf(stderr,"no closing \" at line %d\n",line);
+					exit(1);
+				};
+			} else  {
+				if ((e = index(p,' '))==NULL) 
+					e = p+strlen(p)-1;
+			};
+			*e = '\0';
+			if (vi<3)
+				v[ vi ] = p;
+			vi++;
+			p=e;
+		};
+		if (vi != 3) {
+			fprintf(stderr,"not 3 but %d items at line %d\n",vi,line);
+			exit(1);
+		};
+
+		t0=t1=t2=1; 	/* assume all literals*/
+
+		if (v[0][0]=='<') { v[0]++; v[0][strlen(v[0])-1]='\0'; t0=0; };
+		if (v[1][0]=='<') { v[1]++; v[1][strlen(v[1])-1]='\0'; t1=0;};
+		if (v[2][0]=='<') { v[2]++; v[2][strlen(v[2])-1]='\0'; t2=0; };
+
+		if (0) printf("Triple: '%s','%s','%s'\n", v[0],v[1],v[2]);
+
+		statement.subject = &subject;
+		statement.predicate = &predicate;
+		statement.object = &object;
+		statement.node = NULL;
+		statement.context = NULL;
+
+		subject.value.resource.identifier = v[0];
+		subject.value.resource.identifier_len = strlen(v[0]);
+		statement.hashcode = 0;
+		statement.isreified = 0;
+
+		subject.hashcode = 0;
+		subject.type =  t0;
+assert(!t0);
+assert(!t1);
+		predicate.value.resource.identifier = v[1];
+		predicate.value.resource.identifier_len = strlen(v[1]);
+		predicate.hashcode = 0;
+		predicate.type = t1;
+
+		object.hashcode = 0;
+		object.type = t2;
+		if (t2) {
+			object.value.literal.string = v[2];
+			object.value.literal.string_len = strlen(v[2]);
+			object.value.literal.parseType = 0;
+			object.value.literal.dataType = NULL;
+       			strcpy(object.value.literal.lang,"");	/* lang is not a ptr, but a char lang[10] */
+		} else {
+			object.value.resource.identifier = v[2];
+			object.value.resource.identifier_len = strlen(v[2]);
+		}
+
+		if(rdfstore_insert( me, &statement, NULL )) {
+                	fprintf(stderr,"cannot insert statement\n");
+                	return -1;
+        		};
+
+#define DD (100)
+		if( (c++ % DD) == 0 ) {
+			gettimeofday(&tnow,NULL);
+        		ttime = ( tnow.tv_sec - tstart.tv_sec ) * 1000.0 + ( tnow.tv_usec - tstart.tv_usec ) / 1000.0;
+			printf("adding %d [%.1f sec, %.2f/second overall - %.2f/second now]\n",c,ttime/1000.0,1000.0*c/ttime,1000.0*DD/(ttime-ltime));
+			ltime=ttime;
+			};
+		};
+
+	rdfstore_disconnect( me );
+
+	return 0;
+};

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/mytest.c
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/mytest.c?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/mytest.c (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/mytest.c Fri Apr 13 01:56:01 2007
@@ -0,0 +1,177 @@
+#include <sys/types.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <time.h>
+
+/*#include <sys/syslimits.h>*/
+#if !defined(WIN32)
+#include <sys/param.h>
+#endif
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/errno.h>
+#include <sys/uio.h>
+
+#include "rdfstore_log.h"
+#include "rdfstore.h"
+
+static const char * _sp(DBT t) {
+	char out[1024];
+	char tmp[16];
+	int i;
+
+	out[0]='\0';
+	for(i=0;i<t.size && i<(sizeof(out)-1)/4;i++) {
+		int c = ((unsigned char *)(t.data))[i];
+		if (c<32 || c > 127) {
+			snprintf(tmp,sizeof(tmp),"/%02x/",c);
+		} else {
+			snprintf(tmp,sizeof(tmp),"%c",c);
+		}
+		strcat(out,tmp);
+	}
+	return strdup(out);
+}
+
+static const int _si(DBT t) {
+	return (int)((int *)(t.data))[0];
+}
+
+int main ( int argc, char * * argv ) {
+	rdfstore * me;
+	DBT key, data, data1;
+	int i;
+	int test;
+		
+	test = -1234568;
+
+	memset(&key, 0, sizeof(key));
+        memset(&data, 0, sizeof(data));
+        memset(&data1, 0, sizeof(data1));
+
+	rdfstore_connect( &me, "cooltest", 0, 0, 0, 0, NULL,0,NULL,NULL,NULL,NULL );
+
+	/* store */
+        key.data = "memyselfI";
+        key.size = sizeof("memyselfI");
+        data.data = "Albe";
+        data.size = strlen("Albe")+1;
+
+	if( (rdfstore_flat_store_store( me->model, key, data )) != 0 )
+		printf("Cannot store %s = %d\n",_sp(key),_si(data));
+
+	if(rdfstore_flat_store_exists( me->model, key ) == 0 ) {
+		printf("Ok key %s does exist\n",_sp(key));
+	} else {
+		printf("Ok key %s does NOT exist\n",_sp(key));
+	};
+
+	/* fetch */
+	if( (rdfstore_flat_store_fetch( me->model, key, &data1 )) != 0 ) {
+		printf("Cannot fetch %s \n",_sp(key));
+	} else {
+		RDFSTORE_FREE( data1.data ) ;
+		};
+
+	printf("Fetched '%s'\n",_sp(data1));
+
+        key.data = "you";
+        key.size = sizeof("you");
+        data.data = "Albe";
+        data.size = strlen("Albe")+1;
+
+	if( (rdfstore_flat_store_store( me->model, key, data )) != 0 )
+		printf("Cannot store %s = %d\n",_sp(key),_si(data));
+
+        key.data = "counter";
+        key.size = sizeof("counter");
+        data.data = "0";
+        data.size = strlen("0")+1;
+
+	if( (rdfstore_flat_store_store( me->model, key, data )) != 0 )
+		printf("Cannot store %s = %d\n",_sp(key),_si(data));
+
+	/* fetch */
+	if( (rdfstore_flat_store_fetch( me->model, key, &data1 )) != 0 ) {
+		printf("Cannot fetch %s \n",_sp(key));
+	} else {
+		RDFSTORE_FREE( data1.data ) ;
+		};
+
+	printf("Fetched '%s'\n",_sp(data1));
+
+	for ( i = 0; i <10000 ; i++ ) {
+		/* inc */
+		if( (rdfstore_flat_store_inc( me->model, key, &data1 )) != 0 ) {
+			printf("Cannot inc %s \n",_sp(key));
+		} else {
+			RDFSTORE_FREE( data1.data ) ;
+			};
+	};
+
+	/* fetch */
+	if( (rdfstore_flat_store_fetch( me->model, key, &data1 )) != 0 ) {
+		printf("Cannot fetch %s \n",_sp(key));
+	} else {
+		RDFSTORE_FREE( data1.data ) ;
+		};
+
+	printf("Fetched '%s'\n",_sp(data1));
+
+	for ( i = 0; i <9999 ; i++ ) {
+		/* dec */
+		if( (rdfstore_flat_store_dec( me->model, key, &data1 )) != 0 ) {
+			printf("Cannot dec %s \n",_sp(key));
+		} else {
+			RDFSTORE_FREE( data1.data ) ;
+			};
+	};
+
+	/* NOTE: garbage collection of first and next is not done here */
+	/* first */
+	if( (rdfstore_flat_store_first( me->model, &data1 )) != 0 ) {
+		printf("Cannot first \n");
+		};
+
+	/* next */
+	while (rdfstore_flat_store_next( me->model, data1, &data ) == 0 ) {
+		printf("GOT %s\n",_sp(data));
+	};
+
+	if(rdfstore_flat_store_exists( me->model, key ) == 0 ) {
+		printf("Ok key %s does exist\n",_sp(key));
+	} else {
+		printf("Ok key %s does NOT exist\n",_sp(key));
+	};
+
+	/* delete */
+	if( rdfstore_flat_store_delete ( me->model, key ) != 0 )
+		printf("Cannot delete %s \n",_sp(key));
+
+	if( rdfstore_flat_store_clear ( me->model ) != 0 )
+		printf("Cannot clear \n");
+
+        key.data = "you";
+        key.size = sizeof("you");
+	if(rdfstore_flat_store_exists( me->model, key ) == 0 ) {
+		printf("Ok key %s does exist\n",_sp(key));
+	} else {
+		printf("Ok key %s does NOT exist\n",_sp(key));
+	};
+
+	if( rdfstore_flat_store_sync ( me->model ) != 0 )
+		printf("Cannot sync \n");
+
+	rdfstore_disconnect( me );
+
+	return 0;
+};

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/mytest1.c
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/mytest1.c?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/mytest1.c (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/mytest1.c Fri Apr 13 01:56:01 2007
@@ -0,0 +1,221 @@
+#include <sys/types.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <time.h>
+
+/*#include <sys/syslimits.h>*/
+#if !defined(WIN32)
+#include <sys/param.h>
+#endif
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/errno.h>
+#include <sys/uio.h>
+
+#include "rdfstore.h"
+#include "rdfstore_log.h"
+#include "rdfstore_serializer.h"
+#include "rdfstore_utf8.h"
+
+int main ( int argc, char * * argv ) {
+	rdfstore * me;
+	DBT key, data, data1;
+	int i,n=6000;
+	RDF_Statement * statement;
+	long int ttime=0;
+	struct timeval tstart,tnow;
+
+	gettimeofday(&tstart,NULL);	
+
+	if (argc == 2)
+		n = atoi(argv[1]);
+
+	memset(&key, 0, sizeof(key));
+        memset(&data, 0, sizeof(data));
+        memset(&data1, 0, sizeof(data1));
+
+	/* rdfstore_connect( &me, NULL, 0, 1, 0, 0, NULL,0 );*/
+	/*if ( rdfstore_connect( &me, "cooltest", 0, 1, 0, 1, "localhost",1234 ) != 0 ) */
+	/*if ( rdfstore_connect( &me, NULL, 0, 0, 0, 0, NULL,0,NULL,NULL,NULL,NULL ) != 0 ) */
+	/* if ( rdfstore_connect( &me, "cooltest", 0, 1, 0, 0, NULL,0,NULL,NULL,NULL,NULL ) != 0 ) */
+	/*if ( rdfstore_connect( &me, NULL, 0, 1, 0, 0, NULL,0,NULL,NULL,NULL,NULL ) != 0 )*/
+	/*if ( rdfstore_connect( &me, NULL, 0, 0, 0, 0, NULL,0,NULL,NULL,NULL,NULL ) != 0 )*/
+	if ( rdfstore_connect( &me, "cooltest", 0, 0, 0, 0, NULL,0,NULL,NULL,NULL,NULL ) != 0 )
+
+	{
+		printf("Cannot connect :( \n");
+		return -1;
+		};
+
+/*
+	if(rdfstore_is_empty( me )) {
+		printf("rdfstore should be empty!\n");
+		return -1;
+	};
+*/
+
+
+	for ( i=1; i<n+1; i++ ) {
+		#define BZ(x) { if ((x)==NULL) { fprintf(stderr,"No memory"); exit(1); }; bzero((x),sizeof(*(x))); }
+
+		statement = (RDF_Statement *) RDFSTORE_MALLOC(sizeof(RDF_Statement));
+		BZ(statement);
+
+		statement->context = NULL;
+		statement->hashcode = 0;
+		statement->isreified = 0;
+
+		statement->subject = (RDF_Node *) RDFSTORE_MALLOC(sizeof(RDF_Node));
+		BZ(statement->subject);
+
+		statement->subject->hashcode = 0;
+		statement->subject->type = 0;
+
+		statement->predicate = (RDF_Node *) RDFSTORE_MALLOC(sizeof(RDF_Node));
+		BZ(statement->predicate);
+
+		statement->predicate->hashcode = 0;
+		statement->predicate->type = 0;
+
+		statement->object = (RDF_Node *) RDFSTORE_MALLOC(sizeof(RDF_Node));
+		BZ(statement->object);
+
+		statement->object->hashcode = 0;
+		statement->object->type = 1; /* literal */
+		statement->node = NULL;
+			
+		statement->subject->value.resource.identifier = (char *) RDFSTORE_MALLOC(sizeof(char)*255);
+		sprintf(statement->subject->value.resource.identifier,
+			"http://www.w3.org/Home/Lassila/Creator%09d",i);
+		statement->subject->value.resource.identifier_len = strlen(statement->subject->value.resource.identifier);
+
+		statement->predicate->value.resource.identifier = (char *) RDFSTORE_MALLOC(sizeof(char)*255);
+		strcpy(statement->predicate->value.resource.identifier,
+			"http://description.org/schema/Creator");
+		statement->predicate->value.resource.identifier_len = strlen(statement->predicate->value.resource.identifier);
+
+		statement->object->value.literal.string = (char *) RDFSTORE_MALLOC(sizeof(char)*255);
+		sprintf(statement->object->value.literal.string,
+			"Ora Lassila %09d",i);
+		statement->object->value.literal.string_len = strlen(statement->object->value.literal.string);
+
+		statement->object->value.literal.parseType = 0;
+		statement->object->value.literal.dataType = NULL;
+		strcpy(statement->object->value.literal.lang,"");
+
+/*
+		ntriple = rdfstore_ntriples_statement( statement, NULL );
+		if ( ntriple != NULL ) {
+			printf("%s\n",ntriple);
+			RDFSTORE_FREE( ntriple );
+			};
+*/
+
+		if(rdfstore_insert( me, statement, NULL )) {
+                	fprintf(stderr,"cannot insert statement\n");
+                	return -1;
+        		};
+
+		RDFSTORE_FREE( statement->object->value.literal.string );
+		RDFSTORE_FREE( statement->object );
+		RDFSTORE_FREE( statement->predicate->value.resource.identifier );
+		RDFSTORE_FREE( statement->predicate );
+		RDFSTORE_FREE( statement->subject->value.resource.identifier );
+		RDFSTORE_FREE( statement->subject );
+		RDFSTORE_FREE( statement );
+
+		if( (i % 100) == 0 || (i == n)) {
+			gettimeofday(&tnow,NULL);
+        		ttime += ( tnow.tv_sec - tstart.tv_sec ) * 1000000 + ( tnow.tv_usec - tstart.tv_usec ) * 1;
+        		/*ttime = ( tnow.tv_sec - tstart.tv_sec ) * 1000000 + ( tnow.tv_usec - tstart.tv_usec ) * 1;*/
+			printf("adding\t%d\t[%8d sec, %.02f #/sec]\n",i,(int)(ttime/1000000), 1000000.0*i/ttime);
+
+			gettimeofday(&tstart,NULL);	
+		};
+	};
+
+	exit(1);
+	for ( i=1; i<n+1; i++ ) {
+		#define BZ(x) { if ((x)==NULL) { fprintf(stderr,"No memory"); exit(1); }; bzero((x),sizeof(*(x))); }
+
+		statement = (RDF_Statement *) RDFSTORE_MALLOC(sizeof(RDF_Statement));
+		BZ(statement);
+
+		statement->context = NULL;
+		statement->hashcode = 0;
+		statement->isreified = 0;
+
+		statement->subject = (RDF_Node *) RDFSTORE_MALLOC(sizeof(RDF_Node));
+		BZ(statement->subject);
+
+		statement->subject->hashcode = 0;
+		statement->subject->type = 0;
+
+		statement->predicate = (RDF_Node *) RDFSTORE_MALLOC(sizeof(RDF_Node));
+		BZ(statement->predicate);
+
+		statement->predicate->hashcode = 0;
+		statement->predicate->type = 0;
+
+		statement->object = (RDF_Node *) RDFSTORE_MALLOC(sizeof(RDF_Node));
+		BZ(statement->object);
+
+		statement->object->hashcode = 0;
+		statement->object->type = 1; /* literal */
+		statement->node = NULL;
+			
+		statement->subject->value.resource.identifier = (char *) RDFSTORE_MALLOC(sizeof(char)*255);
+		sprintf(statement->subject->value.resource.identifier,
+			"http://www.w3.org/Home/Lassila/Creator%09d",i);
+		statement->subject->value.resource.identifier_len = strlen(statement->subject->value.resource.identifier);
+
+		statement->predicate->value.resource.identifier = (char *) RDFSTORE_MALLOC(sizeof(char)*255);
+		strcpy(statement->predicate->value.resource.identifier,
+			"http://description.org/schema/Creator");
+		statement->predicate->value.resource.identifier_len = strlen(statement->predicate->value.resource.identifier);
+
+		statement->object->value.literal.string = (char *) RDFSTORE_MALLOC(sizeof(char)*255);
+		sprintf(statement->object->value.literal.string,
+			"Ora Lassila %09d",i);
+		statement->object->value.literal.string_len = strlen(statement->object->value.literal.string);
+
+		statement->object->value.literal.parseType = 0;
+		statement->object->value.literal.dataType = NULL;
+		strcpy(statement->object->value.literal.lang,"");
+
+		if(rdfstore_remove( me, statement, NULL )) {
+                	printf("cannot remove statement\n");
+                	return -1;
+        		};
+
+		RDFSTORE_FREE( statement->object->value.literal.string );
+		RDFSTORE_FREE( statement->object );
+		RDFSTORE_FREE( statement->predicate->value.resource.identifier );
+		RDFSTORE_FREE( statement->predicate );
+		RDFSTORE_FREE( statement->subject->value.resource.identifier );
+		RDFSTORE_FREE( statement->subject );
+		RDFSTORE_FREE( statement );
+
+		if( (i % 100) == 0 || (i == n)) {
+			gettimeofday(&tnow,NULL);
+        		ttime += ( tnow.tv_sec - tstart.tv_sec ) * 1000000 + ( tnow.tv_usec - tstart.tv_usec ) * 1;
+        		/*ttime = ( tnow.tv_sec - tstart.tv_sec ) * 1000000 + ( tnow.tv_usec - tstart.tv_usec ) * 1;*/
+			printf("removing %d [%d sec]\n",i,(int)(ttime/1000000));
+
+			gettimeofday(&tstart,NULL);	
+		};
+	};
+
+	rdfstore_disconnect( me );
+
+	return 0;
+};

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/test.triples
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/test.triples?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/test.triples (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/test.triples Fri Apr 13 01:56:01 2007
@@ -0,0 +1,4 @@
+<http://www.w3.org/Home/Lassila/Creator1> <http://description.org/schema/Creator> "Ora Lassila 1"
+<http://www.w3.org/Home/Lassila/Creator2> <http://description.org/schema/Creator> "Ora Lassila 2"
+<http://www.w3.org/Home/Lassila/Creator3> <http://description.org/schema/Creator> <ma...@bar.com>
+<http://www.w3.org/Home/Lassila/Creator4> <http://description.org/schema/Creator> "Ora Lassila 4"

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/utftest.c
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/utftest.c?view=auto&rev=528394
==============================================================================
Binary file - no diff available.

Propchange: incubator/triplesoup/donations/TRIPLES-3-RDFStore/test/utftest.c
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/typemap
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/typemap?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/typemap (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/typemap Fri Apr 13 01:56:01 2007
@@ -0,0 +1,21 @@
+TYPEMAP
+dbms_xsmode_t					T_INT
+unsigned int *					T_PTROBJ
+RDFStore					T_PTROBJ
+RDFStore_Iterator				T_PTROBJ
+RDFStore_RDFNode				T_PTROBJ
+RDFStore_Statement				T_PTROBJ
+RDFStore_Triple_Pattern				T_PTROBJ
+
+DBT                     			T_DATUM
+DBMS                    			T_PTROBJ
+
+INPUT
+T_DATUM
+        $var.data = SvPV($arg, PL_na);
+        $var.size = (int)PL_na;
+
+OUTPUT
+T_DATUM
+        sv_setpvn($arg, $var.data, $var.size);
+        if ($var.data && $var.size) safefree($var.data);

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/.cvsignore
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/.cvsignore?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/.cvsignore (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/.cvsignore Fri Apr 13 01:56:01 2007
@@ -0,0 +1,2 @@
+Makefile
+gmon.out

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/Makefile
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/Makefile?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/Makefile (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/Makefile Fri Apr 13 01:56:01 2007
@@ -0,0 +1,26 @@
+# *
+# *     Copyright (c) 2000-2006 Alberto Reggiori <ar...@webweaving.org>
+# *                        Dirk-Willem van Gulik <di...@webweaving.org>
+# *
+# * NOTICE
+# *
+# * This product is distributed under a BSD/ASF like license as described in the 'LICENSE'
+# * file you should have received together with this source code. If you did not get a
+# * a copy of such a license agreement you can pick up one at:
+# *
+# *     http://rdfstore.sourceforge.net/LICENSE
+# *
+# * 
+TFILE=`date +%Y-%m-%d`
+
+include ../dbms/arch.conf
+
+OBJS = ../dbms/libdbms/libdbms.o ../rdfstore_flat_store.o ../rdfstore_kernel.o ../rdfstore_bits.o ../rdfstore_utf8.o ../rdfstore_xsd.o ../rdfstore_digest.o ../rdfstore_ap_sha1.o ../rdfstore_compress.o ../rdfstore_log.o ../rdfstore_serializer.o ../rdfstore_iterator.o ../sflcomp.o ../my_compress.o ../fraenkel_compress.o ../backend_bdb_store.o ../backend_dbms_store.o ../backend_caching_store.o
+
+all:	db_stats
+
+clean:
+	rm -f db_stats
+
+db_stats: db_stats.c Makefile
+	$(CC) $(CFLAGS) $(INCLUDES) -I ../dbms/include -I ../dbms/client $(DEFINES) $(LIBS_DIR) $(OBJS)  -o db_stats db_stats.c
\ No newline at end of file

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/Makefile.sample
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/Makefile.sample?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/Makefile.sample (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/Makefile.sample Fri Apr 13 01:56:01 2007
@@ -0,0 +1,26 @@
+# *
+# *     Copyright (c) 2000-2006 Alberto Reggiori <ar...@webweaving.org>
+# *                        Dirk-Willem van Gulik <di...@webweaving.org>
+# *
+# * NOTICE
+# *
+# * This product is distributed under a BSD/ASF like license as described in the 'LICENSE'
+# * file you should have received together with this source code. If you did not get a
+# * a copy of such a license agreement you can pick up one at:
+# *
+# *     http://rdfstore.sourceforge.net/LICENSE
+# *
+# * 
+TFILE=`date +%Y-%m-%d`
+
+include ../dbms/arch.conf
+
+OBJS = ../dbms/libdbms/libdbms.o ../rdfstore_flat_store.o ../rdfstore_kernel.o ../rdfstore_bits.o ../rdfstore_utf8.o ../rdfstore_digest.o ../rdfstore_ap_sha1.o ../rdfstore_compress.o ../rdfstore_log.o ../rdfstore_iterator.o
+
+all:	db_stats
+
+clean:
+	rm -f db_stats
+
+db_stats:
+	$(CC) $(CFLAGS) $(INCLUDES) -I ../dbms/include -I ../dbms/client $(DEFINES) $(LIBS_DIR) $(OBJS) -ldb -o db_stats db_stats.c

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/README
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/README?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/README (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/README Fri Apr 13 01:56:01 2007
@@ -0,0 +1,30 @@
+Some general purpose demo/sample routines.
+
+README
+	This file
+
+rdf.pl
+	parses and stores:
+	perl rdf.pl -output_dir /tmp/rdf -storename sample \
+		-stuff ../samples/rdf/example1.xml
+
+rdfquery.pl
+	Queries a store (see rdf.pl above for creating one):
+	perl rdfquery.pl -input_dir /tmp/rdf -storename sample \
+		-query 'SELECT ...'
+
+vocabulary-generator.pl
+	Generates perl package for a give RDF/XML source e.g. RDFStore::Vocabualry:DC
+	for DublinCore http://purl.org/dc/elements/1.1/
+
+db_stats
+	Prints out compressions statistics for rdfstore database 
+
+	to compile use Makefile and type 'make db_stats'
+
+Makefile
+	To compile C utilities
+
+Not documented:
+
+rdfingest.pl

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/db_stats.c
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/db_stats.c?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/db_stats.c (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/db_stats.c Fri Apr 13 01:56:01 2007
@@ -0,0 +1,889 @@
+#include <sys/types.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <time.h>
+
+/*#include <sys/syslimits.h>*/
+#if !defined(WIN32)
+#include <sys/param.h>
+#endif
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/errno.h>
+#include <sys/uio.h>
+
+#include "rdfstore_compress.h"
+#include "rdfstore_flat_store.h"
+#include "rdfstore_log.h"
+#include "rdfstore_iterator.h"
+#include "rdfstore_serializer.h"
+
+
+static const char * _sp(DBT t) {
+        static char out[1024];
+        char tmp[16];
+        int i;
+
+        out[0]='\0';
+        for(i=0;i<t.size && i<(sizeof(out)-1)/4;i++) {
+                int c = ((unsigned char *)(t.data))[i];
+                if (c<32 || c > 127) {
+                        snprintf(tmp,sizeof(tmp),"/%02x/",c);
+                } else {
+                        snprintf(tmp,sizeof(tmp),"%c",c);
+                }
+                strcat(out,tmp);
+        }
+        return out;
+}
+
+/* print some stats (nibbles/bytes) for each index table concerning the compression algorithm used */
+int main ( int argc, char * argv[]) {
+	rdfstore * me;
+	FLATDB  * db;
+	DBT key, data, key1, data1;
+	static unsigned char bits[RDFSTORE_MAXRECORDS_BYTES_SIZE];
+	unsigned int outsize1=0;
+	int i, items, s1,s2;
+	long global_bytes_stats[256];
+	long bytes_stats[256];
+	long global_nibbles_stats[16];
+	long nibbles_stats[16];
+	char * host=NULL;
+	int port=0;
+	char * name=NULL;
+	rdfstore_iterator * results=NULL;
+	RDF_Node * node;
+	char * buff;
+
+	for( i=1; i<argc; i++) {
+                if ((!strcmp(argv[i],"-port")) && (i+1<argc)) {
+			port=atoi(argv[++i]);
+                        if (port<=1) {
+                                fprintf(stderr,"Aborted: You really want a port number >1.\n");
+                                exit(1);
+                                };
+                } else {
+			if ((!strcmp(argv[i],"-host")) && (i+1<argc)) {
+				host = argv[++i];
+                	} else {
+				if (!strcmp(argv[i],"-v")) {
+					fprintf(stderr,"Not implemented yet :)\n");
+					exit(1);
+				} else {
+					char * cc;
+					if ( (!strcmp(argv[i],"-h")) || ( (cc=strchr(argv[i],'-')) && (cc!=NULL) && (cc==argv[i]) ) ) {
+						fprintf(stderr,"Syntax: %s [-host <dbms server name>] [-port <port>] databasename \n",argv[0]);
+						exit(1);
+					} else {
+						/* rest is DB name */
+						name = argv[i];
+						};
+                			};
+				};
+			};
+		};
+	
+	memset(&key, 0, sizeof(key));
+	memset(&key1, 0, sizeof(key1));
+        memset(&data, 0, sizeof(data));
+        memset(&data1, 0, sizeof(data1));
+
+	if ( rdfstore_connect( &me, name, 1, 0, 0, (port || (host!=NULL)) ? 1 : 0, host,port,NULL,NULL,NULL,NULL ) != 0 ) {
+		printf("Cannot connect to %s\n",name);
+		return -1;
+		};
+
+	results = (rdfstore_iterator *) RDFSTORE_MALLOC(sizeof(rdfstore_iterator));
+        if (results == NULL)
+		return -1;
+        results->store = me;
+        results->remove_holes = 0;
+	results->st_counter = 0;
+	results->pos = 0;
+	results->ids_size = 0;
+	results->size = 1; /* just want the first one each time i.e. key ;) */
+
+	/* subjects */
+	db = me->subjects;
+
+	for ( i=0; i<256; i++ ) {
+		global_bytes_stats[i]=0;
+		};
+	for ( i=0; i<16; i++ ) {
+		global_nibbles_stats[i]=0;
+		};
+	/* NOTE: garbage collection of first, fetch and next is not done here */
+	if ( rdfstore_flat_store_first( db, &key ) == 0 ) {
+        	do {
+                	if ( rdfstore_flat_store_fetch( db, key, &data )) {
+                        	outsize1=0;
+				printf("subjects: LENGTH ZERO\n");
+				continue;
+                        	};
+
+			/* Decode bit array */
+                       	me->func_decode( data.size, data.data, &outsize1, bits);
+
+			/* hack ;) */
+			memcpy(results->ids, bits, outsize1);
+			results->ids_size = outsize1;
+
+			if((node=rdfstore_iterator_first_subject(results))!=NULL) {
+				buff=rdfstore_ntriples_node( node );
+				printf("subjects: key=%s\n",buff);
+				RDFSTORE_FREE( buff );
+				RDFSTORE_FREE( node->value.resource.identifier );
+				RDFSTORE_FREE( node );
+			} else {
+				if (key.size == 4) 
+					printf("subjects: key=%x (hex, 4byte int)\n",*(unsigned int *)(key.data));
+				else
+					printf("subjects: key=\"%s\" (len %d)'\n",_sp(key),key.size);
+				};
+
+			items ++;
+			s1 += data.size;
+			s2 += outsize1;
+
+			for ( i=0; i<256; i++ ) {
+				bytes_stats[i]=0;
+				};
+			for ( i=0; i<16; i++ ) {
+				nibbles_stats[i]=0;
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_bytes_stats[bits[i]]++;
+				bytes_stats[bits[i]]++;
+				};
+
+			printf("subjects: val_len_comp   = %d\n",(int)data.size);
+			printf("subjects: val_len_decomp = %d\n",outsize1);
+			printf("subjects: ratio = %f\n",(double)data.size/(double)outsize1);
+			printf("subjects: byte symbols:\n");
+			for ( i=0; i<256; i++ ) {
+				if(bytes_stats[i]>0) {
+					printf("\tb %02X = %d\n",i,(int)bytes_stats[i]);
+					};
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_nibbles_stats[bits[i] & 0x0f]++;
+				global_nibbles_stats[bits[i] >> 4]++;
+				nibbles_stats[bits[i] & 0x0f]++;
+				nibbles_stats[bits[i] >> 4]++;
+				};
+			printf("subjects: nibble symbols:\n");
+			for ( i=0; i<16; i++ ) {
+				if(nibbles_stats[i]>0) {
+					printf("\tn %0X = %d\n",i,(int)nibbles_stats[i]);
+					};
+				};
+			printf("-----------------------------\n");
+        	} while ( rdfstore_flat_store_next( db, key, &key ) == 0 );
+		printf("subjects: Global byte symbols:\n");
+		for ( i=0; i<256; i++ ) {
+			if(global_bytes_stats[i]>0) {
+				printf("\tgb %02X = %d\n",i,(int)global_bytes_stats[i]);
+				};
+			};
+		printf("subjects: Global nibble symbols:\n");
+		for ( i=0; i<16; i++ ) {
+			if(global_nibbles_stats[i]>0) {
+				printf("\tgn %0X = %d\n",i,(int)global_nibbles_stats[i]);
+				};
+			};
+
+		printf("Items in subjects: %d\n",items);
+ 		printf("Total size of subjects: %d (uncompressed %d)\n",s1,s2);
+
+        	};
+
+	/* predicates */
+	db = me->predicates;
+
+	for ( i=0; i<256; i++ ) {
+		global_bytes_stats[i]=0;
+		};
+	for ( i=0; i<16; i++ ) {
+		global_nibbles_stats[i]=0;
+		};
+	/* NOTE: garbage collection of first, fetch and next is not done here */
+	if ( rdfstore_flat_store_first( db, &key ) == 0 ) {
+        	do {
+                	if ( rdfstore_flat_store_fetch( db, key, &data )) {
+                        	outsize1=0;
+				printf("predicates: LENGTH ZERO\n");
+				continue;
+                        	};
+
+			/* Decode bit array */
+                       	me->func_decode( data.size, data.data, &outsize1, bits);
+
+			/* hack ;) */
+                        memcpy(results->ids, bits, outsize1);
+                        results->ids_size = outsize1;
+
+                        if((node=rdfstore_iterator_first_predicate(results))!=NULL) {
+				buff=rdfstore_ntriples_node( node );               
+                                printf("predicates: key=%s\n",buff);                               
+                                RDFSTORE_FREE( buff );
+				RDFSTORE_FREE( node->value.resource.identifier );
+                                RDFSTORE_FREE( node );
+                        } else {
+                                if (key.size == 4)
+                                        printf("predicates: key=%x (hex, 4byte int)\n",*(unsigned int *)(key.data));
+                                else
+                                        printf("predicates: key=\"%s\" (len %d)'\n",_sp(key),key.size);
+                                };
+
+			items ++;
+			s1 += data.size;
+			s2 += outsize1;
+
+			for ( i=0; i<256; i++ ) {
+				bytes_stats[i]=0;
+				};
+			for ( i=0; i<16; i++ ) {
+				nibbles_stats[i]=0;
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_bytes_stats[bits[i]]++;
+				bytes_stats[bits[i]]++;
+				};
+
+			printf("predicates: val_len_comp   = %d\n",(int)data.size);
+			printf("predicates: val_len_decomp = %d\n",outsize1);
+			printf("predicates: ratio = %f\n",(double)data.size/(double)outsize1);
+			printf("predicates: byte symbols:\n");
+			for ( i=0; i<256; i++ ) {
+				if(bytes_stats[i]>0) {
+					printf("\tb %02X = %d\n",i,(int)bytes_stats[i]);
+					};
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_nibbles_stats[bits[i] & 0x0f]++;
+				global_nibbles_stats[bits[i] >> 4]++;
+				nibbles_stats[bits[i] & 0x0f]++;
+				nibbles_stats[bits[i] >> 4]++;
+				};
+			printf("predicates: nibble symbols:\n");
+			for ( i=0; i<16; i++ ) {
+				if(nibbles_stats[i]>0) {
+					printf("\tn %0X = %d\n",i,(int)nibbles_stats[i]);
+					};
+				};
+			printf("-----------------------------\n");
+        	} while ( rdfstore_flat_store_next( db, key, &key ) == 0 );
+		printf("predicates: Global byte symbols:\n");
+		for ( i=0; i<256; i++ ) {
+			if(global_bytes_stats[i]>0) {
+				printf("\tgb %02X = %d\n",i,(int)global_bytes_stats[i]);
+				};
+			};
+		printf("predicates: Global nibble symbols:\n");
+		for ( i=0; i<16; i++ ) {
+			if(global_nibbles_stats[i]>0) {
+				printf("\tgn %0X = %d\n",i,(int)global_nibbles_stats[i]);
+				};
+			};
+
+		printf("Items in predicates: %d\n",items);
+ 		printf("Total size of predicates: %d (uncompressed %d)\n",s1,s2);
+
+        	};
+
+	/* objects */
+	db = me->objects;
+
+	for ( i=0; i<256; i++ ) {
+		global_bytes_stats[i]=0;
+		};
+	for ( i=0; i<16; i++ ) {
+		global_nibbles_stats[i]=0;
+		};
+	/* NOTE: garbage collection of first, fetch and next is not done here */
+	if ( rdfstore_flat_store_first( db, &key ) == 0 ) {
+        	do {
+                	if ( rdfstore_flat_store_fetch( db, key, &data )) {
+                        	outsize1=0;
+				printf("objects: LENGTH ZERO\n");
+				continue;
+                        	};
+
+			/* Decode bit array */
+                       	me->func_decode( data.size, data.data, &outsize1, bits);
+
+			/* hack ;) */
+                        memcpy(results->ids, bits, outsize1);
+                        results->ids_size = outsize1;
+
+                        if((node=rdfstore_iterator_first_object(results))!=NULL) {
+				buff=rdfstore_ntriples_node( node );
+				printf("objects: key=%s\n",buff);
+				RDFSTORE_FREE( buff );
+				if ( node->type == 1 ) {
+					if ( node->value.literal.dataType != NULL )
+						RDFSTORE_FREE( node->value.literal.dataType );
+                        		RDFSTORE_FREE( node->value.literal.string );
+                		} else {
+					RDFSTORE_FREE( node->value.resource.identifier );
+                        		};	
+                                RDFSTORE_FREE( node );
+                        } else {
+                                if (key.size == 4)
+                                        printf("objects: key=%x (hex, 4byte int)\n",*(unsigned int *)(key.data));
+                                else
+                                        printf("objects: key=\"%s\" (len %d)'\n",_sp(key),key.size);
+                                };
+
+			items ++;
+			s1 += data.size;
+			s2 += outsize1;
+
+			for ( i=0; i<256; i++ ) {
+				bytes_stats[i]=0;
+				};
+			for ( i=0; i<16; i++ ) {
+				nibbles_stats[i]=0;
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_bytes_stats[bits[i]]++;
+				bytes_stats[bits[i]]++;
+				};
+
+			printf("objects: val_len_comp   = %d\n",(int)data.size);
+			printf("objects: val_len_decomp = %d\n",outsize1);
+			printf("objects: ratio = %f\n",(double)data.size/(double)outsize1);
+			printf("objects: byte symbols:\n");
+			for ( i=0; i<256; i++ ) {
+				if(bytes_stats[i]>0) {
+					printf("\tb %02X = %d\n",i,(int)bytes_stats[i]);
+					};
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_nibbles_stats[bits[i] & 0x0f]++;
+				global_nibbles_stats[bits[i] >> 4]++;
+				nibbles_stats[bits[i] & 0x0f]++;
+				nibbles_stats[bits[i] >> 4]++;
+				};
+			printf("objects: nibble symbols:\n");
+			for ( i=0; i<16; i++ ) {
+				if(nibbles_stats[i]>0) {
+					printf("\tn %0X = %d\n",i,(int)nibbles_stats[i]);
+					};
+				};
+			printf("-----------------------------\n");
+        	} while ( rdfstore_flat_store_next( db, key, &key ) == 0 );
+		printf("objects: Global byte symbols:\n");
+		for ( i=0; i<256; i++ ) {
+			if(global_bytes_stats[i]>0) {
+				printf("\tgb %02X = %d\n",i,(int)global_bytes_stats[i]);
+				};
+			};
+		printf("objects: Global nibble symbols:\n");
+		for ( i=0; i<16; i++ ) {
+			if(global_nibbles_stats[i]>0) {
+				printf("\tgn %0X = %d\n",i,(int)global_nibbles_stats[i]);
+				};
+			};
+
+		printf("Items in objects: %d\n",items);
+ 		printf("Total size of objects: %d (uncompressed %d)\n",s1,s2);
+
+        	};
+
+	/* contexts */
+	items=s1=s2=0;
+	db = me->contexts;
+
+	for ( i=0; i<256; i++ ) {
+		global_bytes_stats[i]=0;
+		};
+	for ( i=0; i<16; i++ ) {
+		global_nibbles_stats[i]=0;
+		};
+
+	/* NOTE: garbage collection of first, fetch and next is not done here */
+	if ( rdfstore_flat_store_first( db, &key ) == 0 ) {
+        	do {
+                	if ( rdfstore_flat_store_fetch( db, key, &data ) == 0 ) {
+                        	me->func_decode( data.size, data.data, &outsize1, bits);
+                	} else {
+                        	outsize1=0;
+				printf("contexts: LENGTH ZERO\n");
+				continue;
+                        	};
+
+			/* hack ;) */
+                        memcpy(results->ids, bits, outsize1);
+                        results->ids_size = outsize1;
+
+                        if((node=rdfstore_iterator_first_context(results))!=NULL) {
+				buff=rdfstore_ntriples_node( node );               
+                                printf("contexts: key=%s\n",buff);                               
+                                RDFSTORE_FREE( buff );
+                                RDFSTORE_FREE( node->value.resource.identifier );
+                                RDFSTORE_FREE( node );
+                        } else {
+                                if (key.size == 4)
+                                        printf("contexts: key=%x (hex, 4byte int)\n",*(unsigned int *)(key.data));
+                                else
+                                        printf("contexts: key=\"%s\" (len %d)'\n",_sp(key),key.size);
+                                };
+
+			items ++;
+			s1 += data.size;
+			s2 += outsize1;
+
+			for ( i=0; i<256; i++ ) {
+				bytes_stats[i]=0;
+				};
+			for ( i=0; i<16; i++ ) {
+				nibbles_stats[i]=0;
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_bytes_stats[bits[i]]++;
+				bytes_stats[bits[i]]++;
+				};
+			printf("contexts: val_len_comp   = %d\n",(int)data.size);
+			printf("contexts: val_len_decomp = %d\n",outsize1);
+			printf("contexts: ratio = %f\n",(double)data.size/(double)outsize1);
+			printf("contexts: byte symbols:\n");
+			for ( i=0; i<256; i++ ) {
+				if(bytes_stats[i]>0) {
+					printf("\tb %02X = %d\n",i,(int)bytes_stats[i]);
+					};
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_nibbles_stats[bits[i] & 0x0f]++;
+				global_nibbles_stats[bits[i] >> 4]++;
+				nibbles_stats[bits[i] & 0x0f]++;
+				nibbles_stats[bits[i] >> 4]++;
+				};
+			printf("contexts: nibble symbols:\n");
+			for ( i=0; i<16; i++ ) {
+				if(nibbles_stats[i]>0) {
+					printf("\tn %0X = %d\n",i,(int)nibbles_stats[i]);
+					};
+				};
+			printf("-----------------------------\n");
+        	} while ( rdfstore_flat_store_next( db, key, &key ) == 0 );
+		printf("contexts: Global byte symbols:\n");
+		for ( i=0; i<256; i++ ) {
+			if(global_bytes_stats[i]>0) {
+				printf("\tgb %02X = %d\n",i,(int)global_bytes_stats[i]);
+				};
+			};
+		printf("contexts: Global nibble symbols:\n");
+		for ( i=0; i<16; i++ ) {
+			if(global_nibbles_stats[i]>0) {
+				printf("\tgn %0X = %d\n",i,(int)global_nibbles_stats[i]);
+				};
+			};
+
+		printf("Items in contexts: %d\n",items);
+        	printf("Total size of contexts: %d (uncompressed %d)\n",s1,s2);
+        };
+
+	if(me->windex != NULL) {
+
+	/* windex */
+	items=s1=s2=0;
+	db = me->windex;
+
+	for ( i=0; i<256; i++ ) {
+		global_bytes_stats[i]=0;
+		};
+	for ( i=0; i<16; i++ ) {
+		global_nibbles_stats[i]=0;
+		};
+	/* NOTE: garbage collection of first, fetch and next is not done here */
+	if ( rdfstore_flat_store_first( db, &key ) == 0 ) {
+        	do {
+			if (key.size == 4)
+                                printf("windex: key=%x (hex, 4byte int) ",*(unsigned int *)(key.data));
+                        else
+                                printf("windex: key=\"%s\" (len %d)'",_sp(key),key.size);
+
+                	if ( rdfstore_flat_store_fetch( db, key, &data ) == 0 ) {
+                        	me->func_decode( data.size, data.data, &outsize1, bits);
+                	} else {
+                        	outsize1=0;
+				printf("windex: LENGTH ZERO\n");
+				continue;
+                        	};
+
+			items ++;
+			s1 += data.size;
+			s2 += outsize1;
+
+			for ( i=0; i<256; i++ ) {
+				bytes_stats[i]=0;
+				};
+			for ( i=0; i<16; i++ ) {
+				nibbles_stats[i]=0;
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_bytes_stats[bits[i]]++;
+				bytes_stats[bits[i]]++;
+				};
+			printf("windex: val_len_comp   = %d\n",(int)data.size);
+			printf("windex: val_len_decomp = %d\n",outsize1);
+			printf("windex: ratio = %f\n",(double)data.size/(double)outsize1);
+			printf("windex: byte symbols:\n");
+			for ( i=0; i<256; i++ ) {
+				if(bytes_stats[i]>0) {
+					printf("\tb %02X = %d\n",i,(int)bytes_stats[i]);
+					};
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_nibbles_stats[bits[i] & 0x0f]++;
+				global_nibbles_stats[bits[i] >> 4]++;
+				nibbles_stats[bits[i] & 0x0f]++;
+				nibbles_stats[bits[i] >> 4]++;
+				};
+			printf("windex: nibble symbols:\n");
+			for ( i=0; i<16; i++ ) {
+				if(nibbles_stats[i]>0) {
+					printf("\tn %0X = %d\n",i,(int)nibbles_stats[i]);
+					};
+				};
+			printf("-----------------------------\n");
+        	} while ( rdfstore_flat_store_next( db, key, &key ) == 0 );
+
+		printf("windex: Global byte symbols:\n");
+		for ( i=0; i<256; i++ ) {
+			if(global_bytes_stats[i]>0) {
+				printf("\tgb %02X = %d\n",i,(int)global_bytes_stats[i]);
+				};
+			};
+		printf("windex: Global nibble symbols:\n");
+		for ( i=0; i<16; i++ ) {
+			if(global_nibbles_stats[i]>0) {
+				printf("\tgn %0X = %d\n",i,(int)global_nibbles_stats[i]);
+				};
+			};
+
+		printf("Items in windex: %d\n",items);
+        	printf("Total size of windex: %d (uncompressed %d)\n",s1,s2);
+
+        	};
+	};
+
+#ifdef RDFSTORE_NEW_INDEX
+	/* s_connections */
+	db = me->s_connections;
+
+	for ( i=0; i<256; i++ ) {
+		global_bytes_stats[i]=0;
+		};
+	for ( i=0; i<16; i++ ) {
+		global_nibbles_stats[i]=0;
+		};
+	/* NOTE: garbage collection of first, fetch and next is not done here */
+	if ( rdfstore_flat_store_first( db, &key ) == 0 ) {
+        	do {
+                	if ( rdfstore_flat_store_fetch( db, key, &data )) {
+                        	outsize1=0;
+				printf("s_connections: LENGTH ZERO\n");
+				continue;
+                        	};
+
+			/* Decode bit array */
+                       	me->func_decode_connections( data.size, data.data, &outsize1, bits);
+
+			/* hack ;) */
+                        memcpy(results->ids, bits, outsize1);  
+                        results->ids_size = outsize1;
+
+                        if((node=rdfstore_iterator_first_subject(results))!=NULL) {   
+                                buff=rdfstore_ntriples_node( node );
+                                printf("s_connections: key=%s\n",buff);   
+                                RDFSTORE_FREE( buff );
+                                if ( node->type == 1 ) {
+                                        if ( node->value.literal.dataType != NULL )
+                                                RDFSTORE_FREE( node->value.literal.dataType );
+                                        RDFSTORE_FREE( node->value.literal.string );
+                                } else {
+                                        RDFSTORE_FREE( node->value.resource.identifier );
+                                        };
+                                RDFSTORE_FREE( node );
+                        } else {
+                                if (key.size == 4)
+                                        printf("s_connections: key=%x (hex, 4byte int)\n",*(unsigned int *)(key.data));
+                                else   
+                                        printf("s_connections: key=\"%s\" (len %d)'\n",_sp(key),key.size);
+                                };
+
+			items ++;
+			s1 += data.size;
+			s2 += outsize1;
+
+			for ( i=0; i<256; i++ ) {
+				bytes_stats[i]=0;
+				};
+			for ( i=0; i<16; i++ ) {
+				nibbles_stats[i]=0;
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_bytes_stats[bits[i]]++;
+				bytes_stats[bits[i]]++;
+				};
+
+			printf("s_connections: val_len_comp   = %d\n",(int)data.size);
+			printf("s_connections: val_len_decomp = %d\n",outsize1);
+			printf("s_connections: ratio = %f\n",(double)data.size/(double)outsize1);
+			printf("s_connections: byte symbols:\n");
+			for ( i=0; i<256; i++ ) {
+				if(bytes_stats[i]>0) {
+					printf("\tb %02X = %d\n",i,(int)bytes_stats[i]);
+					};
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_nibbles_stats[bits[i] & 0x0f]++;
+				global_nibbles_stats[bits[i] >> 4]++;
+				nibbles_stats[bits[i] & 0x0f]++;
+				nibbles_stats[bits[i] >> 4]++;
+				};
+			printf("s_connections: nibble symbols:\n");
+			for ( i=0; i<16; i++ ) {
+				if(nibbles_stats[i]>0) {
+					printf("\tn %0X = %d\n",i,(int)nibbles_stats[i]);
+					};
+				};
+			printf("-----------------------------\n");
+        	} while ( rdfstore_flat_store_next( db, key, &key ) == 0 );
+		printf("s_connections: Global byte symbols:\n");
+		for ( i=0; i<256; i++ ) {
+			if(global_bytes_stats[i]>0) {
+				printf("\tgb %02X = %d\n",i,(int)global_bytes_stats[i]);
+				};
+			};
+		printf("s_connections: Global nibble symbols:\n");
+		for ( i=0; i<16; i++ ) {
+			if(global_nibbles_stats[i]>0) {
+				printf("\tgn %0X = %d\n",i,(int)global_nibbles_stats[i]);
+				};
+			};
+
+		printf("Items in s_connections: %d\n",items);
+ 		printf("Total size of s_connections: %d (uncompressed %d)\n",s1,s2);
+
+        	};
+
+	/* p_connections */
+	db = me->p_connections;
+
+	for ( i=0; i<256; i++ ) {
+		global_bytes_stats[i]=0;
+		};
+	for ( i=0; i<16; i++ ) {
+		global_nibbles_stats[i]=0;
+		};
+	/* NOTE: garbage collection of first, fetch and next is not done here */
+	if ( rdfstore_flat_store_first( db, &key ) == 0 ) {
+        	do {
+                	if ( rdfstore_flat_store_fetch( db, key, &data )) {
+                        	outsize1=0;
+				printf("p_connections: LENGTH ZERO\n");
+				continue;
+                        	};
+
+			/* Decode bit array */
+                       	me->func_decode_connections( data.size, data.data, &outsize1, bits);
+
+			/* hack ;) */
+                        memcpy(results->ids, bits, outsize1);
+                        results->ids_size = outsize1;
+
+                        if((node=rdfstore_iterator_first_predicate(results))!=NULL) {
+                                buff=rdfstore_ntriples_node( node );
+                                printf("p_connections: key=%s\n",buff);
+                                RDFSTORE_FREE( buff );
+                                if ( node->type == 1 ) {
+                                        if ( node->value.literal.dataType != NULL )
+                                                RDFSTORE_FREE( node->value.literal.dataType );
+                                        RDFSTORE_FREE( node->value.literal.string );
+                                } else {
+                                        RDFSTORE_FREE( node->value.resource.identifier );
+                                        };
+                                RDFSTORE_FREE( node );
+                        } else {
+                                if (key.size == 4)
+                                        printf("p_connections: key=%x (hex, 4byte int)\n",*(unsigned int *)(key.data));
+                                else
+                                        printf("p_connections: key=\"%s\" (len %d)'\n",_sp(key),key.size);
+                                };
+
+			items ++;
+			s1 += data.size;
+			s2 += outsize1;
+
+			for ( i=0; i<256; i++ ) {
+				bytes_stats[i]=0;
+				};
+			for ( i=0; i<16; i++ ) {
+				nibbles_stats[i]=0;
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_bytes_stats[bits[i]]++;
+				bytes_stats[bits[i]]++;
+				};
+
+			printf("p_connections: val_len_comp   = %d\n",(int)data.size);
+			printf("p_connections: val_len_decomp = %d\n",outsize1);
+			printf("p_connections: ratio = %f\n",(double)data.size/(double)outsize1);
+			printf("p_connections: byte symbols:\n");
+			for ( i=0; i<256; i++ ) {
+				if(bytes_stats[i]>0) {
+					printf("\tb %02X = %d\n",i,(int)bytes_stats[i]);
+					};
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_nibbles_stats[bits[i] & 0x0f]++;
+				global_nibbles_stats[bits[i] >> 4]++;
+				nibbles_stats[bits[i] & 0x0f]++;
+				nibbles_stats[bits[i] >> 4]++;
+				};
+			printf("p_connections: nibble symbols:\n");
+			for ( i=0; i<16; i++ ) {
+				if(nibbles_stats[i]>0) {
+					printf("\tn %0X = %d\n",i,(int)nibbles_stats[i]);
+					};
+				};
+			printf("-----------------------------\n");
+        	} while ( rdfstore_flat_store_next( db, key, &key ) == 0 );
+		printf("p_connections: Global byte symbols:\n");
+		for ( i=0; i<256; i++ ) {
+			if(global_bytes_stats[i]>0) {
+				printf("\tgb %02X = %d\n",i,(int)global_bytes_stats[i]);
+				};
+			};
+		printf("p_connections: Global nibble symbols:\n");
+		for ( i=0; i<16; i++ ) {
+			if(global_nibbles_stats[i]>0) {
+				printf("\tgn %0X = %d\n",i,(int)global_nibbles_stats[i]);
+				};
+			};
+
+		printf("Items in p_connections: %d\n",items);
+ 		printf("Total size of p_connections: %d (uncompressed %d)\n",s1,s2);
+
+        	};
+
+	/* o_connections */
+	db = me->o_connections;
+
+	for ( i=0; i<256; i++ ) {
+		global_bytes_stats[i]=0;
+		};
+	for ( i=0; i<16; i++ ) {
+		global_nibbles_stats[i]=0;
+		};
+	/* NOTE: garbage collection of first, fetch and next is not done here */
+	if ( rdfstore_flat_store_first( db, &key ) == 0 ) {
+        	do {
+                	if ( rdfstore_flat_store_fetch( db, key, &data )) {
+                        	outsize1=0;
+				printf("o_connections: LENGTH ZERO\n");
+				continue;
+                        	};
+
+			/* Decode bit array */
+                       	me->func_decode_connections( data.size, data.data, &outsize1, bits);
+
+			/* hack ;) */
+                        memcpy(results->ids, bits, outsize1);
+                        results->ids_size = outsize1;
+
+                        if((node=rdfstore_iterator_first_object(results))!=NULL) {
+                                buff=rdfstore_ntriples_node( node );
+                                printf("o_connections: key=%s\n",buff);
+                                RDFSTORE_FREE( buff );
+                                if ( node->type == 1 ) {
+                                        if ( node->value.literal.dataType != NULL )
+                                                RDFSTORE_FREE( node->value.literal.dataType );
+                                        RDFSTORE_FREE( node->value.literal.string );
+                                } else {
+                                        RDFSTORE_FREE( node->value.resource.identifier );
+                                        };
+                                RDFSTORE_FREE( node );
+                        } else {
+                                if (key.size == 4)
+                                        printf("o_connections: key=%x (hex, 4byte int)\n",*(unsigned int *)(key.data));
+                                else
+                                        printf("o_connections: key=\"%s\" (len %d)'\n",_sp(key),key.size);
+                                };
+			
+			items ++;
+			s1 += data.size;
+			s2 += outsize1;
+
+			for ( i=0; i<256; i++ ) {
+				bytes_stats[i]=0;
+				};
+			for ( i=0; i<16; i++ ) {
+				nibbles_stats[i]=0;
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_bytes_stats[bits[i]]++;
+				bytes_stats[bits[i]]++;
+				};
+
+			printf("o_connections: val_len_comp   = %d\n",(int)data.size);
+			printf("o_connections: val_len_decomp = %d\n",outsize1);
+			printf("o_connections: ratio = %f\n",(double)data.size/(double)outsize1);
+			printf("o_connections: byte symbols:\n");
+			for ( i=0; i<256; i++ ) {
+				if(bytes_stats[i]>0) {
+					printf("\tb %02X = %d\n",i,(int)bytes_stats[i]);
+					};
+				};
+			for ( i=0; i<outsize1; i++ ) {
+				global_nibbles_stats[bits[i] & 0x0f]++;
+				global_nibbles_stats[bits[i] >> 4]++;
+				nibbles_stats[bits[i] & 0x0f]++;
+				nibbles_stats[bits[i] >> 4]++;
+				};
+			printf("o_connections: nibble symbols:\n");
+			for ( i=0; i<16; i++ ) {
+				if(nibbles_stats[i]>0) {
+					printf("\tn %0X = %d\n",i,(int)nibbles_stats[i]);
+					};
+				};
+			printf("-----------------------------\n");
+        	} while ( rdfstore_flat_store_next( db, key, &key ) == 0 );
+		printf("o_connections: Global byte symbols:\n");
+		for ( i=0; i<256; i++ ) {
+			if(global_bytes_stats[i]>0) {
+				printf("\tgb %02X = %d\n",i,(int)global_bytes_stats[i]);
+				};
+			};
+		printf("o_connections: Global nibble symbols:\n");
+		for ( i=0; i<16; i++ ) {
+			if(global_nibbles_stats[i]>0) {
+				printf("\tgn %0X = %d\n",i,(int)global_nibbles_stats[i]);
+				};
+			};
+
+		printf("Items in o_connections: %d\n",items);
+ 		printf("Total size of o_connections: %d (uncompressed %d)\n",s1,s2);
+
+        	};
+#endif
+
+	rdfstore_iterator_close(results);
+
+	rdfstore_disconnect( me );
+
+	return 0;
+};

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/pod2html.pl
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/pod2html.pl?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/pod2html.pl (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/pod2html.pl Fri Apr 13 01:56:01 2007
@@ -0,0 +1,140 @@
+#!/usr/bin/perl
+##############################################################################
+# 	Copyright (c) 2000-2006 All rights reserved
+# 	Alberto Reggiori <ar...@webweaving.org>
+#	Dirk-Willem van Gulik <di...@webweaving.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer. 
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in
+#    the documentation and/or other materials provided with the
+#    distribution.
+#
+# 3. The end-user documentation included with the redistribution,
+#    if any, must include the following acknowledgment:
+#       "This product includes software developed by 
+#        Alberto Reggiori <ar...@webweaving.org> and
+#        Dirk-Willem van Gulik <di...@webweaving.org>."
+#    Alternately, this acknowledgment may appear in the software itself,
+#    if and wherever such third-party acknowledgments normally appear.
+#
+# 4. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#    This product includes software developed by the University of
+#    California, Berkeley and its contributors. 
+#
+# 5. Neither the name of the University nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# 6. Products derived from this software may not be called "RDFStore"
+#    nor may "RDFStore" appear in their names without prior written
+#    permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+# OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# ====================================================================
+#
+# This software consists of work developed by Alberto Reggiori and 
+# Dirk-Willem van Gulik. The RDF specific part is based on public 
+# domain software written at the Stanford University Database Group by 
+# Sergey Melnik. For more information on the RDF API Draft work, 
+# please see <http://www-db.stanford.edu/~melnik/rdf/api.html>
+# The DBMS TCP/IP server part is based on software originally written
+# by Dirk-Willem van Gulik for Web Weaving Internet Engineering m/v Enschede,
+# The Netherlands.
+#
+##############################################################################
+
+my $Usage =<<EOU;
+Usage is:
+    $0 [-h] [-input_dir <valid_directoryname>] [-output_dir <valid_directoryname>]
+
+Convert POD documentation to HTML - starting from a given input directory it recursevly traverses it looking for *.pm files and converts
+the documentation to HTML using pod2html. The branch structure of the input dir containing the POD files is assured to be recreated into
+the out directory.
+
+-h	Print this message
+
+[-input_dir <valid_directoryname>]
+	Input directory of existing DB files. Default is cwd.
+
+[-output_dir <valid_directoryname>]
+	Output directory where to generate the HTML formatted documentation
+
+[-v]
+	verbose		
+
+EOU
+
+# Process options
+print $Usage and exit if ($#ARGV<0);
+
+my ($verbose,$input_dir,$output_dir);
+my @query;
+while (defined($ARGV[0]) and $ARGV[0] =~ /^[-+]/) {
+    my $opt = shift;
+
+    if ($opt eq '-h') {
+        print $Usage;
+        exit;
+    } elsif ($opt eq '-v') {
+        $verbose=1;
+    } elsif ($opt eq '-input_dir') {
+	$opt=shift;
+	$input_dir = $opt
+                if(-e $opt);
+    } elsif ($opt eq '-output_dir') {
+	$opt=shift;
+	$output_dir = $opt
+                if(-e $opt);
+    } else {
+        die "Unknown option: $opt\n$Usage";
+    };
+};
+
+my $pod2html = '/usr/bin/pod2html';
+my $find = '/usr/bin/find';
+
+$input_dir= '.' unless($input_dir);
+$output_dir= '.' unless($output_dir);
+
+open(PM,"$find $input_dir -name '*.pm' -print |");
+while (<PM>) {
+	chomp;
+	my $pod_file = $_;
+	my $html_dir = $pod_file;
+	$html_dir =~ s#$input_dir/##;
+	my $html_file = $1
+		if $html_dir =~ s#([^/]+)$##;
+	`mkdir -p $output_dir$html_dir`;
+	$html_file =~ s/.pm/.html/;
+	$html_file = $output_dir.$html_dir.$html_file;
+	print "Generating HTML documentation for $pod_file ......" if($verbose);
+	if ( $verbose ) {
+		`$pod2html $pod_file > $html_file`;
+	} else {
+		`$pod2html $pod_file > $html_file 2> /dev/null`;
+		};
+	print "DONE\n" if($verbose)
+	};
+unlink('pod2htmd.x~~');
+unlink('pod2htmi.x~~');
+close(PM);

Propchange: incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/pod2html.pl
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/rdf.pl
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/rdf.pl?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/rdf.pl (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/rdf.pl Fri Apr 13 01:56:01 2007
@@ -0,0 +1,323 @@
+#!/usr/bin/perl
+##############################################################################
+# 	Copyright (c) 2000-2006 All rights reserved
+# 	Alberto Reggiori <ar...@webweaving.org>
+#	Dirk-Willem van Gulik <di...@webweaving.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer. 
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in
+#    the documentation and/or other materials provided with the
+#    distribution.
+#
+# 3. The end-user documentation included with the redistribution,
+#    if any, must include the following acknowledgment:
+#       "This product includes software developed by 
+#        Alberto Reggiori <ar...@webweaving.org> and
+#        Dirk-Willem van Gulik <di...@webweaving.org>."
+#    Alternately, this acknowledgment may appear in the software itself,
+#    if and wherever such third-party acknowledgments normally appear.
+#
+# 4. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#    This product includes software developed by the University of
+#    California, Berkeley and its contributors. 
+#
+# 5. Neither the name of the University nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# 6. Products derived from this software may not be called "RDFStore"
+#    nor may "RDFStore" appear in their names without prior written
+#    permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+# OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# ====================================================================
+#
+# This software consists of work developed by Alberto Reggiori and 
+# Dirk-Willem van Gulik. The RDF specific part is based on public 
+# domain software written at the Stanford University Database Group by 
+# Sergey Melnik. For more information on the RDF API Draft work, 
+# please see <http://www-db.stanford.edu/~melnik/rdf/api.html>
+# The DBMS TCP/IP server part is based on software originally written
+# by Dirk-Willem van Gulik for Web Weaving Internet Engineering m/v Enschede,
+# The Netherlands.
+#
+##############################################################################
+
+use RDFStore::NodeFactory;
+use RDFStore::Model;
+use RDFStore::Parser::SiRPAC;
+use RDFStore::Parser::NTriples;
+use Carp;
+
+my $Usage =<<EOU;
+Usage is:
+    $0 [-h] [-ntriples] [-freetext] [-storename <IDENTIFIER>] [-serialize <syntax>] [-base <URL_or_filename>] [-Context <URI_or_bNode>] [-sync] [-owl:imports] <URL_or_filename>
+
+Parse an input RDF file and optionally store the generated triplets into a RDFStore(3) database.
+
+-h	Print this message
+
+[-ntriples]
+	parse input stuff as N-Triples  - default is RDF/XML
+
+[-v]	Be verbose
+
+[-storename <IDENTIFIER>]
+		RDFStore database name IDENTIFIER is like rdfstore://[HOSTNAME[:PORT]]/PATH/DBDIRNAME
+
+			E.g. URLs
+					rdfstore://mysite.foo.com:1234/this/is/my/rd/store/database
+					rdfstore:///root/this/is/my/rd/store/database
+
+[-freetext]
+		Generates free-text searchable database
+
+[-namespace <URL_or_filename>]
+		Specify a string to set a base URI to use for the generation of 
+		resource URIs during parsing
+
+[-serialize RDF/XML | NTriples ]
+		generate RDF/XML or NTriples syntax
+
+[-Context <URI_or_bNode>]
+		Specify a resource to set a kind of context for the statements e.g. _:lmn20031127
+
+[-sync]
+		Sync databse after each statement insertion - this is option si off by default and it is generally very
+		expensive in terms of I/O operations.
+
+[-owl:imports]
+		Process owl:imports statements specially and include into output result related ontologies.
+
+[-GenidNumberFile]
+		EXISTING valid filename containing a single integer value to seed the parser "genid" numbers with the given value (I.e. for anonymous resources). Note that an exclusive lock on the file is used to guarantee that the value is consistent across runs (and concurrent processes)
+
+[-delete]
+		Remove instead of insert statements as passed into the input RDF file/source - as special case (if confirmed
+		after prompt to the user or yes option enabled) when no input source is specified the WHOLE database is cleared.
+		*WARNING* this operation is can not be undone!
+
+[-y]
+		Assume a yes response to all questions asked; this should be used with great caution as this is a free license
+		to confirm permanent chnages to the database like deletion of data.
+
+[-version]	Print RDFStore $VERSION
+
+Main paramter is URL or filename to parser; '-' denotes STDIN.
+
+EOU
+
+# Process options
+print $Usage and exit if ($#ARGV<0);
+
+my ($sync,$delete,$yes,$delete,$owl_imports,$Context,$ntriples,$freetext,$GenidNumberFile, $verbose,$namespace,$storename,$strawman,$stuff,$output_dir,$dbms_host,$dbms_port,$serialize);
+$sync = 0;
+$delete = 0;
+$yes = 0;
+while (defined($ARGV[0])) {
+    my $opt = shift;
+
+    if ($opt eq '-stuff') {
+	print STDERR "WARNING! -stuff option is deprecated - input source is defined to be last passed argument now\n";
+        $stuff = shift;
+    } elsif ($opt eq '-Context') {
+        $Context = shift;
+    } elsif ($opt eq '-namespace') {
+        $namespace = shift;
+    } elsif ($opt eq '-GenidNumberFile') {
+        $GenidNumberFile = shift;
+    } elsif ($opt eq '-freetext') {
+        $freetext = 1;
+    } elsif ($opt eq '-strawman') {
+        $strawman = 1;
+    } elsif ($opt eq '-sync') {
+        $sync = 1;
+    } elsif ($opt eq '-ntriples') {
+        $ntriples = 1;
+    } elsif ($opt eq '-storename') {
+        $storename = shift;
+    } elsif ($opt eq '-version') {
+	print $RDFStore::VERSION;
+	exit;
+    } elsif ($opt eq '-h') {
+        print $Usage;
+        exit;
+    } elsif ($opt eq '-delete') {
+	$delete=1;
+    } elsif ($opt eq '-y') {
+	$yes=1;
+    } elsif ($opt eq '-v') {
+	$verbose=1;
+    } elsif ($opt eq '-owl:imports') {
+        $owl_imports = 1;
+    } elsif ($opt eq '-output_dir') {
+	$opt=shift;
+        $output_dir = $opt
+		if(-e $opt);
+	$output_dir .= '/'
+		unless(	(not(defined $output_dir)) || 
+			($output_dir eq '') || 
+			($output_dir =~ /\s+/) || 
+			($output_dir =~ /\/$/) );
+    } elsif ($opt eq '-serialize') {
+        $serialize = shift;
+    } elsif ($opt eq '-dbms_host') {
+        $dbms_host = shift;
+    } elsif ($opt eq '-dbms_port') {
+	$opt=shift;
+        $dbms_port = (int($opt)) ? $opt : undef;
+    } else {
+	$stuff = $opt; #last is file/URL is not specificed with -stuff (which is deprecated)
+    	};
+};
+
+my $factory=new RDFStore::NodeFactory();
+
+#special case - no source and delete and confirmed
+if(	(!$stuff) &&
+	($storename) &&
+	($delete) ) {
+	my $in_context = ($Context) ? " in context '$Context'" : '';
+	confirm("\n*WARNINIG* This operation can not be undone!!\n\nAre you sure you want to clear the whole '$storename' database$in_context? (^C to kill, any key to continue)\n\n")
+		unless($yes);
+
+	# zap the whole model
+	my $model = new RDFStore::Model( Name => $output_dir.$storename,
+					 Host => $dbms_host, 
+					 Port => $dbms_port, 
+					 NodeFactory => $factory,
+					 FreeText     =>      $freetext,
+					 Context => ( (defined $Context) ? $Context : undef ) );
+	my $all = $model->elements;
+	if($all->size<=0) {
+		warn "Database '$storename' is empty.\n";
+		exit;
+		};
+	while ( my $st = $all->each ) {
+		$model->remove($st);
+
+		print "Removed statement ".$st->toString."\n"
+			if($verbose);
+		};
+	};
+
+my $cnt;
+if(	(defined $GenidNumberFile) &&
+	(-e $GenidNumberFile) ) {
+	# lock the genid counter
+	open(FH,'+<'.$GenidNumberFile)
+        	or die "Failed to get genid counter $!";
+	# go non buffered.
+	select(FH);
+	$|=1;
+	select(STDOUT);
+	flock FH,2
+        	or die "Failed to get exclusive lock $!";
+	seek FH,0,0
+        	or die "Failed to seek $!";
+	while(<FH>) {
+        	chomp;
+        	$cnt = int $_;
+        };
+	die "No genid counter"
+        	unless defined $cnt;
+};
+
+my $pt;
+if($ntriples) {
+        $pt = 'NTriples';
+} else {
+        $pt = 'SiRPAC';
+};
+$pt = 'RDFStore::Parser::'.$pt;
+
+if($Context) {
+	if($Context =~ m/^_:(.*)/) {
+		$Context = $factory->createAnonymousResource($1);
+	} else {
+		$Context = $factory->createResource($Context);
+		};
+	};
+
+my $style = ($storename or $serialize =~ /RDF\/XML/i ) ? 'RDFStore::Parser::Styles::RDFStore::Model' :
+				'RDFStore::Parser::Styles::RDFStore::Statement';
+my $p=new ${pt}(
+				ErrorContext => 	3, 
+				Style => 		$style,
+				NodeFactory => 		$factory,
+				Source	=> 		(defined $namespace) ?
+								$namespace :
+								($stuff =~ /^-/) ? undef : $stuff,
+				bCreateBags =>		(defined $bagIDs) ? $bagIDs : undef,
+				GenidNumber => $cnt,
+				style_options	=>	{
+							'seevalues' => 	$verbose,
+							'owl:imports' => $owl_imports,
+							'delete' => ($delete) ? 1 : undef,
+							'confirm' => ($yes) ? 1 : undef,
+							'store_options'		=> 	{	
+										Name	=> 	$output_dir.$storename,
+										Host =>	$dbms_host,
+										Port =>	$dbms_port,
+										FreeText     =>      $freetext,
+										Sync    => $sync,
+										Context	=> ( (defined $Context) ? $Context : undef ) }
+						}
+				);
+
+my $m;
+if($stuff =~ /^-/) {
+	# for STDIN use no-blocking
+	$m = $p->parsestream(*STDIN,$namespace);
+} else {
+	$m = $p->parsefile($stuff);
+};
+if(defined $GenidNumberFile) {
+	unless(-e $GenidNumberFile) {
+		open(FH,">".$GenidNumberFile)
+			or die "Failed to create genid counter file $!";
+		};
+	$cnt = $p->getReificationCounter();
+	seek FH,0,0
+        	or die "Failed to seek $!";
+	print FH $cnt."\n";
+ 
+	select(FH);
+	$|=1;
+	flock FH,8
+        	or die "Failed to unlock genid counter $!";
+	close(FH);
+	die "Issue with lock file $!"
+        	if ($?);
+};
+
+$m->serialize(*STDOUT,$serialize)
+	if( !$storename and $serialize );
+
+sub confirm {
+	my ($msg) = @_;
+
+	print $msg;
+
+	return <STDIN>;
+	};

Propchange: incubator/triplesoup/donations/TRIPLES-3-RDFStore/utils/rdf.pl
------------------------------------------------------------------------------
    svn:executable = *