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 2016/01/05 13:45:56 UTC
[02/20] jena git commit: JENA-1108: Command line tools for TDB
bulkloader2
JENA-1108: Command line tools for TDB bulkloader2
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/cda5c7cd
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/cda5c7cd
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/cda5c7cd
Branch: refs/heads/master
Commit: cda5c7cd5804033379f09a3732a55791acd14a60
Parents: 498b226
Author: Andy Seaborne <an...@apache.org>
Authored: Sun Jan 3 11:46:34 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Tue Jan 5 12:31:35 2016 +0000
----------------------------------------------------------------------
apache-jena/bin/tdbloader2common | 3 +-
apache-jena/pom.xml | 20 +++
jena-cmds/pom.xml | 84 +++++++++++
.../src/main/java/tdb/CmdNodeTableBuilder.java | 132 -----------------
.../src/main/java/tdb/CmdRewriteIndex.java | 147 -------------------
.../java/tdb/bulkloader2/CmdIndexBuild.java | 53 +++++++
.../main/java/tdb/bulkloader2/CmdIndexCopy.java | 45 ++++++
.../tdb/bulkloader2/CmdNodeTableBuilder.java | 125 ++++++++++++++++
.../java/tdb/bulkloader2/CmdRewriteIndex.java | 61 ++++++++
jena-fuseki2/jena-fuseki-core/pom.xml | 17 ++-
jena-maven-tools/pom.xml | 2 +-
.../tdb/store/bulkloader2/CmdIndexBuild.java | 126 ----------------
.../tdb/store/bulkloader2/CmdIndexCopy.java | 115 ---------------
.../tdb/store/bulkloader2/ProcIndexBuild.java | 104 +++++++++++++
.../tdb/store/bulkloader2/ProcIndexCopy.java | 102 +++++++++++++
.../store/bulkloader2/ProcNodeTableBuilder.java | 8 +-
.../tdb/store/bulkloader2/ProcRewriteIndex.java | 102 +++++++++++++
pom.xml | 37 +++--
18 files changed, 732 insertions(+), 551 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/apache-jena/bin/tdbloader2common
----------------------------------------------------------------------
diff --git a/apache-jena/bin/tdbloader2common b/apache-jena/bin/tdbloader2common
index 807ac1d..136471d 100644
--- a/apache-jena/bin/tdbloader2common
+++ b/apache-jena/bin/tdbloader2common
@@ -211,4 +211,5 @@ function makeAbsolute() {
#DATE="+%Y-%m-%dT%H:%M:%S%:z"
DATE="+%H:%M:%S"
-PKG=org.apache.jena.tdb.store.bulkloader2
+# Package for the command wrappers.
+PKG=tdb.bulkloader2
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/apache-jena/pom.xml
----------------------------------------------------------------------
diff --git a/apache-jena/pom.xml b/apache-jena/pom.xml
index 885db04..4bbc6e8 100644
--- a/apache-jena/pom.xml
+++ b/apache-jena/pom.xml
@@ -117,6 +117,26 @@
<classifier>javadoc</classifier>
</dependency>
+ <dependency>
+ <groupId>org.apache.jena</groupId>
+ <artifactId>jena-cmds</artifactId>
+ <version>3.1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.jena</groupId>
+ <artifactId>jena-cmds</artifactId>
+ <version>3.1.0-SNAPSHOT</version>
+ <classifier>sources</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.jena</groupId>
+ <artifactId>jena-cmds</artifactId>
+ <version>3.1.0-SNAPSHOT</version>
+ <classifier>javadoc</classifier>
+ </dependency>
+
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-cmds/pom.xml
----------------------------------------------------------------------
diff --git a/jena-cmds/pom.xml b/jena-cmds/pom.xml
index 1bb3d20..738213b 100644
--- a/jena-cmds/pom.xml
+++ b/jena-cmds/pom.xml
@@ -113,5 +113,89 @@
</dependency>
</dependencies>
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>org/apache/jena/arq/arq-properties.xml</include>
+ </includes>
+ </resource>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources</directory>
+ <excludes>
+ <exclude>org/apache/jena/arq/arq-properties.xml</exclude>
+ </excludes>
+ </resource>
+ </resources>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/TS_*.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>attach-sources-test</id>
+ <goals>
+ <goal>test-jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <version>true</version>
+ <show>public</show>
+ <quiet>true</quiet>
+ <encoding>UTF-8</encoding>
+ <windowtitle>Apache Jena ARQ</windowtitle>
+ <doctitle>Apache Jena ARQ ${project.version}</doctitle>
+ <bottom>Licenced under the Apache License, Version 2.0</bottom>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
</project>
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-cmds/src/main/java/tdb/CmdNodeTableBuilder.java
----------------------------------------------------------------------
diff --git a/jena-cmds/src/main/java/tdb/CmdNodeTableBuilder.java b/jena-cmds/src/main/java/tdb/CmdNodeTableBuilder.java
deleted file mode 100644
index 5dc0371..0000000
--- a/jena-cmds/src/main/java/tdb/CmdNodeTableBuilder.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tdb;
-
-import java.util.Arrays ;
-import java.util.List ;
-import java.util.Objects ;
-
-import jena.cmd.ArgDecl;
-import jena.cmd.CmdException;
-import jena.cmd.CmdGeneral;
-import org.apache.jena.atlas.lib.FileOps ;
-import org.apache.jena.atlas.logging.LogCtl ;
-import org.apache.jena.riot.Lang ;
-import org.apache.jena.riot.RDFLanguages ;
-import org.apache.jena.system.JenaSystem ;
-import org.apache.jena.tdb.base.file.Location ;
-import org.apache.jena.tdb.setup.DatasetBuilderStd ;
-import org.apache.jena.tdb.store.bulkloader2.ProcNodeTableBuilder ;
-import tdb.cmdline.CmdTDB ;
-
-/** Build node table - write triples/quads as text file */
-public class CmdNodeTableBuilder extends CmdGeneral
-{
- static { LogCtl.setLog4j() ; }
- static { JenaSystem.init(); }
-
-
- private static ArgDecl argLocation = new ArgDecl(ArgDecl.HasValue, "loc", "location") ;
- private static ArgDecl argTriplesOut = new ArgDecl(ArgDecl.HasValue, "triples") ;
- private static ArgDecl argQuadsOut = new ArgDecl(ArgDecl.HasValue, "quads") ;
- private static ArgDecl argNoStats = new ArgDecl(ArgDecl.NoValue, "nostats") ;
-
- private String locationString ;
- private String dataFileTriples ;
- private String dataFileQuads ;
- private List<String> datafiles ;
- private Location location ;
- private boolean collectStats = true ;
-
- public static void main(String...argv)
- {
- System.err.println("CmdNodeTableBuilder");
- CmdTDB.init() ;
- DatasetBuilderStd.setOptimizerWarningFlag(false) ;
- new CmdNodeTableBuilder(argv).mainRun() ;
- }
-
- public CmdNodeTableBuilder(String...argv)
- {
- super(argv) ;
- super.add(argLocation, "--loc", "Location") ;
- super.add(argTriplesOut, "--triples", "Output file for triples") ;
- super.add(argQuadsOut, "--quads", "Output file for quads") ;
- super.add(argNoStats, "--nostats", "Don't collect stats") ;
- }
-
- @Override
- protected void processModulesAndArgs()
- {
- if ( !super.contains(argLocation) ) throw new CmdException("Required: --loc DIR") ;
-// if ( !super.contains(argTriplesOut) ) throw new CmdException("Required: --triples FILE") ;
-// if ( !super.contains(argQuadsOut) ) throw new CmdException("Required: --quads FILE") ;
-
- locationString = super.getValue(argLocation) ;
- location = Location.create(locationString) ;
-
- dataFileTriples = super.getValue(argTriplesOut) ;
- if ( dataFileTriples == null )
- dataFileTriples = location.getPath("triples", "tmp") ;
-
- dataFileQuads = super.getValue(argQuadsOut) ;
- if ( dataFileQuads == null )
- dataFileQuads = location.getPath("quads", "tmp") ;
-
- if ( Objects.equals(dataFileTriples, dataFileQuads) )
- cmdError("Triples and Quads work files are the same") ;
-
- if ( super.contains(argNoStats) )
- collectStats = false ;
-
- //datafiles = getPositionalOrStdin() ;
- datafiles = getPositional() ;
- if ( datafiles.isEmpty() )
- datafiles = Arrays.asList("-") ;
-
- // ---- Checking.
- for( String filename : datafiles)
- {
- Lang lang = RDFLanguages.filenameToLang(filename, RDFLanguages.NQUADS) ;
- if ( lang == null )
- // Does not happen due to default above.
- cmdError("File suffix not recognized: " +filename) ;
- if ( ! filename.equals("-") && ! FileOps.exists(filename) )
- cmdError("File does not exist: "+filename) ;
- }
- }
-
- @Override
- protected void exec()
- {
- ProcNodeTableBuilder.execInner(location, dataFileTriples, dataFileQuads, datafiles, collectStats);
- }
-
- @Override
- protected String getSummary()
- {
- return getCommandName()+" --loc=DIR [--triples=tmpFile1] [--quads=tmpFile2] FILE ..." ;
- }
-
- @Override
- protected String getCommandName()
- {
- return this.getClass().getName() ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-cmds/src/main/java/tdb/CmdRewriteIndex.java
----------------------------------------------------------------------
diff --git a/jena-cmds/src/main/java/tdb/CmdRewriteIndex.java b/jena-cmds/src/main/java/tdb/CmdRewriteIndex.java
deleted file mode 100644
index 0c4a6fa..0000000
--- a/jena-cmds/src/main/java/tdb/CmdRewriteIndex.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tdb;
-
-import java.util.Iterator ;
-
-import org.apache.jena.atlas.lib.FileOps ;
-import org.apache.jena.atlas.lib.Lib ;
-import org.apache.jena.tdb.base.block.BlockMgr ;
-import org.apache.jena.tdb.base.block.BlockMgrFactory ;
-import org.apache.jena.tdb.base.file.FileSet ;
-import org.apache.jena.tdb.base.file.Location ;
-import org.apache.jena.tdb.base.record.Record ;
-import org.apache.jena.tdb.base.record.RecordFactory ;
-import org.apache.jena.tdb.index.RangeIndex ;
-import org.apache.jena.tdb.index.SetupIndex ;
-import org.apache.jena.tdb.index.bplustree.BPlusTree ;
-import org.apache.jena.tdb.index.bplustree.BPlusTreeParams ;
-import org.apache.jena.tdb.index.bplustree.BPlusTreeRewriter ;
-import org.apache.jena.tdb.sys.Names ;
-import org.apache.jena.tdb.sys.SystemTDB ;
-
-/** Rewrite one index */
-public class CmdRewriteIndex
-{
- public static void main(String...argv)
- {
- // Usage: srcLocation dstLocation indexName
- if ( argv.length != 3 )
- {
- System.err.println("Usage: "+Lib.classShortName(CmdRewriteIndex.class)+" SrcLocation DstLocation IndexName") ;
- System.exit(1) ;
- }
-
- Location srcLoc = Location.create(argv[0]) ;
- Location dstLoc = Location.create(argv[1]) ;
- String indexName = argv[2] ;
-
- if ( ! FileOps.exists(argv[1]) )
- {
- System.err.println("Destination directory does not exist") ;
- System.exit(1) ;
- }
-
- if ( FileOps.exists(dstLoc.getPath(indexName, Names.bptExtTree)) )
- {
- System.err.println("Destination contains an index of that name") ;
- System.exit(1) ;
- }
-
- // To current directory ....
- FileSet destination = new FileSet(dstLoc, indexName) ;
- // Check existance
-
-// FileOps.deleteSilent(destination.filename(Names.bptExt1)) ;
-// FileOps.deleteSilent(destination.filename(Names.bptExt2)) ;
- //FileSet destination = new FileSet(Location.mem(), destIndex) ;
-
- int readCacheSize = 0 ;
- int writeCacheSize = -1 ;
-
- int dftKeyLength ;
- int dftValueLength ;
-
- if ( indexName.length() == 3 )
- {
- dftKeyLength = SystemTDB.LenIndexTripleRecord ;
- dftValueLength = 0 ;
- }
- else if ( indexName.length() == 4 )
- {
- dftKeyLength = SystemTDB.LenIndexQuadRecord ;
- dftValueLength = 0 ;
- }
-// else if ( srcIndex.equals("node2id") )
-// { }
-// java -cp "$CP" -server -Xmx1000M bpt.CmdRewriteIndex "$@" else if ( srcIndex.equals("prefixIdx") )
-// {}
-// else if ( srcIndex.equals("prefix2id") )
-// {}
- else
- {
- System.err.printf("Can't determine record size for %s\n",indexName) ;
- return ;
- }
-
- RecordFactory recordFactory = null ;
- BPlusTreeParams bptParams = null ;
- BlockMgr blkMgrNodes ;
- BlockMgr blkMgrRecords ;
- int blockSize = SystemTDB.BlockSize ;
-
- RangeIndex rangeIndex = SetupIndex.makeRangeIndex(srcLoc, indexName, blockSize, dftKeyLength, dftValueLength, readCacheSize, writeCacheSize) ;
- BPlusTree bpt = (BPlusTree)rangeIndex ;
- bptParams = bpt.getParams() ;
- recordFactory = bpt.getRecordFactory() ;
-
- int blockSizeNodes = blockSize ;
- int blockSizeRecords = blockSize ;
-
- blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExtTree, blockSizeNodes, readCacheSize, writeCacheSize) ;
- blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExtRecords, blockSizeRecords, readCacheSize, writeCacheSize) ;
-
- Iterator<Record> iterator = bpt.iterator() ;
-
-// // Fakery.
-// blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExt1, blockSize, readCacheSize, writeCacheSize) ;
-// blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExt2, blockSize, readCacheSize, writeCacheSize) ;
-// recordFactory = new RecordFactory(dftKeyLength, dftValueLength) ;
-// bptParams = new BPlusTreeParams(3, recordFactory) ;
-// List<Record> data = TestBPlusTreeRewriter.createData(10, recordFactory) ;
-// iterator = data.iterator() ;
-
- //System.out.println("Rewrite: "+srcLoc+" "+indexName+" --> "+destination) ;
-
- BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(iterator,
- bptParams, recordFactory,
- blkMgrNodes, blkMgrRecords) ;
- if ( bpt2 == null )
- return ;
-//
-// Iterator<Record> iter = bpt2.iterator() ;
-// for ( ; iter.hasNext() ; )
-// {
-// Record r = iter.next() ;
-// System.out.println(r) ;
-// }
-
- bpt2.close() ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-cmds/src/main/java/tdb/bulkloader2/CmdIndexBuild.java
----------------------------------------------------------------------
diff --git a/jena-cmds/src/main/java/tdb/bulkloader2/CmdIndexBuild.java b/jena-cmds/src/main/java/tdb/bulkloader2/CmdIndexBuild.java
new file mode 100644
index 0000000..57c2de4
--- /dev/null
+++ b/jena-cmds/src/main/java/tdb/bulkloader2/CmdIndexBuild.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tdb.bulkloader2;
+
+import org.apache.jena.atlas.logging.LogCtl ;
+import org.apache.jena.system.JenaSystem ;
+import org.apache.jena.tdb.store.bulkloader2.ProcIndexBuild ;
+
+public class CmdIndexBuild {
+ static {
+ LogCtl.setLog4j();
+ JenaSystem.init();
+ }
+
+ public static void main(String... argv) {
+ // DATA IN S/P/O columns but sorted by index order.
+
+ if ( argv.length != 3 ) {
+ System.err.println("Usage: Location Index dataFile");
+ System.exit(1);
+ }
+
+ String locationStr = argv[0];
+ String indexName = argv[1];
+
+// if ( ! Arrays.asList(Names.tripleIndexes).contains(indexName) &&
+// ! Arrays.asList(Names.quadIndexes).contains(indexName) )
+// {
+// System.err.println("Index name not recognized: "+indexName) ;
+// System.exit(1) ;
+// }
+
+ String dataFile = argv[2] ;
+ ProcIndexBuild.exec(locationStr, indexName, dataFile);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-cmds/src/main/java/tdb/bulkloader2/CmdIndexCopy.java
----------------------------------------------------------------------
diff --git a/jena-cmds/src/main/java/tdb/bulkloader2/CmdIndexCopy.java b/jena-cmds/src/main/java/tdb/bulkloader2/CmdIndexCopy.java
new file mode 100644
index 0000000..9ea62b8d
--- /dev/null
+++ b/jena-cmds/src/main/java/tdb/bulkloader2/CmdIndexCopy.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tdb.bulkloader2;
+
+import org.apache.jena.atlas.logging.LogCtl ;
+import org.apache.jena.system.JenaSystem ;
+import org.apache.jena.tdb.store.bulkloader2.ProcIndexCopy ;
+
+public class CmdIndexCopy
+{
+ static {
+ LogCtl.setLog4j();
+ JenaSystem.init();
+ }
+
+ public static void main(String... argv) {
+ if ( argv.length != 4 ) {
+ System.err.println("Usage: Location1 Index1 Location2 Index2");
+ System.exit(1);
+ }
+
+ String locationStr1 = argv[0] ;
+ String indexName1 = argv[1] ;
+ String locationStr2 = argv[2] ;
+ String indexName2 = argv[3] ;
+ ProcIndexCopy.exec(locationStr1, indexName1, locationStr2, indexName2);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-cmds/src/main/java/tdb/bulkloader2/CmdNodeTableBuilder.java
----------------------------------------------------------------------
diff --git a/jena-cmds/src/main/java/tdb/bulkloader2/CmdNodeTableBuilder.java b/jena-cmds/src/main/java/tdb/bulkloader2/CmdNodeTableBuilder.java
new file mode 100644
index 0000000..bb56b70
--- /dev/null
+++ b/jena-cmds/src/main/java/tdb/bulkloader2/CmdNodeTableBuilder.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tdb.bulkloader2;
+
+import java.util.Arrays ;
+import java.util.List ;
+import java.util.Objects ;
+
+import jena.cmd.ArgDecl;
+import jena.cmd.CmdException;
+import jena.cmd.CmdGeneral;
+import org.apache.jena.atlas.lib.FileOps ;
+import org.apache.jena.atlas.logging.LogCtl ;
+import org.apache.jena.riot.Lang ;
+import org.apache.jena.riot.RDFLanguages ;
+import org.apache.jena.system.JenaSystem ;
+import org.apache.jena.tdb.base.file.Location ;
+import org.apache.jena.tdb.setup.DatasetBuilderStd ;
+import org.apache.jena.tdb.store.bulkloader2.ProcNodeTableBuilder ;
+import tdb.cmdline.CmdTDB ;
+
+/** Build node table - write triples/quads as text file */
+public class CmdNodeTableBuilder extends CmdGeneral
+{
+ static {
+ LogCtl.setLog4j();
+ JenaSystem.init();
+ }
+
+ private static ArgDecl argLocation = new ArgDecl(ArgDecl.HasValue, "loc", "location");
+ private static ArgDecl argTriplesOut = new ArgDecl(ArgDecl.HasValue, "triples");
+ private static ArgDecl argQuadsOut = new ArgDecl(ArgDecl.HasValue, "quads");
+ private static ArgDecl argNoStats = new ArgDecl(ArgDecl.NoValue, "nostats");
+
+ private String locationString;
+ private String dataFileTriples;
+ private String dataFileQuads;
+ private List<String> datafiles;
+ private Location location;
+ private boolean collectStats = true;
+
+ public static void main(String... argv) {
+ CmdTDB.init();
+ DatasetBuilderStd.setOptimizerWarningFlag(false);
+ new CmdNodeTableBuilder(argv).mainRun();
+ }
+
+ public CmdNodeTableBuilder(String... argv) {
+ super(argv);
+ super.add(argLocation, "--loc", "Location");
+ super.add(argTriplesOut, "--triples", "Output file for triples");
+ super.add(argQuadsOut, "--quads", "Output file for quads");
+ super.add(argNoStats, "--nostats", "Don't collect stats");
+ }
+
+ @Override
+ protected void processModulesAndArgs() {
+ if ( !super.contains(argLocation) ) throw new CmdException("Required: --loc DIR") ;
+// if ( !super.contains(argTriplesOut) ) throw new CmdException("Required: --triples FILE") ;
+// if ( !super.contains(argQuadsOut) ) throw new CmdException("Required: --quads FILE") ;
+
+ locationString = super.getValue(argLocation) ;
+ location = Location.create(locationString) ;
+
+ dataFileTriples = super.getValue(argTriplesOut) ;
+ if ( dataFileTriples == null )
+ dataFileTriples = location.getPath("triples", "tmp") ;
+
+ dataFileQuads = super.getValue(argQuadsOut) ;
+ if ( dataFileQuads == null )
+ dataFileQuads = location.getPath("quads", "tmp") ;
+
+ if ( Objects.equals(dataFileTriples, dataFileQuads) )
+ cmdError("Triples and Quads work files are the same") ;
+
+ if ( super.contains(argNoStats) )
+ collectStats = false ;
+
+ //datafiles = getPositionalOrStdin() ;
+ datafiles = getPositional() ;
+ if ( datafiles.isEmpty() )
+ datafiles = Arrays.asList("-") ;
+
+ // ---- Checking.
+ for ( String filename : datafiles ) {
+ Lang lang = RDFLanguages.filenameToLang(filename, RDFLanguages.NQUADS);
+ if ( lang == null )
+ // Does not happen due to default above.
+ cmdError("File suffix not recognized: " + filename);
+ if ( !filename.equals("-") && !FileOps.exists(filename) )
+ cmdError("File does not exist: " + filename);
+ }
+ }
+
+ @Override
+ protected void exec() {
+ ProcNodeTableBuilder.exec(location, dataFileTriples, dataFileQuads, datafiles, collectStats);
+ }
+
+ @Override
+ protected String getSummary() {
+ return getCommandName() + " --loc=DIR [--triples=tmpFile1] [--quads=tmpFile2] FILE ...";
+ }
+
+ @Override
+ protected String getCommandName() {
+ return this.getClass().getName();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-cmds/src/main/java/tdb/bulkloader2/CmdRewriteIndex.java
----------------------------------------------------------------------
diff --git a/jena-cmds/src/main/java/tdb/bulkloader2/CmdRewriteIndex.java b/jena-cmds/src/main/java/tdb/bulkloader2/CmdRewriteIndex.java
new file mode 100644
index 0000000..43bc29c
--- /dev/null
+++ b/jena-cmds/src/main/java/tdb/bulkloader2/CmdRewriteIndex.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tdb.bulkloader2;
+
+import org.apache.jena.atlas.lib.FileOps ;
+import org.apache.jena.atlas.lib.Lib ;
+import org.apache.jena.atlas.logging.LogCtl ;
+import org.apache.jena.system.JenaSystem ;
+import org.apache.jena.tdb.base.file.Location ;
+import org.apache.jena.tdb.store.bulkloader2.ProcRewriteIndex ;
+import org.apache.jena.tdb.sys.Names ;
+
+/** Rewrite one index */
+public class CmdRewriteIndex
+{
+ static {
+ LogCtl.setLog4j();
+ JenaSystem.init();
+ }
+
+ public static void main(String...argv)
+ {
+ // Usage: srcLocation dstLocation indexName
+ if ( argv.length != 3 ) {
+ System.err.println("Usage: " + Lib.classShortName(CmdRewriteIndex.class) + " SrcLocation DstLocation IndexName");
+ System.exit(1);
+ }
+
+ Location srcLoc = Location.create(argv[0]);
+ Location dstLoc = Location.create(argv[1]);
+ String indexName = argv[2];
+
+ if ( !FileOps.exists(argv[1]) ) {
+ System.err.println("Destination directory does not exist");
+ System.exit(1);
+ }
+
+ if ( FileOps.exists(dstLoc.getPath(indexName, Names.bptExtTree)) ) {
+ System.err.println("Destination contains an index of that name");
+ System.exit(1);
+ }
+
+ ProcRewriteIndex.exec(srcLoc, dstLoc, indexName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-fuseki2/jena-fuseki-core/pom.xml
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/pom.xml b/jena-fuseki2/jena-fuseki-core/pom.xml
index ba8314b..e500114 100644
--- a/jena-fuseki2/jena-fuseki-core/pom.xml
+++ b/jena-fuseki2/jena-fuseki-core/pom.xml
@@ -48,21 +48,20 @@
<dependency>
<groupId>org.apache.jena</groupId>
- <artifactId>jena-arq</artifactId>
+ <artifactId>apache-jena-libs</artifactId>
<version>3.1.0-SNAPSHOT</version>
+ <type>pom</type>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.apache.jena</groupId>
- <artifactId>jena-arq</artifactId>
+ <artifactId>jena-cmds</artifactId>
<version>3.1.0-SNAPSHOT</version>
- <classifier>tests</classifier>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
- <artifactId>jena-base</artifactId>
+ <artifactId>jena-arq</artifactId>
<version>3.1.0-SNAPSHOT</version>
<classifier>tests</classifier>
<scope>test</scope>
@@ -70,8 +69,10 @@
<dependency>
<groupId>org.apache.jena</groupId>
- <artifactId>jena-tdb</artifactId>
+ <artifactId>jena-base</artifactId>
<version>3.1.0-SNAPSHOT</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
</dependency>
<dependency>
@@ -218,7 +219,7 @@
</plugin>
<plugin>
- <!-- Include the test jar for mebedded usein testing (eg. jena-jdbc-driver-remote) -->
+ <!-- Include the test jar for mebedded usein testing (eg. jena-jdbc-driver-remote) -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-maven-tools/pom.xml
----------------------------------------------------------------------
diff --git a/jena-maven-tools/pom.xml b/jena-maven-tools/pom.xml
index fb32f94..26b8bd7 100644
--- a/jena-maven-tools/pom.xml
+++ b/jena-maven-tools/pom.xml
@@ -187,7 +187,7 @@ limitations under the License.
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
- <artifactId>jena-core</artifactId>
+ <artifactId>jena-cmds</artifactId>
<version>3.1.0-SNAPSHOT</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/CmdIndexBuild.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/CmdIndexBuild.java b/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/CmdIndexBuild.java
deleted file mode 100644
index e5a8f6e..0000000
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/CmdIndexBuild.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.tdb.store.bulkloader2;
-
-import java.io.InputStream ;
-import java.util.Iterator ;
-
-import org.apache.jena.atlas.AtlasException ;
-import org.apache.jena.atlas.io.IO ;
-import org.apache.jena.atlas.logging.LogCtl ;
-import org.apache.jena.tdb.base.block.BlockMgr ;
-import org.apache.jena.tdb.base.block.BlockMgrFactory ;
-import org.apache.jena.tdb.base.file.FileSet ;
-import org.apache.jena.tdb.base.file.Location ;
-import org.apache.jena.tdb.base.record.Record ;
-import org.apache.jena.tdb.base.record.RecordFactory ;
-import org.apache.jena.tdb.index.bplustree.BPlusTree ;
-import org.apache.jena.tdb.index.bplustree.BPlusTreeParams ;
-import org.apache.jena.tdb.index.bplustree.BPlusTreeRewriter ;
-import org.apache.jena.tdb.lib.ColumnMap ;
-import org.apache.jena.tdb.sys.Names ;
-import org.apache.jena.tdb.sys.SystemTDB ;
-
-/** From a file of records, build a (packed) index */
-public class CmdIndexBuild
-{
- static { LogCtl.setLog4j() ; }
-
- public static void main(String...argv)
- {
- // DATA IN S/P/O columns but sorted by index order.
-
- if ( argv.length != 3 ) {
- System.err.println("Usage: Location Index dataFile");
- System.exit(1);
- }
-
- String locationStr = argv[0];
- String indexName = argv[1];
-
-// if ( ! Arrays.asList(Names.tripleIndexes).contains(indexName) &&
-// ! Arrays.asList(Names.quadIndexes).contains(indexName) )
-// {
-// System.err.println("Index name not recognized: "+indexName) ;
-// System.exit(1) ;
-// }
-
- String dataFile = argv[2] ;
-
- // Argument processing
-
- Location location = Location.create(locationStr) ;
-
- //InputStream input = System.in ;
- InputStream input = IO.openFile(dataFile) ;
-
- int keyLength = SystemTDB.SizeOfNodeId * indexName.length() ;
- int valueLength = 0 ;
-
- // The name is the order.
- String primary = indexName ;
-
- // Scope for optimization:
- // Null column map => no churn.
- // Do record -> record copy, not Tuple, Tuple copy.
-
- String primaryOrder;
- int dftKeyLength;
- int dftValueLength;
- int tupleLength = indexName.length();
-
- if ( tupleLength == 3 ) {
- primaryOrder = Names.primaryIndexTriples;
- dftKeyLength = SystemTDB.LenIndexTripleRecord;
- dftValueLength = 0;
- } else if ( tupleLength == 4 ) {
- primaryOrder = Names.primaryIndexQuads;
- dftKeyLength = SystemTDB.LenIndexQuadRecord;
- dftValueLength = 0;
- } else {
- throw new AtlasException("Index name: " + indexName);
- }
-
- ColumnMap colMap = new ColumnMap(primaryOrder, indexName) ;
-
- // -1? Write only.
- // Also flush cache every so often => block writes (but not sequential so boring).
- int readCacheSize = 10;
- int writeCacheSize = 100;
-
- int blockSize = SystemTDB.BlockSize;
- RecordFactory recordFactory = new RecordFactory(dftKeyLength, dftValueLength);
-
- int order = BPlusTreeParams.calcOrder(blockSize, recordFactory);
- BPlusTreeParams bptParams = new BPlusTreeParams(order, recordFactory);
-
- int blockSizeNodes = blockSize;
- int blockSizeRecords = blockSize;
-
- FileSet destination = new FileSet(location, indexName);
-
- BlockMgr blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExtTree, blockSizeNodes, readCacheSize, writeCacheSize);
- BlockMgr blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExtRecords, blockSizeRecords, readCacheSize, writeCacheSize);
-
- int rowBlock = 1000;
- Iterator<Record> iter = new RecordsFromInput(input, tupleLength, colMap, rowBlock);
- BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(iter, bptParams, recordFactory, blkMgrNodes, blkMgrRecords);
- bpt2.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/CmdIndexCopy.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/CmdIndexCopy.java b/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/CmdIndexCopy.java
deleted file mode 100644
index 14609d5..0000000
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/CmdIndexCopy.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.tdb.store.bulkloader2;
-
-import java.util.Iterator ;
-
-import org.apache.jena.atlas.lib.DateTimeUtils ;
-import org.apache.jena.atlas.lib.tuple.Tuple ;
-import org.apache.jena.atlas.logging.LogCtl ;
-import org.apache.jena.atlas.logging.ProgressLogger ;
-import org.apache.jena.tdb.base.file.Location ;
-import org.apache.jena.tdb.setup.Build ;
-import org.apache.jena.tdb.store.NodeId ;
-import org.apache.jena.tdb.store.tupletable.TupleIndex ;
-import org.apache.jena.tdb.sys.SystemTDB ;
-import org.slf4j.Logger ;
-import org.slf4j.LoggerFactory ;
-
-/** Copy one index to another, probably with a different key order */
-public class CmdIndexCopy
-{
- static { LogCtl.setLog4j() ; }
- private static Logger log = LoggerFactory.getLogger(CmdIndexCopy.class) ;
-
- static long tickQuantum = 100*1000 ;
- static int superTick = 10 ;
-
- public static void main(String...argv)
- {
- // Ideas:
- // Copy to buffer, sort, write in sequential clumps.
- // Profile code for hotspots
-
- // Maybe be worth opening the data file (the leaves) as a regular,
- // non-memory mapped file as we read it through once, in natural order,
- // and it may be laid out in increasing block order on-disk, e.g. repacked
- // and in increasing order with occassional oddities if SPO from the bulk loader.
-
- if ( argv.length != 4 ) {
- System.err.println("Usage: Location1 Index1 Location2 Index2");
- System.exit(1);
- }
-
- String locationStr1 = argv[0] ;
- String indexName1 = argv[1] ;
- String locationStr2 = argv[2] ;
- String indexName2 = argv[3] ;
-
- // Argument processing
-
- Location location1 = Location.create(locationStr1) ;
- Location location2 = Location.create(locationStr2) ;
-
- int keyLength = SystemTDB.SizeOfNodeId * indexName1.length() ;
- int valueLength = 0 ;
-
- // The name is the order.
- String primary = "SPO" ;
-
- String indexOrder = indexName2 ;
- String label = indexName1+" => "+indexName2 ;
-
- TupleIndex index1 = Build.openTupleIndex(location1, indexName1, primary, indexName1, 10, 10, keyLength, valueLength) ;
- TupleIndex index2 = Build.openTupleIndex(location2, indexName2, primary, indexOrder, 10, 10, keyLength, valueLength) ;
- tupleIndexCopy(index1, index2, label) ;
- index1.close() ;
- index2.close() ;
- }
-
- private static void tupleIndexCopy(TupleIndex index1, TupleIndex index2, String label) {
- ProgressLogger monitor = new ProgressLogger(log, label, tickQuantum, superTick);
- monitor.start();
-
- Iterator<Tuple<NodeId>> iter1 = index1.all();
-
- long counter = 0;
- for ( ; iter1.hasNext() ; ) {
- counter++;
- Tuple<NodeId> tuple = iter1.next();
- index2.add(tuple);
- monitor.tick();
- }
-
- index2.sync();
- long time = monitor.finish();
- float elapsedSecs = time / 1000F;
-
- float rate = (elapsedSecs != 0) ? counter / elapsedSecs : 0;
-
- print("Total: %,d records : %,.2f seconds : %,.2f records/sec [%s]", counter, elapsedSecs, rate, DateTimeUtils.nowAsString());
- }
-
- static private void print(String fmt, Object... args) {
- if ( log != null && log.isInfoEnabled() ) {
- String str = String.format(fmt, args);
- log.info(str);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcIndexBuild.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcIndexBuild.java b/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcIndexBuild.java
new file mode 100644
index 0000000..1a51313
--- /dev/null
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcIndexBuild.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.tdb.store.bulkloader2;
+
+import java.io.InputStream ;
+import java.util.Iterator ;
+
+import org.apache.jena.atlas.AtlasException ;
+import org.apache.jena.atlas.io.IO ;
+import org.apache.jena.tdb.base.block.BlockMgr ;
+import org.apache.jena.tdb.base.block.BlockMgrFactory ;
+import org.apache.jena.tdb.base.file.FileSet ;
+import org.apache.jena.tdb.base.file.Location ;
+import org.apache.jena.tdb.base.record.Record ;
+import org.apache.jena.tdb.base.record.RecordFactory ;
+import org.apache.jena.tdb.index.bplustree.BPlusTree ;
+import org.apache.jena.tdb.index.bplustree.BPlusTreeParams ;
+import org.apache.jena.tdb.index.bplustree.BPlusTreeRewriter ;
+import org.apache.jena.tdb.lib.ColumnMap ;
+import org.apache.jena.tdb.sys.Names ;
+import org.apache.jena.tdb.sys.SystemTDB ;
+
+/** From a file of records, build a (packed) index */
+public class ProcIndexBuild
+{
+ public static void exec(String locationStr, String indexName, String dataFile) {
+
+ // Argument processing
+
+ Location location = Location.create(locationStr) ;
+
+ //InputStream input = System.in ;
+ InputStream input = IO.openFile(dataFile) ;
+
+ int keyLength = SystemTDB.SizeOfNodeId * indexName.length() ;
+ int valueLength = 0 ;
+
+ // The name is the order.
+ String primary = indexName ;
+
+ // Scope for optimization:
+ // Null column map => no churn.
+ // Do record -> record copy, not Tuple, Tuple copy.
+
+ String primaryOrder;
+ int dftKeyLength;
+ int dftValueLength;
+ int tupleLength = indexName.length();
+
+ if ( tupleLength == 3 ) {
+ primaryOrder = Names.primaryIndexTriples;
+ dftKeyLength = SystemTDB.LenIndexTripleRecord;
+ dftValueLength = 0;
+ } else if ( tupleLength == 4 ) {
+ primaryOrder = Names.primaryIndexQuads;
+ dftKeyLength = SystemTDB.LenIndexQuadRecord;
+ dftValueLength = 0;
+ } else {
+ throw new AtlasException("Index name: " + indexName);
+ }
+
+ ColumnMap colMap = new ColumnMap(primaryOrder, indexName) ;
+
+ // -1? Write only.
+ // Also flush cache every so often => block writes (but not sequential so boring).
+ int readCacheSize = 10;
+ int writeCacheSize = 100;
+
+ int blockSize = SystemTDB.BlockSize;
+ RecordFactory recordFactory = new RecordFactory(dftKeyLength, dftValueLength);
+
+ int order = BPlusTreeParams.calcOrder(blockSize, recordFactory);
+ BPlusTreeParams bptParams = new BPlusTreeParams(order, recordFactory);
+
+ int blockSizeNodes = blockSize;
+ int blockSizeRecords = blockSize;
+
+ FileSet destination = new FileSet(location, indexName);
+
+ BlockMgr blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExtTree, blockSizeNodes, readCacheSize, writeCacheSize);
+ BlockMgr blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExtRecords, blockSizeRecords, readCacheSize, writeCacheSize);
+
+ int rowBlock = 1000;
+ Iterator<Record> iter = new RecordsFromInput(input, tupleLength, colMap, rowBlock);
+ BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(iter, bptParams, recordFactory, blkMgrNodes, blkMgrRecords);
+ bpt2.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcIndexCopy.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcIndexCopy.java b/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcIndexCopy.java
new file mode 100644
index 0000000..831dd3c
--- /dev/null
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcIndexCopy.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.tdb.store.bulkloader2;
+
+import java.util.Iterator ;
+
+import org.apache.jena.atlas.lib.DateTimeUtils ;
+import org.apache.jena.atlas.lib.tuple.Tuple ;
+import org.apache.jena.atlas.logging.ProgressLogger ;
+import org.apache.jena.tdb.base.file.Location ;
+import org.apache.jena.tdb.setup.Build ;
+import org.apache.jena.tdb.store.NodeId ;
+import org.apache.jena.tdb.store.tupletable.TupleIndex ;
+import org.apache.jena.tdb.sys.SystemTDB ;
+import org.slf4j.Logger ;
+import org.slf4j.LoggerFactory ;
+
+/** Copy one index to another, probably with a different key order */
+public class ProcIndexCopy
+{
+ private static Logger log = LoggerFactory.getLogger(ProcIndexCopy.class) ;
+
+ static long tickQuantum = 100*1000 ;
+ static int superTick = 10 ;
+
+ // Ideas:
+ // Copy to buffer, sort, write in sequential clumps.
+ // Profile code for hotspots
+
+ // Maybe be worth opening the data file (the leaves) as a regular,
+ // non-memory mapped file as we read it through once, in natural order,
+ // and it may be laid out in increasing block order on-disk, e.g. repacked
+ // and in increasing order with occassional oddities if SPO from the bulk loader.
+
+ public static void exec(String locationStr1, String indexName1, String locationStr2, String indexName2) {
+ // Argument processing
+
+ Location location1 = Location.create(locationStr1) ;
+ Location location2 = Location.create(locationStr2) ;
+
+ int keyLength = SystemTDB.SizeOfNodeId * indexName1.length() ;
+ int valueLength = 0 ;
+
+ // The name is the order.
+ String primary = "SPO" ;
+
+ String indexOrder = indexName2 ;
+ String label = indexName1+" => "+indexName2 ;
+
+ TupleIndex index1 = Build.openTupleIndex(location1, indexName1, primary, indexName1, 10, 10, keyLength, valueLength) ;
+ TupleIndex index2 = Build.openTupleIndex(location2, indexName2, primary, indexOrder, 10, 10, keyLength, valueLength) ;
+ tupleIndexCopy(index1, index2, label) ;
+ index1.close() ;
+ index2.close() ;
+ }
+
+ private static void tupleIndexCopy(TupleIndex index1, TupleIndex index2, String label) {
+ ProgressLogger monitor = new ProgressLogger(log, label, tickQuantum, superTick);
+ monitor.start();
+
+ Iterator<Tuple<NodeId>> iter1 = index1.all();
+
+ long counter = 0;
+ for ( ; iter1.hasNext() ; ) {
+ counter++;
+ Tuple<NodeId> tuple = iter1.next();
+ index2.add(tuple);
+ monitor.tick();
+ }
+
+ index2.sync();
+ long time = monitor.finish();
+ float elapsedSecs = time / 1000F;
+
+ float rate = (elapsedSecs != 0) ? counter / elapsedSecs : 0;
+
+ print("Total: %,d records : %,.2f seconds : %,.2f records/sec [%s]", counter, elapsedSecs, rate, DateTimeUtils.nowAsString());
+ }
+
+ static private void print(String fmt, Object... args) {
+ if ( log != null && log.isInfoEnabled() ) {
+ String str = String.format(fmt, args);
+ log.info(str);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcNodeTableBuilder.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcNodeTableBuilder.java b/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcNodeTableBuilder.java
index 816d27f..d906651 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcNodeTableBuilder.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcNodeTableBuilder.java
@@ -48,11 +48,9 @@ import org.slf4j.Logger ;
public class ProcNodeTableBuilder {
private static Logger cmdLog = TDB.logLoader ;
- public static void execInner(Location location,
- String dataFileTriples,
- String dataFileQuads,
- List<String> datafiles,
- boolean collectStats) {
+ public static void exec(Location location,
+ String dataFileTriples, String dataFileQuads,
+ List<String> datafiles, boolean collectStats) {
// This formats the location correctly.
// But we're not really interested in it all.
DatasetGraphTDB dsg = DatasetBuilderStd.create(location) ;
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcRewriteIndex.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcRewriteIndex.java b/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcRewriteIndex.java
new file mode 100644
index 0000000..2da82a6
--- /dev/null
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcRewriteIndex.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.tdb.store.bulkloader2;
+
+import java.util.Iterator ;
+
+import org.apache.jena.tdb.base.block.BlockMgr ;
+import org.apache.jena.tdb.base.block.BlockMgrFactory ;
+import org.apache.jena.tdb.base.file.FileSet ;
+import org.apache.jena.tdb.base.file.Location ;
+import org.apache.jena.tdb.base.record.Record ;
+import org.apache.jena.tdb.base.record.RecordFactory ;
+import org.apache.jena.tdb.index.RangeIndex ;
+import org.apache.jena.tdb.index.SetupIndex ;
+import org.apache.jena.tdb.index.bplustree.BPlusTree ;
+import org.apache.jena.tdb.index.bplustree.BPlusTreeParams ;
+import org.apache.jena.tdb.index.bplustree.BPlusTreeRewriter ;
+import org.apache.jena.tdb.sys.Names ;
+import org.apache.jena.tdb.sys.SystemTDB ;
+
+public class ProcRewriteIndex {
+ public static void exec(Location srcLoc, Location dstLoc, String indexName)
+ {
+ FileSet destination = new FileSet(dstLoc, indexName) ;
+ int readCacheSize = 0 ;
+ int writeCacheSize = -1 ;
+
+ int dftKeyLength ;
+ int dftValueLength ;
+
+ if ( indexName.length() == 3 ) {
+ dftKeyLength = SystemTDB.LenIndexTripleRecord;
+ dftValueLength = 0;
+ } else if ( indexName.length() == 4 ) {
+ dftKeyLength = SystemTDB.LenIndexQuadRecord;
+ dftValueLength = 0;
+ } else {
+ System.err.printf("Can't determine record size for %s\n", indexName);
+ return;
+ }
+
+ RecordFactory recordFactory = null ;
+ BPlusTreeParams bptParams = null ;
+ BlockMgr blkMgrNodes ;
+ BlockMgr blkMgrRecords ;
+ int blockSize = SystemTDB.BlockSize ;
+
+ RangeIndex rangeIndex = SetupIndex.makeRangeIndex(srcLoc, indexName, blockSize, dftKeyLength, dftValueLength, readCacheSize, writeCacheSize) ;
+ BPlusTree bpt = (BPlusTree)rangeIndex ;
+ bptParams = bpt.getParams() ;
+ recordFactory = bpt.getRecordFactory() ;
+
+ int blockSizeNodes = blockSize ;
+ int blockSizeRecords = blockSize ;
+
+ blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExtTree, blockSizeNodes, readCacheSize, writeCacheSize) ;
+ blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExtRecords, blockSizeRecords, readCacheSize, writeCacheSize) ;
+
+ Iterator<Record> iterator = bpt.iterator() ;
+
+// // Fakery.
+// blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExt1, blockSize, readCacheSize, writeCacheSize) ;
+// blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExt2, blockSize, readCacheSize, writeCacheSize) ;
+// recordFactory = new RecordFactory(dftKeyLength, dftValueLength) ;
+// bptParams = new BPlusTreeParams(3, recordFactory) ;
+// List<Record> data = TestBPlusTreeRewriter.createData(10, recordFactory) ;
+// iterator = data.iterator() ;
+
+ //System.out.println("Rewrite: "+srcLoc+" "+indexName+" --> "+destination) ;
+
+ BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(iterator,
+ bptParams, recordFactory,
+ blkMgrNodes, blkMgrRecords) ;
+ if ( bpt2 == null )
+ return ;
+//
+// Iterator<Record> iter = bpt2.iterator() ;
+// for ( ; iter.hasNext() ; )
+// {
+// Record r = iter.next() ;
+// System.out.println(r) ;
+// }
+
+ bpt2.close() ;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/cda5c7cd/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1b2c7ad..dcc85fe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,7 +15,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Apache Jena</name>
@@ -56,27 +58,28 @@
<profiles>
<profile>
<!--
- This is the dev profile, typically used locally with "mvn clean install".
- It only builds the common modules and
- does not build SDB nor the slow-to-test JDBC module.
+ This is the dev profile, typically used locally with
+ "mvn clean install -Pdev".
+ It only builds the moduels shipped in apache-jena binaries.
-->
<id>dev</id>
<!-- The maven artifacts of the basic modules -->
<modules>
<module>jena-parent</module>
- <!-- <module>jena-shared-guava</module> -->
- <!-- <module>jena-iri</module> -->
- <module>jena-base</module>
+ <!-- <module>jena-shared-guava</module> -->
+ <!-- <module>jena-iri</module> -->
+ <module>jena-base</module>
- <module>jena-core</module>
+ <module>jena-core</module>
<module>jena-arq</module>
<module>jena-tdb</module>
- <module>apache-jena-libs</module>
+ <module>apache-jena-libs</module>
+ <module>jena-cmds</module>
<!--<module>jena-fuseki1</module>-->
- <module>jena-fuseki2</module>
+ <module>jena-fuseki2</module>
- <module>jena-permissions</module>
+ <module>jena-permissions</module>
<!-- Slow to build - exclude from dev build -->
<!-- <module>jena-jdbc</module> -->
@@ -84,14 +87,14 @@
<!-- <module>apache-jena-libs</module> -->
<!-- <module>apache-jena</module> -->
<!-- <module>jena-elephas</module> -->
- <!-- <module>jena-extras</module> -->
+ <!-- <module>jena-extras</module> -->
</modules>
</profile>
<profile>
<!--
- This is the complete profile, it builds everything including slow
- building modules and the distribution packages.
+ This is the complete profile, it builds everything including slow
+ building modules and the distribution packages.
-->
<id>complete</id>
<activation>
@@ -111,20 +114,22 @@
<module>jena-arq</module>
<module>jena-tdb</module>
<module>apache-jena-libs</module>
+ <module>jena-cmds</module>
<module>jena-text</module>
<module>jena-spatial</module>
<module>jena-csv</module>
- <module>jena-sdb</module>
+ <module>jena-sdb</module>
<module>jena-fuseki1</module>
<module>jena-fuseki2</module>
- <module>jena-permissions</module>
+ <module>jena-permissions</module>
<module>jena-jdbc</module>
<module>jena-maven-tools</module>
<module>jena-elephas</module>
+
<module>apache-jena</module>
<module>apache-jena-osgi</module>