diff --git a/community/consistency-check/src/main/java/org/neo4j/consistency/checking/full/PropertyAndNodeIndexedCheck.java b/community/consistency-check/src/main/java/org/neo4j/consistency/checking/full/PropertyAndNodeIndexedCheck.java index 56b05c3af3fbb..74ab89114021a 100644 --- a/community/consistency-check/src/main/java/org/neo4j/consistency/checking/full/PropertyAndNodeIndexedCheck.java +++ b/community/consistency-check/src/main/java/org/neo4j/consistency/checking/full/PropertyAndNodeIndexedCheck.java @@ -36,7 +36,7 @@ import org.neo4j.consistency.report.ConsistencyReport; import org.neo4j.consistency.store.RecordAccess; import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.kernel.impl.api.LookupFilter; import org.neo4j.kernel.impl.store.record.IndexRule; diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/TransactionBoundQueryContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/TransactionBoundQueryContext.scala index c9a894678e419..fd8a3d5f74847 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/TransactionBoundQueryContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v2_3/TransactionBoundQueryContext.scala @@ -43,12 +43,13 @@ import org.neo4j.graphdb.RelationshipType._ import org.neo4j.graphdb._ import org.neo4j.graphdb.security.URLAccessValidationError import org.neo4j.graphdb.traversal.{Evaluators, TraversalDescription, Uniqueness} +import org.neo4j.internal.kernel.api.IndexQuery import org.neo4j.kernel.GraphDatabaseQueryService import org.neo4j.kernel.api.exceptions.schema.{AlreadyConstrainedException, AlreadyIndexedException} import org.neo4j.kernel.api.index.InternalIndexState import org.neo4j.kernel.api.schema.constaints.ConstraintDescriptorFactory import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory -import org.neo4j.kernel.api.schema.{IndexQuery, SchemaDescriptorFactory} +import org.neo4j.kernel.api.schema.SchemaDescriptorFactory import org.neo4j.kernel.api.{exceptions, _} import org.neo4j.kernel.impl.core.NodeManager import org.neo4j.values.storable.Values diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundQueryContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundQueryContext.scala index 400f655436dd8..971766b3c7a8d 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundQueryContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundQueryContext.scala @@ -46,6 +46,7 @@ import org.neo4j.graphdb.RelationshipType._ import org.neo4j.graphdb._ import org.neo4j.graphdb.security.URLAccessValidationError import org.neo4j.graphdb.traversal.{Evaluators, TraversalDescription, Uniqueness} +import org.neo4j.internal.kernel.api.IndexQuery import org.neo4j.kernel.GraphDatabaseQueryService import org.neo4j.kernel.api._ import org.neo4j.kernel.api.dbms.DbmsOperations @@ -55,7 +56,7 @@ import org.neo4j.kernel.api.index.InternalIndexState import org.neo4j.kernel.api.proc.{QualifiedName => KernelQualifiedName} import org.neo4j.kernel.api.schema.constaints.ConstraintDescriptorFactory import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory -import org.neo4j.kernel.api.schema.{IndexQuery, SchemaDescriptorFactory} +import org.neo4j.kernel.api.schema.SchemaDescriptorFactory import org.neo4j.kernel.impl.core.NodeManager import org.neo4j.kernel.impl.locking.ResourceTypes import org.neo4j.values.storable.Values diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/TransactionBoundQueryContext.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/TransactionBoundQueryContext.scala index 24427d7d6a7d7..4980a069c4c96 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/TransactionBoundQueryContext.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/TransactionBoundQueryContext.scala @@ -25,26 +25,24 @@ import java.util.function.Predicate import org.neo4j.collection.RawIterator import org.neo4j.collection.primitive.PrimitiveLongIterator import org.neo4j.collection.primitive.base.Empty.EMPTY_PRIMITIVE_LONG_COLLECTION -import org.neo4j.cypher.internal.util.v3_4.{EntityNotFoundException, FailedIndexException} -import org.neo4j.cypher.internal.runtime.interpreted.commands.convert.DirectionConverter.toGraphDb -import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions -import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.{OnlyDirectionExpander, TypeAndDirectionExpander} -import org.neo4j.cypher.internal.runtime.interpreted.pipes.matching.PatternNode +import org.neo4j.cypher.InternalException import org.neo4j.cypher.internal.javacompat.{GraphDatabaseCypherService, ValueToObjectSerializer} import org.neo4j.cypher.internal.planner.v3_4.spi.{IdempotentResult, IndexDescriptor} import org.neo4j.cypher.internal.runtime._ import org.neo4j.cypher.internal.runtime.interpreted.CypherOrdering.{BY_NUMBER, BY_STRING, BY_VALUE} import org.neo4j.cypher.internal.runtime.interpreted.TransactionBoundQueryContext.IndexSearchMonitor -import org.neo4j.cypher.internal.runtime.interpreted._ -import org.neo4j.cypher.internal.v3_4.logical.plans._ +import org.neo4j.cypher.internal.runtime.interpreted.commands.convert.DirectionConverter.toGraphDb +import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.{OnlyDirectionExpander, TypeAndDirectionExpander} +import org.neo4j.cypher.internal.util.v3_4.{EntityNotFoundException, FailedIndexException} import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection -import org.neo4j.cypher.{InternalException, internal} +import org.neo4j.cypher.internal.v3_4.logical.plans._ import org.neo4j.graphalgo.impl.path.ShortestPath import org.neo4j.graphalgo.impl.path.ShortestPath.ShortestPathPredicate import org.neo4j.graphdb.RelationshipType._ import org.neo4j.graphdb._ import org.neo4j.graphdb.security.URLAccessValidationError import org.neo4j.graphdb.traversal.{Evaluators, TraversalDescription, Uniqueness} +import org.neo4j.internal.kernel.api.IndexQuery import org.neo4j.kernel.GraphDatabaseQueryService import org.neo4j.kernel.api._ import org.neo4j.kernel.api.exceptions.ProcedureException @@ -52,8 +50,8 @@ import org.neo4j.kernel.api.exceptions.schema.{AlreadyConstrainedException, Alre import org.neo4j.kernel.api.index.InternalIndexState import org.neo4j.kernel.api.proc.CallableUserAggregationFunction.Aggregator import org.neo4j.kernel.api.proc.{QualifiedName => KernelQualifiedName} +import org.neo4j.kernel.api.schema.SchemaDescriptorFactory import org.neo4j.kernel.api.schema.constaints.ConstraintDescriptorFactory -import org.neo4j.kernel.api.schema.{IndexQuery, SchemaDescriptorFactory} import org.neo4j.kernel.impl.api.RelationshipVisitor import org.neo4j.kernel.impl.api.store.RelationshipIterator import org.neo4j.kernel.impl.core.{NodeManager, RelationshipProxy} diff --git a/community/kernel-api/LICENSES.txt b/community/kernel-api/LICENSES.txt index e62824d7096a5..fd96cba2c36a7 100644 --- a/community/kernel-api/LICENSES.txt +++ b/community/kernel-api/LICENSES.txt @@ -1,4 +1,212 @@ This file contains the full license text of the included third party libraries. For an overview of the licenses see the NOTICE.txt file. +------------------------------------------------------------------------------ +Apache Software License, Version 2.0 + Apache Commons Lang +------------------------------------------------------------------------------ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. + + diff --git a/community/kernel-api/NOTICE.txt b/community/kernel-api/NOTICE.txt index fd092456b3538..32fcdf972ef08 100644 --- a/community/kernel-api/NOTICE.txt +++ b/community/kernel-api/NOTICE.txt @@ -25,3 +25,6 @@ Full license texts are found in LICENSES.txt. Third-party licenses -------------------- +Apache Software License, Version 2.0 + Apache Commons Lang + diff --git a/community/kernel-api/pom.xml b/community/kernel-api/pom.xml index dc85f82355310..5bd9e19faa377 100644 --- a/community/kernel-api/pom.xml +++ b/community/kernel-api/pom.xml @@ -63,6 +63,10 @@ the relevant Commercial Agreement. neo4j-common ${project.version} + + org.apache.commons + commons-lang3 + diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/schema/IndexQuery.java b/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexQuery.java similarity index 89% rename from community/kernel/src/main/java/org/neo4j/kernel/api/schema/IndexQuery.java rename to community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexQuery.java index 8377195e611c8..6f409a6eb5899 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/schema/IndexQuery.java +++ b/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexQuery.java @@ -17,30 +17,25 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.neo4j.kernel.api.schema; +package org.neo4j.internal.kernel.api; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import java.util.function.Predicate; - -import org.neo4j.kernel.api.ReadOperations; -import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.values.storable.TextValue; import org.neo4j.values.storable.Value; import org.neo4j.values.storable.ValueTuple; import org.neo4j.values.storable.Values; -public abstract class IndexQuery implements Predicate +public abstract class IndexQuery { /** * Searches the index for all entries that has the given property. * * @param propertyKeyId the property ID to match. - * @return an {@link IndexQuery} instance to be passed to {@link ReadOperations#indexQuery(IndexDescriptor, - * IndexQuery...)} + * @return an {@link IndexQuery} instance to be used for querying an index. */ public static ExistsPredicate exists( int propertyKeyId ) { @@ -52,8 +47,7 @@ public static ExistsPredicate exists( int propertyKeyId ) * * @param propertyKeyId the property ID to match. * @param value the property value to search for. - * @return an {@link IndexQuery} instance to be passed to {@link ReadOperations#indexQuery(IndexDescriptor, - * IndexQuery...)} + * @return an {@link IndexQuery} instance to be used for querying an index. */ public static ExactPredicate exact( int propertyKeyId, Object value ) { @@ -68,8 +62,7 @@ public static ExactPredicate exact( int propertyKeyId, Object value ) * @param fromInclusive the lower bound is inclusive if true. * @param to the upper bound of the property value. * @param toInclusive the upper bound is inclusive if true. - * @return an {@link IndexQuery} instance to be passed to {@link ReadOperations#indexQuery(IndexDescriptor, - * IndexQuery...)} + * @return an {@link IndexQuery} instance to be used for querying an index. */ public static NumberRangePredicate range( int propertyKeyId, Number from, boolean fromInclusive, Number to, boolean toInclusive ) @@ -85,8 +78,7 @@ public static NumberRangePredicate range( int propertyKeyId, Number from, boolea * @param fromInclusive the lower bound is inclusive if true. * @param to the upper bound of the property value. * @param toInclusive the upper bound is inclusive if true. - * @return an {@link IndexQuery} instance to be passed to {@link ReadOperations#indexQuery(IndexDescriptor, - * IndexQuery...)} + * @return an {@link IndexQuery} instance to be used for querying an index. */ public static StringRangePredicate range( int propertyKeyId, String from, boolean fromInclusive, String to, boolean toInclusive ) @@ -99,8 +91,7 @@ public static StringRangePredicate range( int propertyKeyId, String from, boolea * * @param propertyKeyId the property ID to match. * @param prefix the string prefix to search for. - * @return an {@link IndexQuery} instance to be passed to {@link ReadOperations#indexQuery(IndexDescriptor, - * IndexQuery...)} + * @return an {@link IndexQuery} instance to be used for querying an index. */ public static StringPrefixPredicate stringPrefix( int propertyKeyId, String prefix ) { @@ -112,8 +103,7 @@ public static StringPrefixPredicate stringPrefix( int propertyKeyId, String pref * * @param propertyKeyId the property ID to match. * @param contains the string to search for. - * @return an {@link IndexQuery} instance to be passed to {@link ReadOperations#indexQuery(IndexDescriptor, - * IndexQuery...)} + * @return an {@link IndexQuery} instance to be used for querying an index. */ public static StringContainsPredicate stringContains( int propertyKeyId, String contains ) { @@ -125,8 +115,7 @@ public static StringContainsPredicate stringContains( int propertyKeyId, String * * @param propertyKeyId the property ID to match. * @param suffix the string suffix to search for. - * @return an {@link IndexQuery} instance to be passed to {@link ReadOperations#indexQuery(IndexDescriptor, - * IndexQuery...)} + * @return an {@link IndexQuery} instance to be used for querying an index. */ public static StringSuffixPredicate stringSuffix( int propertyKeyId, String suffix ) { @@ -179,8 +168,12 @@ public final int propertyKeyId() return propertyKeyId; } - @Override - public abstract boolean test( Value value ); + public abstract boolean acceptsValue( Value value ); + + public boolean acceptsValueAt( PropertyCursor property ) + { + return acceptsValue( property.propertyValue() ); + } public enum IndexQueryType { @@ -207,10 +200,16 @@ public IndexQueryType type() } @Override - public boolean test( Value value ) + public boolean acceptsValue( Value value ) { return value != null && value != Values.NO_VALUE; } + + @Override + public boolean acceptsValueAt( PropertyCursor property ) + { + return true; + } } public static final class ExactPredicate extends IndexQuery @@ -230,7 +229,7 @@ public IndexQueryType type() } @Override - public boolean test( Value value ) + public boolean acceptsValue( Value value ) { return exactValue.equals( value ); } @@ -264,7 +263,7 @@ public IndexQueryType type() } @Override - public boolean test( Value value ) + public boolean acceptsValue( Value value ) { if ( value == null ) { @@ -347,7 +346,7 @@ public IndexQueryType type() } @Override - public boolean test( Value value ) + public boolean acceptsValue( Value value ) { if ( value == null ) { @@ -414,7 +413,7 @@ public IndexQueryType type() } @Override - public boolean test( Value value ) + public boolean acceptsValue( Value value ) { return value != null && Values.isTextValue( value ) && ((TextValue)value).stringValue().startsWith( prefix ); @@ -443,7 +442,7 @@ public IndexQueryType type() } @Override - public boolean test( Value value ) + public boolean acceptsValue( Value value ) { return value != null && Values.isTextValue( value ) && ((String)value.asObject()).contains( contains ); } @@ -471,7 +470,7 @@ public IndexQueryType type() } @Override - public boolean test( Value value ) + public boolean acceptsValue( Value value ) { return value != null && Values.isTextValue( value ) && ((String)value.asObject()).endsWith( suffix ); } diff --git a/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexReference.java b/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexReference.java index f69c962cdc1ef..d85bb462d6d33 100644 --- a/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexReference.java +++ b/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexReference.java @@ -23,6 +23,11 @@ * This class is really a renamed org.neo4j.kernel.api.schema.IndexDescriptor. Maybe it will compose an * IndexDescriptor with an offset for faster index lookup. */ -public class IndexReference +public interface IndexReference { + boolean isUnique(); + + int label(); + + int[] properties(); } diff --git a/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/Read.java b/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/Read.java index 6b85bc398a9b5..6f5a95e82ff80 100644 --- a/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/Read.java +++ b/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/Read.java @@ -25,14 +25,12 @@ public interface Read { /** - * TODO: this method needs a better definition. - * - * @param predicates - * predicates describing what to look for in the index. + * @param index * @param cursor * the cursor to use for consuming the results. + * @param query */ - void nodeIndexSeek( IndexReference index, NodeValueIndexCursor cursor, IndexPredicate... predicates ); + void nodeIndexSeek( IndexReference index, NodeValueIndexCursor cursor, IndexQuery... query ); void nodeIndexScan( IndexReference index, NodeValueIndexCursor cursor ); @@ -73,7 +71,7 @@ public interface Read * @param nodeReference * a reference from {@link NodeCursor#nodeReference()}. * @param reference - * a reference from {@link NodeCursor#relationshipReference()}. + * a reference from {@link NodeCursor#relationshipGroupReference()}. * @param cursor * the cursor to use for consuming the results. */ @@ -116,4 +114,12 @@ public interface Read void futureNodePropertyReferenceRead( long reference ); void futureRelationshipPropertyReferenceRead( long reference ); + + // TOKEN/meta operations + + IndexReference index( int label, int... properties ); + + int nodeLabel( String name ); + + int propertyKey( String name ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/schema/IndexQueryTest.java b/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/IndexQueryTest.java similarity index 94% rename from community/kernel/src/test/java/org/neo4j/kernel/api/schema/IndexQueryTest.java rename to community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/IndexQueryTest.java index eb6f280a91ffd..f437ad680a089 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/schema/IndexQueryTest.java +++ b/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/IndexQueryTest.java @@ -17,18 +17,18 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.neo4j.kernel.api.schema; +package org.neo4j.internal.kernel.api; import org.junit.Assert; import org.junit.Test; -import org.neo4j.kernel.api.schema.IndexQuery.ExactPredicate; -import org.neo4j.kernel.api.schema.IndexQuery.ExistsPredicate; -import org.neo4j.kernel.api.schema.IndexQuery.NumberRangePredicate; -import org.neo4j.kernel.api.schema.IndexQuery.StringContainsPredicate; -import org.neo4j.kernel.api.schema.IndexQuery.StringPrefixPredicate; -import org.neo4j.kernel.api.schema.IndexQuery.StringRangePredicate; -import org.neo4j.kernel.api.schema.IndexQuery.StringSuffixPredicate; +import org.neo4j.internal.kernel.api.IndexQuery.ExactPredicate; +import org.neo4j.internal.kernel.api.IndexQuery.ExistsPredicate; +import org.neo4j.internal.kernel.api.IndexQuery.NumberRangePredicate; +import org.neo4j.internal.kernel.api.IndexQuery.StringContainsPredicate; +import org.neo4j.internal.kernel.api.IndexQuery.StringPrefixPredicate; +import org.neo4j.internal.kernel.api.IndexQuery.StringRangePredicate; +import org.neo4j.internal.kernel.api.IndexQuery.StringSuffixPredicate; import org.neo4j.values.storable.Values; import static junit.framework.TestCase.assertFalse; @@ -326,6 +326,6 @@ private void assertFalseForOtherThings( IndexQuery p ) private boolean test( IndexQuery p, Object x ) { - return p.test( Values.of( x ) ); + return p.acceptsValue( Values.of( x ) ); } } diff --git a/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/NodeValueIndexCursorTestBase.java b/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/NodeValueIndexCursorTestBase.java new file mode 100644 index 0000000000000..cda7109eb8a5a --- /dev/null +++ b/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/NodeValueIndexCursorTestBase.java @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2002-2017 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.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.internal.kernel.api; + +import org.junit.Test; + +import org.neo4j.collection.primitive.Primitive; +import org.neo4j.collection.primitive.PrimitiveLongSet; +import org.neo4j.graphdb.GraphDatabaseService; +import org.neo4j.graphdb.Transaction; +import org.neo4j.graphdb.schema.IndexDefinition; + +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.neo4j.graphdb.Label.label; + +public abstract class NodeValueIndexCursorTestBase + extends KernelAPIReadTestBase +{ + @Override + void createTestGraph( GraphDatabaseService graphDb ) + { + IndexDefinition index; + try ( Transaction tx = graphDb.beginTx() ) + { + index = graphDb.schema().indexFor( label( "Node" ) ).on( "prop" ).create(); + tx.success(); + } + try ( Transaction tx = graphDb.beginTx() ) + { + graphDb.schema().awaitIndexOnline( index, 5, SECONDS ); + tx.success(); + } + try ( Transaction tx = graphDb.beginTx() ) + { + graphDb.createNode( label( "Node" ) ).setProperty( "prop", "one" ); + graphDb.createNode( label( "Node" ) ).setProperty( "prop", "two" ); + graphDb.createNode( label( "Node" ) ).setProperty( "prop", "two" ); + graphDb.createNode( label( "Node" ) ).setProperty( "prop", "three" ); + graphDb.createNode( label( "Node" ) ).setProperty( "prop", "three" ); + graphDb.createNode( label( "Node" ) ).setProperty( "prop", "three" ); + graphDb.createNode( label( "Node" ) ).setProperty( "prop", 4 ); + graphDb.createNode( label( "Node" ) ).setProperty( "prop", 5 ); + graphDb.createNode( label( "Node" ) ).setProperty( "prop", 6 ); + graphDb.createNode( label( "Node" ) ).setProperty( "prop", 12 ); + graphDb.createNode( label( "Node" ) ).setProperty( "prop", 18 ); + graphDb.createNode( label( "Node" ) ).setProperty( "prop", 24 ); + graphDb.createNode( label( "Node" ) ).setProperty( "prop", 30 ); + graphDb.createNode( label( "Node" ) ).setProperty( "prop", 36 ); + graphDb.createNode( label( "Node" ) ).setProperty( "prop", 42 ); + + tx.success(); + } + } + + @Test + public void shouldPerformExactLookup() throws Exception + { + // given + int label = read.nodeLabel( "Node" ); + int prop = read.propertyKey( "prop" ); + IndexReference index = read.index( label, prop ); + try ( NodeValueIndexCursor node = cursors.allocateNodeValueIndexCursor(); + PrimitiveLongSet uniqueIds = Primitive.longSet() ) + { + // when + read.nodeIndexSeek( index, node, IndexQuery.exact( prop, "zero" ) ); + + // then + assertFoundNodes( node, 0, uniqueIds ); + + // when + read.nodeIndexSeek( index, node, IndexQuery.exact( prop, "one" ) ); + + // then + assertFoundNodes( node, 1, uniqueIds ); + + // when + read.nodeIndexSeek( index, node, IndexQuery.exact( prop, "two" ) ); + + // then + assertFoundNodes( node, 2, uniqueIds ); + + // when + read.nodeIndexSeek( index, node, IndexQuery.exact( prop, "three" ) ); + + // then + assertFoundNodes( node, 3, uniqueIds ); + + // when + read.nodeIndexSeek( index, node, IndexQuery.exact( prop, 6 ) ); + + // then + assertFoundNodes( node, 1, uniqueIds ); + } + } + + @Test + public void shouldPerformStringPrefixSearch() throws Exception + { + // given + int label = read.nodeLabel( "Node" ); + int prop = read.propertyKey( "prop" ); + IndexReference index = read.index( label, prop ); + try ( NodeValueIndexCursor node = cursors.allocateNodeValueIndexCursor(); + PrimitiveLongSet uniqueIds = Primitive.longSet() ) + { + // when + read.nodeIndexSeek( index, node, IndexQuery.stringPrefix( prop, "t" ) ); + + // then + assertFoundNodes( node, 5, uniqueIds ); + } + } + + @Test + public void shouldPerformStringSuffixSearch() throws Exception + { + // given + int label = read.nodeLabel( "Node" ); + int prop = read.propertyKey( "prop" ); + IndexReference index = read.index( label, prop ); + try ( NodeValueIndexCursor node = cursors.allocateNodeValueIndexCursor(); + PrimitiveLongSet uniqueIds = Primitive.longSet() ) + { + // when + read.nodeIndexSeek( index, node, IndexQuery.stringSuffix( prop, "e" ) ); + + // then + assertFoundNodes( node, 4, uniqueIds ); + } + } + + @Test + public void shouldPerformStringContainmentSearch() throws Exception + { + // given + int label = read.nodeLabel( "Node" ); + int prop = read.propertyKey( "prop" ); + IndexReference index = read.index( label, prop ); + try ( NodeValueIndexCursor node = cursors.allocateNodeValueIndexCursor(); + PrimitiveLongSet uniqueIds = Primitive.longSet() ) + { + // when + read.nodeIndexSeek( index, node, IndexQuery.stringContains( prop, "o" ) ); + + // then + assertFoundNodes( node, 3, uniqueIds ); + } + } + + @Test + public void shouldPerformStringRangeSearch() throws Exception + { + // given + int label = read.nodeLabel( "Node" ); + int prop = read.propertyKey( "prop" ); + IndexReference index = read.index( label, prop ); + try ( NodeValueIndexCursor node = cursors.allocateNodeValueIndexCursor(); + PrimitiveLongSet uniqueIds = Primitive.longSet() ) + { + // when + uniqueIds.clear(); + read.nodeIndexSeek( index, node, IndexQuery.range( prop, "one", true, "three", true ) ); + + // then + assertFoundNodes( node, 4, uniqueIds ); + + // when + uniqueIds.clear(); + read.nodeIndexSeek( index, node, IndexQuery.range( prop, "one", true, "three", false ) ); + + // then + assertFoundNodes( node, 1, uniqueIds ); + + // when + uniqueIds.clear(); + read.nodeIndexSeek( index, node, IndexQuery.range( prop, "one", false, "three", true ) ); + + // then + assertFoundNodes( node, 3, uniqueIds ); + + // when + uniqueIds.clear(); + read.nodeIndexSeek( index, node, IndexQuery.range( prop, "one", false, "two", false ) ); + + // then + assertFoundNodes( node, 3, uniqueIds ); + + // when + uniqueIds.clear(); + read.nodeIndexSeek( index, node, IndexQuery.range( prop, "one", true, "two", true ) ); + + // then + assertFoundNodes( node, 6, uniqueIds ); + } + } + + @Test + public void shouldPerformNumericRangeSearch() throws Exception + { + // given + int label = read.nodeLabel( "Node" ); + int prop = read.propertyKey( "prop" ); + IndexReference index = read.index( label, prop ); + try ( NodeValueIndexCursor node = cursors.allocateNodeValueIndexCursor(); + PrimitiveLongSet uniqueIds = Primitive.longSet(); + NodeCursor n = cursors.allocateNodeCursor(); PropertyCursor p = cursors.allocatePropertyCursor() ) + { + // when + uniqueIds.clear(); + read.nodeIndexSeek( index, node, IndexQuery.range( prop, 5, true, 12, true ) ); + + // then + assertFoundNodes( node, 3, uniqueIds ); + + // when + uniqueIds.clear(); + read.nodeIndexSeek( index, node, IndexQuery.range( prop, 5, true, 12, false ) ); + + // then + assertFoundNodes( node, 2, uniqueIds ); + + // when + uniqueIds.clear(); + read.nodeIndexSeek( index, node, IndexQuery.range( prop, 5, false, 12, true ) ); + + // then + assertFoundNodes( node, 2, uniqueIds ); + + // when + uniqueIds.clear(); + read.nodeIndexSeek( index, node, IndexQuery.range( prop, 5, false, 12, false ) ); + + // then + assertFoundNodes( node, 1, uniqueIds ); + } + } + + @Test + public void shouldPerformIndexScan() throws Exception + { + // given + int label = read.nodeLabel( "Node" ); + int prop = read.propertyKey( "prop" ); + IndexReference index = read.index( label, prop ); + try ( NodeValueIndexCursor node = cursors.allocateNodeValueIndexCursor(); + PrimitiveLongSet uniqueIds = Primitive.longSet() ) + { + // when + read.nodeIndexScan( index, node ); + + // then + assertFoundNodes( node, 15, uniqueIds ); + } + } + + private static void assertFoundNodes( NodeValueIndexCursor node, int nodes, PrimitiveLongSet uniqueIds ) + { + for ( int i = 0; i < nodes; i++ ) + { + assertTrue( "at least " + nodes + " nodes", node.next() ); + assertTrue( uniqueIds.add( node.nodeReference() ) ); + } + assertFalse( "no more than " + nodes + " nodes", node.next() ); + } +} diff --git a/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/RelationshipTraversalCursorTestBase.java b/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/RelationshipTraversalCursorTestBase.java index de465bd023e9f..57f8c020f1438 100644 --- a/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/RelationshipTraversalCursorTestBase.java +++ b/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/RelationshipTraversalCursorTestBase.java @@ -41,7 +41,6 @@ public abstract class RelationshipTraversalCursorTestBase { private static long bare, start, end, sparse, dense; - private static int FOO, BAR, BAZ; @Override void createTestGraph( GraphDatabaseService graphDb ) diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/ReadOperations.java b/community/kernel/src/main/java/org/neo4j/kernel/api/ReadOperations.java index 0e89f33b35782..67f5ea93066d0 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/ReadOperations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/ReadOperations.java @@ -44,7 +44,7 @@ import org.neo4j.kernel.api.proc.ProcedureSignature; import org.neo4j.kernel.api.proc.QualifiedName; import org.neo4j.kernel.api.proc.UserFunctionSignature; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema.SchemaDescriptor; import org.neo4j.kernel.api.schema.constaints.ConstraintDescriptor; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/index/DelegatingIndexReader.java b/community/kernel/src/main/java/org/neo4j/kernel/api/index/DelegatingIndexReader.java index 446a001471001..c707143ad969e 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/index/DelegatingIndexReader.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/index/DelegatingIndexReader.java @@ -21,7 +21,7 @@ import org.neo4j.collection.primitive.PrimitiveLongIterator; import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.IndexSampler; import org.neo4j.values.storable.Value; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/ConstraintEnforcingEntityOperations.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/ConstraintEnforcingEntityOperations.java index 3b5c4d6514112..cc60ccaa8077f 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/ConstraintEnforcingEntityOperations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/ConstraintEnforcingEntityOperations.java @@ -49,8 +49,8 @@ import org.neo4j.kernel.api.exceptions.schema.RepeatedPropertyInCompositeSchemaException; import org.neo4j.kernel.api.exceptions.schema.UnableToValidateConstraintException; import org.neo4j.kernel.api.exceptions.schema.UniquePropertyValueValidationException; -import org.neo4j.kernel.api.schema.IndexQuery; -import org.neo4j.kernel.api.schema.IndexQuery.ExactPredicate; +import org.neo4j.internal.kernel.api.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery.ExactPredicate; import org.neo4j.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema.RelationTypeSchemaDescriptor; import org.neo4j.kernel.api.schema.SchemaDescriptor; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/LookupFilter.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/LookupFilter.java index 523a7911931d6..cb5fd166e156e 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/LookupFilter.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/LookupFilter.java @@ -27,7 +27,7 @@ import org.neo4j.cursor.Cursor; import org.neo4j.kernel.api.exceptions.EntityNotFoundException; import org.neo4j.kernel.api.index.PropertyAccessor; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.impl.api.operations.EntityOperations; import org.neo4j.storageengine.api.NodeItem; import org.neo4j.values.storable.Value; @@ -73,7 +73,7 @@ public static PrimitiveLongIterator exactIndexMatches( PropertyAccessor accessor { int propertyKeyId = predicate.propertyKeyId(); Value value = accessor.getPropertyValue( nodeId, propertyKeyId ); - if ( !predicate.test( value ) ) + if ( !predicate.acceptsValue( value ) ) { return false; } @@ -125,7 +125,7 @@ public static PrimitiveLongIterator exactIndexMatches( EntityOperations operatio { int propertyKeyId = predicate.propertyKeyId(); Value value = operations.nodeGetProperty( state, nodeItem, propertyKeyId ); - if ( !predicate.test( value ) ) + if ( !predicate.acceptsValue( value ) ) { return false; } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java index d74f9781266b8..106156cdbb374 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java @@ -74,7 +74,7 @@ import org.neo4j.kernel.api.proc.QualifiedName; import org.neo4j.kernel.api.proc.UserFunctionSignature; import org.neo4j.kernel.api.query.ExecutingQuery; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema.RelationTypeSchemaDescriptor; import org.neo4j.kernel.api.schema.SchemaDescriptor; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/StateHandlingStatementOperations.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/StateHandlingStatementOperations.java index 400264c4da693..4a5e5c9fab2ab 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/StateHandlingStatementOperations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/StateHandlingStatementOperations.java @@ -59,7 +59,7 @@ import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.SchemaIndexProvider; import org.neo4j.kernel.api.properties.PropertyKeyIdIterator; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema.RelationTypeSchemaDescriptor; import org.neo4j.kernel.api.schema.SchemaDescriptor; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/EntityReadOperations.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/EntityReadOperations.java index c66a70c1842ba..ced25fb4e52c3 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/EntityReadOperations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/operations/EntityReadOperations.java @@ -29,7 +29,7 @@ import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.exceptions.schema.IndexBrokenKernelException; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.impl.api.KernelStatement; import org.neo4j.kernel.impl.api.RelationshipVisitor; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java index 9d4a30f47d04c..2ea0a652575d6 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java @@ -68,7 +68,7 @@ import org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException; import org.neo4j.kernel.api.explicitindex.AutoIndexing; import org.neo4j.kernel.api.index.InternalIndexState; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.security.SecurityContext; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexReader.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexReader.java index 0fa63b9f759ec..f0db51d70d11b 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexReader.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexReader.java @@ -32,9 +32,9 @@ import org.neo4j.index.internal.gbptree.Layout; import org.neo4j.io.IOUtils; import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException; -import org.neo4j.kernel.api.schema.IndexQuery; -import org.neo4j.kernel.api.schema.IndexQuery.ExactPredicate; -import org.neo4j.kernel.api.schema.IndexQuery.NumberRangePredicate; +import org.neo4j.internal.kernel.api.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery.ExactPredicate; +import org.neo4j.internal.kernel.api.IndexQuery.NumberRangePredicate; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.storageengine.api.schema.IndexReader; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexReader.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexReader.java index d3cfefebe5a23..44f4d92bf801c 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexReader.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexReader.java @@ -22,10 +22,10 @@ import org.neo4j.collection.primitive.PrimitiveLongCollections; import org.neo4j.collection.primitive.PrimitiveLongIterator; import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException; -import org.neo4j.kernel.api.schema.IndexQuery; -import org.neo4j.kernel.api.schema.IndexQuery.ExactPredicate; -import org.neo4j.kernel.api.schema.IndexQuery.ExistsPredicate; -import org.neo4j.kernel.api.schema.IndexQuery.NumberRangePredicate; +import org.neo4j.internal.kernel.api.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery.ExactPredicate; +import org.neo4j.internal.kernel.api.IndexQuery.ExistsPredicate; +import org.neo4j.internal.kernel.api.IndexQuery.NumberRangePredicate; import org.neo4j.kernel.impl.index.schema.fusion.FusionSchemaIndexProvider.Selector; import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.IndexSampler; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/locking/ResourceTypes.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/locking/ResourceTypes.java index 43835b6661028..eddf52bae4a6f 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/locking/ResourceTypes.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/locking/ResourceTypes.java @@ -25,7 +25,7 @@ import org.neo4j.hashing.HashFunction; import org.neo4j.helpers.Strings; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.impl.util.concurrent.LockWaitStrategies; import org.neo4j.storageengine.api.lock.ResourceType; import org.neo4j.storageengine.api.lock.WaitStrategy; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/CursorProgressor.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/CursorProgressor.java new file mode 100644 index 0000000000000..2961661c9e0ae --- /dev/null +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/CursorProgressor.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2002-2017 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.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.newapi; + +public interface CursorProgressor +{ + boolean next( Sink sink ); + + void close(); + + interface Cursor + { + void empty(); + + void initialize( CursorProgressor progressor ); + } +} diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/IndexCursorFilter.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/IndexCursorFilter.java new file mode 100644 index 0000000000000..a67f654650690 --- /dev/null +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/IndexCursorFilter.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2002-2017 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.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.newapi; + +import java.util.Arrays; +import java.util.Comparator; + +import org.neo4j.internal.kernel.api.IndexQuery; +import org.neo4j.values.storable.Value; + +class IndexCursorFilter implements CursorProgressor.Cursor +{ + private static final Comparator ASCENDING_BY_KEY = Comparator.comparingInt( IndexQuery::propertyKeyId ); + private final CursorProgressor.Cursor target; + private final NodeCursor node; + private final PropertyCursor property; + private final IndexQuery[] filters; + + IndexCursorFilter( + CursorProgressor.Cursor target, + NodeCursor node, PropertyCursor property, IndexQuery... filters ) + { + this.target = target; + this.node = node; + this.property = property; + this.filters = filters; + Arrays.sort( filters, ASCENDING_BY_KEY ); + } + + @Override + public void empty() + { + node.close(); + property.close(); + target.empty(); + } + + @Override + public void initialize( CursorProgressor progressor ) + { + target.initialize( new Progressor( progressor, node, property, filters ) ); + } + + private static class Progressor implements CursorProgressor, IndexState.NodeValue + { + private final CursorProgressor progressor; + private final NodeCursor node; + private final PropertyCursor property; + private final IndexQuery[] filters; + private long reference; + private int[] keys; + private Value[] values; + + Progressor( + CursorProgressor progressor, + NodeCursor node, PropertyCursor property, IndexQuery[] filters ) + { + this.progressor = progressor; + this.node = node; + this.property = property; + this.filters = filters; + } + + @Override + public boolean next( IndexState.NodeValue nodeValue ) + { + if ( !progressor.next( this ) ) + { + return false; + } + PROPERTIES: + while ( property.next() ) + { + for ( IndexQuery filter : filters ) + { + if ( filter.propertyKeyId() == property.propertyKey() ) + { + if ( !filter.acceptsValueAt( property ) ) + { + // this will reset the property cursor to the properties of the next node + if ( !progressor.next( this ) ) + { + return false; + } + // so all we have to do is continue in order to inspect the next one + continue PROPERTIES; + } + } + else if ( property.propertyKey() < filter.propertyKeyId() ) + { + continue PROPERTIES; + } + } + } + // when we get here, we know that we are on a node where all filters are accepted + nodeValue.node( reference, keys, values ); + return true; + } + + @Override + public void close() + { + node.close(); + property.close(); + progressor.close(); + } + + @Override + public void node( long reference, int[] keys, Value[] values ) + { + // it's a bit iffy that we have to put these things into fields, but ok enough. + this.reference = reference; + this.keys = keys; + this.values = values; + node.single( reference ); + if ( node.next() ) + { + node.properties( property ); + } + else + { + property.clear(); + } + } + + @Override + public void done() + { + } + } +} diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/IndexReference.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/IndexReference.java new file mode 100644 index 0000000000000..fe9e2aa658629 --- /dev/null +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/IndexReference.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2002-2017 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.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.newapi; + +class IndexReference implements org.neo4j.internal.kernel.api.IndexReference +{ + private final int label; + private final int[] properties; + private final boolean unique; + + IndexReference( boolean unique, int label, int... properties ) + { + this.unique = unique; + this.label = label; + this.properties = properties; + } + + @Override + public boolean isUnique() + { + return unique; + } + + @Override + public int label() + { + return label; + } + + @Override + public int[] properties() + { + return properties; + } +} diff --git a/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexPredicate.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/IndexState.java similarity index 76% rename from community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexPredicate.java rename to community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/IndexState.java index 35419ee46c5dd..179858230c412 100644 --- a/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexPredicate.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/IndexState.java @@ -17,12 +17,16 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.neo4j.internal.kernel.api; +package org.neo4j.kernel.impl.newapi; -/** - * This class is really a renamed org.neo4j.kernel.api.schema.IndexQuery. Describes part of an index query related to - * one property. - */ -public interface IndexPredicate +import org.neo4j.values.storable.Value; + +public interface IndexState { + void done(); + + interface NodeValue extends IndexState + { + void node( long reference, int[] keys, Value[] values ); + } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/NodeValueIndexCursor.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/NodeValueIndexCursor.java index ec7bcb92380c5..0bf534f639d06 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/NodeValueIndexCursor.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/NodeValueIndexCursor.java @@ -22,49 +22,82 @@ import org.neo4j.internal.kernel.api.NodeCursor; import org.neo4j.values.storable.Value; -class NodeValueIndexCursor implements org.neo4j.internal.kernel.api.NodeValueIndexCursor +import static org.neo4j.kernel.impl.store.record.AbstractBaseRecord.NO_ID; + +class NodeValueIndexCursor implements org.neo4j.internal.kernel.api.NodeValueIndexCursor, + CursorProgressor.Cursor, IndexState.NodeValue { private final Read read; + private long node; + private int[] keys; + private Value[] values; + private CursorProgressor progressor; NodeValueIndexCursor( Read read ) { this.read = read; } + @Override + public void empty() + { + close(); + } + + @Override + public void initialize( CursorProgressor progressor ) + { + this.progressor = progressor; + } + + @Override + public void done() + { + close(); + } + + @Override + public void node( long reference, int[] keys, Value[] values ) + { + this.node = reference; + this.keys = keys; + this.values = values; + } + @Override public void node( NodeCursor cursor ) { - throw new UnsupportedOperationException( "not implemented" ); + read.singleNode( node, cursor ); } @Override public long nodeReference() { - throw new UnsupportedOperationException( "not implemented" ); + return node; } @Override public int numberOfProperties() { - throw new UnsupportedOperationException( "not implemented" ); + return keys == null ? 0 : keys.length; } @Override public int propertyKey( int offset ) { - throw new UnsupportedOperationException( "not implemented" ); + return keys[offset]; } @Override public Value propertyValue( int offset ) { - throw new UnsupportedOperationException( "not implemented" ); + return values[offset]; } @Override public boolean next() { - throw new UnsupportedOperationException( "not implemented" ); + return progressor != null && progressor.next( this ); } @Override @@ -76,6 +109,9 @@ public boolean shouldRetry() @Override public void close() { - throw new UnsupportedOperationException( "not implemented" ); + this.progressor = null; + this.node = NO_ID; + this.keys = null; + this.values = null; } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/Read.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/Read.java index a74d291ac071a..2ef89d638afd3 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/Read.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/Read.java @@ -19,15 +19,19 @@ */ package org.neo4j.kernel.impl.newapi; -import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.util.Arrays; -import org.neo4j.internal.kernel.api.IndexPredicate; -import org.neo4j.internal.kernel.api.IndexReference; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.internal.kernel.api.Scan; import org.neo4j.io.pagecache.PageCursor; +import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; +import org.neo4j.kernel.api.schema.LabelSchemaDescriptor; +import org.neo4j.kernel.api.schema.index.IndexDescriptor; +import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.impl.api.store.PropertyUtil; +import org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine; import org.neo4j.kernel.impl.store.AbstractDynamicStore; import org.neo4j.kernel.impl.store.NeoStores; import org.neo4j.kernel.impl.store.NodeStore; @@ -43,9 +47,14 @@ import org.neo4j.kernel.impl.store.record.RecordLoad; import org.neo4j.kernel.impl.store.record.RelationshipGroupRecord; import org.neo4j.kernel.impl.store.record.RelationshipRecord; +import org.neo4j.storageengine.api.StorageStatement; +import org.neo4j.storageengine.api.StoreReadLayer; +import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.string.UTF8; import org.neo4j.values.storable.ArrayValue; import org.neo4j.values.storable.TextValue; +import org.neo4j.values.storable.Value; +import org.neo4j.values.storable.ValueGroup; import org.neo4j.values.storable.Values; import static org.neo4j.kernel.impl.store.record.AbstractBaseRecord.NO_ID; @@ -58,9 +67,14 @@ public class Read implements org.neo4j.internal.kernel.api.Read private final PropertyStore propertyStore; private NodeStore nodeStore; private RelationshipStore relationshipStore; + private final StorageStatement statement; + private final StoreReadLayer read; - public Read( NeoStores stores ) + public Read( RecordStorageEngine engine ) { + read = engine.storeReadLayer(); + statement = read.newStatement(); + NeoStores stores = engine.testAccessNeoStores(); this.nodeStore = stores.getNodeStore(); this.relationshipStore = stores.getRelationshipStore(); this.groupStore = stores.getRelationshipGroupStore(); @@ -69,17 +83,68 @@ public Read( NeoStores stores ) @Override public void nodeIndexSeek( - IndexReference index, + org.neo4j.internal.kernel.api.IndexReference index, org.neo4j.internal.kernel.api.NodeValueIndexCursor cursor, - IndexPredicate... predicates ) + IndexQuery... query ) { - throw new UnsupportedOperationException( "not implemented" ); + CursorProgressor.Cursor target = (NodeValueIndexCursor) cursor; + IndexReader reader = indexReader( (IndexReference) index ); + if ( !reader.hasFullNumberPrecision( query ) ) + { + IndexQuery[] filters = new IndexQuery[query.length]; + int j = 0; + for ( IndexQuery q : query ) + { + switch ( q.type() ) + { + case rangeNumeric: + if ( !reader.hasFullNumberPrecision( q ) ) + { + filters[j++] = q; + } + break; + case exact: + Value value = ((IndexQuery.ExactPredicate) q).value(); + if ( value.valueGroup() == ValueGroup.NUMBER ) + { + if ( !reader.hasFullNumberPrecision( q ) ) + { + filters[j++] = q; + } + } + break; + default: + } + } + if ( j > 0 ) + { + filters = Arrays.copyOf( filters, j ); + target = new IndexCursorFilter( target, new NodeCursor( this ), new PropertyCursor( this ), filters ); + } + } + reader.query( target, query ); } @Override - public void nodeIndexScan( IndexReference index, org.neo4j.internal.kernel.api.NodeValueIndexCursor cursor ) + public void nodeIndexScan( + org.neo4j.internal.kernel.api.IndexReference index, + org.neo4j.internal.kernel.api.NodeValueIndexCursor cursor ) { - throw new UnsupportedOperationException( "not implemented" ); + indexReader( (IndexReference) index ).scan( (NodeValueIndexCursor)cursor ); + } + + private IndexReader indexReader( IndexReference index ) + { + try + { + return statement.getIndexReader( index.isUnique() + ? IndexDescriptorFactory.uniqueForLabel( index.label(), index.properties() ) + : IndexDescriptorFactory.forLabel( index.label(), index.properties() ) ); + } + catch ( IndexNotFoundKernelException e ) + { + throw new IllegalStateException( e ); + } } @Override @@ -241,6 +306,25 @@ public void futureRelationshipPropertyReferenceRead( long reference ) { } + @Override + public IndexReference index( int label, int... properties ) + { + IndexDescriptor indexDescriptor = read.indexGetForSchema( new LabelSchemaDescriptor( label, properties ) ); + return new IndexReference( indexDescriptor.type() == IndexDescriptor.Type.UNIQUE, label, properties ); + } + + @Override + public int nodeLabel( String name ) + { + return read.labelGetForName( name ); + } + + @Override + public int propertyKey( String name ) + { + return read.propertyKeyGetForName( name ); + } + PageCursor nodePage( long reference ) { return nodeStore.openPageCursor( reference ); @@ -338,7 +422,8 @@ ArrayValue array( PropertyCursor cursor, long reference, PageCursor page ) *

* This function is its own inverse function. * - * @param reference the reference to invert. + * @param reference + * the reference to invert. * @return the inverted reference. */ static long invertReference( long reference ) @@ -363,7 +448,8 @@ static boolean needsFiltering( long reference ) return (reference & FILTER_MASK) != 0L; } - private static ByteBuffer readDynamic( AbstractDynamicStore store, long reference, ByteBuffer buffer, + private static ByteBuffer readDynamic( + AbstractDynamicStore store, long reference, ByteBuffer buffer, PageCursor page ) { if ( buffer == null ) diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/TempKernel.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/TempKernel.java index bd6f1add6f390..a4da6f151bc40 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/TempKernel.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/TempKernel.java @@ -35,7 +35,7 @@ class TempKernel implements KernelAPI TempKernel( GraphDatabaseAPI db ) { RecordStorageEngine engine = db.getDependencyResolver().resolveDependency( RecordStorageEngine.class ); - this.tx = new Transaction( engine.testAccessNeoStores() ); + this.tx = new Transaction( engine ); this.cursors = new Cursors( tx ); } @@ -59,9 +59,9 @@ public Token token() private static class Transaction extends Read implements org.neo4j.internal.kernel.api.Transaction { - Transaction( NeoStores stores ) + Transaction( RecordStorageEngine engine ) { - super( stores ); + super( engine ); } @Override diff --git a/community/kernel/src/main/java/org/neo4j/storageengine/api/schema/IndexReader.java b/community/kernel/src/main/java/org/neo4j/storageengine/api/schema/IndexReader.java index e02eb361ad86a..bdd04bd605d15 100644 --- a/community/kernel/src/main/java/org/neo4j/storageengine/api/schema/IndexReader.java +++ b/community/kernel/src/main/java/org/neo4j/storageengine/api/schema/IndexReader.java @@ -19,12 +19,13 @@ */ package org.neo4j.storageengine.api.schema; - import org.neo4j.collection.primitive.PrimitiveLongCollections; import org.neo4j.collection.primitive.PrimitiveLongIterator; import org.neo4j.graphdb.Resource; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.kernel.impl.newapi.CursorProgressor; +import org.neo4j.kernel.impl.newapi.IndexState; import org.neo4j.values.storable.Value; /** @@ -91,5 +92,50 @@ public boolean hasFullNumberPrecision( IndexQuery... predicates ) { return true; } + + @Override + public void query( + CursorProgressor.Cursor cursor, + IndexQuery... query ) + { + cursor.empty(); + } + + @Override + public void scan( CursorProgressor.Cursor cursor ) + { + cursor.empty(); + } }; + + default void query( CursorProgressor.Cursor cursor, IndexQuery... query ) + { + try + { + cursor.initialize( new NodeIdProgressor( query( query ) ) ); + } + catch ( IndexNotApplicableKernelException e ) + { + throw new RuntimeException( "SOMEONE FORGOT TO DO EXCEPTION HANDLING", e ); // TODO: exception handling + } + } + + default void scan( CursorProgressor.Cursor cursor ) + { + try + { + // the actual property key is ignored in the implementation, so we can pass in whatever... + // it is actually ok for the index implementation to ignore the property key under these two assumptions: + // 1. That all queries is "well formed" - i.e. we never ask for a key not in the index. + // 2. For compound indexes all nodes have all properties assigned. + // While we violate 1. here, we are at least "well intended", we don't actually care about what the key is. + // 2. holds because compound indexes are only created through node keys. + IndexQuery.ExistsPredicate scan = IndexQuery.exists( -1 ); + cursor.initialize( new NodeIdProgressor( query( scan ) ) ); + } + catch ( IndexNotApplicableKernelException e ) + { + throw new RuntimeException( "SOMEONE FORGOT TO DO EXCEPTION HANDLING", e ); // TODO: exception handling + } + } } diff --git a/community/kernel/src/main/java/org/neo4j/storageengine/api/schema/NodeIdProgressor.java b/community/kernel/src/main/java/org/neo4j/storageengine/api/schema/NodeIdProgressor.java new file mode 100644 index 0000000000000..449e02e8e0b0c --- /dev/null +++ b/community/kernel/src/main/java/org/neo4j/storageengine/api/schema/NodeIdProgressor.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2002-2017 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.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.storageengine.api.schema; + +import org.neo4j.collection.primitive.PrimitiveLongIterator; +import org.neo4j.graphdb.Resource; +import org.neo4j.kernel.impl.newapi.CursorProgressor; +import org.neo4j.kernel.impl.newapi.IndexState; + +class NodeIdProgressor implements CursorProgressor +{ + private final PrimitiveLongIterator ids; + + NodeIdProgressor( PrimitiveLongIterator ids ) + { + this.ids = ids; + } + + @Override + public boolean next( IndexState.NodeValue target ) + { + if ( ids.hasNext() ) + { + target.node( ids.next(), null, null ); + return true; + } + return false; + } + + @Override + public void close() + { + if ( ids instanceof Resource ) + { + ((Resource) ids).close(); + } + } +} diff --git a/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java b/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java index 7aac5e02376bc..fe8b6ebd4b297 100644 --- a/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java +++ b/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java @@ -51,7 +51,7 @@ import static org.neo4j.helpers.collection.Iterators.asSet; import static org.neo4j.helpers.collection.Iterators.count; import static org.neo4j.helpers.collection.MapUtil.map; -import static org.neo4j.kernel.api.schema.IndexQuery.stringPrefix; +import static org.neo4j.internal.kernel.api.IndexQuery.stringPrefix; import static org.neo4j.kernel.impl.coreapi.schema.PropertyNameUtils.getPropertyIds; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.containsOnly; import static org.neo4j.test.mockito.matcher.Neo4jMatchers.findNodesByLabelAndProperty; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/CompositeIndexingIT.java b/community/kernel/src/test/java/org/neo4j/kernel/api/CompositeIndexingIT.java index 2c406764d3c69..103ac9ba7719e 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/CompositeIndexingIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/CompositeIndexingIT.java @@ -45,7 +45,7 @@ import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.exceptions.schema.ConstraintValidationException; import org.neo4j.kernel.api.index.InternalIndexState; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.constaints.ConstraintDescriptorFactory; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java index 4f9f225088cac..1e1b827003a72 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java @@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; import static org.neo4j.kernel.api.index.IndexQueryHelper.exact; -import static org.neo4j.kernel.api.schema.IndexQuery.exists; +import static org.neo4j.internal.kernel.api.IndexQuery.exists; @Ignore( "Not a test. This is a compatibility suite that provides test cases for verifying" + " SchemaIndexProvider implementations. Each index provider that is to be tested by this suite" + diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexPopulatorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexPopulatorCompatibility.java index c7a6892ea7e8f..d8641a1e53f6b 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexPopulatorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexPopulatorCompatibility.java @@ -27,7 +27,7 @@ import org.neo4j.collection.primitive.PrimitiveLongCollections; import org.neo4j.collection.primitive.PrimitiveLongIterator; import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.configuration.Config; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexAccessorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexAccessorCompatibility.java index c0ce6a29fcc92..99b67f4ef1491 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexAccessorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexAccessorCompatibility.java @@ -29,7 +29,7 @@ import org.neo4j.collection.primitive.PrimitiveLongIterator; import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.api.index.IndexUpdateMode; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexQueryHelper.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexQueryHelper.java index b7f5f3a0bfec2..14488519fbc90 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexQueryHelper.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexQueryHelper.java @@ -19,7 +19,7 @@ */ package org.neo4j.kernel.api.index; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.values.storable.Value; import org.neo4j.values.storable.Values; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java index 6ca231e823eb0..c9decaf57a805 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java @@ -24,7 +24,7 @@ import java.util.Collections; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; @@ -33,12 +33,12 @@ import static java.util.Collections.singletonList; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; -import static org.neo4j.kernel.api.schema.IndexQuery.exact; -import static org.neo4j.kernel.api.schema.IndexQuery.exists; -import static org.neo4j.kernel.api.schema.IndexQuery.range; -import static org.neo4j.kernel.api.schema.IndexQuery.stringContains; -import static org.neo4j.kernel.api.schema.IndexQuery.stringPrefix; -import static org.neo4j.kernel.api.schema.IndexQuery.stringSuffix; +import static org.neo4j.internal.kernel.api.IndexQuery.exact; +import static org.neo4j.internal.kernel.api.IndexQuery.exists; +import static org.neo4j.internal.kernel.api.IndexQuery.range; +import static org.neo4j.internal.kernel.api.IndexQuery.stringContains; +import static org.neo4j.internal.kernel.api.IndexQuery.stringPrefix; +import static org.neo4j.internal.kernel.api.IndexQuery.stringSuffix; import static org.neo4j.kernel.api.index.IndexQueryHelper.add; @Ignore( "Not a test. This is a compatibility suite that provides test cases for verifying" + diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexPopulatorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexPopulatorCompatibility.java index f2a2d873b8167..9ac57773e8f51 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexPopulatorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexPopulatorCompatibility.java @@ -27,7 +27,7 @@ import org.neo4j.collection.primitive.PrimitiveLongCollections; import org.neo4j.collection.primitive.PrimitiveLongIterator; import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.configuration.Config; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/StatementOperationsTestHelper.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/StatementOperationsTestHelper.java index 76b568080045e..ae7b85f864fd5 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/StatementOperationsTestHelper.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/StatementOperationsTestHelper.java @@ -23,7 +23,7 @@ import org.neo4j.kernel.api.ReadOperations; import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.txstate.TransactionState; import org.neo4j.kernel.impl.api.operations.CountsOperations; import org.neo4j.kernel.impl.api.operations.EntityReadOperations; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/HashBasedIndex.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/HashBasedIndex.java index 9d367cd426b32..83ebeb055883c 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/HashBasedIndex.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/HashBasedIndex.java @@ -31,12 +31,12 @@ import org.neo4j.collection.primitive.PrimitiveLongCollections; import org.neo4j.collection.primitive.PrimitiveLongIterator; import org.neo4j.helpers.collection.Iterables; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.storageengine.api.schema.IndexSampler; import org.neo4j.values.storable.Value; import static org.neo4j.collection.primitive.PrimitiveLongCollections.toPrimitiveIterator; -import static org.neo4j.kernel.api.schema.IndexQuery.IndexQueryType.exact; +import static org.neo4j.internal.kernel.api.IndexQuery.IndexQueryType.exact; import static org.neo4j.kernel.impl.api.PropertyValueComparison.COMPARE_VALUES; import static org.neo4j.kernel.impl.api.PropertyValueComparison.SuperType.NUMBER; import static org.neo4j.kernel.impl.api.PropertyValueComparison.SuperType.STRING; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/NodeGetUniqueFromIndexSeekIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/NodeGetUniqueFromIndexSeekIT.java index cd29cdd60c264..a60e2ffa07620 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/NodeGetUniqueFromIndexSeekIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/NodeGetUniqueFromIndexSeekIT.java @@ -41,7 +41,7 @@ import org.neo4j.values.storable.Values; import static org.junit.Assert.assertTrue; -import static org.neo4j.kernel.api.schema.IndexQuery.exact; +import static org.neo4j.internal.kernel.api.IndexQuery.exact; public class NodeGetUniqueFromIndexSeekIT extends KernelIntegrationTest { diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintValidationIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintValidationIT.java index e6e7a629a0cb0..216d7cd1afee6 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintValidationIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/integrationtest/UniquenessConstraintValidationIT.java @@ -41,7 +41,7 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.neo4j.collection.primitive.PrimitiveLongCollections.count; -import static org.neo4j.kernel.api.schema.IndexQuery.exact; +import static org.neo4j.internal.kernel.api.IndexQuery.exact; import static org.neo4j.kernel.api.schema.SchemaDescriptorFactory.forLabel; public class UniquenessConstraintValidationIT extends KernelIntegrationTest diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/operations/ConstraintEnforcingEntityOperationsTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/operations/ConstraintEnforcingEntityOperationsTest.java index 7243fcbec1169..02b78cd9a29e0 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/operations/ConstraintEnforcingEntityOperationsTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/operations/ConstraintEnforcingEntityOperationsTest.java @@ -25,7 +25,7 @@ import org.neo4j.collection.primitive.PrimitiveIntCollections; import org.neo4j.cursor.Cursor; import org.neo4j.kernel.api.index.InternalIndexState; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations; @@ -48,7 +48,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; import static org.neo4j.kernel.api.StatementConstants.NO_SUCH_NODE; -import static org.neo4j.kernel.api.schema.IndexQuery.exact; +import static org.neo4j.internal.kernel.api.IndexQuery.exact; import static org.neo4j.kernel.impl.locking.ResourceTypes.INDEX_ENTRY; import static org.neo4j.kernel.impl.locking.ResourceTypes.indexEntryResourceId; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/IndexQueryTransactionStateTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/IndexQueryTransactionStateTest.java index 8d4c879aa5006..4bfee63fd93a0 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/IndexQueryTransactionStateTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/IndexQueryTransactionStateTest.java @@ -32,7 +32,7 @@ import org.neo4j.kernel.api.AssertOpen; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.properties.PropertyKeyValue; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.api.txstate.TransactionState; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/StateHandlingStatementOperationsTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/StateHandlingStatementOperationsTest.java index ce6a954b57882..85e03cda54f8d 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/StateHandlingStatementOperationsTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/state/StateHandlingStatementOperationsTest.java @@ -35,7 +35,7 @@ import org.neo4j.kernel.api.explicitindex.AutoIndexOperations; import org.neo4j.kernel.api.explicitindex.AutoIndexing; import org.neo4j.kernel.api.properties.PropertyKeyValue; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema.constaints.ConstraintDescriptor; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexAccessorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexAccessorTest.java index 89f840aff2034..ba4c2da79439b 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexAccessorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexAccessorTest.java @@ -42,7 +42,7 @@ import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.IndexUpdater; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.impl.api.index.IndexUpdateMode; import org.neo4j.storageengine.api.schema.IndexReader; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexReaderTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexReaderTest.java index 4f7291ec37f66..a226bda99c657 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexReaderTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexReaderTest.java @@ -27,12 +27,12 @@ import org.neo4j.collection.primitive.PrimitiveLongIterator; import org.neo4j.collection.primitive.PrimitiveLongSet; import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException; -import org.neo4j.kernel.api.schema.IndexQuery; -import org.neo4j.kernel.api.schema.IndexQuery.NumberRangePredicate; -import org.neo4j.kernel.api.schema.IndexQuery.StringContainsPredicate; -import org.neo4j.kernel.api.schema.IndexQuery.StringPrefixPredicate; -import org.neo4j.kernel.api.schema.IndexQuery.StringRangePredicate; -import org.neo4j.kernel.api.schema.IndexQuery.StringSuffixPredicate; +import org.neo4j.internal.kernel.api.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery.NumberRangePredicate; +import org.neo4j.internal.kernel.api.IndexQuery.StringContainsPredicate; +import org.neo4j.internal.kernel.api.IndexQuery.StringPrefixPredicate; +import org.neo4j.internal.kernel.api.IndexQuery.StringRangePredicate; +import org.neo4j.internal.kernel.api.IndexQuery.StringSuffixPredicate; import org.neo4j.kernel.impl.index.schema.NativeSelector; import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.values.storable.Value; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/locking/IndexEntryResourceTypesTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/locking/IndexEntryResourceTypesTest.java index 2bd62c3793968..f25a39d037be5 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/locking/IndexEntryResourceTypesTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/locking/IndexEntryResourceTypesTest.java @@ -26,14 +26,14 @@ import java.util.Set; import org.neo4j.helpers.collection.Iterables; -import org.neo4j.kernel.api.schema.IndexQuery.ExactPredicate; +import org.neo4j.internal.kernel.api.IndexQuery.ExactPredicate; import org.neo4j.values.storable.Value; import org.neo4j.values.storable.Values; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.neo4j.helpers.collection.Iterators.array; -import static org.neo4j.kernel.api.schema.IndexQuery.exact; +import static org.neo4j.internal.kernel.api.IndexQuery.exact; public class IndexEntryResourceTypesTest { diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/locking/ResourceTypesIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/locking/ResourceTypesIT.java index 69e154f09ac92..ff4264188e68a 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/locking/ResourceTypesIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/locking/ResourceTypesIT.java @@ -27,7 +27,7 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; -import static org.neo4j.kernel.api.schema.IndexQuery.exact; +import static org.neo4j.internal.kernel.api.IndexQuery.exact; import static org.neo4j.kernel.impl.locking.ResourceTypes.indexEntryResourceId; /** diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/NodeValueIndexCursorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/NodeValueIndexCursorTest.java new file mode 100644 index 0000000000000..2b495094681d2 --- /dev/null +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/newapi/NodeValueIndexCursorTest.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2002-2017 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.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.newapi; + +import org.neo4j.internal.kernel.api.NodeValueIndexCursorTestBase; + +public class NodeValueIndexCursorTest extends NodeValueIndexCursorTestBase +{ + @Override + public ReadTestSupport newTestSupport() + { + return new ReadTestSupport(); + } +} diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/IndexWorkSyncTransactionApplicationStressIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/IndexWorkSyncTransactionApplicationStressIT.java index 03af971f00d3b..f49dd627b752f 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/IndexWorkSyncTransactionApplicationStressIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/IndexWorkSyncTransactionApplicationStressIT.java @@ -32,7 +32,7 @@ import org.neo4j.collection.primitive.PrimitiveLongIterator; import org.neo4j.helpers.collection.Visitor; import org.neo4j.kernel.api.index.InternalIndexState; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema.SchemaDescriptorFactory; import org.neo4j.kernel.api.txstate.TransactionState; diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/reader/PartitionedIndexReader.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/reader/PartitionedIndexReader.java index f0ca18ab5c75d..b9f4ccd81d528 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/reader/PartitionedIndexReader.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/reader/PartitionedIndexReader.java @@ -31,7 +31,7 @@ import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException; import org.neo4j.kernel.api.impl.index.partition.PartitionSearcher; import org.neo4j.kernel.api.impl.index.sampler.AggregatingIndexSampler; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.storageengine.api.schema.IndexReader; diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/reader/SimpleIndexReader.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/reader/SimpleIndexReader.java index 3d6e186a708e4..13f79840ef98d 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/reader/SimpleIndexReader.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/reader/SimpleIndexReader.java @@ -38,8 +38,8 @@ import org.neo4j.kernel.api.impl.schema.LuceneDocumentStructure; import org.neo4j.kernel.api.impl.schema.sampler.NonUniqueLuceneIndexSampler; import org.neo4j.kernel.api.impl.schema.sampler.UniqueLuceneIndexSampler; -import org.neo4j.kernel.api.schema.IndexQuery; -import org.neo4j.kernel.api.schema.IndexQuery.IndexQueryType; +import org.neo4j.internal.kernel.api.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery.IndexQueryType; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.storageengine.api.schema.IndexReader; @@ -47,7 +47,7 @@ import org.neo4j.values.storable.Value; import static org.neo4j.kernel.api.impl.schema.LuceneDocumentStructure.NODE_ID_KEY; -import static org.neo4j.kernel.api.schema.IndexQuery.IndexQueryType.exact; +import static org.neo4j.internal.kernel.api.IndexQuery.IndexQueryType.exact; import static org.neo4j.kernel.api.schema.index.IndexDescriptor.Type.UNIQUE; /** diff --git a/community/lucene-index/src/test/java/org/neo4j/concurrencytest/ConstraintIndexConcurrencyTest.java b/community/lucene-index/src/test/java/org/neo4j/concurrencytest/ConstraintIndexConcurrencyTest.java index 4c8f0e2092a33..ce3d198b956b4 100644 --- a/community/lucene-index/src/test/java/org/neo4j/concurrencytest/ConstraintIndexConcurrencyTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/concurrencytest/ConstraintIndexConcurrencyTest.java @@ -30,7 +30,7 @@ import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; import org.neo4j.kernel.api.exceptions.schema.UniquePropertyValueValidationException; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.constaints.ConstraintDescriptorFactory; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; diff --git a/community/lucene-index/src/test/java/org/neo4j/index/impl/lucene/explicit/NonUniqueIndexTest.java b/community/lucene-index/src/test/java/org/neo4j/index/impl/lucene/explicit/NonUniqueIndexTest.java index f0b3f6a809c5e..7ff1385966f66 100644 --- a/community/lucene-index/src/test/java/org/neo4j/index/impl/lucene/explicit/NonUniqueIndexTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/index/impl/lucene/explicit/NonUniqueIndexTest.java @@ -40,7 +40,7 @@ import org.neo4j.kernel.api.impl.schema.NativeLuceneFusionSchemaIndexProviderFactory; import org.neo4j.kernel.api.index.IndexAccessor; import org.neo4j.kernel.api.index.SchemaIndexProvider; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/index/LuceneSchemaIndexPopulationIT.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/index/LuceneSchemaIndexPopulationIT.java index ad4879de23fe6..c253e28a21fdc 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/index/LuceneSchemaIndexPopulationIT.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/index/LuceneSchemaIndexPopulationIT.java @@ -38,7 +38,7 @@ import org.neo4j.kernel.api.impl.schema.SchemaIndex; import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.IndexUpdater; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.impl.api.index.IndexUpdateMode; diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseCompositeIndexAccessorTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseCompositeIndexAccessorTest.java index 31343418665cf..912f0fd550834 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseCompositeIndexAccessorTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseCompositeIndexAccessorTest.java @@ -44,7 +44,7 @@ import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.IndexQueryHelper; import org.neo4j.kernel.api.index.IndexUpdater; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.impl.api.index.IndexUpdateMode; @@ -59,7 +59,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import static org.neo4j.helpers.collection.Iterators.asSet; -import static org.neo4j.kernel.api.schema.IndexQuery.exact; +import static org.neo4j.internal.kernel.api.IndexQuery.exact; import static org.neo4j.test.rule.concurrent.ThreadingRule.waitingWhileIn; @RunWith( Parameterized.class ) diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseIndexAccessorTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseIndexAccessorTest.java index 7b64081c7b763..4628f4dd6a834 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseIndexAccessorTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseIndexAccessorTest.java @@ -44,7 +44,7 @@ import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.IndexQueryHelper; import org.neo4j.kernel.api.index.IndexUpdater; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.impl.api.index.IndexUpdateMode; @@ -60,8 +60,8 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.neo4j.helpers.collection.Iterators.asSet; -import static org.neo4j.kernel.api.schema.IndexQuery.exact; -import static org.neo4j.kernel.api.schema.IndexQuery.range; +import static org.neo4j.internal.kernel.api.IndexQuery.exact; +import static org.neo4j.internal.kernel.api.IndexQuery.range; import static org.neo4j.test.rule.concurrent.ThreadingRule.waitingWhileIn; @RunWith( Parameterized.class ) diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueDatabaseIndexPopulatorTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueDatabaseIndexPopulatorTest.java index d7126dddfe710..e1152d1293836 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueDatabaseIndexPopulatorTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueDatabaseIndexPopulatorTest.java @@ -37,7 +37,7 @@ import org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexBuilder; import org.neo4j.kernel.api.impl.schema.SchemaIndex; import org.neo4j.kernel.api.index.IndexEntryUpdate; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/UniqueDatabaseIndexPopulatorTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/UniqueDatabaseIndexPopulatorTest.java index 9335fd1ca08a4..a60dc14a35ebf 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/UniqueDatabaseIndexPopulatorTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/UniqueDatabaseIndexPopulatorTest.java @@ -44,7 +44,7 @@ import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.PropertyAccessor; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema.index.IndexDescriptor; diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/reader/PartitionedIndexReaderTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/reader/PartitionedIndexReaderTest.java index 05ff1372222f0..5b0460d8ce838 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/reader/PartitionedIndexReaderTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/reader/PartitionedIndexReaderTest.java @@ -33,7 +33,7 @@ import org.neo4j.helpers.TaskCoordinator; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.impl.index.partition.PartitionSearcher; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/reader/SimpleIndexReaderTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/reader/SimpleIndexReaderTest.java index 498268aa48dd7..6d2d6e66faf3e 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/reader/SimpleIndexReaderTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/reader/SimpleIndexReaderTest.java @@ -38,7 +38,7 @@ import org.neo4j.kernel.api.impl.index.partition.PartitionSearcher; import org.neo4j.kernel.api.impl.schema.sampler.NonUniqueLuceneIndexSampler; import org.neo4j.kernel.api.impl.schema.sampler.UniqueLuceneIndexSampler; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; @@ -50,7 +50,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.neo4j.kernel.api.schema.IndexQuery.range; +import static org.neo4j.internal.kernel.api.IndexQuery.range; public class SimpleIndexReaderTest { diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/impl/api/OperationsFacadeSchemaIndexIteratorTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/impl/api/OperationsFacadeSchemaIndexIteratorTest.java index 76efb6b3bf4d3..56f23f4b391ec 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/impl/api/OperationsFacadeSchemaIndexIteratorTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/impl/api/OperationsFacadeSchemaIndexIteratorTest.java @@ -38,6 +38,7 @@ import org.neo4j.graphdb.Label; import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Transaction; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.ReadOperations; import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.exceptions.InvalidTransactionTypeKernelException; @@ -46,7 +47,6 @@ import org.neo4j.kernel.api.exceptions.schema.AlreadyConstrainedException; import org.neo4j.kernel.api.exceptions.schema.AlreadyIndexedException; import org.neo4j.kernel.api.exceptions.schema.RepeatedPropertyInCompositeSchemaException; -import org.neo4j.kernel.api.schema.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.test.rule.DatabaseRule; diff --git a/community/neo4j/src/test/java/migration/Start3_2DbOn3_3AndCreateFusionIndexIT.java b/community/neo4j/src/test/java/migration/Start3_2DbOn3_3AndCreateFusionIndexIT.java index 767b689e94e14..f3a64f1c99bc0 100644 --- a/community/neo4j/src/test/java/migration/Start3_2DbOn3_3AndCreateFusionIndexIT.java +++ b/community/neo4j/src/test/java/migration/Start3_2DbOn3_3AndCreateFusionIndexIT.java @@ -38,7 +38,7 @@ import org.neo4j.kernel.api.KernelTransaction; import org.neo4j.kernel.api.ReadOperations; import org.neo4j.kernel.api.Statement; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.impl.api.KernelStatement; diff --git a/community/neo4j/src/test/java/org/neo4j/locking/QueryExecutionLocksIT.java b/community/neo4j/src/test/java/org/neo4j/locking/QueryExecutionLocksIT.java index f92b45435b0ca..d2a608d11cff0 100644 --- a/community/neo4j/src/test/java/org/neo4j/locking/QueryExecutionLocksIT.java +++ b/community/neo4j/src/test/java/org/neo4j/locking/QueryExecutionLocksIT.java @@ -67,7 +67,7 @@ import org.neo4j.kernel.api.proc.QualifiedName; import org.neo4j.kernel.api.proc.UserFunctionSignature; import org.neo4j.kernel.api.query.ExecutingQuery; -import org.neo4j.kernel.api.schema.IndexQuery; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.kernel.api.schema.SchemaDescriptor; import org.neo4j.kernel.api.schema.constaints.ConstraintDescriptor; diff --git a/community/values/src/main/java/org/neo4j/values/storable/ArrayValue.java b/community/values/src/main/java/org/neo4j/values/storable/ArrayValue.java index 30b16233bf174..3cfc1b886b050 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/ArrayValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/ArrayValue.java @@ -65,6 +65,18 @@ public boolean equals( boolean x ) return false; } + @Override + public boolean equals( long x ) + { + return false; + } + + @Override + public boolean equals( double x ) + { + return false; + } + @Override public boolean equals( char x ) { diff --git a/community/values/src/main/java/org/neo4j/values/storable/BooleanValue.java b/community/values/src/main/java/org/neo4j/values/storable/BooleanValue.java index b017d3bfe4a12..e01f6ac1ea813 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/BooleanValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/BooleanValue.java @@ -54,6 +54,18 @@ public boolean equals( boolean x ) return value == x; } + @Override + public boolean equals( long x ) + { + return false; + } + + @Override + public boolean equals( double x ) + { + return false; + } + @Override public boolean equals( char x ) { diff --git a/community/values/src/main/java/org/neo4j/values/storable/ByteValue.java b/community/values/src/main/java/org/neo4j/values/storable/ByteValue.java index 612483cfd3b60..0b53f0f26b693 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/ByteValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/ByteValue.java @@ -70,7 +70,7 @@ public void writeTo( ValueWriter writer ) throws E } @Override - public Object asObjectCopy() + public Byte asObjectCopy() { return value; } diff --git a/community/values/src/main/java/org/neo4j/values/storable/DoubleValue.java b/community/values/src/main/java/org/neo4j/values/storable/DoubleValue.java index d5983903b6f40..271f01e2e2566 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/DoubleValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/DoubleValue.java @@ -66,7 +66,7 @@ public void writeTo( ValueWriter writer ) throws E } @Override - public Object asObjectCopy() + public Double asObjectCopy() { return value; } diff --git a/community/values/src/main/java/org/neo4j/values/storable/FloatValue.java b/community/values/src/main/java/org/neo4j/values/storable/FloatValue.java index a506a9adf074f..27707817352d9 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/FloatValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/FloatValue.java @@ -66,7 +66,7 @@ public void writeTo( ValueWriter writer ) throws E } @Override - public Object asObjectCopy() + public Float asObjectCopy() { return value; } diff --git a/community/values/src/main/java/org/neo4j/values/storable/FloatingPointValue.java b/community/values/src/main/java/org/neo4j/values/storable/FloatingPointValue.java index 248a1164e3cc1..64f67eadb2023 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/FloatingPointValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/FloatingPointValue.java @@ -21,6 +21,18 @@ public abstract class FloatingPointValue extends NumberValue { + @Override + public boolean equals( long x ) + { + return NumberValues.numbersEqual( doubleValue(), x ); + } + + @Override + public boolean equals( double x ) + { + return doubleValue() == x; + } + @Override public final int computeHash() { diff --git a/community/values/src/main/java/org/neo4j/values/storable/IntValue.java b/community/values/src/main/java/org/neo4j/values/storable/IntValue.java index e3325901b5cd3..59e84a5602f6e 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/IntValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/IntValue.java @@ -48,7 +48,7 @@ public void writeTo( ValueWriter writer ) throws E } @Override - public Object asObjectCopy() + public Integer asObjectCopy() { return value; } diff --git a/community/values/src/main/java/org/neo4j/values/storable/IntegralValue.java b/community/values/src/main/java/org/neo4j/values/storable/IntegralValue.java index 2e0104d3a7c0e..19f46ff85e8de 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/IntegralValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/IntegralValue.java @@ -21,6 +21,18 @@ public abstract class IntegralValue extends NumberValue { + @Override + public boolean equals( long x ) + { + return longValue() == x; + } + + @Override + public boolean equals( double x ) + { + return NumberValues.numbersEqual( x, longValue() ); + } + @Override public final int computeHash() { diff --git a/community/values/src/main/java/org/neo4j/values/storable/LongValue.java b/community/values/src/main/java/org/neo4j/values/storable/LongValue.java index 4f21c7c42444c..219a24500c9db 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/LongValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/LongValue.java @@ -66,7 +66,7 @@ public void writeTo( ValueWriter writer ) throws E } @Override - public Object asObjectCopy() + public Long asObjectCopy() { return value; } diff --git a/community/values/src/main/java/org/neo4j/values/storable/NoValue.java b/community/values/src/main/java/org/neo4j/values/storable/NoValue.java index 520fd24005632..485e2aa8e12f6 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/NoValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/NoValue.java @@ -100,6 +100,18 @@ public boolean equals( boolean[] x ) return false; } + @Override + public boolean equals( long x ) + { + return false; + } + + @Override + public boolean equals( double x ) + { + return false; + } + @Override public boolean equals( char x ) { diff --git a/community/values/src/main/java/org/neo4j/values/storable/NumberValue.java b/community/values/src/main/java/org/neo4j/values/storable/NumberValue.java index f99dc71e9dbae..46bb946778ea8 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/NumberValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/NumberValue.java @@ -29,6 +29,15 @@ public abstract class NumberValue extends ScalarValue abstract int compareTo( FloatingPointValue other ); + @Override + public abstract Number asObjectCopy(); + + @Override + public Number asObject() + { + return asObjectCopy(); + } + @Override public boolean equals( boolean x ) { diff --git a/community/values/src/main/java/org/neo4j/values/storable/ShortValue.java b/community/values/src/main/java/org/neo4j/values/storable/ShortValue.java index fc1732ad94df0..61e0ccf7c153a 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/ShortValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/ShortValue.java @@ -70,7 +70,7 @@ public void writeTo( ValueWriter writer ) throws E } @Override - public Object asObjectCopy() + public Short asObjectCopy() { return value; } diff --git a/community/values/src/main/java/org/neo4j/values/storable/TextValue.java b/community/values/src/main/java/org/neo4j/values/storable/TextValue.java index c26400bb62588..0d803e2a5265b 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/TextValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/TextValue.java @@ -56,6 +56,17 @@ public boolean equals( boolean x ) } @Override + public boolean equals( long x ) + { + return false; + } + + @Override + public boolean equals( double x ) + { + return false; + } + public ValueGroup valueGroup() { return ValueGroup.TEXT; diff --git a/community/values/src/main/java/org/neo4j/values/storable/Value.java b/community/values/src/main/java/org/neo4j/values/storable/Value.java index a465606c9da57..9bc4d3cf91480 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/Value.java +++ b/community/values/src/main/java/org/neo4j/values/storable/Value.java @@ -42,6 +42,10 @@ public abstract class Value extends AnyValue public abstract boolean equals( boolean[] x ); + public abstract boolean equals( long x ); + + public abstract boolean equals( double x ); + public abstract boolean equals( char x ); public abstract boolean equals( String x ); diff --git a/community/values/src/main/java/org/neo4j/values/storable/ValueTuple.java b/community/values/src/main/java/org/neo4j/values/storable/ValueTuple.java index 2346d0f5fcdfa..2b031ec46b0c9 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/ValueTuple.java +++ b/community/values/src/main/java/org/neo4j/values/storable/ValueTuple.java @@ -19,11 +19,11 @@ */ package org.neo4j.values.storable; +import java.util.Comparator; + /** * A tuple of n values. */ -import java.util.Comparator; - public class ValueTuple { public static ValueTuple of( Value... values ) diff --git a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/GeneratedMethodStructure.scala b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/GeneratedMethodStructure.scala index 4fcaae2ce8255..29940d586afa9 100644 --- a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/GeneratedMethodStructure.scala +++ b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/GeneratedMethodStructure.scala @@ -20,8 +20,7 @@ package org.neo4j.cypher.internal.spi.v3_4.codegen import java.util.PrimitiveIterator -import java.util.{Iterator => JIterator, Map => JMap, HashMap => JHashMap, - Set => JSet, HashSet => JHashSet, ArrayList => JArrayList} +import java.util.{ArrayList => JArrayList, HashMap => JHashMap, HashSet => JHashSet, Iterator => JIterator, Map => JMap, Set => JSet} import java.util.stream.{DoubleStream, IntStream, LongStream} import org.neo4j.codegen.Expression.{invoke, not, or, _} @@ -45,9 +44,10 @@ import org.neo4j.cypher.internal.spi.v3_4.codegen.Methods._ import org.neo4j.cypher.internal.spi.v3_4.codegen.Templates._ import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection import org.neo4j.graphdb.{Direction, Node, Relationship} +import org.neo4j.internal.kernel.api.IndexQuery import org.neo4j.kernel.api.ReadOperations import org.neo4j.kernel.api.schema.index.{IndexDescriptor, IndexDescriptorFactory} -import org.neo4j.kernel.api.schema.{IndexQuery, LabelSchemaDescriptor} +import org.neo4j.kernel.api.schema.LabelSchemaDescriptor import org.neo4j.kernel.impl.api.RelationshipDataExtractor import org.neo4j.kernel.impl.api.store.RelationshipIterator import org.neo4j.kernel.impl.util.ValueUtils diff --git a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/Methods.scala b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/Methods.scala index 7b9caf7a3fe83..58b6c110c92cc 100644 --- a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/Methods.scala +++ b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/Methods.scala @@ -32,8 +32,8 @@ import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.cypher.result.QueryResult.{QueryResultVisitor, Record} import org.neo4j.graphdb.Direction import org.neo4j.helpers.collection.MapUtil +import org.neo4j.internal.kernel.api.IndexQuery import org.neo4j.kernel.api.ReadOperations -import org.neo4j.kernel.api.schema.IndexQuery import org.neo4j.kernel.api.schema.index.IndexDescriptor import org.neo4j.kernel.impl.api.store.RelationshipIterator import org.neo4j.kernel.impl.api.{RelationshipDataExtractor, RelationshipVisitor} diff --git a/enterprise/runtime/neole/LICENSES.txt b/enterprise/runtime/neole/LICENSES.txt index e62824d7096a5..fd96cba2c36a7 100644 --- a/enterprise/runtime/neole/LICENSES.txt +++ b/enterprise/runtime/neole/LICENSES.txt @@ -1,4 +1,212 @@ This file contains the full license text of the included third party libraries. For an overview of the licenses see the NOTICE.txt file. +------------------------------------------------------------------------------ +Apache Software License, Version 2.0 + Apache Commons Lang +------------------------------------------------------------------------------ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. + + diff --git a/enterprise/runtime/neole/NOTICE.txt b/enterprise/runtime/neole/NOTICE.txt index 5519ed4ba3c2e..be3ce6bad9586 100644 --- a/enterprise/runtime/neole/NOTICE.txt +++ b/enterprise/runtime/neole/NOTICE.txt @@ -24,3 +24,6 @@ Full license texts are found in LICENSES.txt. Third-party licenses -------------------- +Apache Software License, Version 2.0 + Apache Commons Lang + diff --git a/enterprise/runtime/neole/src/main/java/org/neo4j/internal/store/prototype/neole/ReadStore.java b/enterprise/runtime/neole/src/main/java/org/neo4j/internal/store/prototype/neole/ReadStore.java index cdf2cc70fe608..eeb0d6bc3caa1 100644 --- a/enterprise/runtime/neole/src/main/java/org/neo4j/internal/store/prototype/neole/ReadStore.java +++ b/enterprise/runtime/neole/src/main/java/org/neo4j/internal/store/prototype/neole/ReadStore.java @@ -22,7 +22,8 @@ import java.io.File; import java.io.IOException; -import org.neo4j.internal.kernel.api.IndexPredicate; +import org.neo4j.internal.kernel.api.IndexQuery; +import org.neo4j.internal.kernel.api.NodeValueIndexCursor; import org.neo4j.internal.kernel.api.IndexReference; import org.neo4j.internal.kernel.api.Read; import org.neo4j.internal.kernel.api.RelationshipGroupCursor; @@ -58,8 +59,8 @@ public ReadStore( File storeDir ) throws IOException @Override public void nodeIndexSeek( IndexReference index, - org.neo4j.internal.kernel.api.NodeValueIndexCursor cursor, - IndexPredicate... predicates ) + NodeValueIndexCursor cursor, + IndexQuery... query ) { throw new UnsupportedOperationException( "not implemented" ); } @@ -196,6 +197,24 @@ public void futureRelationshipPropertyReferenceRead( long reference ) throw new UnsupportedOperationException( "not implemented" ); } + @Override + public IndexReference index( int label, int... properties ) + { + throw new UnsupportedOperationException( "not implemented" ); + } + + @Override + public int nodeLabel( String name ) + { + throw new UnsupportedOperationException( "not implemented" ); + } + + @Override + public int propertyKey( String name ) + { + throw new UnsupportedOperationException( "not implemented" ); + } + public void block( long reference, ByteBlockCursor cursor ) { throw new UnsupportedOperationException( "not implemented" ); diff --git a/enterprise/runtime/neole/src/test/java/org/neo4j/internal/store/prototype/neole/GraphSetup.java b/enterprise/runtime/neole/src/test/java/org/neo4j/internal/store/prototype/neole/GraphSetup.java index c23e7c7541bba..ef2dc59ea8699 100644 --- a/enterprise/runtime/neole/src/test/java/org/neo4j/internal/store/prototype/neole/GraphSetup.java +++ b/enterprise/runtime/neole/src/test/java/org/neo4j/internal/store/prototype/neole/GraphSetup.java @@ -30,7 +30,7 @@ import org.neo4j.graphdb.config.Setting; import org.neo4j.graphdb.factory.GraphDatabaseBuilder; import org.neo4j.graphdb.factory.GraphDatabaseFactory; -import org.neo4j.internal.kernel.api.IndexPredicate; +import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.internal.kernel.api.IndexReference; import org.neo4j.internal.kernel.api.NodeCursor; import org.neo4j.internal.kernel.api.NodeLabelIndexCursor; @@ -116,9 +116,9 @@ protected void cleanup() } @Override - public void nodeIndexSeek( IndexReference index, NodeValueIndexCursor cursor, IndexPredicate... predicates ) + public void nodeIndexSeek( IndexReference index, NodeValueIndexCursor cursor, IndexQuery... query ) { - store.nodeIndexSeek( index, cursor, predicates ); + store.nodeIndexSeek( index, cursor, query ); } @Override @@ -235,6 +235,24 @@ public void futureRelationshipPropertyReferenceRead( long reference ) store.futureRelationshipPropertyReferenceRead( reference ); } + @Override + public IndexReference index( int label, int... properties ) + { + return store.index( label, properties ); + } + + @Override + public int nodeLabel( String name ) + { + return store.nodeLabel( name ); + } + + @Override + public int propertyKey( String name ) + { + return store.propertyKey( name ); + } + @Override public NodeCursor allocateNodeCursor() {