From 74b7bc88b49921f569b28723b1991e4b6a7ebbf3 Mon Sep 17 00:00:00 2001 From: Anton Persson Date: Thu, 27 Sep 2018 16:05:27 +0200 Subject: [PATCH] Remove different Unique and NonUnique implementations of StringLayoutTestUtil and NumberLayoutTestUtil Instead when needing unique layout, wrap layout in UniqueLayoutTestUtil like we do for temporal layouts. --- .../index/schema/NativeIndexAccessorTest.java | 4 +- .../NativeUniqueIndexPopulatorTest.java | 4 +- ...mberFullScanNonUniqueIndexSamplerTest.java | 3 +- .../index/schema/NumberLayoutTestUtil.java | 14 +++++- .../NumberNonUniqueIndexPopulatorTest.java | 4 +- .../schema/NumberNonUniqueLayoutTestUtil.java | 44 ---------------- .../schema/NumberUniqueLayoutTestUtil.java | 50 ------------------- .../StringNonUniqueIndexPopulatorTest.java | 4 +- .../schema/StringNonUniqueLayoutTestUtil.java | 38 -------------- .../schema/StringUniqueLayoutTestUtil.java | 44 ---------------- 10 files changed, 25 insertions(+), 184 deletions(-) delete mode 100644 community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberNonUniqueLayoutTestUtil.java delete mode 100644 community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberUniqueLayoutTestUtil.java delete mode 100644 community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/StringNonUniqueLayoutTestUtil.java delete mode 100644 community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/StringUniqueLayoutTestUtil.java diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeIndexAccessorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeIndexAccessorTest.java index cd3c079e5a73b..ff09c25984844 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeIndexAccessorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeIndexAccessorTest.java @@ -51,11 +51,11 @@ public static Collection data() return Arrays.asList( new Object[][]{ {"Number", numberAccessorFactory(), - (LayoutTestUtilFactory) NumberNonUniqueLayoutTestUtil::new + (LayoutTestUtilFactory) () -> new NumberLayoutTestUtil( descriptor ) }, {"String", stringAccessorFactory(), - (LayoutTestUtilFactory) StringNonUniqueLayoutTestUtil::new + (LayoutTestUtilFactory) () -> new StringLayoutTestUtil( descriptor ) }, {"Date", temporalAccessorFactory( ValueGroup.DATE ), diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeUniqueIndexPopulatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeUniqueIndexPopulatorTest.java index 688180624b87c..3add6646f28f7 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeUniqueIndexPopulatorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeUniqueIndexPopulatorTest.java @@ -26,11 +26,11 @@ public static Collection data() return Arrays.asList( new Object[][]{ {"Number", numberPopulatorFactory(), - (LayoutTestUtilFactory) NumberUniqueLayoutTestUtil::new + (LayoutTestUtilFactory) () -> new UniqueLayoutTestUtil<>( new NumberLayoutTestUtil( descriptor ) ) }, {"String", (PopulatorFactory) StringIndexPopulator::new, - (LayoutTestUtilFactory) StringUniqueLayoutTestUtil::new + (LayoutTestUtilFactory) () -> new UniqueLayoutTestUtil<>( new StringLayoutTestUtil( descriptor ) ) }, {"Date", temporalPopulatorFactory( ValueGroup.DATE ), diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberFullScanNonUniqueIndexSamplerTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberFullScanNonUniqueIndexSamplerTest.java index 4cd49381738ef..172b6834c88fc 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberFullScanNonUniqueIndexSamplerTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberFullScanNonUniqueIndexSamplerTest.java @@ -26,6 +26,7 @@ import org.neo4j.index.internal.gbptree.GBPTree; import org.neo4j.index.internal.gbptree.Writer; import org.neo4j.io.pagecache.IOLimiter; +import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory; import org.neo4j.storageengine.api.schema.IndexSample; import org.neo4j.values.storable.NumberValue; import org.neo4j.values.storable.RandomValues; @@ -97,6 +98,6 @@ private void buildTree( Value[] values ) throws IOException @Override protected LayoutTestUtil createLayoutTestUtil() { - return new NumberNonUniqueLayoutTestUtil(); + return new NumberLayoutTestUtil( TestIndexDescriptorFactory.forLabel( 42, 666 ) ); } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberLayoutTestUtil.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberLayoutTestUtil.java index b9171de7ed8ad..fec9f9ef1aa2a 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberLayoutTestUtil.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberLayoutTestUtil.java @@ -26,7 +26,7 @@ import org.neo4j.values.storable.RandomValues; import org.neo4j.values.storable.ValueGroup; -abstract class NumberLayoutTestUtil extends LayoutTestUtil +class NumberLayoutTestUtil extends LayoutTestUtil { private static final Number[] ALL_EXTREME_VALUES = new Number[] { @@ -55,6 +55,18 @@ abstract class NumberLayoutTestUtil extends LayoutTestUtil createLayout() + { + return new NumberLayoutNonUnique(); + } + + @Override + IndexEntryUpdate[] someUpdates() + { + return someUpdatesWithDuplicateValues(); + } + @Override RandomValues.Type[] supportedTypes() { diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberNonUniqueIndexPopulatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberNonUniqueIndexPopulatorTest.java index 2cd3269bb6ecf..cdb3681940994 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberNonUniqueIndexPopulatorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberNonUniqueIndexPopulatorTest.java @@ -19,6 +19,8 @@ */ package org.neo4j.kernel.impl.index.schema; +import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory; + public class NumberNonUniqueIndexPopulatorTest extends NativeNonUniqueIndexPopulatorTest { @Override @@ -30,6 +32,6 @@ NativeIndexPopulator createPopulator() @Override protected LayoutTestUtil createLayoutTestUtil() { - return new NumberNonUniqueLayoutTestUtil(); + return new NumberLayoutTestUtil( TestIndexDescriptorFactory.forLabel( 42, 666 ) ); } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberNonUniqueLayoutTestUtil.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberNonUniqueLayoutTestUtil.java deleted file mode 100644 index 1f1bb9bf10cfb..0000000000000 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberNonUniqueLayoutTestUtil.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2002-2018 "Neo4j," - * Neo4j Sweden AB [http://neo4j.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.kernel.impl.index.schema; - -import org.neo4j.kernel.api.index.IndexEntryUpdate; -import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory; -import org.neo4j.storageengine.api.schema.IndexDescriptor; - -class NumberNonUniqueLayoutTestUtil extends NumberLayoutTestUtil -{ - NumberNonUniqueLayoutTestUtil() - { - super( TestIndexDescriptorFactory.forLabel( 42, 666 ) ); - } - - @Override - IndexLayout createLayout() - { - return new NumberLayoutNonUnique(); - } - - @Override - IndexEntryUpdate[] someUpdates() - { - return someUpdatesWithDuplicateValues(); - } -} diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberUniqueLayoutTestUtil.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberUniqueLayoutTestUtil.java deleted file mode 100644 index 7aaca73a3ed13..0000000000000 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberUniqueLayoutTestUtil.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2002-2018 "Neo4j," - * Neo4j Sweden AB [http://neo4j.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.kernel.impl.index.schema; - -import org.neo4j.kernel.api.index.IndexEntryUpdate; -import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory; -import org.neo4j.storageengine.api.schema.IndexDescriptor; - -public class NumberUniqueLayoutTestUtil extends NumberLayoutTestUtil -{ - NumberUniqueLayoutTestUtil() - { - super( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ); - } - - @Override - public IndexLayout createLayout() - { - return new NumberLayoutUnique(); - } - - @Override - IndexEntryUpdate[] someUpdates() - { - return someUpdatesNoDuplicateValues(); - } - - @Override - protected double fractionDuplicates() - { - return 0.0; - } -} diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/StringNonUniqueIndexPopulatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/StringNonUniqueIndexPopulatorTest.java index 9cd5ea07fbdd4..0812db33ffc8f 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/StringNonUniqueIndexPopulatorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/StringNonUniqueIndexPopulatorTest.java @@ -19,6 +19,8 @@ */ package org.neo4j.kernel.impl.index.schema; +import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory; + public class StringNonUniqueIndexPopulatorTest extends NativeNonUniqueIndexPopulatorTest { @Override @@ -30,6 +32,6 @@ NativeIndexPopulator createPopulator() @Override protected LayoutTestUtil createLayoutTestUtil() { - return new StringNonUniqueLayoutTestUtil(); + return new StringLayoutTestUtil( TestIndexDescriptorFactory.forLabel( 42, 666 ) ); } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/StringNonUniqueLayoutTestUtil.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/StringNonUniqueLayoutTestUtil.java deleted file mode 100644 index 93b13cb760adc..0000000000000 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/StringNonUniqueLayoutTestUtil.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2002-2018 "Neo4j," - * Neo4j Sweden AB [http://neo4j.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.kernel.impl.index.schema; - -import org.neo4j.kernel.api.index.IndexEntryUpdate; -import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory; -import org.neo4j.storageengine.api.schema.IndexDescriptor; - -class StringNonUniqueLayoutTestUtil extends StringLayoutTestUtil -{ - StringNonUniqueLayoutTestUtil() - { - super( TestIndexDescriptorFactory.forLabel( 42, 666 ) ); - } - - @Override - IndexEntryUpdate[] someUpdates() - { - return someUpdatesWithDuplicateValues(); - } -} diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/StringUniqueLayoutTestUtil.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/StringUniqueLayoutTestUtil.java deleted file mode 100644 index 6a20d5a7203c7..0000000000000 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/StringUniqueLayoutTestUtil.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2002-2018 "Neo4j," - * Neo4j Sweden AB [http://neo4j.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.kernel.impl.index.schema; - -import org.neo4j.kernel.api.index.IndexEntryUpdate; -import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory; -import org.neo4j.storageengine.api.schema.IndexDescriptor; - -class StringUniqueLayoutTestUtil extends StringLayoutTestUtil -{ - StringUniqueLayoutTestUtil() - { - super( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ); - } - - @Override - IndexEntryUpdate[] someUpdates() - { - return someUpdatesNoDuplicateValues(); - } - - @Override - protected double fractionDuplicates() - { - return 0.0; - } -}