-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement GraphStoreService api for maxgraph && add snapshot (#537)
* implement GraphStoreService api for maxgraph && add snapshot function * guarantee one query use the same snapshot id * refine cached graph schema structure
- Loading branch information
Showing
15 changed files
with
288 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>maxgraph-src</artifactId> | ||
<groupId>com.alibaba.maxgraph</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>gaia-adaptor</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.alibaba.graphscope</groupId> | ||
<artifactId>gremlin-server-plugin</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba.maxgraph</groupId> | ||
<artifactId>v2</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.2.1</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<filters> | ||
<filter> | ||
<artifact>*:*</artifact> | ||
<excludes> | ||
<exclude>META-INF/*.SF</exclude> | ||
<exclude>META-INF/*.DSA</exclude> | ||
<exclude>META-INF/*.RSA</exclude> | ||
</excludes> | ||
</filter> | ||
</filters> | ||
<transformers> | ||
<transformer | ||
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> | ||
</transformers> | ||
<relocations> | ||
<relocation> | ||
<pattern>com.google.common</pattern> | ||
<shadedPattern>shaded.com.google.common</shadedPattern> | ||
</relocation> | ||
<relocation> | ||
<pattern>com.google.protobuf</pattern> | ||
<shadedPattern>shaded.com.google.protobuf</shadedPattern> | ||
</relocation> | ||
</relocations> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
31 changes: 31 additions & 0 deletions
31
...engine/src/gaia-adaptor/src/main/java/com/alibaba/graphscope/gaia/CachedMaxGraphMeta.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,31 @@ | ||
package com.alibaba.graphscope.gaia; | ||
|
||
import com.alibaba.maxgraph.compiler.api.schema.GraphSchema; | ||
import com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
|
||
public class CachedMaxGraphMeta { | ||
private SchemaFetcher schemaFetcher; | ||
private GraphSchema graphSchema; | ||
private Long snapshotId; | ||
|
||
public CachedMaxGraphMeta(SchemaFetcher schemaFetcher) { | ||
this.schemaFetcher = schemaFetcher; | ||
} | ||
|
||
public synchronized void update() { | ||
Pair<GraphSchema, Long> pair = this.schemaFetcher.getSchemaSnapshotPair(); | ||
if (pair != null) { | ||
this.graphSchema = pair.getLeft(); | ||
this.snapshotId = pair.getRight(); | ||
} | ||
} | ||
|
||
public GraphSchema getGraphSchema() { | ||
return graphSchema; | ||
} | ||
|
||
public Long getSnapshotId() { | ||
return snapshotId; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...tive_engine/src/gaia-adaptor/src/main/java/com/alibaba/graphscope/gaia/MaxGraphStore.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,68 @@ | ||
package com.alibaba.graphscope.gaia; | ||
|
||
import com.alibaba.graphscope.gaia.store.GraphStoreService; | ||
import com.alibaba.graphscope.gaia.store.SchemaNotFoundException; | ||
import com.alibaba.maxgraph.compiler.api.schema.GraphSchema; | ||
import com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class MaxGraphStore extends GraphStoreService { | ||
private static final Logger logger = LoggerFactory.getLogger(MaxGraphStore.class); | ||
public static final String MAXGRAPH_MODERN_PROPERTY_RESOURCE = "maxgraph.modern.properties.json"; | ||
private CachedMaxGraphMeta cachedGraphSchemaPair; | ||
|
||
public MaxGraphStore(SchemaFetcher schemaFetcher) { | ||
super(MAXGRAPH_MODERN_PROPERTY_RESOURCE); | ||
this.cachedGraphSchemaPair = new CachedMaxGraphMeta(schemaFetcher); | ||
} | ||
|
||
@Override | ||
public long getLabelId(String label) { | ||
try { | ||
GraphSchema graphSchema = this.cachedGraphSchemaPair.getGraphSchema(); | ||
return graphSchema.getElement(label).getLabelId(); | ||
} catch (Exception e) { | ||
logger.error("label " + label + " is invalid, please check schema"); | ||
throw new SchemaNotFoundException("label " + label + " is invalid, please check schema"); | ||
} | ||
} | ||
|
||
@Override | ||
public String getLabel(long labelId) { | ||
GraphSchema graphSchema = this.cachedGraphSchemaPair.getGraphSchema(); | ||
return graphSchema.getElement((int) labelId).getLabel(); | ||
} | ||
|
||
@Override | ||
public long getGlobalId(long labelId, long propertyId) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int getPropertyId(String propertyName) { | ||
try { | ||
GraphSchema graphSchema = this.cachedGraphSchemaPair.getGraphSchema(); | ||
return graphSchema.getPropertyId(propertyName); | ||
} catch (Exception e) { | ||
logger.error("property " + propertyName + " is invalid, please check schema"); | ||
throw new SchemaNotFoundException("property " + propertyName + " is invalid, please check schema"); | ||
} | ||
} | ||
|
||
@Override | ||
public String getPropertyName(int propertyId) { | ||
GraphSchema graphSchema = this.cachedGraphSchemaPair.getGraphSchema(); | ||
return graphSchema.getPropertyName(propertyId); | ||
} | ||
|
||
@Override | ||
public long getSnapShotId() { | ||
return this.cachedGraphSchemaPair.getSnapshotId(); | ||
} | ||
|
||
@Override | ||
public synchronized void updateSnapShotId() { | ||
this.cachedGraphSchemaPair.update(); | ||
} | ||
} |
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
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.