Skip to content

Commit

Permalink
Add missing query_type in array_open capnp (#3616)
Browse files Browse the repository at this point in the history
Currently in Array open v2 we are not specifying in what "mode" we are requesting to open the array. Thus the Cloud side unconditionally opens the array in READ mode (https://github.com/TileDB-Inc/TileDB-Cloud-REST/blob/master/internal/arrays/v2/array.go#L252).

This PR fixes this issue by adding a `query_type` CAPNP field to be used by Cloud to open the array.

---
TYPE: BUG
DESC: Add missing query_type in array_open capnp

===

* Add query_type in array_open capnp

* build target update-serialization for windows (plus clang format)

* Default initalize Array query_type to fix test failures

* Fix CI warning

Co-authored-by: dhoke4tdb <david.hoke@tiledb.com>
  • Loading branch information
2 people authored and github-actions[bot] committed Nov 1, 2022
1 parent 852f5a3 commit 3aadb5a
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 32 deletions.
6 changes: 0 additions & 6 deletions tiledb/sm/array/array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -580,12 +580,6 @@ tuple<Status, optional<shared_ptr<ArraySchema>>> Array::get_array_schema()
}

QueryType Array::get_query_type() const {
// Error if the array is not open
if (!is_open_) {
throw StatusException(
Status_ArrayError("Cannot get query_type; Array is not open"));
}

return query_type_;
}

Expand Down
9 changes: 7 additions & 2 deletions tiledb/sm/array/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ class Array {
/** Checks the config to see if refactored array open should be used. */
bool use_refactored_array_open() const;

/** Set the query type to open the array for. */
inline void set_query_type(QueryType query_type) {
query_type_ = query_type;
}

private:
/* ********************************* */
/* PRIVATE ATTRIBUTES */
Expand Down Expand Up @@ -490,8 +495,8 @@ class Array {
/** `True` if the array is currently in the process of opening or closing. */
std::atomic<bool> is_opening_or_closing_;

/** The query type the array was opened for. */
QueryType query_type_;
/** The query type the array was opened for. Default: READ */
QueryType query_type_ = QueryType::READ;

/**
* The starting timestamp between to open `open_array_` at.
Expand Down
9 changes: 9 additions & 0 deletions tiledb/sm/serialization/array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ Status array_open_to_capnp(
auto config = array.config();
RETURN_NOT_OK(config_to_capnp(&config, &config_builder));

array_open_builder->setQueryType(query_type_str(array.get_query_type()));

return Status::Ok();
}

Expand All @@ -260,6 +262,13 @@ Status array_open_from_capnp(
RETURN_NOT_OK(array->set_config(*decoded_config));
}

if (array_open_reader.hasQueryType()) {
auto query_type_str = array_open_reader.getQueryType();
QueryType query_type = QueryType::READ;
RETURN_NOT_OK(query_type_enum(query_type_str, &query_type));
array->set_query_type(query_type);
}

return Status::Ok();
}

Expand Down
38 changes: 27 additions & 11 deletions tiledb/sm/serialization/posix/tiledb-rest.capnp.c++

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 49 additions & 1 deletion tiledb/sm/serialization/posix/tiledb-rest.capnp.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tiledb/sm/serialization/tiledb-rest.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ struct Array {
struct ArrayOpen {
config @0 :Config;
# Config
queryType @1 :Text;
# Query type to open the array for
}

struct ArraySchema {
Expand Down
38 changes: 27 additions & 11 deletions tiledb/sm/serialization/win32/tiledb-rest.capnp.c++

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 49 additions & 1 deletion tiledb/sm/serialization/win32/tiledb-rest.capnp.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3aadb5a

Please sign in to comment.