Writes out the accumulated contents. Does not change the state.
| 1491 | |
| 1492 | // Writes out the accumulated contents. Does not change the state. |
| 1493 | void flush(OutputStream* out) { |
| 1494 | out->write(reinterpret_cast<char*>(header_.buffer), header_.size); |
| 1495 | |
| 1496 | if (encoding_.has_value()) { |
| 1497 | switch (encoding_.value()) { |
| 1498 | case VectorEncoding::Simple::CONSTANT: { |
| 1499 | writeInt32(out, nonNullCount_); |
| 1500 | children_[0]->flush(out); |
| 1501 | return; |
| 1502 | } |
| 1503 | case VectorEncoding::Simple::DICTIONARY: { |
| 1504 | writeInt32(out, nonNullCount_); |
| 1505 | children_[0]->flush(out); |
| 1506 | values_.flush(out); |
| 1507 | |
| 1508 | // Write 24 bytes of 'instance id'. |
| 1509 | int64_t unused{0}; |
| 1510 | writeInt64(out, unused); |
| 1511 | writeInt64(out, unused); |
| 1512 | writeInt64(out, unused); |
| 1513 | return; |
| 1514 | } |
| 1515 | default: |
| 1516 | break; |
| 1517 | } |
| 1518 | } |
| 1519 | |
| 1520 | switch (type_->kind()) { |
| 1521 | case TypeKind::ROW: |
| 1522 | case TypeKind::VARIANT: |
| 1523 | if (isTimestampWithTimeZoneType(type_)) { |
| 1524 | writeInt32(out, nullCount_ + nonNullCount_); |
| 1525 | flushNulls(out); |
| 1526 | values_.flush(out); |
| 1527 | return; |
| 1528 | } |
| 1529 | |
| 1530 | writeInt32(out, children_.size()); |
| 1531 | for (auto& child : children_) { |
| 1532 | child->flush(out); |
| 1533 | } |
| 1534 | writeInt32(out, nullCount_ + nonNullCount_); |
| 1535 | lengths_.flush(out); |
| 1536 | flushNulls(out); |
| 1537 | return; |
| 1538 | |
| 1539 | case TypeKind::ARRAY: |
| 1540 | children_[0]->flush(out); |
| 1541 | writeInt32(out, nullCount_ + nonNullCount_); |
| 1542 | lengths_.flush(out); |
| 1543 | flushNulls(out); |
| 1544 | return; |
| 1545 | |
| 1546 | case TypeKind::MAP: { |
| 1547 | children_[0]->flush(out); |
| 1548 | children_[1]->flush(out); |
| 1549 | // hash table size. -1 means not included in serialization. |
| 1550 | writeInt32(out, -1); |
no test coverage detected