Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add schema C++ helpers #675

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

paleolimbot
Copy link
Member

@paleolimbot paleolimbot commented Nov 5, 2024

Poking away at some ideas for #599.

Some thoughts from writing this:

  • Managing the recursive child/dictionary lifecycle is probably best left to some "root holder" like the UniqueSchema. I tried making a Schema class but it's very hard to write things like Child() without some sharedness or a lot of copying. I went with ViewSchema() for argument's sake.
  • For the SchemaBuilder I went with an approach that probably copies too much (but in theory lets you std::move() to avoid issues, sort of like std::vector will let you copy or move.

Example:

TEST(SchemaHpp, SchemaHppDump) {
  std::stringstream ss;

  auto schema = nanoarrow::schema::struct_({{"foofy", NANOARROW_TYPE_INT32}});
  nanoarrow::ViewSchema view(schema);

  ss << "metadata size: " << view.metadata().size() << std::endl;

  for (const auto& item : view.metadata()) {
    ss << item.first << ", " << item.second << std::endl;
  }

  for (const auto& child : view.children()) {
    ss << "child: " << child.name() << std::endl;
  }

  if (view.dictionary()) {
    ss << "has dictionary\n";
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant