Skip to content

Commit

Permalink
Add field and metadata kv to test
Browse files Browse the repository at this point in the history
  • Loading branch information
amoeba committed Apr 8, 2024
1 parent a35aaca commit 2e32daa
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions cpp/src/arrow/ipc/message_internal_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,36 @@ TEST(TestMessageInternal, TestByteIdentical) {

// Create a simple Schema with just one metadata KVP
auto f0 = field("f0", int64());
std::vector<std::shared_ptr<Field>> fields = {f0};
auto f1 = field("f1", int64());
std::vector<std::shared_ptr<Field>> fields = {f0, f1};
std::shared_ptr<KeyValueMetadata> metadata =
KeyValueMetadata::Make({"my_key"}, {"my_value"});
KeyValueMetadata::Make({"key_1", "key_2"}, {"key_1_value", "key_2_value"});
auto schema = ::arrow::schema({f0}, metadata);

// Serialize the Schema to a Buffer
std::shared_ptr<Buffer> outBuffer;
ASSERT_OK(WriteSchemaMessage(*schema, mapper, IpcWriteOptions::Defaults(), &outBuffer));

// This is example output from macOS+ARM+LLVM
const uint8_t len = 184;
const uint8_t len = 228;
const uint8_t expected[] = {
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x0E, 0x00, 0x06, 0x00, 0x05, 0x00,
0x08, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0A, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0A, 0x00,
0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08, 0x00,
0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x6D, 0x79, 0x5F, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
0x00, 0x00, 0x6D, 0x79, 0x5F, 0x6B, 0x65, 0x79, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x14, 0x00, 0x08, 0x00, 0x06, 0x00, 0x07, 0x00,
0x0C, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02,
0x10, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x66, 0x30, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00,
0x08, 0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00,
0x00, 0x00};
0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x38, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xD8, 0xFF, 0xFF, 0xFF, 0x18, 0x00,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x6B, 0x65, 0x79, 0x5F,
0x32, 0x5F, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x00, 0x05, 0x00, 0x00, 0x00, 0x6B, 0x65,
0x79, 0x5F, 0x32, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0C, 0x00, 0x04, 0x00, 0x08, 0x00,
0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0B, 0x00,
0x00, 0x00, 0x6B, 0x65, 0x79, 0x5F, 0x31, 0x5F, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x00,
0x05, 0x00, 0x00, 0x00, 0x6B, 0x65, 0x79, 0x5F, 0x31, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x14, 0x00, 0x08, 0x00, 0x06, 0x00,
0x07, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x02, 0x10, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x66, 0x30, 0x00, 0x00, 0x08, 0x00,
0x0C, 0x00, 0x08, 0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x40, 0x00, 0x00, 0x00};
Buffer expectedBuffer(expected, len);

ASSERT_TRUE(expectedBuffer.Equals(*outBuffer));
Expand Down

0 comments on commit 2e32daa

Please sign in to comment.