WillAyd commented on code in PR #1110:
URL: https://github.com/apache/arrow-adbc/pull/1110#discussion_r1339085863
##########
c/driver/postgresql/postgres_copy_reader.h:
##########
@@ -117,6 +117,53 @@ ArrowErrorCode ReadChecked(ArrowBufferView* data, T* out,
ArrowError* error) {
return NANOARROW_OK;
}
+// Write a value to a buffer without checking the buffer size. Advances
+// the cursor of buffer and reduces it by sizeof(T)
+template <typename T>
+inline void WriteUnsafe(ArrowBuffer* buffer, T in) {
+ const T value = SwapNetworkToHost(in);
+ memcpy(buffer->data, &value, sizeof(T));
+ buffer->data += sizeof(T);
+ buffer->size_bytes += sizeof(T);
+}
+
+template <>
+inline void WriteUnsafe(ArrowBuffer* buffer, int8_t in) {
+ buffer->data[0] = in;
+ buffer->data += sizeof(int8_t);
+ buffer->size_bytes += sizeof(int8_t);
+}
Review Comment:
The specializations exist because of the unsigned argument requirement
for`SwapNetworkToHost` requirement, although that makes me realize these are
incorrect as is
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]