Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions cpp/src/graphar/label.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include <cassert>
#include <cstring>
#include <memory>
#include <vector>

namespace graphar {

/// Read a parquet file by ParquetReader & get valid indices
/// The first column_num labels are concerned.
Expand All @@ -44,9 +47,9 @@ int read_parquet_file_and_get_valid_indices(

// Initialize the column row counts
std::vector<int> col_row_counts(num_columns, 0);
bool** value = new bool*[num_columns];
std::vector<std::unique_ptr<bool[]>> value(num_columns);
for (int i = 0; i < num_columns; i++) {
value[i] = new bool[row_num];
value[i] = std::make_unique<bool[]>(row_num);
}

// Iterate over all the RowGroups in the file
Expand All @@ -73,9 +76,9 @@ int read_parquet_file_and_get_valid_indices(
// Read BATCH_SIZE values at a time. The number of rows read is
// returned. values_read contains the number of non-null rows

rows_read = bool_reader->ReadBatch(BATCH_SIZE, nullptr, nullptr,
value[k] + col_row_counts[col_id],
&values_read);
rows_read = bool_reader->ReadBatch(
BATCH_SIZE, nullptr, nullptr,
value[k].get() + col_row_counts[col_id], &values_read);

// There are no NULL values in the rows written
col_row_counts[col_id] += rows_read;
Expand All @@ -99,11 +102,7 @@ int read_parquet_file_and_get_valid_indices(
}
}

// destroy the allocated space
for (int i = 0; i < num_columns; i++) {
delete[] value[i];
}
delete[] value;

return count;
}

} // namespace graphar
7 changes: 5 additions & 2 deletions cpp/src/graphar/label.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
#include <parquet/api/writer.h>
#include <parquet/properties.h>

#include <iostream>
#include <set>
#include <functional>
#include <vector>

using parquet::ConvertedType;
Expand All @@ -37,6 +36,8 @@ using parquet::Type;
using parquet::schema::GroupNode;
using parquet::schema::PrimitiveNode;

namespace graphar {

constexpr int BATCH_SIZE = 1024; // the batch size

/// The query type
Expand All @@ -60,4 +61,6 @@ int read_parquet_file_and_get_valid_indices(
uint64_t* bitmap = nullptr,
const QUERY_TYPE query_type = QUERY_TYPE::COUNT);

} // namespace graphar

#endif // CPP_SRC_GRAPHAR_LABEL_H_
Loading