Class JSONDB

Inheritance Relationships

Base Type

Class Documentation

class JSONDB : public ams::db::FileDB

JSON database backend for storing both tensor and graph data.

This class provides a JSON-based storage backend that can serialize flat tensors and homogeneous graphs. Heterogeneous graph storage is not yet supported.

Supports two modes:

  • ”binary”: Binary tensor files + JSON manifest (default, efficient)

  • ”json”: Self-contained JSON with base64-encoded tensor data

Homogeneous graph inputs are stored under each case’s “tensors” object. Named graph outputs are stored under “outputs”, grouped into “node”, “edge”, and “global” objects using the application-provided field names.

Output format is compatible with PyTorch Geometric data loaders.

Note

Case and step directory names include the database rank ID so concurrent MPI ranks can write to the same output directory without tensor file collisions.

Public Functions

JSONDB(std::string path, std::string domain_name, uint64_t rId, std::string json_mode = "binary")

Construct a JSON database.

Parameters:
  • path – [in] Directory path for output files

  • domain_name – [in] Name of the domain (used in filenames)

  • rId – [in] Rank ID for distributed execution

  • json_mode – [in] “binary” (default) or “json” for output mode

~JSONDB() override

Destructor - finalizes manifest if not already done.

JSONDB(const JSONDB&) = delete
JSONDB &operator=(const JSONDB&) = delete
virtual void store(ArrayRef<torch::Tensor> Inputs, ArrayRef<torch::Tensor> Outputs) override

Store tensor data (inputs and outputs)

Parameters:
  • Inputs – [in] Vector of input tensors

  • Outputs – [in] Vector of output tensors

virtual void store(const ams::AMSHomogeneousGraph &graph, const ams::AMSHomogeneousGraphFields &outputs) override

Store homogeneous graph data with outputs.

Parameters:
  • graph – [in] Input graph structure and features

  • outputs – [in] Output/target fields for training

virtual void store(const ams::AMSHeterogeneousGraph &graph, const ams::AMSHeterogeneousGraphFields &outputs) override

Store heterogeneous graph data with outputs.

Parameters:
  • graph – [in] Input graph structure and features

  • outputs – [in] Output/target fields for training

virtual void close() override

Finalize and write the JSON manifest.

inline void setMetadata(const nlohmann::json &metadata)

Set application metadata.

Parameters:

metadata – [in] JSON object with application-specific config

inline void setFeatureNames(const nlohmann::json &feature_names)

Set feature names for documentation.

Parameters:

feature_names – [in] JSON object mapping tensor types to name lists

inline virtual std::string type() override

Database type identifier.

inline virtual AMSDBType dbType() override

Database type enum.