Class SchemaObj

Class Documentation

class SchemaObj

A schema object to set column type, data type and data shape.

Public Functions

inline explicit SchemaObj(const std::string &schema_file = "")

Constructor.

~SchemaObj() = default

Destructor.

Status Init()

SchemaObj Init function.

Returns

bool true if schema initialization is successful.

inline Status add_column(const std::string &name, mindspore::DataType ms_type)

Add new column to the schema with unknown shape of rank 1.

Parameters
  • name[in] Name of the column.

  • ms_type[in] Data type of the column(mindspore::DataType).

Returns

Status code.

inline Status add_column(const std::string &name, const std::string &ms_type)

Add new column to the schema with unknown shape of rank 1.

Parameters
  • name[in] Name of the column.

  • ms_type[in] Data type of the column(std::string).

  • shape[in] Shape of the column.

Returns

Status code.

inline Status add_column(const std::string &name, mindspore::DataType ms_type, const std::vector<int32_t> &shape)

Add new column to the schema.

Parameters
  • name[in] Name of the column.

  • ms_type[in] Data type of the column(mindspore::DataType).

  • shape[in] Shape of the column.

Returns

Status code.

inline Status add_column(const std::string &name, const std::string &ms_type, const std::vector<int32_t> &shape)

Add new column to the schema.

Parameters
  • name[in] Name of the column.

  • ms_type[in] Data type of the column(std::string).

  • shape[in] Shape of the column.

Returns

Status code.

inline std::string to_json()

Get a JSON string of the schema.

Returns

JSON string of the schema.

Status schema_to_json(nlohmann::json *out_json)

Serialize schema config to JSON.

Returns

Status code.

inline std::string to_string()

Get a JSON string of the schema.

Returns

JSON string of the schema.

void set_dataset_type(const std::string &dataset_type)

Set a new value to dataset_type.

Parameters

dataset_type[in] Data type of the schema.

void set_num_rows(int32_t num_rows)

Set a new value to num_rows.

Parameters

dataset_type[in] Number of rows of the schema.

int32_t get_num_rows() const

Get the current num_rows.

Returns

Number of rows.

Status from_json(nlohmann::json json_obj)

Get schema file from JSON file.

Parameters

json_obj[in] parsed JSON object.

Returns

Status code.

inline Status FromJSONString(const std::string &json_string)

Get schema file from JSON file.

Parameters

json_string[in] Name of JSON file to be parsed.

Returns

Status code.

inline Status ParseColumnString(const std::string &json_string)

Parse and add column information.

Parameters

json_string[in] Name of JSON string for column dataset attribute information, decoded from schema file.

Returns

Status code.