| 604 | } |
| 605 | |
| 606 | Status Array::close() { |
| 607 | Status st; |
| 608 | // Check if array is open |
| 609 | if (!is_open()) { |
| 610 | // If array is not open treat this as a no-op |
| 611 | // This keeps existing behavior from TileDB 2.6 and older |
| 612 | return Status::Ok(); |
| 613 | } |
| 614 | |
| 615 | try { |
| 616 | set_array_closed(); |
| 617 | |
| 618 | if (remote_) { |
| 619 | // Update array metadata for write queries if metadata was written by the |
| 620 | // user |
| 621 | if ((query_type_ == QueryType::WRITE || |
| 622 | query_type_ == QueryType::MODIFY_EXCLUSIVE) && |
| 623 | opened_array_->metadata().num() > 0) { |
| 624 | // Set metadata loaded to be true so when serialization fetchs the |
| 625 | // metadata it won't trigger a deadlock |
| 626 | set_metadata_loaded(true); |
| 627 | auto rest_client = resources_.rest_client(); |
| 628 | if (rest_client == nullptr) { |
| 629 | throw ArrayException( |
| 630 | "Error closing array; remote array with no REST client."); |
| 631 | } |
| 632 | throw_if_not_ok(rest_client->post_array_metadata_to_rest( |
| 633 | array_uri_, |
| 634 | array_dir_timestamp_start_, |
| 635 | array_dir_timestamp_end_, |
| 636 | this)); |
| 637 | } |
| 638 | } else { |
| 639 | if (query_type_ == QueryType::WRITE || |
| 640 | query_type_ == QueryType::MODIFY_EXCLUSIVE) { |
| 641 | opened_array_->metadata().store( |
| 642 | resources_, array_uri_, *encryption_key()); |
| 643 | } else if ( |
| 644 | query_type_ != QueryType::READ && query_type_ != QueryType::DELETE && |
| 645 | query_type_ != QueryType::UPDATE) { |
| 646 | throw std::logic_error("Error closing array; Unsupported query type."); |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | opened_array_.reset(); |
| 651 | } catch (std::exception& e) { |
| 652 | is_opening_or_closing_ = false; |
| 653 | throw ArrayException(e.what()); |
| 654 | } |
| 655 | |
| 656 | is_opening_or_closing_ = false; |
| 657 | return Status::Ok(); |
| 658 | } |
| 659 | |
| 660 | void Array::delete_fragments( |
| 661 | ContextResources& resources, ArrayDirectory& array_dir) { |
no test coverage detected