[Liblas-commits] hg-main-tree: completely back up the chipper in preparation for ...

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Mar 23 17:37:22 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/9798b3952688
changeset: 416:9798b3952688
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Mar 23 16:37:10 2011 -0500
description:
completely back up the chipper in preparation for random iterators

diffstat:

 include/libpc/Chipper.hpp |  23 +++----------
 src/Chipper.cpp           |  76 ++++++++--------------------------------------
 test/unit/ChipperTest.cpp |  32 +++++++++---------
 3 files changed, 35 insertions(+), 96 deletions(-)

diffs (275 lines):

diff -r 0475852dc135 -r 9798b3952688 include/libpc/Chipper.hpp
--- a/include/libpc/Chipper.hpp	Wed Mar 23 14:27:22 2011 -0500
+++ b/include/libpc/Chipper.hpp	Wed Mar 23 16:37:10 2011 -0500
@@ -1,21 +1,19 @@
 #ifndef LIBLAS_CHIPPER_H
 #define LIBLAS_CHIPPER_H
 
-#include <libpc/PointBuffer.hpp>
+#include <libpc/Stage.hpp>
 #include <libpc/Bounds.hpp>
 #include <libpc/export.hpp>
 #include <libpc/Dimension.hpp>
-#include <libpc/exceptions.hpp>
+#include <libpc/Iterator.hpp>
+
+#include <boost/scoped_ptr.hpp>
 
 #include <vector>
 
 namespace libpc
 {
 
-class Schema;
-class Stage;
-class CacheFilter;
-    
 namespace chipper
 {
 
@@ -28,17 +26,13 @@
 
 class LIBPC_DLL PtRef
 {
-    
 public:
     double m_pos;
     boost::uint32_t m_ptindex;
     boost::uint32_t m_oindex;
-    boost::uint32_t m_pointSize;
-    boost::uint8_t m_data[40];
 
     bool operator < (const PtRef& pt) const
         { return m_pos < pt.m_pos; }
-
 };
 
 struct LIBPC_DLL RefList
@@ -76,7 +70,7 @@
 
 class LIBPC_DLL Chipper;
 
-class LIBPC_DLL Block : libpc::PointBuffer
+class LIBPC_DLL Block
 {
     friend class Chipper;
 
@@ -91,13 +85,9 @@
     // double m_ymax;
 
 public:
-    Block(Schema const& schema, boost::uint32_t capacity);
-    Block(Block const& block);
     std::vector<boost::uint32_t> GetIDs() const; 
     libpc::Bounds<double> const& GetBounds() const {return m_bounds;} 
     void SetBounds(libpc::Bounds<double> const& bounds) {m_bounds = bounds;}
-    PointBuffer GetPointBuffer(libpc::SchemaLayout const& layout) const;
-    
     // double GetXmin() const
     //     { return m_xmin; }
     // double GetYmin() const
@@ -113,7 +103,7 @@
 public:
     Chipper(Stage& prevStage, boost::uint32_t max_partition_size) :
         m_stage(prevStage), m_threshold(max_partition_size),
-        m_xvec(DIR_X), m_yvec(DIR_Y), m_spare(DIR_NONE), m_cache(0)
+        m_xvec(DIR_X), m_yvec(DIR_Y), m_spare(DIR_NONE)
     {}
 
     void Chip();
@@ -143,7 +133,6 @@
     RefList m_xvec;
     RefList m_yvec;
     RefList m_spare;
-    CacheFilter* m_cache;
 
     Chipper& operator=(const Chipper&); // not implemented
     Chipper(const Chipper&); // not implemented
diff -r 0475852dc135 -r 9798b3952688 src/Chipper.cpp
--- a/src/Chipper.cpp	Wed Mar 23 14:27:22 2011 -0500
+++ b/src/Chipper.cpp	Wed Mar 23 16:37:10 2011 -0500
@@ -38,14 +38,10 @@
  * OF SUCH DAMAGE.
  ****************************************************************************/
 
-#include <libpc/Chipper.hpp>
-#include <libpc/Header.hpp>
-#include <libpc/Stage.hpp>
-#include <libpc/filters/CacheFilter.hpp>
+#include <libpc/chipper.hpp>
 #include <libpc/Utils.hpp>
 // boost
 #include <boost/cstdint.hpp>
-#include <boost/scoped_ptr.hpp>
 // std
 #include <cmath>
 
@@ -83,20 +79,6 @@
 
 namespace libpc { namespace chipper {
 
-Block::Block(Schema const& schema, boost::uint32_t capacity)
- : PointBuffer(schema, capacity)
-{
-    
-}
-Block::Block(Block const& other)
- : PointBuffer(other)
- , m_list_p(other.m_list_p)
- , m_left(other.m_left)
- , m_right(other.m_right)
- , m_bounds(other.m_bounds)
-{
-    
-}
 vector<boost::uint32_t> Block::GetIDs() const
 {
     vector<boost::uint32_t> ids;
@@ -106,23 +88,6 @@
     return ids;
 }
 
-PointBuffer Block::GetPointBuffer(SchemaLayout const& layout) const
-{
-    PointBuffer buffer(layout, m_list_p->size());
-    
-    for (boost::uint32_t i = 0; i < m_list_p->size(); ++i)
-    {
-        boost::uint8_t* data = (*m_list_p)[i].m_data;
-        buffer.setData(data, i);
-    }
-    
-    return buffer;
-    // for (boost::uint32_t i = m_left; i <= m_right; ++i)
-    //     ids.push_back((*m_list_p)[i].m_ptindex);
-    // return ids;
-}
-
-
 void Chipper::Chip()
 {
     Load(m_xvec, m_yvec, m_spare);
@@ -132,30 +97,21 @@
 
 void Chipper::Load(RefList& xvec, RefList& yvec, RefList& spare )
 {
-
+    PtRef ref;
     boost::uint32_t idx;
     vector<PtRef>::iterator it;
    
     libpc::Header const& header = m_stage.getHeader();
     libpc::Schema const& schema = header.getSchema();
-    libpc::SchemaLayout const& layout = SchemaLayout(schema);
     
-
-    PtRef ref;
-
     boost::uint64_t count = header.getNumPoints();
-    
-    if (count == 0) 
-    {
-        if (header.getPointCountType() == libpc::PointCount_Unknown)
-            throw libpc::indeterminate_count_error("The chipper requires a complete point count");
-    }
     xvec.reserve(count);
     yvec.reserve(count);
     spare.resize(count);
+    
+    // boost::uint32_t chunks = count/m_threshold;
 
-    
-    boost::scoped_ptr<Iterator> iter(m_stage.createIterator());
+
 
     const int indexX = schema.getDimensionIndex(Dimension::Field_X);
     const int indexY = schema.getDimensionIndex(Dimension::Field_Y);
@@ -172,6 +128,8 @@
     std::size_t num_points_loaded = 0;
     std::size_t num_points_to_load = count;
     
+    boost::scoped_ptr<Iterator> iter(m_stage.createIterator());
+    
     boost::uint32_t counter = 0;
     while (num_points_loaded < num_points_to_load)
     {
@@ -179,23 +137,15 @@
         boost::uint32_t num_to_read = static_cast<boost::uint32_t>(std::min<boost::uint64_t>(num_remaining, m_threshold));
 
         PointBuffer buffer(schema, num_to_read);
-
-        boost::uint32_t num_read = iter->read(buffer);
         
-        if (num_read == 0) break;
+        
+        
+        boost::uint32_t num_read =  iter->read(buffer);
+        
         assert(num_read <= num_to_read);
 
-        for (boost::uint32_t j = 0; j < m_threshold; j++)
+        for (boost::uint32_t j = 0; j < num_read; j++)
         {
-            if (layout.getByteSize() > 40) {
-                throw libpc_error("Chipper PtRef size not large enough to hold point data");
-            }
-            
-            memcpy (ref.m_data, buffer.getData(j), layout.getByteSize());
-            // PointBuffer data(buffer.getSchemaLayout(), 1);            
-            // data.copyPointFast(0, j, buffer);
-            
-            if (j == num_to_read) break; // we're outta here
 
             // (v * m_header->GetScaleX()) + m_header->GetOffsetX();
             const double x = (buffer.getField<boost::int32_t>(j, indexX) * xscale) + xoffset;
@@ -413,7 +363,7 @@
 void Chipper::Emit(RefList& wide, boost::uint32_t widemin, boost::uint32_t widemax,
     RefList& narrow, boost::uint32_t narrowmin, boost::uint32_t narrowmax )
 {
-    Block b(m_stage.getHeader().getSchema(), m_threshold);
+    Block b;
 
     b.m_list_p = &wide;
     if (wide.m_dir == DIR_X) { 
diff -r 0475852dc135 -r 9798b3952688 test/unit/ChipperTest.cpp
--- a/test/unit/ChipperTest.cpp	Wed Mar 23 14:27:22 2011 -0500
+++ b/test/unit/ChipperTest.cpp	Wed Mar 23 16:37:10 2011 -0500
@@ -80,22 +80,22 @@
         BOOST_CHECK(ids.size() == 15);
         BOOST_CHECK(ids[14] == 1050 );
 
-        PointBuffer buffer = chipper.GetBlock(20).GetPointBuffer(libpc::SchemaLayout(reader.getHeader().getSchema()));
-        
-        // Check X's of first three points in block 20
-        BOOST_CHECK(buffer.getField<boost::int32_t>(0, 0) == 63567405);
-        BOOST_CHECK(buffer.getField<boost::int32_t>(1, 0) == 63568054);
-        BOOST_CHECK(buffer.getField<boost::int32_t>(2, 0) == 63569865);
-
-        // Check Y's of first three points in block 20
-        BOOST_CHECK(buffer.getField<boost::int32_t>(0, 1) == 84901732);
-        BOOST_CHECK(buffer.getField<boost::int32_t>(1, 1) == 84936266);
-        BOOST_CHECK(buffer.getField<boost::int32_t>(2, 1) == 84941588);
-
-        // Check Z's of first three points in block 20
-        BOOST_CHECK(buffer.getField<boost::int32_t>(0, 2) == 42802);
-        BOOST_CHECK(buffer.getField<boost::int32_t>(1, 2) == 42156);
-        BOOST_CHECK(buffer.getField<boost::int32_t>(2, 2) == 42392);
+        // PointBuffer buffer = chipper.GetBlock(20).GetPointBuffer(libpc::SchemaLayout(reader.getHeader().getSchema()));
+        // 
+        // // Check X's of first three points in block 20
+        // BOOST_CHECK(buffer.getField<boost::int32_t>(0, 0) == 63567405);
+        // BOOST_CHECK(buffer.getField<boost::int32_t>(1, 0) == 63568054);
+        // BOOST_CHECK(buffer.getField<boost::int32_t>(2, 0) == 63569865);
+        // 
+        // // Check Y's of first three points in block 20
+        // BOOST_CHECK(buffer.getField<boost::int32_t>(0, 1) == 84901732);
+        // BOOST_CHECK(buffer.getField<boost::int32_t>(1, 1) == 84936266);
+        // BOOST_CHECK(buffer.getField<boost::int32_t>(2, 1) == 84941588);
+        // 
+        // // Check Z's of first three points in block 20
+        // BOOST_CHECK(buffer.getField<boost::int32_t>(0, 2) == 42802);
+        // BOOST_CHECK(buffer.getField<boost::int32_t>(1, 2) == 42156);
+        // BOOST_CHECK(buffer.getField<boost::int32_t>(2, 2) == 42392);
 
     }
 


More information about the Liblas-commits mailing list