Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change array schema format for schema evolution #2258

Merged
merged 30 commits into from Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9aa9e85
rebase format change for schema evolution to latest dev
May 5, 2021
0e2931f
fix some unit test errors
bdeng-xt May 7, 2021
397efbb
fix some failed unit tests for fragments
bdeng-xt May 7, 2021
6367c67
fix unused parameter warnings for default constructors
bdeng-xt May 9, 2021
03c6dfc
change consolidation.step_size_ratio from 0.75 to 0.78 to pass the un…
bdeng-xt May 10, 2021
04da8d9
make format
bdeng-xt May 10, 2021
b6db8ae
rebase format change for schema evolution to latest dev
May 5, 2021
1822f26
fix some unit test errors
bdeng-xt May 7, 2021
204e09f
fix some failed unit tests for fragments
bdeng-xt May 7, 2021
1902ada
fix unused parameter warnings for default constructors
bdeng-xt May 9, 2021
2db7a72
change consolidation.step_size_ratio from 0.75 to 0.78 to pass the un…
bdeng-xt May 10, 2021
c85a36f
make format
bdeng-xt May 10, 2021
f4a15e8
fix heap memory api violations
bdeng-xt May 10, 2021
ea9941f
rebase to dev
bdeng-xt May 10, 2021
9400b7b
fix error for back compatibility when array schema is stored in a file
bdeng-xt May 11, 2021
4a40cb8
try to fix questions raised by reviewers
bdeng-xt May 12, 2021
fd487b7
make StorageManager::is_array less expensive
bdeng-xt May 17, 2021
f0ee7ef
make is_array more robust
bdeng-xt May 18, 2021
12baba5
merge dev and resolve conflicts
bdeng-xt May 18, 2021
132d69c
merge dev and resolve conflict
bdeng-xt May 18, 2021
c09720f
reuse ls result when openning an array
bdeng-xt May 20, 2021
94d139e
make format
bdeng-xt May 20, 2021
e242195
Merge branch 'dev' into bd/schema-evolution-format-change
bdeng-xt May 20, 2021
bbdcbcf
merge dev and resolve coflicts
bdeng-xt May 21, 2021
ca5cb29
fix some coding styles on reviews
bdeng-xt May 27, 2021
1eafd60
Merge branch 'dev' into bd/schema-evolution-format-change
bdeng-xt Jun 16, 2021
04cd7f9
merge dev and not do a listing on top level array directory
bdeng-xt Jun 16, 2021
436b992
check is_dir before listing a schema directory
bdeng-xt Jun 16, 2021
521a993
Merge branch 'dev' into bd/schema-evolution-format-change
Jul 3, 2021
200c74f
fix the bug for is_array in StorageManager
Jul 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/src/unit-backwards_compat.cc
Expand Up @@ -1163,4 +1163,4 @@ TEST_CASE(
delete array;
}
}
}
}
8 changes: 4 additions & 4 deletions tiledb/sm/array_schema/array_schema.cc
Expand Up @@ -721,12 +721,12 @@ void ArraySchema::set_uri(URI& uri) {
utils::parse::get_timestamp_range(uri_, &timestamp_range_);
}

