Skip to content

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