Skip to content

Commit

Permalink
chore(go): fix up minor Go things in 1.1.0 draft (#926)
Browse files Browse the repository at this point in the history
  • Loading branch information
lidavidm authored Jul 21, 2023
1 parent d501092 commit a06e53a
Show file tree
Hide file tree
Showing 12 changed files with 901 additions and 275 deletions.
32 changes: 16 additions & 16 deletions adbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ AdbcStatusCode AdbcDatabaseGetOptionBytes(struct AdbcDatabase* database, const c
uint8_t* value, size_t* length,
struct AdbcError* error);

/// \brief Get an integer option of the database.
/// \brief Get a double option of the database.
///
/// This must always be thread-safe (other operations are not).
///
Expand All @@ -1075,8 +1075,8 @@ AdbcStatusCode AdbcDatabaseGetOptionBytes(struct AdbcDatabase* database, const c
/// the type specified in the option. (For example, an option set via
/// SetOptionDouble must be retrievable via GetOptionDouble.) Drivers
/// may also support getting a converted option value via other
/// getters if needed. (For example, getting the integer
/// representation of a double option.)
/// getters if needed. (For example, getting the double
/// representation of an integer option.)
///
/// \since ADBC API revision 1.1.0
/// \addtogroup adbc-1.1.0
Expand All @@ -1086,10 +1086,10 @@ AdbcStatusCode AdbcDatabaseGetOptionBytes(struct AdbcDatabase* database, const c
/// \param[out] error An optional location to return an error
/// message if necessary.
/// \return ADBC_STATUS_NOT_FOUND if the option is not recognized.
AdbcStatusCode AdbcDatabaseGetOptionInt(struct AdbcDatabase* database, const char* key,
int64_t* value, struct AdbcError* error);
AdbcStatusCode AdbcDatabaseGetOptionDouble(struct AdbcDatabase* database, const char* key,
double* value, struct AdbcError* error);

/// \brief Get a double option of the database.
/// \brief Get an integer option of the database.
///
/// This must always be thread-safe (other operations are not).
///
Expand All @@ -1098,8 +1098,8 @@ AdbcStatusCode AdbcDatabaseGetOptionInt(struct AdbcDatabase* database, const cha
/// the type specified in the option. (For example, an option set via
/// SetOptionDouble must be retrievable via GetOptionDouble.) Drivers
/// may also support getting a converted option value via other
/// getters if needed. (For example, getting the double
/// representation of an integer option.)
/// getters if needed. (For example, getting the integer
/// representation of a double option.)
///
/// \since ADBC API revision 1.1.0
/// \addtogroup adbc-1.1.0
Expand All @@ -1109,8 +1109,8 @@ AdbcStatusCode AdbcDatabaseGetOptionInt(struct AdbcDatabase* database, const cha
/// \param[out] error An optional location to return an error
/// message if necessary.
/// \return ADBC_STATUS_NOT_FOUND if the option is not recognized.
AdbcStatusCode AdbcDatabaseGetOptionDouble(struct AdbcDatabase* database, const char* key,
double* value, struct AdbcError* error);
AdbcStatusCode AdbcDatabaseGetOptionInt(struct AdbcDatabase* database, const char* key,
int64_t* value, struct AdbcError* error);

/// \brief Set a char* option.
///
Expand Down Expand Up @@ -1143,7 +1143,7 @@ AdbcStatusCode AdbcDatabaseSetOptionBytes(struct AdbcDatabase* database, const c
const uint8_t* value, size_t length,
struct AdbcError* error);

/// \brief Set an integer option on a database.
/// \brief Set a double option on a database.
///
/// \since ADBC API revision 1.1.0
/// \addtogroup adbc-1.1.0
Expand All @@ -1154,10 +1154,10 @@ AdbcStatusCode AdbcDatabaseSetOptionBytes(struct AdbcDatabase* database, const c
/// message if necessary.
/// \return ADBC_STATUS_NOT_IMPLEMENTED if the option is not recognized
ADBC_EXPORT
AdbcStatusCode AdbcDatabaseSetOptionInt(struct AdbcDatabase* database, const char* key,
int64_t value, struct AdbcError* error);
AdbcStatusCode AdbcDatabaseSetOptionDouble(struct AdbcDatabase* database, const char* key,
double value, struct AdbcError* error);

/// \brief Set a double option on a database.
/// \brief Set an integer option on a database.
///
/// \since ADBC API revision 1.1.0
/// \addtogroup adbc-1.1.0
Expand All @@ -1168,8 +1168,8 @@ AdbcStatusCode AdbcDatabaseSetOptionInt(struct AdbcDatabase* database, const cha
/// message if necessary.
/// \return ADBC_STATUS_NOT_IMPLEMENTED if the option is not recognized
ADBC_EXPORT
AdbcStatusCode AdbcDatabaseSetOptionDouble(struct AdbcDatabase* database, const char* key,
double value, struct AdbcError* error);
AdbcStatusCode AdbcDatabaseSetOptionInt(struct AdbcDatabase* database, const char* key,
int64_t value, struct AdbcError* error);

/// \brief Finish setting options and initialize the database.
///
Expand Down
7 changes: 4 additions & 3 deletions go/adbc/driver/flightsql/record_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ func newRecordReader(ctx context.Context, alloc memory.Allocator, cl *flightsql.
Code: adbc.StatusInvalidState}
}
} else {
rdr, err := doGet(ctx, cl, endpoints[0], clCache, opts...)
firstEndpoint := endpoints[0]
rdr, err := doGet(ctx, cl, firstEndpoint, clCache, opts...)
if err != nil {
return nil, adbcFromFlightStatus(err, "DoGet: endpoint 0: remote: %s", endpoints[0].Location)
return nil, adbcFromFlightStatus(err, "DoGet: endpoint 0: remote: %s", firstEndpoint.Location)
}
schema = rdr.Schema()
group.Go(func() error {
Expand All @@ -104,7 +105,7 @@ func newRecordReader(ctx context.Context, alloc memory.Allocator, cl *flightsql.
rec.Retain()
ch <- rec
}
return adbcFromFlightStatus(rdr.Err(), "DoGet: endpoint 0: remote: %s", endpoints[0].Location)
return adbcFromFlightStatus(rdr.Err(), "DoGet: endpoint 0: remote: %s", firstEndpoint.Location)
})

endpoints = endpoints[1:]
Expand Down
4 changes: 2 additions & 2 deletions go/adbc/driver/flightsql/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ func adbcFromFlightStatus(err error, context string, args ...any) error {
}

return adbc.Error{
Msg: fmt.Sprintf("[FlightSQL] %s (%s; %s)", grpcStatus.Message(), grpcStatus.Code(), fmt.Sprintf(context, args...)),
Code: adbcCode,
Msg: fmt.Sprintf("[FlightSQL] %s (%s; %s)", grpcStatus.Message(), grpcStatus.Code(), fmt.Sprintf(context, args...)),
Code: adbcCode,
Details: details,
}
}
32 changes: 16 additions & 16 deletions go/adbc/drivermgr/adbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ AdbcStatusCode AdbcDatabaseGetOptionBytes(struct AdbcDatabase* database, const c
uint8_t* value, size_t* length,
struct AdbcError* error);

/// \brief Get an integer option of the database.
/// \brief Get a double option of the database.
///
/// This must always be thread-safe (other operations are not).
///
Expand All @@ -1075,8 +1075,8 @@ AdbcStatusCode AdbcDatabaseGetOptionBytes(struct AdbcDatabase* database, const c
/// the type specified in the option. (For example, an option set via
/// SetOptionDouble must be retrievable via GetOptionDouble.) Drivers
/// may also support getting a converted option value via other
/// getters if needed. (For example, getting the integer
/// representation of a double option.)
/// getters if needed. (For example, getting the double
/// representation of an integer option.)
///
/// \since ADBC API revision 1.1.0
/// \addtogroup adbc-1.1.0
Expand All @@ -1086,10 +1086,10 @@ AdbcStatusCode AdbcDatabaseGetOptionBytes(struct AdbcDatabase* database, const c
/// \param[out] error An optional location to return an error
/// message if necessary.
/// \return ADBC_STATUS_NOT_FOUND if the option is not recognized.
AdbcStatusCode AdbcDatabaseGetOptionInt(struct AdbcDatabase* database, const char* key,
int64_t* value, struct AdbcError* error);
AdbcStatusCode AdbcDatabaseGetOptionDouble(struct AdbcDatabase* database, const char* key,
double* value, struct AdbcError* error);

/// \brief Get a double option of the database.
/// \brief Get an integer option of the database.
///
/// This must always be thread-safe (other operations are not).
///
Expand All @@ -1098,8 +1098,8 @@ AdbcStatusCode AdbcDatabaseGetOptionInt(struct AdbcDatabase* database, const cha
/// the type specified in the option. (For example, an option set via
/// SetOptionDouble must be retrievable via GetOptionDouble.) Drivers
/// may also support getting a converted option value via other
/// getters if needed. (For example, getting the double
/// representation of an integer option.)
/// getters if needed. (For example, getting the integer
/// representation of a double option.)
///
/// \since ADBC API revision 1.1.0
/// \addtogroup adbc-1.1.0
Expand All @@ -1109,8 +1109,8 @@ AdbcStatusCode AdbcDatabaseGetOptionInt(struct AdbcDatabase* database, const cha
/// \param[out] error An optional location to return an error
/// message if necessary.
/// \return ADBC_STATUS_NOT_FOUND if the option is not recognized.
AdbcStatusCode AdbcDatabaseGetOptionDouble(struct AdbcDatabase* database, const char* key,
double* value, struct AdbcError* error);
AdbcStatusCode AdbcDatabaseGetOptionInt(struct AdbcDatabase* database, const char* key,
int64_t* value, struct AdbcError* error);

/// \brief Set a char* option.
///
Expand Down Expand Up @@ -1143,7 +1143,7 @@ AdbcStatusCode AdbcDatabaseSetOptionBytes(struct AdbcDatabase* database, const c
const uint8_t* value, size_t length,
struct AdbcError* error);

/// \brief Set an integer option on a database.
/// \brief Set a double option on a database.
///
/// \since ADBC API revision 1.1.0
/// \addtogroup adbc-1.1.0
Expand All @@ -1154,10 +1154,10 @@ AdbcStatusCode AdbcDatabaseSetOptionBytes(struct AdbcDatabase* database, const c
/// message if necessary.
/// \return ADBC_STATUS_NOT_IMPLEMENTED if the option is not recognized
ADBC_EXPORT
AdbcStatusCode AdbcDatabaseSetOptionInt(struct AdbcDatabase* database, const char* key,
int64_t value, struct AdbcError* error);
AdbcStatusCode AdbcDatabaseSetOptionDouble(struct AdbcDatabase* database, const char* key,
double value, struct AdbcError* error);

/// \brief Set a double option on a database.
/// \brief Set an integer option on a database.
///
/// \since ADBC API revision 1.1.0
/// \addtogroup adbc-1.1.0
Expand All @@ -1168,8 +1168,8 @@ AdbcStatusCode AdbcDatabaseSetOptionInt(struct AdbcDatabase* database, const cha
/// message if necessary.
/// \return ADBC_STATUS_NOT_IMPLEMENTED if the option is not recognized
ADBC_EXPORT
AdbcStatusCode AdbcDatabaseSetOptionDouble(struct AdbcDatabase* database, const char* key,
double value, struct AdbcError* error);
AdbcStatusCode AdbcDatabaseSetOptionInt(struct AdbcDatabase* database, const char* key,
int64_t value, struct AdbcError* error);

/// \brief Finish setting options and initialize the database.
///
Expand Down
2 changes: 2 additions & 0 deletions go/adbc/pkg/_tmpl/driver.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,7 @@ func {{.Prefix}}ConnectionGetObjects(cnxn *C.struct_AdbcConnection, depth C.int,
if e != nil {
return C.AdbcStatusCode(conn.errToAdbcErr(err, e))
}
defer rdr.Release()
cdata.ExportRecordReader(rdr, toCdataStream(out))
return C.ADBC_STATUS_OK
}
Expand Down Expand Up @@ -1024,6 +1025,7 @@ func {{.Prefix}}ConnectionGetStatistics(cnxn *C.struct_AdbcConnection, catalog,
return C.AdbcStatusCode(conn.errToAdbcErr(err, e))
}

defer rdr.Release()
cdata.ExportRecordReader(rdr, toCdataStream(out))
return C.ADBC_STATUS_OK
}
Expand Down
Loading

0 comments on commit a06e53a

Please sign in to comment.