Skip to content

Commit

Permalink
Address last comments from StrikerRUS
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoEAF committed Mar 19, 2021
1 parent 418e72d commit 3ed0e3e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions include/LightGBM/utils/chunked_array.hpp
Expand Up @@ -11,9 +11,9 @@

#include <stdint.h>

#include <algorithm>
#include <new>
#include <vector>
#include <algorithm>


namespace LightGBM {
Expand Down Expand Up @@ -43,7 +43,7 @@ namespace LightGBM {
* - get_add_count() # total count of added elements.
* - get_chunks_count() # how many chunks are currently allocated.
* - get_current_chunk_added_count() # for the last add() chunk, how many items there are.
* - get_chunk_size() # Get constant chunk_size from constructor call.
* - get_chunk_size() # get constant chunk_size from constructor call.
*
* With those you can generate int32_t sizes[]. Last chunk can be smaller than chunk_size, so, for any i:
* - sizes[i<last] = get_chunk_size()
Expand All @@ -63,7 +63,7 @@ class ChunkedArray {
explicit ChunkedArray(size_t chunk_size)
: _chunk_size(chunk_size), _last_chunk_idx(0), _last_idx_in_last_chunk(0) {
if (chunk_size == 0) {
throw std::length_error("ChunkedArray chunk size must be larger than 0!");
Log::Fatal("ChunkedArray chunk size must be larger than 0!");
}
new_chunk();
}
Expand Down Expand Up @@ -170,7 +170,7 @@ class ChunkedArray {
* Return value from array of chunks.
*
* @param chunk_index index of the chunk
* @param index index within chunk
* @param index_within_chunk index within chunk
* @param on_fail_value sentinel value. If out of bounds returns that value.
*
* @return pointer or nullptr if index is out of bounds.
Expand Down Expand Up @@ -241,7 +241,7 @@ class ChunkedArray {
// Check memory allocation success:
if (!_chunks[_chunks.size()-1]) {
release();
throw std::bad_alloc();
Log::Fatal("Memory exhausted! Cannot allocate new ChunkedArray chunk.");
}
}

Expand Down
2 changes: 1 addition & 1 deletion swig/ChunkedArray_API_extensions.i
@@ -1,5 +1,5 @@
/**
* Wrap ChunkedArray.hpp class for SWIG usage.
* Wrap chunked_array.hpp class for SWIG usage.
*
* Author: Alberto Ferreira
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/cpp_test/test_chunked_array.cpp
Expand Up @@ -69,7 +69,7 @@ class ChunkedArrayTest : public testing::Test {

/*! ChunkedArray cannot be built from chunks of size 0. */
TEST_F(ChunkedArrayTest, constructorWithChunkSize0Throws) {
ASSERT_THROW(ChunkedArray<int> ca(0), std::length_error);
ASSERT_THROW(ChunkedArray<int> ca(0), std::runtime_error);
}

/*! get_chunk_size() should return the size used in the constructor */
Expand Down

0 comments on commit 3ed0e3e

Please sign in to comment.