| 2605 | } |
| 2606 | |
| 2607 | void StreamIndexedIO::Index::commitNodeToSubIndex( DirectoryNode *n ) |
| 2608 | { |
| 2609 | if (!n) |
| 2610 | { |
| 2611 | return; |
| 2612 | } |
| 2613 | |
| 2614 | if ( n->subindex() == DirectoryNode::NoSubIndex ) |
| 2615 | { |
| 2616 | MemoryStreamSink sink; |
| 2617 | io::filtering_ostream outIndexStream; |
| 2618 | outIndexStream.push( sink ); |
| 2619 | assert( outIndexStream.is_complete() ); |
| 2620 | |
| 2621 | writeNodeChildren( n, outIndexStream ); |
| 2622 | |
| 2623 | outIndexStream.pop(); |
| 2624 | |
| 2625 | // compress the output stream using blosc before writing |
| 2626 | char* indexData = nullptr; |
| 2627 | std::streamsize indexDataSize; |
| 2628 | |
| 2629 | sink.get(indexData, indexDataSize); |
| 2630 | |
| 2631 | std::vector<char> compressedIndex; |
| 2632 | compress( indexData, indexDataSize, compressedIndex, indexCompressionLevel, indexCompressor, 1, BLOSC_MAX_BUFFERSIZE, 0); |
| 2633 | |
| 2634 | uint32_t subindexSize = compressedIndex.size(); |
| 2635 | |
| 2636 | // tell the Directory node that it's contents have been written as a subindex |
| 2637 | uint64_t offset = writeUniqueData( &compressedIndex[0], subindexSize, true ); |
| 2638 | n->setSubIndexOffset( offset ); |
| 2639 | } |
| 2640 | } |
| 2641 | |
| 2642 | void StreamIndexedIO::Index::readNodeFromSubIndex( DirectoryNode *n ) |
| 2643 | { |