Esempio n. 1
0
void OciReader::readBlob(Statement stmt, BlockPtr block)
{
    uint32_t amountRead = 0;
    uint32_t blobLength = stmt->GetBlobLength(block->locator);

    if (block->chunk.size() < blobLength)
        block->chunk.resize(blobLength);

    if (!stmt->ReadBlob(block->locator, (void*)(block->chunk.data()),
                        block->chunk.size() , &amountRead))
        throw pdal_error("Did not read all blob data!");

    block->chunk.resize(amountRead);
}
Esempio n. 2
0
void IteratorBase::readBlob(Statement statement,
                            BlockPtr block,
                            boost::uint32_t howMany)
{
    boost::uint32_t nAmountRead = 0;
    boost::uint32_t nBlobLength = statement->GetBlobLength(block->locator);

    if (block->chunk.size() < nBlobLength)
    {
        block->chunk.resize(nBlobLength);
    }

    getReader().log()->get(logDEBUG4) << "IteratorBase::readBlob expected point count: " << howMany << std::endl;
    getReader().log()->get(logDEBUG4) << "IteratorBase::readBlob expected nBlobLength: " << nBlobLength << std::endl;

    // statement->OpenBlob(block->locator);
    bool read_all_data = statement->ReadBlob(block->locator,
                         (void*)(&(block->chunk)[0]),
                         block->chunk.size() ,
                         &nAmountRead);

    // statement->CloseBlob(block->locator);

    getReader().log()->get(logDEBUG4) << "IteratorBase::readBlob read nAmountRead: " << nAmountRead << std::endl;
    if (!read_all_data) throw pdal_error("Did not read all blob data!");

    getReader().log()->get(logDEBUG4) << "IteratorBase::readBlob actual nAmountRead: " << nAmountRead  << std::endl;

    if (nBlobLength > m_oracle_buffer->getBufferByteLength())
    {
        // resize and check again. If the schema doesn't match 
        // what the blob actually had, this won't divide correctly and 
        // we're screwed.
        boost::uint32_t capacity = nBlobLength/m_oracle_buffer->getSchema().getByteSize();
        assert(nBlobLength % m_oracle_buffer->getSchema().getByteSize() == 0);
        m_oracle_buffer->resize(capacity, true);
    }

    if (m_oracle_buffer->getSchema().getOrientation() == schema::DIMENSION_INTERLEAVED)
    {
        boost::uint32_t capacity = nBlobLength/m_oracle_buffer->getSchema().getByteSize();
        assert(nBlobLength % m_oracle_buffer->getSchema().getByteSize() == 0);
        m_oracle_buffer->resize(capacity, true);
    }

    m_oracle_buffer->setDataStride(&(block->chunk)[0], 0, nAmountRead);
    m_oracle_buffer->setNumPoints(m_block->num_points);

}