Skip to content

Commit

Permalink
document helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Sep 20, 2024
1 parent 1c3dfd3 commit 88189f4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
16 changes: 12 additions & 4 deletions c/driver/framework/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
#include <string_view>
#include <vector>

#include <nanoarrow/nanoarrow.h>

#include <arrow-adbc/adbc.h>
#include "driver/framework/status.h"
#include "driver/framework/type_fwd.h"

namespace adbc::driver {

Status MakeGetObjectsSchema(struct ArrowSchema* schema);
/// \defgroup adbc-framework-catalog Catalog Utilities
/// Utilities for implementing catalog/metadata-related functions.
///
/// @{

/// \brief Create the ArrowSchema for AdbcConnectionGetObjects().
Status MakeGetObjectsSchema(ArrowSchema* schema);

/// \brief The GetObjects level.
enum class GetObjectsDepth {
Expand All @@ -39,6 +44,9 @@ enum class GetObjectsDepth {
};

/// \brief Helper to implement GetObjects.
///
/// Drivers can implement methods of the GetObjectsHelper in a driver-specific
/// class to get a compliant implementation of AdbcConnectionGetObjects().
struct GetObjectsHelper {
virtual ~GetObjectsHelper() = default;

Expand Down Expand Up @@ -136,5 +144,5 @@ Status BuildGetObjects(GetObjectsHelper* helper, GetObjectsDepth depth,
std::optional<std::string_view> table_filter,
std::optional<std::string_view> column_filter,
const std::vector<std::string_view>& table_types,
struct ArrowArrayStream* out);
ArrowArrayStream* out);
} // namespace adbc::driver
25 changes: 25 additions & 0 deletions c/driver/framework/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,34 @@

namespace adbc::driver {

/// \brief Create an ArrowArrayStream with zero batches from a given ArrowSchema.
/// \ingroup adbc-framework-catalog
///
/// This function takes ownership of schema; the caller is responsible for
/// releasing out.
void MakeEmptyStream(ArrowSchema* schema, ArrowArrayStream* out);

/// \brief Create an ArrowArrayStream from a given ArrowSchema and ArrowArray.
/// \ingroup adbc-framework-catalog
///
/// The resulting ArrowArrayStream will contain zero batches if the length of the
/// array is zero, or exactly one batch if the length of the array is non-zero.
/// This function takes ownership of schema and array; the caller is responsible for
/// releasing out.
void MakeArrayStream(ArrowSchema* schema, ArrowArray* array, ArrowArrayStream* out);

/// \brief Create an ArrowArrayStream representation of a vector of table types.
/// \ingroup adbc-framework-catalog
///
/// Create an ArrowArrayStream representation of an array of table types
/// that can be used to implement AdbcConnectionGetTableTypes(). The caller is responsible
/// for releasing out on success.
Status MakeTableTypesStream(const std::vector<std::string>& table_types,
ArrowArrayStream* out);

/// \brief Representation of a single item in an array to be returned
/// from AdbcConnectionGetInfo().
/// \ingroup adbc-framework-catalog
struct InfoValue {
uint32_t code;
std::variant<std::string, int64_t> value;
Expand All @@ -43,6 +64,10 @@ struct InfoValue {
InfoValue(uint32_t code, const char* value) : InfoValue(code, std::string(value)) {}
};

/// \brief Create an ArrowArrayStream to be returned from AdbcConnectionGetInfo().
/// \ingroup adbc-framework-catalog
///
/// The caller is responsible for releasing out on success.
Status MakeGetInfoStream(const std::vector<InfoValue>& infos, ArrowArrayStream* out);

} // namespace adbc::driver

0 comments on commit 88189f4

Please sign in to comment.