Status ArraySchema::get_uri(URI& uri) {
Status ArraySchema::get_uri(URI* uri) {
if (uri_.is_invalid()) {
return LOG_STATUS(
Status::ArraySchemaError("Error in ArraySchema; invalid URI"));
}
uri = uri_;
*uri = uri_;
return Status::Ok();
}

Expand All @@ -738,12 +738,12 @@ const std::string& ArraySchema::name() {
return name_;
}

Status ArraySchema::get_name(std::string& name) const {
Status ArraySchema::get_name(std::string* name) const {
if (name_.empty()) {
return LOG_STATUS(
Status::ArraySchemaError("Error in ArraySchema; Empty name"));
}
name = name_;
*name = name_;
return Status::Ok();
}

Expand Down
4 changes: 2 additions & 2 deletions tiledb/sm/array_schema/array_schema.h
Expand Up @@ -313,13 +313,13 @@ class ArraySchema {
void set_uri(URI& uri);

/** Get schema URI with return status */
Status get_uri(URI& uri);
Status get_uri(URI* uri);

/** Returns the schema name. If it is not set, will build it */
const std::string& name();

/** Returns the schema name. If it is not set, will returns error status */
Status get_name(std::string& name) const;
Status get_name(std::string* name) const;

private:
/* ********************************* */
Expand Down
7 changes: 2 additions & 5 deletions tiledb/sm/fragment/fragment_metadata.cc
Expand Up @@ -90,7 +90,7 @@ FragmentMetadata::FragmentMetadata(
idx_map_[dim_name] = array_schema_->attribute_num() + 1 + i;
}

array_schema_->get_name(array_schema_name_);
array_schema_->get_name(&array_schema_name_);
}

FragmentMetadata::~FragmentMetadata() = default;
Expand Down Expand Up @@ -2187,10 +2187,7 @@ Status FragmentMetadata::write_generic_tile_offsets(Buffer* buff) const {

Status FragmentMetadata::write_array_schema_name(Buffer* buff) const {
uint64_t size = array_schema_name_.size();
Shelnutt2 marked this conversation as resolved.
Show resolved Hide resolved
Status status = buff->write(&size, sizeof(uint64_t));
if (!status.ok()) {
return status;
}
RETURN_NOT_OK(buff->write(&size, sizeof(uint64_t)));
return buff->write(array_schema_name_.c_str(), size);
}

Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/misc/utils.cc
Expand Up @@ -277,7 +277,7 @@ Status get_fragment_name_version(const std::string& name, uint32_t* version) {
// version is greater than or equal to 7, we have a footer version of 4.
bdeng-xt marked this conversation as resolved.
Show resolved Hide resolved
// Otherwise, it is version 3.
const int frag_version = std::stoi(name.substr(name.find_last_of('_') + 1));
if (frag_version >= 8)
if (frag_version >= 10)
*version = 5;
else if (frag_version >= 7)
*version = 4;
Expand Down
32 changes: 15 additions & 17 deletions tiledb/sm/storage_manager/storage_manager.cc
Expand Up @@ -1572,19 +1572,18 @@ Status StorageManager::get_array_schema_uris(
const URI& array_uri, std::vector<URI>* uris) const {
STATS_START_TIMER(stats::GlobalStats::TimerType::READ_GET_ARRAY_SCHEMAS)

// Always add array_name/__array_schema.tdb as the first schema uri
uris->clear();
auto schema_uri_old = array_uri.join_path(constants::array_schema_filename);
uris->emplace_back(schema_uri_old);

// Add schema uris under directory array_name/__schema
const URI schema_uri =
array_uri.join_path(constants::array_schema_folder_name);
bool is_dir = false;
RETURN_NOT_OK(vfs_->is_dir(schema_uri, &is_dir));
if (!is_dir) {
// If it is not a directory, the array schema could be stored in the
// previous format
uris->clear();
return Status::Ok();
}
RETURN_NOT_OK(vfs_->ls(schema_uri, uris));
// Sort schema URIs
std::sort(uris->begin(), uris->end());

// Since ls could return NOT Ok status, we will not use RETURN_NOT_OK here
vfs_->ls(schema_uri, uris);
Shelnutt2 marked this conversation as resolved.
Show resolved Hide resolved

return Status::Ok();

STATS_END_TIMER(stats::GlobalStats::TimerType::READ_GET_ARRAY_SCHEMAS)
Expand All @@ -1594,13 +1593,12 @@ Status StorageManager::get_latest_array_schema_uri(
const URI& array_uri, URI* uri) const {
STATS_START_TIMER(stats::GlobalStats::TimerType::READ_GET_LATEST_ARRAY_SCHEMA)
std::vector<URI> uris;
Status status = get_array_schema_uris(array_uri, &uris);
if (status.ok() && (!uris.empty())) {
*uri = uris.back();
} else {
// For older version, array schema file is under the array folder
*uri = array_uri.join_path(constants::array_schema_filename);
RETURN_NOT_OK(get_array_schema_uris(array_uri, &uris));
if (uris.size() == 0) {
return LOG_STATUS(Status::StorageManagerError(
"Can not get the latest array schema; Empty array schemas."));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change comment to Cannot get the latest array schema; No array schemas found.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

}
*uri = uris.back();
if (uri->is_invalid()) {
return LOG_STATUS(
Status::StorageManagerError("Could not find array schema URI"));
Expand Down