hugegraph-struct is a foundational data structures module that defines the core abstractions and type definitions shared across HugeGraph's distributed components. It serves as the “data contract layer” enabling type-safe communication between hugegraph-pd (Placement Driver), hugegraph-store (distributed storage), and hugegraph-server (graph engine).
Key Characteristics:
HugeGraph instance dependencies)Originally, all data structures and graph engine logic resided in hugegraph-server/hugegraph-core. As HugeGraph evolved toward a distributed architecture, this created several challenges:
We extracted stateless data structures from hugegraph-core into a separate hugegraph-struct module:
Before (Monolithic): hugegraph-server/hugegraph-core (everything together) ├─ Data structures (schema, types, IDs) ├─ Graph engine (traversal, optimization) ├─ Transactions (GraphTransaction, SchemaTransaction) ├─ Storage backends (memory, raft, cache) └─ Business logic (jobs, tasks, auth) After (Modular): hugegraph-struct (shared foundation) ├─ Schema definitions (VertexLabel, EdgeLabel, PropertyKey, IndexLabel) ├─ Type system (HugeType, DataType, IdStrategy) ├─ Data structures (BaseVertex, BaseEdge, BaseProperty) ├─ Serialization (BytesBuffer, BinarySerializer) ├─ Query abstractions (Query, ConditionQuery, Aggregate) └─ Utilities (ID generation, text analyzers, exceptions) hugegraph-core (graph engine only) ├─ Depends on hugegraph-struct ├─ Implements graph engine logic ├─ Manages transactions and storage └─ Provides TinkerPop API
| Module | Purpose | Dependencies |
|---|---|---|
| hugegraph-struct | Shared data structures, type definitions, serialization | Minimal (Guava, TinkerPop, serialization libs) |
| hugegraph-core | Graph engine, traversal, transactions, storage abstraction | hugegraph-struct + heavy libs (Jersey, JRaft, K8s) |
| hugegraph-pd | Metadata coordination, service discovery | hugegraph-struct only |
| hugegraph-store | Distributed storage with Raft | hugegraph-struct only |
hugegraph-struct (foundational)
↑
┌──────────────────┼──────────────────┐
│ │ │
hugegraph-pd hugegraph-store hugegraph-core
│ │ │
└──────────────────┼──────────────────┘
↓
hugegraph-server (REST API)
Build Order:
# 1. Build struct first (required dependency) mvn install -pl hugegraph-struct -am -DskipTests # 2. Then build dependent modules mvn install -pl hugegraph-pd -am -DskipTests mvn install -pl hugegraph-store -am -DskipTests mvn install -pl hugegraph-server -am -DskipTests
Current Status (Transition Period):
Both hugegraph-struct and hugegraph-core contain similar data structures for backward compatibility. This is a temporary state during the migration period.
Future Direction:
Migration Strategy:
Example Migration:
// OLD (hugegraph-core) import org.apache.hugegraph.schema.SchemaElement; // ❌ Will be deprecated // NEW (hugegraph-struct) import org.apache.hugegraph.struct.schema.SchemaElement; // ✅ Use this
Use struct when:
Use core when:
Rule: All new shared data structures should go into hugegraph-struct, not hugegraph-core.
Example:
// ✅ Correct: Add to hugegraph-struct/src/main/java/org/apache/hugegraph/struct/ public class NewSchemaType extends SchemaElement { // Pure data structure, no HugeGraph dependency } // ❌ Wrong: Don't add to hugegraph-core unless it's graph engine logic
If you need to modify a data structure:
org.apache.hugegraph/ ├── struct/schema/ # Schema definitions (VertexLabel, EdgeLabel, etc.) ├── structure/ # Graph elements (BaseVertex, BaseEdge, BaseProperty) ├── type/ # Type system (HugeType, DataType, IdStrategy) ├── id/ # ID generation and management ├── serializer/ # Binary serialization (BytesBuffer, BinarySerializer) ├── query/ # Query abstractions (Query, ConditionQuery, Aggregate) ├── analyzer/ # Text analyzers (8 Chinese NLP implementations) ├── auth/ # Auth utilities (JWT, constants) ├── backend/ # Backend abstractions (BinaryId, BackendColumn, Shard) ├── options/ # Configuration options ├── util/ # Utilities (encoding, compression, collections) └── exception/ # Exception hierarchy
HugeGraph instance dependencies in struct# Build struct module mvn clean install -DskipTests # Build with tests (when tests are added) mvn clean install # From parent directory cd /path/to/hugegraph mvn install -pl hugegraph-struct -am -DskipTests
When contributing to hugegraph-struct:
HugeGraph graph fieldsApache License 2.0 - See LICENSE file for details.