Skip to content

Commit

Permalink
[c++] Add ManagedQuery constructor that takes SOMAArray
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenv committed Nov 2, 2024
1 parent 5f154bf commit 6f1119a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libtiledbsoma/src/soma/managed_query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ ManagedQuery::ManagedQuery(
reset();
}

ManagedQuery::ManagedQuery(
std::unique_ptr<SOMAArray> array,
std::shared_ptr<Context> ctx,
std::string_view name)
: array_(array->arr_)
, ctx_(ctx)
, name_(name)
, schema_(std::make_shared<ArraySchema>(array->arr_->schema())) {
reset();
}

void ManagedQuery::close() {
array_->close();
}
Expand Down
16 changes: 16 additions & 0 deletions libtiledbsoma/src/soma/managed_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
namespace tiledbsoma {

using namespace tiledb;
class SOMAArray;

// Probably we should just use a std::tuple here
class StatusAndException {
Expand Down Expand Up @@ -86,6 +87,11 @@ class ManagedQuery {
std::shared_ptr<Context> ctx,
std::string_view name = "unnamed");

ManagedQuery(
std::unique_ptr<SOMAArray> array,
std::shared_ptr<Context> ctx,
std::string_view name = "unnamed");

ManagedQuery() = delete;

ManagedQuery(const ManagedQuery&) = delete;
Expand Down Expand Up @@ -406,6 +412,16 @@ class ManagedQuery {
return query_->query_type();
}

/**
* @brief Return the query status.
*
* @return tiledb::Query::Status INCOMPLETE, COMPLETE, INPROGRESS, FAILED,
* UNINITIALIZED, or INITIALIZED
*/
Query::Status query_status() const {
return query_->query_status();
}

private:
//===================================================================
//= private non-static
Expand Down
2 changes: 2 additions & 0 deletions libtiledbsoma/src/soma/soma_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ enum class Domainish {

class SOMAArray : public SOMAObject {
public:
friend class ManagedQuery;

//===================================================================
//= public static
//===================================================================
Expand Down

0 comments on commit 6f1119a

Please sign in to comment.