Skip to content

Commit

Permalink
autodetect endianness
Browse files Browse the repository at this point in the history
  • Loading branch information
julienledem committed Aug 8, 2016
1 parent 889dc83 commit 2a00a16
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cpp/src/arrow/ipc/metadata-internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,21 @@ Status MessageBuilder::SetSchema(const Schema* schema) {
return Status::OK();
}

// will return the endianness of the system we are running on
flatbuf::Endianness endianness(void) {
union {
uint32_t i;
char c[4];
} bint = {0x01020304};

return bint.c[0] == 1 ? flatbuf::Endianness_Big : flatbuf::Endianness_Little;
}

Status MessageBuilder::SetRecordBatch(int32_t length, int64_t body_length,
const std::vector<flatbuf::FieldNode>& nodes,
const std::vector<flatbuf::Buffer>& buffers) {
header_type_ = flatbuf::MessageHeader_RecordBatch;
header_ = flatbuf::CreateRecordBatch(fbb_, length, flatbuf::Endianness_Little,
header_ = flatbuf::CreateRecordBatch(fbb_, length, endianness(),
fbb_.CreateVectorOfStructs(nodes),
fbb_.CreateVectorOfStructs(buffers))
.Union();
Expand Down

0 comments on commit 2a00a16

Please sign in to comment.