| 1728 | |
| 1729 | template<typename ValueType_, typename Codec_> |
| 1730 | void |
| 1731 | TypedAttributeArray<ValueType_, Codec_>::writeMetadata(std::ostream& os, bool outputTransient, bool paged) const |
| 1732 | { |
| 1733 | if (!outputTransient && this->isTransient()) return; |
| 1734 | |
| 1735 | if (mFlags & PARTIALREAD) { |
| 1736 | OPENVDB_THROW(IoError, "Cannot write out a partially-read AttributeArray."); |
| 1737 | } |
| 1738 | |
| 1739 | uint8_t flags(mFlags); |
| 1740 | uint8_t serializationFlags(0); |
| 1741 | Index size(mSize); |
| 1742 | Index strideOrTotalSize(mStrideOrTotalSize); |
| 1743 | bool strideOfOne(this->stride() == 1); |
| 1744 | |
| 1745 | bool bloscCompression = io::getDataCompression(os) & io::COMPRESS_BLOSC; |
| 1746 | |
| 1747 | // any compressed data needs to be loaded if out-of-core |
| 1748 | if (bloscCompression) this->doLoad(); |
| 1749 | |
| 1750 | size_t compressedBytes = 0; |
| 1751 | |
| 1752 | if (!strideOfOne) |
| 1753 | { |
| 1754 | serializationFlags |= WRITESTRIDED; |
| 1755 | } |
| 1756 | |
| 1757 | if (mIsUniform) |
| 1758 | { |
| 1759 | serializationFlags |= WRITEUNIFORM; |
| 1760 | if (bloscCompression && paged) serializationFlags |= WRITEPAGED; |
| 1761 | } |
| 1762 | else if (bloscCompression) |
| 1763 | { |
| 1764 | if (paged) serializationFlags |= WRITEPAGED; |
| 1765 | else { |
| 1766 | const char* charBuffer = reinterpret_cast<const char*>(this->data()); |
| 1767 | const size_t inBytes = this->arrayMemUsage(); |
| 1768 | compressedBytes = compression::bloscCompressedSize(charBuffer, inBytes); |
| 1769 | } |
| 1770 | } |
| 1771 | |
| 1772 | Index64 bytes = /*flags*/ sizeof(Int16) + /*size*/ sizeof(Index); |
| 1773 | |
| 1774 | bytes += (compressedBytes > 0) ? compressedBytes : this->arrayMemUsage(); |
| 1775 | |
| 1776 | // write data |
| 1777 | |
| 1778 | os.write(reinterpret_cast<const char*>(&bytes), sizeof(Index64)); |
| 1779 | os.write(reinterpret_cast<const char*>(&flags), sizeof(uint8_t)); |
| 1780 | os.write(reinterpret_cast<const char*>(&serializationFlags), sizeof(uint8_t)); |
| 1781 | os.write(reinterpret_cast<const char*>(&size), sizeof(Index)); |
| 1782 | |
| 1783 | // write strided |
| 1784 | if (!strideOfOne) os.write(reinterpret_cast<const char*>(&strideOrTotalSize), sizeof(Index)); |
| 1785 | } |
| 1786 | |
| 1787 |
no test coverage detected