You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2011/11/11 16:16:52 UTC
svn commit: r1200916 -
/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/tdbindex.java
Author: andy
Date: Fri Nov 11 15:16:52 2011
New Revision: 1200916
URL: http://svn.apache.org/viewvc?rev=1200916&view=rev
Log: (empty)
Modified:
incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/tdbindex.java
Modified: incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/tdbindex.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/tdbindex.java?rev=1200916&r1=1200915&r2=1200916&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/tdbindex.java (original)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/tdbindex.java Fri Nov 11 15:16:52 2011
@@ -19,25 +19,34 @@
package dev;
import java.util.List ;
+import java.util.Properties ;
import tdb.cmdline.CmdTDB ;
import arq.cmd.CmdException ;
+import com.hp.hpl.jena.tdb.TDB ;
import com.hp.hpl.jena.tdb.index.TupleIndex ;
import com.hp.hpl.jena.tdb.nodetable.NodeTupleTable ;
import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
+import com.hp.hpl.jena.tdb.store.NodeId ;
import com.hp.hpl.jena.tdb.store.bulkloader.BuilderSecondaryIndexes ;
import com.hp.hpl.jena.tdb.store.bulkloader.BuilderSecondaryIndexesSequential ;
import com.hp.hpl.jena.tdb.store.bulkloader.BulkLoader ;
import com.hp.hpl.jena.tdb.store.bulkloader.LoadMonitor ;
import com.hp.hpl.jena.tdb.sys.Names ;
+import com.hp.hpl.jena.tdb.sys.SetupTDB ;
/** Create a TDB index.
* Defaults to assuming the "primary" index (SPO or GSPO) already exists.
*/
public class tdbindex extends CmdTDB
{
-
+ static public void main(String... argv)
+ {
+ TDB.setOptimizerWarningFlag(false) ;
+ new tdbindex(argv).mainRun() ;
+ }
+
protected tdbindex(String[] argv)
{
super(argv) ;
@@ -55,14 +64,14 @@ public class tdbindex extends CmdTDB
List<String> args = super.getPositional() ;
if ( args.size() == 0 || args.size() > 2 )
- throw new CmdException("Wrong number of arguments (expected 1 or 2; got "+args.size()) ;
+ throw new CmdException("Wrong number of arguments (expected 1 or 2; got "+args.size()+")") ;
String srcIndex ;
String destIndex ;
if ( args.size() == 1 )
{
destIndex = args.get(0) ;
- if ( destIndex.length() != 3 || destIndex.length() != 4 )
+ if ( destIndex.length() != 3 && destIndex.length() != 4 )
throw new CmdException("Index '"+destIndex+"' must be of length 3 or 4") ;
if ( destIndex.length() == 3 )
srcIndex = Names.primaryIndexTriples ;
@@ -88,10 +97,10 @@ public class tdbindex extends CmdTDB
BuilderSecondaryIndexes builder = new BuilderSecondaryIndexesSequential(loadMonitor) ;
- if ( srcIndex.length() != 3 || srcIndex.length() != 4 )
+ if ( srcIndex.length() != 3 && srcIndex.length() != 4 )
throw new CmdException("Source index '"+srcIndex+"' must be of length 3 or 4") ;
- if ( destIndex.length() != 3 || destIndex.length() != 4 )
+ if ( destIndex.length() != 3 && destIndex.length() != 4 )
throw new CmdException("Destination index '"+destIndex+"' must be of length 3 or 4") ;
if ( srcIndex .length() != destIndex.length() )
@@ -110,9 +119,12 @@ public class tdbindex extends CmdTDB
if ( dstIdx != null )
throw new CmdException("Index already exists: "+destIndex) ;
- if ( true) throw new RuntimeException("BANG") ;
+ //if ( true) throw new RuntimeException("BANG") ;
+
+ int indexRecordLen = srcIndex.length()*NodeId.SIZE ;
- //dstIndex = new Index
+ Properties config = new Properties() ;
+ dstIdx = SetupTDB.makeTupleIndex(dsg.getLocation(), config, srcIndex, destIndex, destIndex, indexRecordLen) ;
// What about a builder that knows how to copy from one index to another while exploiting semi-locality?
builder.createSecondaryIndexes(srcIdx, new TupleIndex[] {dstIdx}) ;
@@ -122,7 +134,10 @@ public class tdbindex extends CmdTDB
{
for ( TupleIndex idx : indexes )
{
- if ( idx.getLabel().equals(srcIndex) )
+ // This is silly.
+ int i = idx.getLabel().indexOf('>') ;
+ String name = idx.getLabel().substring(i+1) ;
+ if ( name.equals(srcIndex) )
return idx ;
}
return null ;