Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Let kernel augment the generic native index capability to support all…
… values
- Loading branch information
Showing
4 changed files
with
118 additions
and
24 deletions.
There are no files selected for viewing
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
74 changes: 74 additions & 0 deletions
74
community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/KernelIndexAugmentation.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-2018 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.kernel.impl.newapi; | ||
|
||
import org.neo4j.graphdb.factory.GraphDatabaseSettings; | ||
import org.neo4j.internal.kernel.api.IndexCapability; | ||
import org.neo4j.internal.kernel.api.IndexOrder; | ||
import org.neo4j.internal.kernel.api.IndexReference; | ||
import org.neo4j.internal.kernel.api.IndexValueCapability; | ||
import org.neo4j.internal.kernel.api.schema.IndexProviderDescriptor; | ||
import org.neo4j.values.storable.ValueCategory; | ||
|
||
/** | ||
* Gathers the business logic on what indexes to augment with node property value injection. | ||
* | ||
* Currently, the new generic native index provider can provide values directly from the index for | ||
* all value types except points, which are stored in a lossy fashion in the index. Even thought | ||
* that does not initially seems like a big deal, this stops Cypher completely from being able to | ||
* rely on index-backed property values from index scans, even though the index does not contain any | ||
* points - the reason being that it might get points later, and in that case the plan must still | ||
* hold. Therefore augmenting the index with property lookup backed values makes sense. | ||
*/ | ||
public class KernelIndexAugmentation | ||
{ | ||
private static final String NATIVE_PROVIDER = GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10.providerName(); | ||
|
||
public static IndexCapability augmentIndexCapability( IndexCapability capability, | ||
IndexProviderDescriptor providerDescriptor ) | ||
{ | ||
if ( NATIVE_PROVIDER.equals( providerDescriptor.getKey() ) ) | ||
{ | ||
return new IndexCapability() | ||
{ | ||
@Override | ||
public IndexOrder[] orderCapability( ValueCategory... valueCategories ) | ||
{ | ||
return capability.orderCapability( valueCategories ); | ||
} | ||
|
||
@Override | ||
public IndexValueCapability valueCapability( ValueCategory... valueCategories ) | ||
{ | ||
return IndexValueCapability.YES; | ||
} | ||
}; | ||
} | ||
else | ||
{ | ||
return capability; | ||
} | ||
} | ||
|
||
public static boolean shouldInjectValues( IndexReference index, boolean needsValues ) | ||
{ | ||
return needsValues && NATIVE_PROVIDER.equals( index.providerKey() ); | ||
} | ||
} |
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