TimeCache& setMaxSize(size_t size) { maxSize = size; if (maxSize < 1) maxSize = 1; while (cache.size() > maxSize) popOne(); return *this; }
// insert this as the LRU data void insert(const CDTime& time, const Data& d) { // are we full? push out the oldest data while (cache.size() >= maxSize) popOne(); order.push_front(time); cache[time] = CacheItem(d, order.begin()); }
CelledBaseChunkReader::CelledBaseChunkReader( const Metadata& m, PointPool& pool, const arbiter::Endpoint& endpoint) : BaseChunkReader(m, pool) { DimList dims; dims.push_back(DimInfo("TubeId", "unsigned", 8)); dims.insert(dims.end(), m.schema().dims().begin(), m.schema().dims().end()); const Schema celledSchema(dims); PointPool celledPool(celledSchema, m.delta()); auto tubedCells(m.storage().deserialize(endpoint, celledPool, m_id)); Data::PooledStack tubedData(celledPool.dataPool()); auto dataNodes(m_pool.dataPool().acquire(tubedCells.size())); m_cells = m_pool.cellPool().acquire(tubedCells.size()); const std::size_t celledPointSize(celledSchema.pointSize()); const std::size_t tubeIdSize(sizeof(uint64_t)); uint64_t tube(0); char* tPos(reinterpret_cast<char*>(&tube)); BinaryPointTable table(m.schema()); pdal::PointRef pointRef(table, 0); for (auto& cell : m_cells) { auto tubedCell(tubedCells.popOne()); const char* src(tubedCell->uniqueData()); Data::PooledNode data(dataNodes.popOne()); std::copy(src, src + tubeIdSize, tPos); std::copy(src + tubeIdSize, src + celledPointSize, *data); table.setPoint(*data); cell.set(pointRef, std::move(data)); m_points.at(tube).emplace_back(cell.point(), cell.uniqueData()); tubedData.push(tubedCell->acquire()); } }