Move AbstractTestTupleIndex into store/tupleindex. Project: http://git-wip-us.apache.org/repos/asf/jena/repo Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/2e4c6c77 Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/2e4c6c77 Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/2e4c6c77
Branch: refs/heads/hadoop-rdf Commit: 2e4c6c77f5f364ce037665da19653176ff17ae0b Parents: eb9400d Author: Andy Seaborne <[email protected]> Authored: Fri Jan 9 15:38:00 2015 +0000 Committer: Andy Seaborne <[email protected]> Committed: Fri Jan 9 15:38:00 2015 +0000 ---------------------------------------------------------------------- .../jena/tdb/index/AbstractTestTupleIndex.java | 271 ------------------- .../tupletable/AbstractTestTupleIndex.java | 271 +++++++++++++++++++ .../store/tupletable/TestTupleIndexRecord.java | 1 - 3 files changed, 271 insertions(+), 272 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jena/blob/2e4c6c77/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/index/AbstractTestTupleIndex.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/index/AbstractTestTupleIndex.java b/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/index/AbstractTestTupleIndex.java deleted file mode 100644 index bcc078d..0000000 --- a/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/index/AbstractTestTupleIndex.java +++ /dev/null @@ -1,271 +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 com.hp.hpl.jena.tdb.index; - -import java.util.Iterator ; -import java.util.Set ; - -import org.apache.jena.atlas.iterator.Iter ; -import org.apache.jena.atlas.junit.BaseTest ; -import org.apache.jena.atlas.lib.Tuple ; -import static org.apache.jena.atlas.lib.Tuple.* ; -import org.junit.Test ; - -import com.hp.hpl.jena.tdb.store.NodeId ; -import com.hp.hpl.jena.tdb.store.tupletable.TupleIndex ; - -/** Test TupleIndexes (general) */ -public abstract class AbstractTestTupleIndex extends BaseTest -{ - protected static NodeId n1 = new NodeId(1) ; - protected static NodeId n2 = new NodeId(2) ; - protected static NodeId n3 = new NodeId(3) ; - protected static NodeId n4 = new NodeId(0x4040404040404040L) ; - protected static NodeId n5 = new NodeId(0x5555555555555555L) ; - protected static NodeId n6 = new NodeId(0x6666666666666666L) ; - - protected abstract TupleIndex create(String description) ; - - protected static void add(TupleIndex index, NodeId x1, NodeId x2, NodeId x3) - { - Tuple<NodeId> tuple = createTuple(x1, x2, x3) ; - index.add(tuple) ; - } - - @Test public void TupleIndex_1() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - } - - @Test public void TupleIndexRecordSPO_1() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - - Tuple<NodeId> tuple2 = createTuple(n1, n2, n3) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - assertTrue(iter.hasNext()) ; - iter.next(); - assertFalse(iter.hasNext()) ; - } - - @Test public void TupleIndexRecordSPO_2() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - - Tuple<NodeId> tuple2 = createTuple(n1, n2, null) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - assertTrue(iter.hasNext()) ; - iter.next(); - assertFalse(iter.hasNext()) ; - } - - @Test public void TupleIndexRecordSPO_3() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - - Tuple<NodeId> tuple2 = createTuple(n1, null, n3) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - assertTrue(iter.hasNext()) ; - iter.next(); - assertFalse(iter.hasNext()) ; - } - - @Test public void TupleIndexRecordSPO_4() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - - Tuple<NodeId> tuple2 = createTuple(n1, NodeId.NodeIdAny, NodeId.NodeIdAny) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - assertTrue(iter.hasNext()) ; - iter.next(); - assertFalse(iter.hasNext()) ; - } - - @Test public void TupleIndexRecordSPO_5() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - add(index, n1, n2, n4) ; - - Tuple<NodeId> tuple2 = createTuple(n1, n2, n3) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - Set<Tuple<NodeId>> x = Iter.toSet(iter) ; - assertEquals(1, x.size()) ; - assertTrue(x.contains(createTuple(n1, n2, n3))) ; - assertFalse(x.contains(createTuple(n1, n2, n4))) ; - } - - @Test public void TupleIndexRecordSPO_6() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - add(index, n1, n2, n4) ; - - Tuple<NodeId> tuple2 = createTuple(n1, n2, NodeId.NodeIdAny) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - Set<Tuple<NodeId>> x = Iter.toSet(iter) ; - assertEquals(2, x.size()) ; - assertTrue(x.contains(createTuple(n1, n2, n3))) ; - assertTrue(x.contains(createTuple(n1, n2, n4))) ; - } - - @Test public void TupleIndexRecordSPO_7() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - add(index, n1, n2, n4) ; - - Tuple<NodeId> tuple2 = createTuple(n1, NodeId.NodeIdAny, NodeId.NodeIdAny) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - Set<Tuple<NodeId>> x = Iter.toSet(iter) ; - assertEquals(2, x.size()) ; - assertTrue(x.contains(createTuple(n1, n2, n3))) ; - assertTrue(x.contains(createTuple(n1, n2, n4))) ; - } - - @Test public void TupleIndexRecordSPO_8() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - add(index, n2, n3, n4) ; - - { - Tuple<NodeId> tuple2 = createTuple(n1, NodeId.NodeIdAny, NodeId.NodeIdAny) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - Set<Tuple<NodeId>> x = Iter.toSet(iter) ; - assertEquals(1, x.size()) ; - assertTrue(x.contains(createTuple(n1, n2, n3))) ; - } - - { - Tuple<NodeId> tuple2 = createTuple(n2, NodeId.NodeIdAny, NodeId.NodeIdAny) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - Set<Tuple<NodeId>> x = Iter.toSet(iter) ; - assertEquals(1, x.size()) ; - assertTrue(x.contains(createTuple(n2, n3, n4))) ; - } - } - - @Test public void TupleIndexRecordPOS_1() - { - TupleIndex index = create("POS") ; - add(index, n1, n2, n3) ; - Tuple<NodeId> tuple2 = createTuple(n1, n2, n3) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - assertTrue("Can't find tuple", iter.hasNext()) ; - iter.next(); - assertFalse(iter.hasNext()) ; - } - - @Test public void TupleIndexRecordPOS_2() - { - TupleIndex index = create("POS") ; - add(index, n1, n2, n3) ; - - Tuple<NodeId> tuple2 = createTuple(null, n2, null) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - assertTrue("Can't find tuple",iter.hasNext()) ; - iter.next(); - assertFalse(iter.hasNext()) ; - } - - - @Test public void TupleIndexRecordPOS_3() - { - TupleIndex index = create("POS") ; - add(index, n1, n2, n3) ; - - Tuple<NodeId> tuple2 = createTuple(null, n2, n3) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - assertTrue("Can't find tuple", iter.hasNext()) ; - iter.next(); - assertFalse(iter.hasNext()) ; - } - - @Test public void TupleIndexRecordFindNot_1() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - - Tuple<NodeId> tuple2 = createTuple(n4, n5, n6) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - assertNotNull(iter) ; - assertFalse(iter.hasNext()) ; - } - - @Test public void TupleIndexRecordFindNot_2() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - - Tuple<NodeId> tuple2 = createTuple(n1, n5, n6) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - assertFalse(iter.hasNext()) ; - } - - @Test public void TupleIndexRecordFindNot_3() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - - Tuple<NodeId> tuple2 = createTuple(n1, null, n6) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - assertFalse(iter.hasNext()) ; - } - - @Test public void TupleIndexRecordFindNot_4() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - add(index, n1, n5, n6) ; - - Tuple<NodeId> tuple2 = createTuple(n4, n5, n6) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - assertFalse(iter.hasNext()) ; - } - - @Test public void TupleIndexRecordFindNot_5() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - add(index, n1, n5, n6) ; - - Tuple<NodeId> tuple2 = createTuple(n2, n5, n6) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - assertFalse(iter.hasNext()) ; - } - - @Test public void TupleIndexRecordFindNot_6() - { - TupleIndex index = create("SPO") ; - add(index, n1, n2, n3) ; - add(index, n4, n5, n6) ; - - Tuple<NodeId> tuple2 = createTuple(n1, null, n6) ; - Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; - assertFalse(iter.hasNext()) ; - } - - -} http://git-wip-us.apache.org/repos/asf/jena/blob/2e4c6c77/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/tupletable/AbstractTestTupleIndex.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/tupletable/AbstractTestTupleIndex.java b/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/tupletable/AbstractTestTupleIndex.java new file mode 100644 index 0000000..496d3b5 --- /dev/null +++ b/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/tupletable/AbstractTestTupleIndex.java @@ -0,0 +1,271 @@ +/* + * 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 com.hp.hpl.jena.tdb.store.tupletable; + +import java.util.Iterator ; +import java.util.Set ; + +import org.apache.jena.atlas.iterator.Iter ; +import org.apache.jena.atlas.junit.BaseTest ; +import org.apache.jena.atlas.lib.Tuple ; +import static org.apache.jena.atlas.lib.Tuple.* ; +import org.junit.Test ; + +import com.hp.hpl.jena.tdb.store.NodeId ; +import com.hp.hpl.jena.tdb.store.tupletable.TupleIndex ; + +/** Test TupleIndexes (general) */ +public abstract class AbstractTestTupleIndex extends BaseTest +{ + protected static NodeId n1 = new NodeId(1) ; + protected static NodeId n2 = new NodeId(2) ; + protected static NodeId n3 = new NodeId(3) ; + protected static NodeId n4 = new NodeId(0x4040404040404040L) ; + protected static NodeId n5 = new NodeId(0x5555555555555555L) ; + protected static NodeId n6 = new NodeId(0x6666666666666666L) ; + + protected abstract TupleIndex create(String description) ; + + protected static void add(TupleIndex index, NodeId x1, NodeId x2, NodeId x3) + { + Tuple<NodeId> tuple = createTuple(x1, x2, x3) ; + index.add(tuple) ; + } + + @Test public void TupleIndex_1() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + } + + @Test public void TupleIndexRecordSPO_1() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + + Tuple<NodeId> tuple2 = createTuple(n1, n2, n3) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + assertTrue(iter.hasNext()) ; + iter.next(); + assertFalse(iter.hasNext()) ; + } + + @Test public void TupleIndexRecordSPO_2() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + + Tuple<NodeId> tuple2 = createTuple(n1, n2, null) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + assertTrue(iter.hasNext()) ; + iter.next(); + assertFalse(iter.hasNext()) ; + } + + @Test public void TupleIndexRecordSPO_3() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + + Tuple<NodeId> tuple2 = createTuple(n1, null, n3) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + assertTrue(iter.hasNext()) ; + iter.next(); + assertFalse(iter.hasNext()) ; + } + + @Test public void TupleIndexRecordSPO_4() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + + Tuple<NodeId> tuple2 = createTuple(n1, NodeId.NodeIdAny, NodeId.NodeIdAny) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + assertTrue(iter.hasNext()) ; + iter.next(); + assertFalse(iter.hasNext()) ; + } + + @Test public void TupleIndexRecordSPO_5() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + add(index, n1, n2, n4) ; + + Tuple<NodeId> tuple2 = createTuple(n1, n2, n3) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + Set<Tuple<NodeId>> x = Iter.toSet(iter) ; + assertEquals(1, x.size()) ; + assertTrue(x.contains(createTuple(n1, n2, n3))) ; + assertFalse(x.contains(createTuple(n1, n2, n4))) ; + } + + @Test public void TupleIndexRecordSPO_6() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + add(index, n1, n2, n4) ; + + Tuple<NodeId> tuple2 = createTuple(n1, n2, NodeId.NodeIdAny) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + Set<Tuple<NodeId>> x = Iter.toSet(iter) ; + assertEquals(2, x.size()) ; + assertTrue(x.contains(createTuple(n1, n2, n3))) ; + assertTrue(x.contains(createTuple(n1, n2, n4))) ; + } + + @Test public void TupleIndexRecordSPO_7() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + add(index, n1, n2, n4) ; + + Tuple<NodeId> tuple2 = createTuple(n1, NodeId.NodeIdAny, NodeId.NodeIdAny) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + Set<Tuple<NodeId>> x = Iter.toSet(iter) ; + assertEquals(2, x.size()) ; + assertTrue(x.contains(createTuple(n1, n2, n3))) ; + assertTrue(x.contains(createTuple(n1, n2, n4))) ; + } + + @Test public void TupleIndexRecordSPO_8() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + add(index, n2, n3, n4) ; + + { + Tuple<NodeId> tuple2 = createTuple(n1, NodeId.NodeIdAny, NodeId.NodeIdAny) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + Set<Tuple<NodeId>> x = Iter.toSet(iter) ; + assertEquals(1, x.size()) ; + assertTrue(x.contains(createTuple(n1, n2, n3))) ; + } + + { + Tuple<NodeId> tuple2 = createTuple(n2, NodeId.NodeIdAny, NodeId.NodeIdAny) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + Set<Tuple<NodeId>> x = Iter.toSet(iter) ; + assertEquals(1, x.size()) ; + assertTrue(x.contains(createTuple(n2, n3, n4))) ; + } + } + + @Test public void TupleIndexRecordPOS_1() + { + TupleIndex index = create("POS") ; + add(index, n1, n2, n3) ; + Tuple<NodeId> tuple2 = createTuple(n1, n2, n3) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + assertTrue("Can't find tuple", iter.hasNext()) ; + iter.next(); + assertFalse(iter.hasNext()) ; + } + + @Test public void TupleIndexRecordPOS_2() + { + TupleIndex index = create("POS") ; + add(index, n1, n2, n3) ; + + Tuple<NodeId> tuple2 = createTuple(null, n2, null) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + assertTrue("Can't find tuple",iter.hasNext()) ; + iter.next(); + assertFalse(iter.hasNext()) ; + } + + + @Test public void TupleIndexRecordPOS_3() + { + TupleIndex index = create("POS") ; + add(index, n1, n2, n3) ; + + Tuple<NodeId> tuple2 = createTuple(null, n2, n3) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + assertTrue("Can't find tuple", iter.hasNext()) ; + iter.next(); + assertFalse(iter.hasNext()) ; + } + + @Test public void TupleIndexRecordFindNot_1() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + + Tuple<NodeId> tuple2 = createTuple(n4, n5, n6) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + assertNotNull(iter) ; + assertFalse(iter.hasNext()) ; + } + + @Test public void TupleIndexRecordFindNot_2() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + + Tuple<NodeId> tuple2 = createTuple(n1, n5, n6) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + assertFalse(iter.hasNext()) ; + } + + @Test public void TupleIndexRecordFindNot_3() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + + Tuple<NodeId> tuple2 = createTuple(n1, null, n6) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + assertFalse(iter.hasNext()) ; + } + + @Test public void TupleIndexRecordFindNot_4() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + add(index, n1, n5, n6) ; + + Tuple<NodeId> tuple2 = createTuple(n4, n5, n6) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + assertFalse(iter.hasNext()) ; + } + + @Test public void TupleIndexRecordFindNot_5() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + add(index, n1, n5, n6) ; + + Tuple<NodeId> tuple2 = createTuple(n2, n5, n6) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + assertFalse(iter.hasNext()) ; + } + + @Test public void TupleIndexRecordFindNot_6() + { + TupleIndex index = create("SPO") ; + add(index, n1, n2, n3) ; + add(index, n4, n5, n6) ; + + Tuple<NodeId> tuple2 = createTuple(n1, null, n6) ; + Iterator<Tuple<NodeId>> iter = index.find(tuple2) ; + assertFalse(iter.hasNext()) ; + } + + +} http://git-wip-us.apache.org/repos/asf/jena/blob/2e4c6c77/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/tupletable/TestTupleIndexRecord.java ---------------------------------------------------------------------- diff --git a/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/tupletable/TestTupleIndexRecord.java b/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/tupletable/TestTupleIndexRecord.java index 1f2bd2c..4078628 100644 --- a/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/tupletable/TestTupleIndexRecord.java +++ b/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/tupletable/TestTupleIndexRecord.java @@ -23,7 +23,6 @@ import org.apache.jena.atlas.lib.ColumnMap ; import com.hp.hpl.jena.tdb.base.file.FileSet ; import com.hp.hpl.jena.tdb.base.record.RecordFactory ; -import com.hp.hpl.jena.tdb.index.AbstractTestTupleIndex ; import com.hp.hpl.jena.tdb.index.IndexFactory ; import com.hp.hpl.jena.tdb.index.IndexParams ; import com.hp.hpl.jena.tdb.index.RangeIndex ;
