Delete old dev code. Project: http://git-wip-us.apache.org/repos/asf/jena/repo Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/a55e1478 Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/a55e1478 Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/a55e1478
Branch: refs/heads/add-contract-tests Commit: a55e14780ac58e5cc08dd64424ad8307195ed885 Parents: e81ee64 Author: Andy Seaborne <[email protected]> Authored: Thu May 7 10:29:40 2015 +0100 Committer: Andy Seaborne <[email protected]> Committed: Thu May 7 10:29:40 2015 +0100 ---------------------------------------------------------------------- jena-tdb/src-dev/dev/Tests.java | 32 ---- jena-tdb/src-dev/test/BPlusTreeRun.java | 74 --------- jena-tdb/src-dev/test/ByteBufferTest.java | 78 --------- jena-tdb/src-dev/test/ExtHashRun.java | 200 ----------------------- jena-tdb/src-dev/test/RunnerExecute.java | 119 -------------- jena-tdb/src-dev/test/RunnerRangeIndex.java | 149 ----------------- 6 files changed, 652 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jena/blob/a55e1478/jena-tdb/src-dev/dev/Tests.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src-dev/dev/Tests.java b/jena-tdb/src-dev/dev/Tests.java deleted file mode 100644 index 8802761..0000000 --- a/jena-tdb/src-dev/dev/Tests.java +++ /dev/null @@ -1,32 +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 dev; - -import org.junit.runner.RunWith ; -import org.junit.runners.Suite ; - -@RunWith(Suite.class) [email protected]( { -}) - -public class Tests -{ - -} - http://git-wip-us.apache.org/repos/asf/jena/blob/a55e1478/jena-tdb/src-dev/test/BPlusTreeRun.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src-dev/test/BPlusTreeRun.java b/jena-tdb/src-dev/test/BPlusTreeRun.java deleted file mode 100644 index 5e65f41..0000000 --- a/jena-tdb/src-dev/test/BPlusTreeRun.java +++ /dev/null @@ -1,74 +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 test; - -import org.openjena.atlas.logging.Log ; - -import com.hp.hpl.jena.tdb.base.file.BlockAccessMem ; -import com.hp.hpl.jena.tdb.index.RangeIndexMaker ; -import com.hp.hpl.jena.tdb.index.bplustree.BPlusTree ; -import com.hp.hpl.jena.tdb.index.bplustree.BPlusTreeMaker ; -import com.hp.hpl.jena.tdb.index.bplustree.BPlusTreeParams ; -import com.hp.hpl.jena.tdb.sys.SystemTDB ; - -public class BPlusTreeRun extends RunnerRangeIndex -{ - static { Log.setLog4j() ; } - - static public void main(String...a) - { - new BPlusTreeRun().perform(a) ; - } - - @Override - protected RangeIndexMaker makeRangeIndexMaker() - { - BPlusTreeMaker maker = new BPlusTreeMaker(order, order, trackingBlocks) ; - - BPlusTree bpt = (BPlusTree)(maker.makeIndex()) ; - BPlusTreeParams param = bpt.getParams() ; - System.out.println(bpt.getParams()) ; - System.out.println("Block size = "+bpt.getParams().getCalcBlockSize()) ; - return maker ; - } - - @Override - protected void initialize(RunType runType) - { - switch (runType) - { - case test: - showProgress = true ; - //BPlusTreeParams.checkAll() ; - BPlusTreeParams.CheckingTree = true ; - BPlusTreeParams.CheckingNode = true ; - SystemTDB.NullOut = true ; - BlockAccessMem.SafeMode = true ; - break ; - case perf: - showProgress = false ; - BPlusTreeParams.CheckingTree = false ; - BPlusTreeParams.CheckingNode = false ; - SystemTDB.NullOut = false ; - BlockAccessMem.SafeMode = false ; - break ; - } - } - -} http://git-wip-us.apache.org/repos/asf/jena/blob/a55e1478/jena-tdb/src-dev/test/ByteBufferTest.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src-dev/test/ByteBufferTest.java b/jena-tdb/src-dev/test/ByteBufferTest.java deleted file mode 100644 index 7012530..0000000 --- a/jena-tdb/src-dev/test/ByteBufferTest.java +++ /dev/null @@ -1,78 +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 test ; -import java.nio.ByteBuffer; - -import org.junit.Test; - - -public class ByteBufferTest { - //@Test - public void direct0() { - testDirect("direct0"); - } - @Test - public void heap1() { - testHeap("heap1"); - } - - @Test - public void direct1() { - testDirect("direct1"); - } - - @Test - public void heap2() { - testHeap("heap2"); - } - - @Test - public void direct2() { - testDirect("direct2"); - } - - private void testHeap(String name) { - ByteBuffer buf = ByteBuffer.allocate(2048); - long startTime = System.currentTimeMillis(); - for (int i = 1048576; i > 0; i --) { - buf.clear(); - while (buf.hasRemaining()) { - buf.getInt(buf.position()); - buf.putInt((byte) 0); - } - } - long endTime = System.currentTimeMillis(); - System.out.println(name + ": " + (endTime - startTime)); - } - - private void testDirect(String name) { - ByteBuffer buf = ByteBuffer.allocateDirect(2048); - long startTime = System.currentTimeMillis(); - for (int i = 1048576; i > 0; i --) { - buf.clear(); - while (buf.hasRemaining()) { - buf.getInt(buf.position()); - buf.putInt((byte) 0); - } - } - long endTime = System.currentTimeMillis(); - System.out.println(name + ": " + (endTime - startTime)); - } - -} http://git-wip-us.apache.org/repos/asf/jena/blob/a55e1478/jena-tdb/src-dev/test/ExtHashRun.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src-dev/test/ExtHashRun.java b/jena-tdb/src-dev/test/ExtHashRun.java deleted file mode 100644 index 0f74037..0000000 --- a/jena-tdb/src-dev/test/ExtHashRun.java +++ /dev/null @@ -1,200 +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 test; - -import static org.openjena.atlas.lib.RandomLib.random; -import static org.openjena.atlas.test.Gen.permute; -import static org.openjena.atlas.test.Gen.rand; -import static org.openjena.atlas.test.Gen.strings; - -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.openjena.atlas.logging.Log ; - - -import com.hp.hpl.jena.tdb.index.ext.ExtHash; -import com.hp.hpl.jena.tdb.index.ext.ExtHashTestBase; -import com.hp.hpl.jena.tdb.sys.SystemTDB; - - -//import tdb.Cmd; - -public abstract class ExtHashRun -{ - static boolean showProgress = true ; - - static { Log.setLog4j() ; } - - static public void main(String...a) - { - List<String> args = new ArrayList<String>(Arrays.asList(a)) ; - if ( args.size() == 0 ) - { - System.err.println("No subcommand") ; - System.exit(1) ; - } - String subCmd = args.remove(0) ; - if ( "test".equalsIgnoreCase(subCmd) ) - new Test().exec(args) ; - else if ( "perf".equalsIgnoreCase(subCmd) ) - new Perf().exec(args) ; - else - { - System.err.println("Unknown subcommand: "+subCmd) ; - System.exit(1) ; - } - } - - public void exec(List<String> args) - { - args = processArgs(args) ; - int numKeys = Integer.parseInt(args.get(0)) ; - int iterations = Integer.parseInt(args.get(1)) ; - exec(numKeys, iterations) ; - } - - protected abstract void exec(int numKeys, int iterations) ; - - // ---- Test - public static class Test extends ExtHashRun - { - @Override - protected void exec(int numKeys, int iterations) - { - ExtHash.Checking = true ; - ExtHashTestBase.randTests(10*numKeys, numKeys, iterations, showProgress) ; - } - } - - // ---- Perfromance - public static class Perf extends ExtHashRun - { - @Override - public void exec(List<String> args) - { - showProgress = true ; - ExtHash.Checking = false ; - ExtHash.Logging = false ; - SystemTDB.NullOut = false ; - super.exec(args) ; - } - - @Override - protected void exec(int numKeys, int iterations) - { - RandomGen rand = new RandomGen(100*numKeys, numKeys) ; - org.openjena.atlas.test.RepeatExecution.repeatExecutions(rand, iterations, showProgress) ; - } - } - - static class RandomGen implements org.openjena.atlas.test.ExecGenerator - { - int maxNumKeys ; - int maxValue ; - - RandomGen(int maxValue, int maxNumKeys) - { - if ( maxValue <= maxNumKeys ) - throw new IllegalArgumentException("ExtHash: Max value less than number of keys") ; - this.maxValue = maxValue ; - this.maxNumKeys = maxNumKeys ; - } - - @Override - public void executeOneTest() - { - int numKeys = random.nextInt(maxNumKeys)+1 ; - perfTest(maxValue, numKeys) ; - } - - /* Performance test : print the keys if there was a problem */ - public static void perfTest(int maxValue, int numKeys) - { -// if ( numKeys >= 3000 ) -// System.err.printf("Warning: a lot of keys\n") ; - - int[] keys1 = rand(numKeys, 0, maxValue) ; - int[] keys2 = permute(keys1, numKeys) ; - try { - ExtHash extHash = ExtHashTestBase.create(keys1) ; - ExtHashTestBase.delete(extHash, keys2) ; - } catch (RuntimeException ex) - { - System.err.printf("int[] keys1 = {%s} ;\n", strings(keys1)) ; - System.err.printf("int[] keys2 = {%s}; \n", strings(keys2)) ; - throw ex ; - } - } - } - - List<String> processArgs(List<String> args) - { - - int i = 0 ; - while ( args.size()>0 ) - { - if ( !args.get(0).startsWith("-") ) - break ; - - String a = args.remove(0) ; - if ( a.startsWith("--") ) - a = a.substring(2) ; - else - a = a.substring(1) ; - - if ( a.equals("h") || a.equals("help") ) - { - usage(System.out) ; - System.exit(0) ; - } - else if ( a.equals("v") ) - {} - else if ( a.equalsIgnoreCase("check") ) - { - ExtHash.Checking = true ; - } - else if ( a.equalsIgnoreCase("display") ) - { - showProgress = ! showProgress ; - } - else - { - System.err.println("Unknown argument: "+a) ; - System.exit(1) ; - } - } - - if ( args.size() != 2 ) - { - usage(System.err) ; - System.exit(1) ; - } - return args ; - } - - public static void usage(PrintStream printStream) - { - printStream.println("Usage: OPTIONS NumKeys Iterations") ; - printStream.println("Options:") ; - printStream.println(" --check") ; - } -} http://git-wip-us.apache.org/repos/asf/jena/blob/a55e1478/jena-tdb/src-dev/test/RunnerExecute.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src-dev/test/RunnerExecute.java b/jena-tdb/src-dev/test/RunnerExecute.java deleted file mode 100644 index cd37329..0000000 --- a/jena-tdb/src-dev/test/RunnerExecute.java +++ /dev/null @@ -1,119 +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 test; - -import static org.openjena.atlas.test.Gen.permute ; -import static org.openjena.atlas.test.Gen.rand ; -import static org.openjena.atlas.test.Gen.strings ; - -import java.io.PrintStream ; -import java.util.ArrayList ; -import java.util.Arrays ; -import java.util.List ; - -import org.openjena.atlas.test.ExecGenerator ; -import org.openjena.atlas.test.RepeatExecution ; - -import com.hp.hpl.jena.tdb.index.Index ; -import com.hp.hpl.jena.tdb.index.IndexMaker ; -import com.hp.hpl.jena.tdb.index.IndexTestLib ; -import com.hp.hpl.jena.tdb.index.bplustree.BPlusTreeMaker ; - - -public abstract class RunnerExecute -{ - static enum RunType { test , perf } - - static boolean showProgress = true ; - - public void perform(String...a) - { - List<String> args = new ArrayList<String>(Arrays.asList(a)) ; - if ( args.size() == 0 ) - { - System.err.println("No subcommand") ; - System.exit(1) ; - } - System.out.println(args) ; - String subCmd = args.remove(0) ; - RunType runType = null ; - - if ( "test".equalsIgnoreCase(subCmd) ) - runType = RunType.test ; - else if ( "perf".equalsIgnoreCase(subCmd) ) - runType = RunType.perf ; - else - { - System.err.println("Unknown subcommand: "+subCmd) ; - System.exit(1) ; - } - - initialize(runType) ; - - args = processArgs(args) ; - int iterations = startRun(args, runType) ; - - ExecGenerator gen = execGenerator() ; - RepeatExecution.repeatExecutions(gen, iterations, showProgress) ; - finishRun() ; - } - - protected abstract void initialize(RunType runType) ; - protected abstract List<String> processArgs(List<String> args) ; - - protected abstract ExecGenerator execGenerator() ; - protected abstract int startRun(List<String> args, RunType runType) ; - protected abstract void finishRun() ; - - public static void usage(PrintStream printStream) - { - printStream.println("Usage: OPTIONS Order NumKeys Iterations") ; - printStream.println("Options:") ; - printStream.println(" --display") ; - printStream.println(" --check (same as btree:checknode)") ; - printStream.println(" --bptree:check") ; - printStream.println(" --bptree:track") ; - printStream.println(" --bptree:checknode (expensive)") ; - printStream.println(" --bptree:log") ; - printStream.println(" --bptree:safe") ; - } - - /* Performance test : print the keys if there was a problem */ - - public static void perfTest(int order, int maxValue, int numKeys) - { - // UNUSED. -// if ( numKeys >= 3000 ) -// System.err.printf("Warning: too many keys\n") ; - - int[] keys1 = rand(numKeys, 0, maxValue) ; - int[] keys2 = permute(keys1, numKeys) ; - try { - IndexMaker maker = new BPlusTreeMaker(order, order, false) ; - Index rIndex = IndexTestLib.buildIndex(maker, keys1); - IndexTestLib.delete(rIndex, keys2) ; - } catch (RuntimeException ex) - { - System.err.printf("int order=%d ;\n", order) ; - System.err.printf("int[] keys1 = {%s} ;\n", strings(keys1)) ; - System.err.printf("int[] keys2 = {%s} ; \n", strings(keys2)) ; - throw ex ; - } - } -} http://git-wip-us.apache.org/repos/asf/jena/blob/a55e1478/jena-tdb/src-dev/test/RunnerRangeIndex.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src-dev/test/RunnerRangeIndex.java b/jena-tdb/src-dev/test/RunnerRangeIndex.java deleted file mode 100644 index 38fe57e..0000000 --- a/jena-tdb/src-dev/test/RunnerRangeIndex.java +++ /dev/null @@ -1,149 +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 test; -import java.util.List ; - -import org.apache.log4j.Level ; -import org.openjena.atlas.test.ExecGenerator ; - -import com.hp.hpl.jena.tdb.base.file.BlockAccessMem ; -import com.hp.hpl.jena.tdb.index.IndexTestGenerator ; -import com.hp.hpl.jena.tdb.index.RangeIndexMaker ; -import com.hp.hpl.jena.tdb.index.bplustree.BPlusTreeParams ; -import com.hp.hpl.jena.tdb.sys.SystemTDB ; - -public abstract class RunnerRangeIndex extends RunnerExecute -{ - int order ; - int maxValue ; - int maxNumKeys ; - - static boolean trackingBlocks = false ; - - protected abstract RangeIndexMaker makeRangeIndexMaker() ; - - @Override - protected ExecGenerator execGenerator() - { - RangeIndexMaker maker = makeRangeIndexMaker() ; - //new RangeIndexTestGenerator(maker, numKeys*100, numKeys) ; - IndexTestGenerator test = new IndexTestGenerator(maker, maxValue, maxNumKeys) ; - return test ; - } - - @Override - protected int startRun(List<String> args, RunType runType) - { - order = Integer.parseInt(args.get(0)) ; - int numKeys = Integer.parseInt(args.get(1)) ; - int iterations = Integer.parseInt(args.get(2)) ; - - maxValue = 10*numKeys ; - maxNumKeys = numKeys ; - return iterations ; - } - - @Override - protected void finishRun() - {} - - /** Process the arguments - return any to be done later (positionals) */ - @Override - protected List<String> processArgs(List<String> args) - { - int i = 0 ; - while ( args.size()>0 ) - { - if ( !args.get(0).startsWith("-") ) - break ; - - String a = args.remove(0) ; - if ( a.startsWith("--") ) - a = a.substring(2) ; - else - a = a.substring(1) ; - - if ( a.equals("h") || a.equals("help") ) - { - usage(System.out) ; - System.exit(0) ; - } - else if ( a.equals("v") ) - BPlusTreeParams.DumpTree = true ; - else if ( a.equalsIgnoreCase("bptree:check") ) - { - BPlusTreeParams.CheckingTree = true ; - BPlusTreeParams.CheckingNode = false ; - SystemTDB.NullOut = true ; - BlockAccessMem.SafeMode = true ; - } - else if ( a.equalsIgnoreCase("bptree:checknode") ) - { - BPlusTreeParams.CheckingTree = true ; - BPlusTreeParams.CheckingNode = true ; - SystemTDB.NullOut = true ; - BlockAccessMem.SafeMode = true ; - } - else if ( a.equalsIgnoreCase("bptree:log") ) - { - showProgress = false ; - org.apache.log4j.LogManager.getLogger("bptree").setLevel(Level.DEBUG) ; - org.apache.log4j.LogManager.getLogger("bptree.block").setLevel(Level.INFO) ; - } - else if ( a.equalsIgnoreCase("block:log") ) - { - showProgress = false ; - org.apache.log4j.LogManager.getLogger("bptree.block").setLevel(Level.DEBUG) ; - } - else if ( a.equalsIgnoreCase("block:safe") ) - BlockAccessMem.SafeMode = true ; - else if ( a.equalsIgnoreCase("check") ) - { - BPlusTreeParams.CheckingNode = false; - BPlusTreeParams.CheckingTree = false ; -// SystemTDB.NullOut = true ; -// FileAccessMem.SafeMode = true ; - } - else if ( a.equalsIgnoreCase("display") ) - { - showProgress = ! showProgress ; - } - else if ( a.equalsIgnoreCase("bptree:track") ) - { - BPlusTreeParams.CheckingTree = false ; - BPlusTreeParams.CheckingNode = false ; - trackingBlocks = true ; - } - else - { - System.err.println("Unknown argument: "+a) ; - System.exit(1) ; - } - } - - if ( args.size() != 3 ) - { - usage(System.err) ; - System.exit(1) ; - } - - return args ; - } - -}
