You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by tu...@apache.org on 2022/12/16 13:54:42 UTC

[arrow-rs] branch master updated: Use ArrayData::ptr_eq in DictionaryTracker (#3354)

This is an automated email from the ASF dual-hosted git repository.

tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 309cf5cd2 Use ArrayData::ptr_eq in DictionaryTracker (#3354)
309cf5cd2 is described below

commit 309cf5cd299dbf91235b60876e092c1af3990b84
Author: Raphael Taylor-Davies <17...@users.noreply.github.com>
AuthorDate: Fri Dec 16 13:54:37 2022 +0000

    Use ArrayData::ptr_eq in DictionaryTracker (#3354)
    
    * Use ArrayData::ptr_eq in DictionaryTracker
    
    * Fallback to logical comparison if error_on_replacement
---
 arrow-ipc/src/writer.rs | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arrow-ipc/src/writer.rs b/arrow-ipc/src/writer.rs
index c407cd12c..006660b6a 100644
--- a/arrow-ipc/src/writer.rs
+++ b/arrow-ipc/src/writer.rs
@@ -537,10 +537,16 @@ impl DictionaryTracker {
 
         // If a dictionary with this id was already emitted, check if it was the same.
         if let Some(last) = self.written.get(&dict_id) {
-            if last.data().child_data()[0] == *dict_values {
+            if ArrayData::ptr_eq(&last.data().child_data()[0], dict_values) {
                 // Same dictionary values => no need to emit it again
                 return Ok(false);
-            } else if self.error_on_replacement {
+            }
+            if self.error_on_replacement {
+                // If error on replacement perform a logical comparison
+                if last.data().child_data()[0] == *dict_values {
+                    // Same dictionary values => no need to emit it again
+                    return Ok(false);
+                }
                 return Err(ArrowError::InvalidArgumentError(
                     "Dictionary replacement detected when writing IPC file format. \
                      Arrow IPC files only support a single dictionary for a given field \