Skip to content

Commit

Permalink
Merge pull request #8329 from s1ck/decouple-cypher-projection
Browse files Browse the repository at this point in the history
Refactor Cypher Projection into its own module
  • Loading branch information
s1ck authored Nov 2, 2023
2 parents 7bde22e + b491725 commit 635eedb
Show file tree
Hide file tree
Showing 45 changed files with 190 additions and 76 deletions.
1 change: 1 addition & 0 deletions alpha/alpha-proc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies {
implementation project(':core')
implementation project(':core-utils')
implementation project(':core-write')
implementation project(':legacy-cypher-projection')
implementation project(':executor')
implementation project(':memory-usage')
implementation project(':neo4j-api')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.Map;
import java.util.Set;

import static org.neo4j.gds.config.GraphProjectFromCypherConfig.RELATIONSHIP_QUERY_KEY;
import static org.neo4j.gds.legacycypherprojection.GraphProjectFromCypherConfig.RELATIONSHIP_QUERY_KEY;
import static org.neo4j.gds.core.ProcedureConstants.DIRECTION_KEY;

public class LinkPredictionFunc extends BaseProc {
Expand Down
1 change: 1 addition & 0 deletions applications/graph-store-catalog/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
implementation project(':config-api')
implementation project(':core')
implementation project(':core-write')
implementation project(':legacy-cypher-projection')
implementation project(':executor')
implementation project(':graph-projection-api')
implementation project(':graph-sampling')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.neo4j.gds.core.loading.GraphDropNodePropertiesResult;
import org.neo4j.gds.core.loading.GraphDropRelationshipResult;
import org.neo4j.gds.core.loading.GraphFilterResult;
import org.neo4j.gds.core.loading.GraphProjectCypherResult;
import org.neo4j.gds.core.loading.GraphStoreWithConfig;
import org.neo4j.gds.core.utils.TerminationFlag;
import org.neo4j.gds.core.utils.progress.TaskRegistryFactory;
Expand All @@ -34,6 +33,7 @@
import org.neo4j.gds.core.write.NodePropertyExporterBuilder;
import org.neo4j.gds.core.write.RelationshipExporterBuilder;
import org.neo4j.gds.core.write.RelationshipPropertiesExporterBuilder;
import org.neo4j.gds.legacycypherprojection.GraphProjectCypherResult;
import org.neo4j.gds.projection.GraphProjectNativeResult;
import org.neo4j.gds.results.MemoryEstimateResult;
import org.neo4j.gds.transaction.TransactionContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.neo4j.gds.config.BaseConfig;
import org.neo4j.gds.config.GraphDropNodePropertiesConfig;
import org.neo4j.gds.config.GraphProjectConfig;
import org.neo4j.gds.config.GraphProjectFromCypherConfig;
import org.neo4j.gds.config.GraphProjectFromGraphConfig;
import org.neo4j.gds.config.GraphRemoveGraphPropertiesConfig;
import org.neo4j.gds.config.GraphStreamGraphPropertiesConfig;
Expand All @@ -36,6 +35,7 @@
import org.neo4j.gds.core.CypherMapAccess;
import org.neo4j.gds.core.CypherMapWrapper;
import org.neo4j.gds.core.loading.GraphStoreWithConfig;
import org.neo4j.gds.legacycypherprojection.GraphProjectFromCypherConfig;
import org.neo4j.gds.graphsampling.config.CommonNeighbourAwareRandomWalkConfig;
import org.neo4j.gds.projection.GraphProjectFromStoreConfig;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

import org.neo4j.gds.api.DatabaseId;
import org.neo4j.gds.config.GraphProjectConfig;
import org.neo4j.gds.config.GraphProjectFromCypherConfig;
import org.neo4j.gds.core.loading.GraphProjectCypherResult;
import org.neo4j.gds.core.utils.TerminationFlag;
import org.neo4j.gds.core.utils.progress.TaskRegistryFactory;
import org.neo4j.gds.core.utils.warnings.UserLogRegistryFactory;
import org.neo4j.gds.legacycypherprojection.GraphProjectCypherResult;
import org.neo4j.gds.legacycypherprojection.GraphProjectFromCypherConfig;
import org.neo4j.gds.results.MemoryEstimateResult;
import org.neo4j.gds.transaction.TransactionContext;
import org.neo4j.graphdb.GraphDatabaseService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.neo4j.gds.core.loading.GraphDropNodePropertiesResult;
import org.neo4j.gds.core.loading.GraphDropRelationshipResult;
import org.neo4j.gds.core.loading.GraphFilterResult;
import org.neo4j.gds.core.loading.GraphProjectCypherResult;
import org.neo4j.gds.core.loading.GraphStoreCatalogService;
import org.neo4j.gds.core.loading.GraphStoreWithConfig;
import org.neo4j.gds.core.utils.TerminationFlag;
Expand All @@ -40,6 +39,7 @@
import org.neo4j.gds.core.write.NodePropertyExporterBuilder;
import org.neo4j.gds.core.write.RelationshipExporterBuilder;
import org.neo4j.gds.core.write.RelationshipPropertiesExporterBuilder;
import org.neo4j.gds.legacycypherprojection.GraphProjectCypherResult;
import org.neo4j.gds.graphsampling.RandomWalkBasedNodesSampler;
import org.neo4j.gds.graphsampling.config.RandomWalkWithRestartsConfig;
import org.neo4j.gds.logging.Log;
Expand Down
3 changes: 2 additions & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ dependencies {
testAnnotationProcessor project(':config-generator')
testAnnotationProcessor group: 'org.immutables', name: 'value', version: ver.'immutables'

testImplementation project(':legacy-cypher-projection')
testImplementation project(':edition-api')
testImplementation project(':progress-tracking')
testImplementation project(':test-graph-loaders')
testImplementation project(':test-utils')
testImplementation project(':edition-api')

testImplementation group: 'net.jqwik', name: 'jqwik', version: ver.'jqwik'
testImplementation group: 'io.qala.datagen', name: 'qala-datagen-junit5', version: ver.'qala-datagen'
Expand Down
10 changes: 0 additions & 10 deletions core/src/main/java/org/neo4j/gds/config/GraphProjectConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ default void validateReadConcurrency() {

interface Cases<R> {

R cypher(GraphProjectFromCypherConfig cypherConfig);

R graph(GraphProjectFromGraphConfig graphConfig);

R random(RandomGraphGeneratorConfig randomGraphConfig);
Expand All @@ -131,12 +129,6 @@ interface Cases<R> {

interface Visitor extends Cases<Void> {

@Override
default Void cypher(GraphProjectFromCypherConfig cypherConfig) {
visit(cypherConfig);
return null;
}

@Override
default Void graph(GraphProjectFromGraphConfig graphConfig) {
visit(graphConfig);
Expand All @@ -161,8 +153,6 @@ default Void catalog(GraphCatalogConfig graphCatalogConfig) {
return null;
}

default void visit(GraphProjectFromCypherConfig cypherConfig) {}

default void visit(GraphProjectFromGraphConfig graphConfig) {}

default void visit(RandomGraphGeneratorConfig randomGraphConfig) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.neo4j.gds.Orientation;
import org.neo4j.gds.StoreLoaderBuilder;
import org.neo4j.gds.api.Graph;
import org.neo4j.gds.config.GraphProjectFromCypherConfig;
import org.neo4j.gds.legacycypherprojection.GraphProjectFromCypherConfig;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.neo4j.gds.GraphFactoryTestSupport.AllGraphStoreFactoryTypesTest;
Expand Down
38 changes: 38 additions & 0 deletions graph-construction/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apply plugin: 'java-library'

description = 'Neo4j Graph Data Science :: Graph Construction'
group = 'org.neo4j.gds'

dependencies {
annotationProcessor project(':annotations')
annotationProcessor group: 'org.immutables', name: 'builder', version: ver.'immutables'
annotationProcessor group: 'org.immutables', name: 'value', version: ver.'immutables'
annotationProcessor group: 'org.neo4j', name: 'annotations', version: ver.'neo4j'

compileOnly group: 'org.immutables', name: 'builder', version: ver.'immutables'
compileOnly group: 'org.immutables', name: 'value-annotations', version: ver.'immutables'
compileOnly group: 'org.jetbrains', name: 'annotations', version: ver.'jetbrains-annotations'

implementation project(':annotations')
// implementation project(':config-api')
implementation project(':core')
// implementation project(':core-utils')
implementation project(':graph-schema-api')
// implementation project(':memory-usage')
// implementation project(':progress-tracking')
// implementation project(':string-formatting')
// implementation project(':transaction')

// implementation group: 'org.openjdk.jol', name: 'jol-core', version: ver.'jol'
// implementation group: 'org.opencypher', name: 'cypher-javacc-parser-9.0', version: ver.'opencypher-front-end', transitive: false
// implementation group: 'org.hdrhistogram', name: 'HdrHistogram', version: ver.'HdrHistogram'

testAnnotationProcessor project(':annotations')

testCompileOnly group: 'org.immutables', name: 'value-annotations', version: ver.'immutables'
testCompileOnly group: 'org.immutables', name: 'builder', version: ver.'immutables'
testCompileOnly group: 'org.jetbrains', name: 'annotations', version: ver.'jetbrains-annotations'
testCompileOnly group: 'com.github.spotbugs', name: 'spotbugs-annotations', version: ver.'spotbugsToolVersion'

testImplementation project(':test-utils')
}
52 changes: 52 additions & 0 deletions legacy-cypher-projection/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apply plugin: 'java-library'

description = 'Neo4j Graph Data Science :: Cypher Projection'
group = 'org.neo4j.gds'

dependencies {
annotationProcessor project(':annotations')
annotationProcessor project(':config-generator')
annotationProcessor group: 'org.immutables', name: 'builder', version: ver.'immutables'
annotationProcessor group: 'org.immutables', name: 'value', version: ver.'immutables'
annotationProcessor group: 'org.neo4j', name: 'annotations', version: ver.'neo4j'

compileOnly group: 'org.immutables', name: 'value-annotations', version: ver.'immutables'
compileOnly group: 'org.jetbrains', name: 'annotations', version: ver.'jetbrains-annotations'

neodeps().each {
compileOnly(group: 'org.neo4j', name: it, version: ver.'neo4j') {
transitive = false
}
}

implementation project(':annotations')
implementation project(':config-api')
implementation project(':core')
implementation project(':graph-schema-api')
implementation project(':memory-usage')
implementation project(':progress-tracking')
implementation project(':string-formatting')
implementation project(':transaction')


implementation group: 'org.openjdk.jol', name: 'jol-core', version: ver.'jol'
implementation group: 'org.opencypher', name: 'cypher-javacc-parser-9.0', version: ver.'opencypher-front-end', transitive: false
implementation group: 'org.hdrhistogram', name: 'HdrHistogram', version: ver.'HdrHistogram'

testAnnotationProcessor project(':annotations')

testCompileOnly group: 'org.immutables', name: 'value-annotations', version: ver.'immutables'
testCompileOnly group: 'org.immutables', name: 'builder', version: ver.'immutables'
testCompileOnly group: 'org.jetbrains', name: 'annotations', version: ver.'jetbrains-annotations'
testCompileOnly group: 'com.github.spotbugs', name: 'spotbugs-annotations', version: ver.'spotbugsToolVersion'

testImplementation project(':executor')
testImplementation project(':test-utils')
testImplementation project(':proc-catalog')
testImplementation project(':proc-community')
testImplementation project(':test-graph-loaders')

testImplementation group: 'org.neo4j', name: 'neo4j-cypher-dsl', version: ver.'cypher-dsl'

testImplementation project(':opengds-extension')
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* 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.gds.core.loading;
package org.neo4j.gds.legacycypherprojection;

class BatchLoadResult {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
* 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.gds.core.loading;
package org.neo4j.gds.legacycypherprojection;

import org.neo4j.gds.api.GraphLoaderContext;
import org.neo4j.gds.config.GraphProjectFromCypherConfig;
import org.neo4j.graphdb.security.AuthorizationViolationException;
import org.neo4j.kernel.impl.coreapi.InternalTransaction;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* 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.gds.core.loading;
package org.neo4j.gds.legacycypherprojection;

import org.neo4j.gds.ElementProjection;
import org.neo4j.gds.NodeLabel;
Expand All @@ -30,7 +30,9 @@
import org.neo4j.gds.api.CSRGraphStoreFactory;
import org.neo4j.gds.api.DefaultValue;
import org.neo4j.gds.api.GraphLoaderContext;
import org.neo4j.gds.config.GraphProjectFromCypherConfig;
import org.neo4j.gds.core.loading.CSRGraphStore;
import org.neo4j.gds.core.loading.Capabilities;
import org.neo4j.gds.core.loading.ImmutableStaticCapabilities;
import org.neo4j.gds.core.GraphDimensions;
import org.neo4j.gds.core.ImmutableGraphDimensions;
import org.neo4j.gds.core.utils.mem.MemoryEstimation;
Expand All @@ -46,7 +48,7 @@
import java.util.stream.Collectors;
import java.util.stream.LongStream;

import static org.neo4j.gds.core.loading.CypherQueryEstimator.EstimationResult;
import static org.neo4j.gds.legacycypherprojection.CypherQueryEstimator.EstimationResult;
import static org.neo4j.internal.kernel.api.security.AccessMode.Static.READ;

public final class CypherFactory extends CSRGraphStoreFactory<GraphProjectFromCypherConfig> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* 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.gds.core.loading;
package org.neo4j.gds.legacycypherprojection;

import org.neo4j.kernel.impl.query.QueryExecutionKernelException;
import org.neo4j.kernel.impl.query.QuerySubscription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
* 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.gds.core.loading;
package org.neo4j.gds.legacycypherprojection;

import org.immutables.value.Value;
import org.neo4j.gds.api.GraphLoaderContext;
import org.neo4j.gds.api.PropertyState;
import org.neo4j.gds.config.GraphProjectFromCypherConfig;
import org.neo4j.gds.core.loading.Nodes;
import org.neo4j.gds.core.loading.construction.GraphFactory;
import org.neo4j.gds.core.loading.construction.NodesBuilder;
import org.neo4j.gds.core.utils.progress.tasks.ProgressTracker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* 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.gds.core.loading;
package org.neo4j.gds.legacycypherprojection;

import org.neo4j.gds.PropertyMapping;
import org.neo4j.gds.annotation.ValueClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
* 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.gds.core.loading;
package org.neo4j.gds.legacycypherprojection;

import org.neo4j.gds.api.GraphLoaderContext;
import org.neo4j.gds.compat.Neo4jProxy;
import org.neo4j.gds.config.GraphProjectFromCypherConfig;
import org.neo4j.gds.core.loading.RecordsBatchBuffer;
import org.neo4j.gds.utils.StringJoining;
import org.neo4j.graphdb.security.AuthorizationViolationException;
import org.neo4j.kernel.GraphDatabaseQueryService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* 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.gds.core.loading;
package org.neo4j.gds.legacycypherprojection;

import org.eclipse.collections.impl.map.mutable.primitive.ObjectDoubleHashMap;
import org.immutables.value.Value;
Expand All @@ -29,8 +29,8 @@
import org.neo4j.gds.api.DefaultValue;
import org.neo4j.gds.api.GraphLoaderContext;
import org.neo4j.gds.api.IdMap;
import org.neo4j.gds.config.GraphProjectFromCypherConfig;
import org.neo4j.gds.core.Aggregation;
import org.neo4j.gds.core.loading.RelationshipImportResult;
import org.neo4j.gds.core.loading.construction.GraphFactory;
import org.neo4j.gds.core.loading.construction.RelationshipsBuilder;
import org.neo4j.gds.core.utils.progress.tasks.ProgressTracker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* 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.gds.core.loading;
package org.neo4j.gds.legacycypherprojection;

import org.neo4j.gds.config.GraphProjectFromCypherConfig;
import org.neo4j.gds.core.loading.GraphProjectResult;

public final class GraphProjectCypherResult extends GraphProjectResult {
public final String nodeQuery;
Expand Down
Loading

0 comments on commit 635eedb

Please sign in to comment.