[Liblas-commits] hg-main-tree: more blob fetching for libpc::drivers::oci::Reader

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Apr 1 14:54:09 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/1747c2f81b4a
changeset: 490:1747c2f81b4a
user:      Howard Butler <hobu.inc at gmail.com>
date:      Fri Apr 01 13:53:59 2011 -0500
description:
more blob fetching for libpc::drivers::oci::Reader

diffstat:

 include/libpc/drivers/oci/Reader.hpp    |   1 +
 include/libpc/drivers/oci/oci_wrapper.h |   3 ++-
 src/drivers/oci/Iterator.cpp            |   1 +
 src/drivers/oci/Reader.cpp              |  21 +++++++++++++++++----
 src/drivers/oci/common.cpp              |   1 +
 src/drivers/oci/oci_wrapper.cpp         |  17 ++++++++++++++++-
 6 files changed, 38 insertions(+), 6 deletions(-)

diffs (126 lines):

diff -r 682a3fe2c2cf -r 1747c2f81b4a include/libpc/drivers/oci/Reader.hpp
--- a/include/libpc/drivers/oci/Reader.hpp	Fri Apr 01 09:15:55 2011 -0500
+++ b/include/libpc/drivers/oci/Reader.hpp	Fri Apr 01 13:53:59 2011 -0500
@@ -125,6 +125,7 @@
     Block* m_block_table;
     OCILobLocator* m_locator;
     std::vector<boost::uint8_t> m_points;
+    boost::uint32_t m_blob_read_byte_size;
 
 };
 
diff -r 682a3fe2c2cf -r 1747c2f81b4a include/libpc/drivers/oci/oci_wrapper.h
--- a/include/libpc/drivers/oci/oci_wrapper.h	Fri Apr 01 09:15:55 2011 -0500
+++ b/include/libpc/drivers/oci/oci_wrapper.h	Fri Apr 01 13:53:59 2011 -0500
@@ -452,8 +452,9 @@
     unsigned long       ReadBlob( OCILobLocator* phLocator,
                             void* pBuffer, int nSize );
     bool                ReadBlob( OCILobLocator* phLocator,
-                            void* pBuffer, int nSize, int* nAmountRead );
+                            void* pBuffer, int nSize, unsigned int* nAmountRead );
     char*               ReadCLob( OCILobLocator* phLocator );
+    unsigned long       GetBlobLength(OCILobLocator* phLocator);
     void                WriteCLob( OCILobLocator** pphLocator, char* pszData );
     bool                WriteBlob( OCILobLocator* phLocator,
                             void* pBuffer, int nSize );
diff -r 682a3fe2c2cf -r 1747c2f81b4a src/drivers/oci/Iterator.cpp
--- a/src/drivers/oci/Iterator.cpp	Fri Apr 01 09:15:55 2011 -0500
+++ b/src/drivers/oci/Iterator.cpp	Fri Apr 01 13:53:59 2011 -0500
@@ -46,6 +46,7 @@
 IteratorBase::IteratorBase(const Reader& reader)
     : m_at_end(false)
     , m_reader(reader)
+
 {
     oci::Options& options = m_reader.getOptions();
     
diff -r 682a3fe2c2cf -r 1747c2f81b4a src/drivers/oci/Reader.cpp
--- a/src/drivers/oci/Reader.cpp	Fri Apr 01 09:15:55 2011 -0500
+++ b/src/drivers/oci/Reader.cpp	Fri Apr 01 13:53:59 2011 -0500
@@ -65,6 +65,8 @@
     
     registerFields();
     
+    
+    
     m_statement->Execute(0);
 
     m_qtype = describeQueryType();
@@ -91,7 +93,6 @@
 
     setNumPoints(1000);
 
-    m_points.resize(200000);
 
 
     
@@ -104,9 +105,21 @@
     
     std::cout << "This block has " << m_block_table->num_points << " points" << std::endl;
     
-    boost::uint32_t nAmountRead = m_statement->ReadBlob( m_locator,
-                                                         (void*)&(m_points[0]),
-                                                         m_points.size() );
+    boost::uint32_t nAmountRead;
+    
+    std::vector<boost::uint8_t> chunk;// = iterator.getChunk();
+
+    boost::uint32_t blob_length = m_statement->GetBlobLength(m_locator);
+    
+    if (chunk.size() < blob_length)
+    {
+        chunk.resize(blob_length);
+    }
+    bool read_all_data = m_statement->ReadBlob( m_locator,
+                                     (void*)(&chunk[0]),
+                                     chunk.size(), 
+                                     &nAmountRead);
+    if (!read_all_data) throw libpc_error("Did not read all blob data!");
     std::cout << "nAmountRead: " << nAmountRead << std::endl;
     
     return bDidRead;
diff -r 682a3fe2c2cf -r 1747c2f81b4a src/drivers/oci/common.cpp
--- a/src/drivers/oci/common.cpp	Fri Apr 01 09:15:55 2011 -0500
+++ b/src/drivers/oci/common.cpp	Fri Apr 01 13:53:59 2011 -0500
@@ -73,6 +73,7 @@
     m_tree.put("post_block_sql", std::string(""));
     m_tree.put("select_sql", std::string(""));
     m_tree.put("base_table_bounds", libpc::Bounds<double>());
+    m_tree.put("blob_read_byte_size", boost::uint32_t(2000));
     
     boost::property_tree::ptree scales;
     scales.put("x", double(0.01));
diff -r 682a3fe2c2cf -r 1747c2f81b4a src/drivers/oci/oci_wrapper.cpp
--- a/src/drivers/oci/oci_wrapper.cpp	Fri Apr 01 09:15:55 2011 -0500
+++ b/src/drivers/oci/oci_wrapper.cpp	Fri Apr 01 13:53:59 2011 -0500
@@ -1648,7 +1648,7 @@
 bool OWStatement::ReadBlob( OCILobLocator* phLocator,
                                      void* pBuffer,
                                      int nSize,
-                                     int* nAmountRead )
+                                     unsigned int* nAmountRead )
 {
 
     sword status = OCILobRead(
@@ -1674,6 +1674,21 @@
     return true;
 }
 
+unsigned long OWStatement::GetBlobLength( OCILobLocator* phLocator)
+{
+    ub4 nLength      = (ub4) 0;
+
+    if( CheckError( OCILobGetLength(
+        poConnection->hSvcCtx,
+        hError,
+        phLocator,
+        (ub4*) &nLength), hError ) )
+    {
+        return 0;
+    }
+
+    return nLength;
+}
 
 bool OWStatement::WriteBlob( OCILobLocator* phLocator,
                              void* pBuffer,


More information about the Liblas-commits mailing list