ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
e57::CompressedVectorWriterImpl Class Reference

#include <CompressedVectorWriterImpl.h>

Public Member Functions

 CompressedVectorWriterImpl (std::shared_ptr< CompressedVectorNodeImpl > ni, std::vector< SourceDestBuffer > &sbufs)
 
 ~CompressedVectorWriterImpl ()
 
void write (const size_t requestedRecordCount)
 
void write (std::vector< SourceDestBuffer > &sbufs, const size_t requestedRecordCount)
 
bool isOpen () const
 
std::shared_ptr< CompressedVectorNodeImplcompressedVectorNode () const
 
void close ()
 
void dump (int indent=0, std::ostream &os=std::cout)
 

Detailed Description

Definition at line 34 of file CompressedVectorWriterImpl.h.

Constructor & Destructor Documentation

◆ CompressedVectorWriterImpl()

e57::CompressedVectorWriterImpl::CompressedVectorWriterImpl ( std::shared_ptr< CompressedVectorNodeImpl ni,
std::vector< SourceDestBuffer > &  sbufs 
)

Empty sbufs is an error

Get CompressedArray's prototype node (all array elements must match this type)

Check sbufs well formed (matches proto exactly)

For each individual sbuf, create an appropriate Encoder based on the cVector_ attributes

Create vector of single sbuf ??? for now, may have groups later

Calc which stream the given path belongs to. This depends on position of the node in the proto tree.

EncoderFactory picks the appropriate encoder to match type declared in prototype

The bytestreams_ vector must be ordered by bytestreamNumber, not by order called specified sbufs, so sort it.

Reserve space for CompressedVector binary section header, record location so can save to when writer closes. Request that file be extended with zeros since we will write to it at a later time (when writer closes).

Just before return (and can't throw) increment writer count ??? safer way to assure don't miss close?

If get here, the writer is open

Definition at line 48 of file CompressedVectorWriterImpl.cpp.

References e57::E57_ERROR_BAD_API_ARGUMENT, e57::E57_ERROR_INTERNAL, E57_EXCEPTION2, e57::Encoder::EncoderFactory(), and e57::toString().

◆ ~CompressedVectorWriterImpl()

e57::CompressedVectorWriterImpl::~CompressedVectorWriterImpl ( )

Definition at line 130 of file CompressedVectorWriterImpl.cpp.

References close(), and QtCompat::endl().

Member Function Documentation

◆ close()

void e57::CompressedVectorWriterImpl::close ( )

Before anything that can throw, decrement writer count

don't call checkWriterOpen();

Set closed before do anything, so if get fault and start unwinding, don't try to close again.

If have any data, write packet Write all remaining ioBuffers and internal encoder register cache into file. Know we are done when totalOutputAvailable() returns 0 after a flush().

Compute length of whole section we just wrote (from section start to current start of free space).

Prepare CompressedVectorSectionHeader

??? can be zero, if no data written ???not set yet

??? can be zero, if no data written ???not set yet

Verify OK before write it.

Write header at beginning of section, previously allocated

Set address and size of associated CompressedVector

Free channels

Definition at line 149 of file CompressedVectorWriterImpl.cpp.

References e57::CompressedVectorSectionHeader::dataPhysicalOffset, dump(), e57::CompressedVectorSectionHeader::dump(), QtCompat::endl(), e57::CompressedVectorSectionHeader::indexPhysicalOffset, e57::CheckedFile::Physical, e57::CompressedVectorSectionHeader::sectionLogicalLength, and e57::CompressedVectorSectionHeader::verify().

Referenced by ~CompressedVectorWriterImpl().

◆ compressedVectorNode()

std::shared_ptr< CompressedVectorNodeImpl > e57::CompressedVectorWriterImpl::compressedVectorNode ( ) const

Definition at line 228 of file CompressedVectorWriterImpl.cpp.

◆ dump()

void e57::CompressedVectorWriterImpl::dump ( int  indent = 0,
std::ostream &  os = std::cout 
)

Don't call dump() for DataPacket, since it may contain junk when debugging. Just print a few byte values.

Definition at line 616 of file CompressedVectorWriterImpl.cpp.

References QtCompat::endl(), and e57::space().

Referenced by close().

◆ isOpen()

bool e57::CompressedVectorWriterImpl::isOpen ( ) const

don't checkImageFileOpen(FILE, LINE, FUNCTION), or checkWriterOpen()

Definition at line 221 of file CompressedVectorWriterImpl.cpp.

◆ write() [1/2]

void e57::CompressedVectorWriterImpl::write ( const size_t  requestedRecordCount)

Check that requestedRecordCount is not larger than the sbufs

Rewind all sbufs so start reading from beginning

Loop until all channels have completed requestedRecordCount transfers

Calc remaining record counts for all channels

We are done if have no more work, break out of loop

Estimate how many records can write before have enough data to fill data packet to efficient length Efficient packet length is >= 75% of maximum packet length. It is OK if get too much data (more than one packet) in an iteration. Reader will be able to handle packets whose streams are not exactly synchronized to the record boundaries. But try to do a good job of keeping the stream synchronization "close enough" (so a reader that can cache only two packets is efficient).

If have more than target fraction of packet, send it now

restart loop so recalc statistics (packet size may not be zero after write, if have too much data)

??? useful? Get approximation of number of bytes per record of CompressedVector and total of bytes used

Don't allow straggler to get too far behind. ??? Don't allow a single channel to get too far ahead ??? Process channels that are furthest behind first. ???

!!!! For now just process one record per loop until packet is full enough, or completed request

!! For now, process up to 50 records at a time

When we leave this function, will likely still have data in channel ioBuffers as well as partial words in Encoder registers.

Definition at line 274 of file CompressedVectorWriterImpl.cpp.

References e57::DATA_PACKET_MAX, e57::E57_ERROR_BAD_API_ARGUMENT, E57_EXCEPTION2, QtCompat::endl(), max(), and e57::toString().

Referenced by write().

◆ write() [2/2]

void e57::CompressedVectorWriterImpl::write ( std::vector< SourceDestBuffer > &  sbufs,
const size_t  requestedRecordCount 
)

don't checkImageFileOpen, write(unsigned) will do it don't checkWriterOpen(), write(unsigned) will do it

Definition at line 265 of file CompressedVectorWriterImpl.cpp.

References write().


The documentation for this class was generated from the following files: