in cpp/src/graphar/arrow/chunk_writer.cc [531:583]
Status EdgeChunkWriter::validate(
const std::shared_ptr<arrow::Table>& input_table, IdType vertex_chunk_index,
ValidateLevel validate_level) const {
// use the writer's validate level
if (validate_level == ValidateLevel::default_validate)
validate_level = validate_level_;
// no validate
if (validate_level == ValidateLevel::no_validate)
return Status::OK();
// validate for adj list type & index
GAR_RETURN_NOT_OK(validate(vertex_chunk_index, 0, validate_level));
// weak validate for the input table
if (adj_list_type_ != AdjListType::ordered_by_source &&
adj_list_type_ != AdjListType::ordered_by_dest) {
return Status::Invalid(
"The adj list type has to be ordered_by_source or ordered_by_dest, but "
"got " +
std::string(AdjListTypeToString(adj_list_type_)));
}
if (adj_list_type_ == AdjListType::ordered_by_source &&
input_table->num_rows() > edge_info_->GetSrcChunkSize() + 1) {
return Status::Invalid(
"The number of rows of input offset table is ", input_table->num_rows(),
" which is larger than the offset size of source vertex chunk ",
edge_info_->GetSrcChunkSize() + 1, ".");
}
if (adj_list_type_ == AdjListType::ordered_by_dest &&
input_table->num_rows() > edge_info_->GetDstChunkSize() + 1) {
return Status::Invalid(
"The number of rows of input offset table is ", input_table->num_rows(),
" which is larger than the offset size of destination vertex chunk ",
edge_info_->GetSrcChunkSize() + 1, ".");
}
// strong validate for the input_table
if (validate_level == ValidateLevel::strong_validate) {
// validate the input table
RETURN_NOT_ARROW_OK(input_table->Validate());
// validate the schema
auto schema = input_table->schema();
int index = schema->GetFieldIndex(GeneralParams::kOffsetCol);
if (index == -1) {
return Status::Invalid("The offset column ", GeneralParams::kOffsetCol,
" does not exist in the input table");
}
auto field = schema->field(index);
if (field->type()->id() != arrow::Type::INT64) {
return Status::TypeError(
"The data type for offset column should be INT64, but got ",
field->type()->name());
}
}
return Status::OK();
}