! * \brief Interface for bin data. This class will store bin data for one feature. * unlike OrderedBin, this class will store data by original order. * Note that it may cause cache misses when construct histogram, * but it doesn't need to re-order operation, So it will be faster than OrderedBin for dense feature */
| 289 | * but it doesn't need to re-order operation, So it will be faster than OrderedBin for dense feature |
| 290 | */ |
| 291 | class Bin { |
| 292 | public: |
| 293 | /*! \brief virtual destructor */ |
| 294 | virtual ~Bin() {} |
| 295 | /*! |
| 296 | * \brief Push one record |
| 297 | * \pram tid Thread id |
| 298 | * \param idx Index of record |
| 299 | * \param value bin value of record |
| 300 | */ |
| 301 | virtual void Push(int tid, data_size_t idx, uint32_t value) = 0; |
| 302 | |
| 303 | |
| 304 | virtual void CopySubset(const Bin* full_bin, const data_size_t* used_indices, data_size_t num_used_indices) = 0; |
| 305 | /*! |
| 306 | * \brief Get bin iterator of this bin for specific feature |
| 307 | * \param min_bin min_bin of current used feature |
| 308 | * \param max_bin max_bin of current used feature |
| 309 | * \param default_bin default bin if bin not in [min_bin, max_bin] |
| 310 | * \return Iterator of this bin |
| 311 | */ |
| 312 | virtual BinIterator* GetIterator(uint32_t min_bin, uint32_t max_bin, uint32_t default_bin) const = 0; |
| 313 | |
| 314 | /*! |
| 315 | * \brief Save binary data to file |
| 316 | * \param file File want to write |
| 317 | */ |
| 318 | virtual void SaveBinaryToFile(const VirtualFileWriter* writer) const = 0; |
| 319 | |
| 320 | /*! |
| 321 | * \brief Load from memory |
| 322 | * \param memory |
| 323 | * \param local_used_indices |
| 324 | */ |
| 325 | virtual void LoadFromMemory(const void* memory, |
| 326 | const std::vector<data_size_t>& local_used_indices) = 0; |
| 327 | |
| 328 | /*! |
| 329 | * \brief Get sizes in byte of this object |
| 330 | */ |
| 331 | virtual size_t SizesInByte() const = 0; |
| 332 | |
| 333 | /*! \brief Number of all data */ |
| 334 | virtual data_size_t num_data() const = 0; |
| 335 | |
| 336 | virtual void ReSize(data_size_t num_data) = 0; |
| 337 | |
| 338 | /*! |
| 339 | * \brief Construct histogram of this feature, |
| 340 | * Note: We use ordered_gradients and ordered_hessians to improve cache hit chance |
| 341 | * The naive solution is using gradients[data_indices[i]] for data_indices[i] to get gradients, |
| 342 | which is not cache friendly, since the access of memory is not continuous. |
| 343 | * ordered_gradients and ordered_hessians are preprocessed, and they are re-ordered by data_indices. |
| 344 | * Ordered_gradients[i] is aligned with data_indices[i]'s gradients (same for ordered_hessians). |
| 345 | * \param data_indices Used data indices in current leaf |
| 346 | * \param num_data Number of used data |
| 347 | * \param ordered_gradients Pointer to gradients, the data_indices[i]-th data's gradient is ordered_gradients[i] |
| 348 | * \param ordered_hessians Pointer to hessians, the data_indices[i]-th data's hessian is ordered_hessians[i] |
nothing calls this directly
no outgoing calls
no test coverage detected