Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add IndexCapability and CapableIndexReference
First step toward providing index backed ORDER BY in cypher. IndexCapability answer the questions: - Can I get the actual property values from this index? - What ordering of index query results does this index naturally provide? IndexCapability describe the functional capabilities of a given index. Each schema index rule stored in schema store will have it's own capabilities depending on index type (unique, general), index description (label, properties) and index provider. Right now IndexCapability is decided by the SchemaIndexProvider backing the given index. IndexCapability can not change for a given index during its lifetime.
- Loading branch information
Showing
41 changed files
with
602 additions
and
104 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/CapableIndexReference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.neo4j.internal.kernel.api; | ||
|
||
import org.neo4j.values.storable.ValueGroup; | ||
|
||
public interface CapableIndexReference extends IndexReference, IndexCapability | ||
{ | ||
CapableIndexReference NO_INDEX = new CapableIndexReference() | ||
{ | ||
IndexReference noIndexReference = IndexReference.NO_INDEX; | ||
|
||
@Override | ||
public IndexOrderCapability[] order( ValueGroup... valueGroups ) | ||
{ | ||
return new IndexOrderCapability[0]; | ||
} | ||
|
||
@Override | ||
public IndexValueCapability value( ValueGroup... valueGroups ) | ||
{ | ||
return IndexValueCapability.NO; | ||
} | ||
|
||
@Override | ||
public boolean isUnique() | ||
{ | ||
return noIndexReference.isUnique(); | ||
} | ||
|
||
@Override | ||
public int label() | ||
{ | ||
return noIndexReference.label(); | ||
} | ||
|
||
@Override | ||
public int[] properties() | ||
{ | ||
return noIndexReference.properties(); | ||
} | ||
}; | ||
} |
74 changes: 74 additions & 0 deletions
74
community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexCapability.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.internal.kernel.api; | ||
|
||
import org.neo4j.values.storable.ValueGroup; | ||
|
||
/** | ||
* Capabilities of an index. | ||
* Capabilities of an index can not change during the indexes lifetimes. | ||
* Caching of IndexCapability is allowed. | ||
* It does NOT describe the capabilities of the index at some given moment. For example it does not describe | ||
* index state. Rather it describe the functionality that index provide given that it is available. | ||
*/ | ||
public interface IndexCapability | ||
{ | ||
/** | ||
* What possible orderings is this index capable to provide for a query on given combination of {@link ValueGroup}. | ||
* Ordering of ValueGroup correspond to ordering of related {@link IndexReference#properties()}. | ||
* | ||
* @param valueGroups Ordered array of {@link ValueGroup ValueGroups} for which index should be queried. Note that valueGroup | ||
* must correspond to related {@link IndexReference#properties()}. A {@code null} value in the array | ||
* ({@code new ValueGroup[]{null}}) is interpreted as a wildcard for any {@link ValueGroup}. Note that this is not the same as | ||
* {@code order(null)} which is undefined. | ||
* @return {@link IndexOrderCapability} array containing all possible orderings for provided value groups or empty array if no explicit | ||
* ordering is possible or if length of {@code valueGroups} and {@link IndexReference#properties()} differ. | ||
*/ | ||
IndexOrderCapability[] order( ValueGroup... valueGroups ); | ||
|
||
/** | ||
* Is the index capable of providing values for a query on given combination of {@link ValueGroup}. | ||
* Ordering of ValueGroup correspond to ordering of {@code properties} in related {@link IndexReference}. | ||
* | ||
* @param valueGroups Ordered array of {@link ValueGroup ValueGroups} for which index should be queried. Note that valueGroup | ||
* must correspond to related {@link IndexReference#properties()}. A {@code null} value in the array | ||
* ({@code new ValueGroup[]{null}}) is interpreted as a wildcard for any {@link ValueGroup}. Note that this is not the same as | ||
* {@code order(null)} which is undefined. | ||
* @return {@link IndexValueCapability#YES} if index is capable of providing values for query on provided array of value groups, | ||
* {@link IndexValueCapability#NO} if not or {@link IndexValueCapability#MAYBE} for some results. If length of | ||
* {@code valueGroups} and {@link IndexReference#properties()} differ {@link IndexValueCapability#NO} is returned. | ||
*/ | ||
IndexValueCapability value( ValueGroup... valueGroups ); | ||
|
||
IndexCapability NO_CAPABILITY = new IndexCapability() | ||
{ | ||
@Override | ||
public IndexOrderCapability[] order( ValueGroup... valueGroups ) | ||
{ | ||
return new IndexOrderCapability[0]; | ||
} | ||
|
||
@Override | ||
public IndexValueCapability value( ValueGroup... valueGroups ) | ||
{ | ||
return IndexValueCapability.NO; | ||
} | ||
}; | ||
} |
25 changes: 25 additions & 0 deletions
25
community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexOrderCapability.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.internal.kernel.api; | ||
|
||
public enum IndexOrderCapability | ||
{ | ||
ASCENDING, DESCENDING | ||
} |
25 changes: 25 additions & 0 deletions
25
community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexValueCapability.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.internal.kernel.api; | ||
|
||
public enum IndexValueCapability | ||
{ | ||
YES, NO, MAYBE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.