SDK configuration

更新时间:
复制 MD 格式

The MaxCompute Graph SDK for Java provides the classes you need to build, configure, and submit graph processing jobs on MaxCompute. Each class plays a specific role and is registered on a central GraphJob object before the job is submitted.

Add the Maven dependency

Search for odps-sdk-graph in the Maven repository to find the latest version, then declare the dependency in your project:

<dependency>
    <groupId>com.aliyun.odps</groupId>
    <artifactId>odps-sdk-graph</artifactId>
    <version>0.20.7-public</version>
</dependency>

SDK classes

ClassDescriptionGraphJob configuration method
GraphJobDefines, submits, and manages a graph job. Inherits JobConf.— (entry point)
VertexDefines a vertex. Properties: id, value, halted, edges.setVertexClass
EdgeDefines an edge. Properties: destVertexId, value. MaxCompute Graph uses the adjacency list — a vertex's outbound edges are stored in its edges property.Defined as part of Vertex
GraphLoaderLoads a graph.setGraphLoaderClass
VertexResolverHandles conflicts during graph topology modification. Register separate instances for graph loading and iterative computing.setLoadingVertexResolverClass, setComputingVertexResolverClass
PartitionerDistributes vertices across workers to enable parallel computing. The default HashPartitioner assigns each vertex by computing hash(vertexId) % numWorkers.setPartitionerClass
WorkerComputerRuns custom logic when a worker starts and stops — useful for initializing shared state or flushing results.setWorkerComputerClass
AggregatorProcesses and summarizes global information across all workers. You can register multiple Aggregator classes in the same job.setAggregatorClass(Class…)
CombinerSummarizes the output records with the same key.setCombinerClass
CountersTracks counts across workers. Get a Counters instance from WorkerContext and increment it; the framework sums values across all workers automatically.Accessed via WorkerContext
WorkerContextProvides access to all framework features within a superstep: modify graph topology, send messages, write results, and read resources.Injected by the framework