Search in sources :

Example 1 with ExperimentalGraphStore

use of com.alibaba.graphscope.gaia.store.ExperimentalGraphStore in project GraphScope by alibaba.

the class QueryTest method main.

public static void main(String[] args) {
    GaiaConfig config = new ExperimentalGaiaConfig("conf");
    GraphStoreService graphStore = new ExperimentalGraphStore(config);
    IdMaker queryIdMaker = new IncrementalQueryIdMaker();
    test_CR_1_1(config, graphStore, queryIdMaker);
    test_CR_1_2(config, graphStore, queryIdMaker);
    test_CR_2(config, graphStore, queryIdMaker);
    test_CR_3_1(config, graphStore, queryIdMaker);
    test_CR_3_2(config, graphStore, queryIdMaker);
    test_CR_5(config, graphStore, queryIdMaker);
    test_CR_6(config, graphStore, queryIdMaker);
    test_CR_7(config, graphStore, queryIdMaker);
    test_CR_8(config, graphStore, queryIdMaker);
    test_CR_9(config, graphStore, queryIdMaker);
    test_CR_11(config, graphStore, queryIdMaker);
    test_CR_12(config, graphStore, queryIdMaker);
}
Also used : IncrementalQueryIdMaker(com.alibaba.graphscope.gaia.idmaker.IncrementalQueryIdMaker) ExperimentalGraphStore(com.alibaba.graphscope.gaia.store.ExperimentalGraphStore) GraphStoreService(com.alibaba.graphscope.gaia.store.GraphStoreService) GaiaConfig(com.alibaba.graphscope.gaia.config.GaiaConfig) ExperimentalGaiaConfig(com.alibaba.graphscope.gaia.config.ExperimentalGaiaConfig) ExperimentalGaiaConfig(com.alibaba.graphscope.gaia.config.ExperimentalGaiaConfig) IdMaker(com.alibaba.graphscope.gaia.idmaker.IdMaker) TagIdMaker(com.alibaba.graphscope.gaia.idmaker.TagIdMaker) IncrementalQueryIdMaker(com.alibaba.graphscope.gaia.idmaker.IncrementalQueryIdMaker)

Example 2 with ExperimentalGraphStore

use of com.alibaba.graphscope.gaia.store.ExperimentalGraphStore in project GraphScope by alibaba.

the class GaiaGraphStep method processPrimaryKey.

/**
 * label + id -> global_id
 */
public static boolean processPrimaryKey(final GaiaGraphStep<?, ?> graphStep, final HasContainer hasContainer, final List<HasContainer> originalContainers, boolean[] primaryKeyAsIndex, final GraphStoreService graphStore) {
    if (graphStep.ids.length == 0 && isValidPrimaryKey(hasContainer) && (hasContainer.getKey().equals(T.label.getAccessor()) && isValidPrimaryKey(getContainer(originalContainers, "id")) || hasContainer.getKey().equals("id") && isValidPrimaryKey(getContainer(originalContainers, T.label.getAccessor())))) {
        primaryKeyAsIndex[0] = true;
    }
    if (!hasContainer.getKey().equals(T.label.getAccessor()) && !hasContainer.getKey().equals("id") || hasContainer.getBiPredicate() != Compare.eq && hasContainer.getBiPredicate() != Contains.within || !isFirstHasContainerWithKey(hasContainer, originalContainers) || !primaryKeyAsIndex[0] || !(graphStore instanceof ExperimentalGraphStore)) {
        return false;
    }
    if (primaryKeyAsIndex[0] && hasContainer.getKey().equals(T.label.getAccessor())) {
        HasContainer propertyIdContainer = getContainer(originalContainers, "id");
        P predicate = hasContainer.getPredicate();
        if (predicate.getValue() instanceof List && ((List) predicate.getValue()).get(0) instanceof String) {
            List<String> values = (List<String>) predicate.getValue();
            values.forEach(k -> {
                long globalId = graphStore.getGlobalId(Long.valueOf(k), ((Number) propertyIdContainer.getPredicate().getValue()).longValue());
                graphStep.addIds(globalId);
            });
        } else if (predicate.getValue() instanceof String) {
            long globalId = graphStore.getGlobalId(Long.valueOf((String) predicate.getValue()), ((Number) propertyIdContainer.getPredicate().getValue()).longValue());
            graphStep.addIds(globalId);
        } else {
            throw new UnsupportedOperationException("hasLabel value type not support " + predicate.getValue().getClass());
        }
    }
    return true;
}
Also used : AndP(org.apache.tinkerpop.gremlin.process.traversal.util.AndP) P(org.apache.tinkerpop.gremlin.process.traversal.P) ExperimentalGraphStore(com.alibaba.graphscope.gaia.store.ExperimentalGraphStore) HasContainer(org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer)

