Skip to content

Commit 52dbf06

Browse files
desertstsungjameslambStrikerRUS
authored
[C-API] Avoid C++ includes from arrow.h when including c_api.h (#6973)
Bug-fix of include c_api.h in C code Co-authored-by: James Lamb <[email protected]> Co-authored-by: Nikita Titov <[email protected]>
1 parent 544d439 commit 52dbf06

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

include/LightGBM/arrow.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#ifndef LIGHTGBM_INCLUDE_LIGHTGBM_ARROW_H_
99
#define LIGHTGBM_INCLUDE_LIGHTGBM_ARROW_H_
1010

11+
#ifdef __cplusplus
1112
#include <algorithm>
1213
#include <cstdint>
1314
#include <functional>
@@ -17,6 +18,7 @@
1718
#include <utility>
1819
#include <vector>
1920
#include <stdexcept>
21+
#endif
2022

2123
/* -------------------------------------- C DATA INTERFACE ------------------------------------- */
2224
// The C data interface is taken from
@@ -72,6 +74,7 @@ struct ArrowArray {
7274
/* CHUNKED ARRAY */
7375
/* --------------------------------------------------------------------------------------------- */
7476

77+
#ifdef __cplusplus
7578
namespace LightGBM {
7679

7780
/**
@@ -295,5 +298,6 @@ class ArrowTable {
295298
} // namespace LightGBM
296299

297300
#include "arrow.tpp"
301+
#endif /* __cplusplus */
298302

299303
#endif // LIGHTGBM_INCLUDE_LIGHTGBM_ARROW_H_

include/LightGBM/c_api.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,8 @@ LIGHTGBM_C_EXPORT int LGBM_DatasetCreateFromMats(int32_t nmat,
449449
* \return 0 when succeed, -1 when failure happens
450450
*/
451451
LIGHTGBM_C_EXPORT int LGBM_DatasetCreateFromArrow(int64_t n_chunks,
452-
const ArrowArray* chunks,
453-
const ArrowSchema* schema,
452+
const struct ArrowArray* chunks,
453+
const struct ArrowSchema* schema,
454454
const char* parameters,
455455
const DatasetHandle reference,
456456
DatasetHandle *out);
@@ -571,8 +571,8 @@ LIGHTGBM_C_EXPORT int LGBM_DatasetSetField(DatasetHandle handle,
571571
LIGHTGBM_C_EXPORT int LGBM_DatasetSetFieldFromArrow(DatasetHandle handle,
572572
const char* field_name,
573573
int64_t n_chunks,
574-
const ArrowArray* chunks,
575-
const ArrowSchema* schema);
574+
const struct ArrowArray* chunks,
575+
const struct ArrowSchema* schema);
576576

577577
/*!
578578
* \brief Get info vector from dataset.
@@ -1450,8 +1450,8 @@ LIGHTGBM_C_EXPORT int LGBM_BoosterPredictForMats(BoosterHandle handle,
14501450
*/
14511451
LIGHTGBM_C_EXPORT int LGBM_BoosterPredictForArrow(BoosterHandle handle,
14521452
int64_t n_chunks,
1453-
const ArrowArray* chunks,
1454-
const ArrowSchema* schema,
1453+
const struct ArrowArray* chunks,
1454+
const struct ArrowSchema* schema,
14551455
int predict_type,
14561456
int start_iteration,
14571457
int num_iteration,

src/c_api.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,8 +1643,8 @@ int LGBM_DatasetCreateFromCSC(const void* col_ptr,
16431643
}
16441644

16451645
int LGBM_DatasetCreateFromArrow(int64_t n_chunks,
1646-
const ArrowArray* chunks,
1647-
const ArrowSchema* schema,
1646+
const struct ArrowArray* chunks,
1647+
const struct ArrowSchema* schema,
16481648
const char* parameters,
16491649
const DatasetHandle reference,
16501650
DatasetHandle *out) {
@@ -1858,8 +1858,8 @@ int LGBM_DatasetSetField(DatasetHandle handle,
18581858
int LGBM_DatasetSetFieldFromArrow(DatasetHandle handle,
18591859
const char* field_name,
18601860
int64_t n_chunks,
1861-
const ArrowArray* chunks,
1862-
const ArrowSchema* schema) {
1861+
const struct ArrowArray* chunks,
1862+
const struct ArrowSchema* schema) {
18631863
API_BEGIN();
18641864
auto dataset = reinterpret_cast<Dataset*>(handle);
18651865
ArrowChunkedArray ca(n_chunks, chunks, schema);
@@ -2617,8 +2617,8 @@ int LGBM_BoosterPredictForMats(BoosterHandle handle,
26172617

26182618
int LGBM_BoosterPredictForArrow(BoosterHandle handle,
26192619
int64_t n_chunks,
2620-
const ArrowArray* chunks,
2621-
const ArrowSchema* schema,
2620+
const struct ArrowArray* chunks,
2621+
const struct ArrowSchema* schema,
26222622
int predict_type,
26232623
int start_iteration,
26242624
int num_iteration,

0 commit comments

Comments
 (0)