Skip to content

Commit

Permalink
Example of EPT reader processing in parallel - does not work for boun…
Browse files Browse the repository at this point in the history
…ded queries.
  • Loading branch information
connormanning committed Apr 13, 2019
1 parent fc5e6bb commit 2d62180
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
50 changes: 32 additions & 18 deletions io/EptReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,21 +555,33 @@ uint64_t EptReader::readLaszip(PointView& dst, const Key& key,
LasReader reader;
reader.setOptions(options);

std::lock_guard<std::mutex> lock(m_mutex);
reader.prepare(table);
{
std::lock_guard<std::mutex> lock(m_mutex);
reader.prepare(table);
}

const PointViewSet views(reader.execute(table));
if (views.size() != 1)
{
throwError("Unexpected view count: " + key.toString());
}

auto& src(*views.begin());

// Reserve all the points we are about to populate from this node.
std::unique_lock<std::mutex> lock(m_mutex);
const uint64_t startId(dst.size());
for (uint64_t pointId(0); pointId < src->size(); ++pointId)
{
dst.getOrAddPoint(startId + pointId);
}
lock.unlock();

uint64_t pointId(0);
for (auto& src : reader.execute(table))
PointRef pr(*src);
for (uint64_t pointId(0); pointId < src->size(); ++pointId)
{
PointRef pr(*src);
for (uint64_t i(0); i < src->size(); ++i)
{
pr.setPointId(i);
process(dst, pr, nodeId, pointId);
++pointId;
}
pr.setPointId(pointId);
process(dst, pr, nodeId, pointId, startId + pointId);
}

return startId;
Expand All @@ -582,27 +594,29 @@ uint64_t EptReader::readBinary(PointView& dst, const Key& key,
ShallowPointTable table(*m_remoteLayout, data.data(), data.size());
PointRef pr(table);

std::lock_guard<std::mutex> lock(m_mutex);

// Reserve all the points we are about to populate from this node.
std::unique_lock<std::mutex> lock(m_mutex);
const uint64_t startId(dst.size());
for (uint64_t pointId(0); pointId < table.numPoints(); ++pointId)
{
dst.getOrAddPoint(startId + pointId);
}
lock.unlock();

uint64_t pointId(0);
for (uint64_t pointId(0); pointId < table.numPoints(); ++pointId)
{
pr.setPointId(pointId);
process(dst, pr, nodeId, pointId);
process(dst, pr, nodeId, pointId, startId + pointId);
}

return startId;
}

void EptReader::process(PointView& dst, PointRef& pr, const uint64_t nodeId,
const uint64_t pointId) const
const uint64_t pointId, const uint64_t dstId) const
{
using D = Dimension::Id;

const point_count_t dstId(dst.size());

const double x = pr.getFieldAs<double>(D::X) *
m_xyzTransforms[0].m_scale.m_val + m_xyzTransforms[0].m_offset.m_val;
const double y = pr.getFieldAs<double>(D::Y) *
Expand Down
2 changes: 1 addition & 1 deletion io/EptReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class PDAL_DLL EptReader : public Reader
uint64_t readLaszip(PointView& view, const Key& key, uint64_t nodeId) const;
uint64_t readBinary(PointView& view, const Key& key, uint64_t nodeId) const;
void process(PointView& view, PointRef& pr, uint64_t nodeId,
uint64_t pointId) const;
uint64_t pointId, uint64_t dstId) const;

void readAddon(PointView& dst, const Key& key, const Addon& addon,
uint64_t startId) const;
Expand Down

0 comments on commit 2d62180

Please sign in to comment.