Example 3 with ExperimentalGraphStore

use of com.alibaba.graphscope.gaia.store.ExperimentalGraphStore in project GraphScope by alibaba.

the class GremlinServiceMain method main.

public static void main(String[] args) throws Exception {
    logger.info("start server");
    Settings settings = load();
    GremlinServer server = new GremlinServer(settings);
    // create graph
    GaiaConfig gaiaConfig = new ExperimentalGaiaConfig("conf");
    GraphStoreService storeService = new ExperimentalGraphStore(gaiaConfig);
    GaiaProcessorLoader.load(gaiaConfig, storeService);
    // set global variables
    Graph traversalGraph = server.getServerGremlinExecutor().getGraphManager().getGraph("graph");
    GlobalEngineConf.setGlobalVariables(traversalGraph.variables());
    // bind g to traversal source
    Bindings globalBindings = PlanUtils.getGlobalBindings(server.getServerGremlinExecutor().getGremlinExecutor());
    globalBindings.put("g", traversalGraph.traversal());
    // start gremlin server
    server.start().exceptionally(t -> {
        logger.error("Gremlin Server was unable to start and will now begin shutdown" + " {}", t);
        server.stop().join();
        return null;
    }).join();
}
Also used : Logger(org.slf4j.Logger) Bindings(javax.script.Bindings) GaiaConfig(com.alibaba.graphscope.gaia.config.GaiaConfig) GremlinServer(org.apache.tinkerpop.gremlin.server.GremlinServer) ExperimentalGraphStore(com.alibaba.graphscope.gaia.store.ExperimentalGraphStore) Settings(org.apache.tinkerpop.gremlin.server.Settings) GaiaProcessorLoader(com.alibaba.graphscope.gaia.processor.GaiaProcessorLoader) Graph(org.apache.tinkerpop.gremlin.structure.Graph) PlanUtils(com.alibaba.graphscope.gaia.plan.PlanUtils) LoggerFactory(org.slf4j.LoggerFactory) ExperimentalGaiaConfig(com.alibaba.graphscope.gaia.config.ExperimentalGaiaConfig) GraphStoreService(com.alibaba.graphscope.gaia.store.GraphStoreService) GremlinServer(org.apache.tinkerpop.gremlin.server.GremlinServer) Graph(org.apache.tinkerpop.gremlin.structure.Graph) ExperimentalGraphStore(com.alibaba.graphscope.gaia.store.ExperimentalGraphStore) GraphStoreService(com.alibaba.graphscope.gaia.store.GraphStoreService) GaiaConfig(com.alibaba.graphscope.gaia.config.GaiaConfig) ExperimentalGaiaConfig(com.alibaba.graphscope.gaia.config.ExperimentalGaiaConfig) Bindings(javax.script.Bindings) Settings(org.apache.tinkerpop.gremlin.server.Settings) ExperimentalGaiaConfig(com.alibaba.graphscope.gaia.config.ExperimentalGaiaConfig)

Aggregations

ExperimentalGraphStore (com.alibaba.graphscope.gaia.store.ExperimentalGraphStore)3 ExperimentalGaiaConfig (com.alibaba.graphscope.gaia.config.ExperimentalGaiaConfig)2 GaiaConfig (com.alibaba.graphscope.gaia.config.GaiaConfig)2 GraphStoreService (com.alibaba.graphscope.gaia.store.GraphStoreService)2 IdMaker (com.alibaba.graphscope.gaia.idmaker.IdMaker)1 IncrementalQueryIdMaker (com.alibaba.graphscope.gaia.idmaker.IncrementalQueryIdMaker)1 TagIdMaker (com.alibaba.graphscope.gaia.idmaker.TagIdMaker)1 PlanUtils (com.alibaba.graphscope.gaia.plan.PlanUtils)1 GaiaProcessorLoader (com.alibaba.graphscope.gaia.processor.GaiaProcessorLoader)1 Bindings (javax.script.Bindings)1 P (org.apache.tinkerpop.gremlin.process.traversal.P)1 HasContainer (org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer)1 AndP (org.apache.tinkerpop.gremlin.process.traversal.util.AndP)1 GremlinServer (org.apache.tinkerpop.gremlin.server.GremlinServer)1 Settings (org.apache.tinkerpop.gremlin.server.Settings)1 Graph (org.apache.tinkerpop.gremlin.structure.Graph)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1