2222#include < cassert>
2323#include < cstring>
2424#include < memory>
25+ #include < vector>
26+
27+ namespace graphar {
2528
2629// / Read a parquet file by ParquetReader & get valid indices
2730// / The first column_num labels are concerned.
@@ -44,9 +47,9 @@ int read_parquet_file_and_get_valid_indices(
4447
4548 // Initialize the column row counts
4649 std::vector<int > col_row_counts (num_columns, 0 );
47- bool ** value = new bool *[ num_columns] ;
50+ std::vector<std::unique_ptr< bool []>> value ( num_columns) ;
4851 for (int i = 0 ; i < num_columns; i++) {
49- value[i] = new bool [row_num] ;
52+ value[i] = std::make_unique< bool []>(row_num) ;
5053 }
5154
5255 // Iterate over all the RowGroups in the file
@@ -73,9 +76,9 @@ int read_parquet_file_and_get_valid_indices(
7376 // Read BATCH_SIZE values at a time. The number of rows read is
7477 // returned. values_read contains the number of non-null rows
7578
76- rows_read = bool_reader->ReadBatch (BATCH_SIZE, nullptr , nullptr ,
77- value[k] + col_row_counts[col_id] ,
78- &values_read);
79+ rows_read = bool_reader->ReadBatch (
80+ BATCH_SIZE, nullptr , nullptr ,
81+ value[k]. get () + col_row_counts[col_id], &values_read);
7982
8083 // There are no NULL values in the rows written
8184 col_row_counts[col_id] += rows_read;
@@ -99,11 +102,7 @@ int read_parquet_file_and_get_valid_indices(
99102 }
100103 }
101104
102- // destroy the allocated space
103- for (int i = 0 ; i < num_columns; i++) {
104- delete[] value[i];
105- }
106- delete[] value;
107-
108105 return count;
109106}
107+
108+ } // namespace graphar
0 commit comments