andygrove commented on code in PR #2089:
URL: https://github.com/apache/datafusion-comet/pull/2089#discussion_r2261275165


##########
native/core/src/common/buffer.rs:
##########
@@ -291,6 +276,67 @@ mod tests {
     use super::*;
     use arrow::buffer::Buffer as ArrowBuffer;
 
+    impl CometBuffer {
+        pub fn from_ptr(
+            ptr: *const u8,
+            len: usize,
+            capacity: usize,
+        ) -> Result<Self, ExecutionError> {
+            if capacity % ALIGNMENT != 0 {
+                return Err(ExecutionError::GeneralError(format!(
+                    "input buffer is not aligned to {ALIGNMENT} bytes"
+                )));
+            }
+            if ptr.is_null() {
+                return Err(ExecutionError::GeneralError(
+                    "cannot create CometBuffer from null pointer".to_string(),
+                ));
+            }
+            Ok(Self {
+                data: NonNull::new(ptr as *mut u8).unwrap(),
+                len,
+                capacity,
+                owned: false,
+                allocation: Arc::new(CometBufferAllocation::new()),
+            })
+        }
+
+        /// Extends this buffer (must be an owned buffer) by appending bytes 
from `src`,
+        /// starting from `offset`.
+        pub fn extend_from_slice(
+            &mut self,
+            offset: usize,
+            src: &[u8],
+        ) -> Result<(), ExecutionError> {
+            if !self.owned {
+                return Err(ExecutionError::GeneralError(
+                    "cannot modify un-owned buffer".to_string(),
+                ));
+            }
+
+            // TODO this implementation does not seem complete or correct but 
this code is
+            // only used in the unit tests in this module, so it probably 
doesn't matter

Review Comment:
   I added these comments



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to