You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/18 11:26:31 UTC

[GitHub] [arrow-rs] Ted-Jiang commented on a diff in pull request #2097: Support skip_values in DictionaryDecoder

Ted-Jiang commented on code in PR #2097:
URL: https://github.com/apache/arrow-rs/pull/2097#discussion_r923253992


##########
parquet/src/arrow/array_reader/byte_array_dictionary.rs:
##########
@@ -459,7 +481,75 @@ mod tests {
                 None,
                 Some("1"),
                 Some("2"),
-                None
+                None,
+            ]
+        )
+    }
+
+    #[test]
+    fn test_dictionary_preservation_skip() {
+        let data_type = utf8_dictionary();
+
+        let data: Vec<_> = vec!["0", "1", "0", "1", "2", "1", "2"]
+            .into_iter()
+            .map(ByteArray::from)
+            .collect();
+        let (dict, encoded) = encode_dictionary(&data);
+
+        let column_desc = utf8_column();
+        let mut decoder = DictionaryDecoder::<i32, i32>::new(&column_desc);
+
+        decoder
+            .set_dict(dict, 3, Encoding::RLE_DICTIONARY, false)
+            .unwrap();
+
+        decoder
+            .set_data(Encoding::RLE_DICTIONARY, encoded, 14, Some(data.len()))
+            .unwrap();
+
+        let mut output = DictionaryBuffer::<i32, i32>::default();
+        assert_eq!(decoder.skip_values(1).unwrap(), 1);
+        assert_eq!(decoder.read(&mut output, 0..2).unwrap(), 2);
+
+        let mut valid = vec![false, false, false, true, false, true];
+        let valid_buffer = Buffer::from_iter(valid.iter().cloned());
+        output.pad_nulls(0, 2, valid.len(), valid_buffer.as_slice());
+
+        assert!(matches!(output, DictionaryBuffer::Dict { .. }));
+
+        assert_eq!(decoder.skip_values(1).unwrap(), 1);
+        assert_eq!(decoder.read(&mut output, 0..3).unwrap(), 3);

Review Comment:
   @tustvold  Like you metion in https://github.com/apache/arrow-rs/pull/2076#discussion_r922306318
   If i try to use ` assert_eq!(decoder.read(&mut output, 3..6).unwrap(), 3);`
   
   The result is not right, also appear in `test_dictionary_preservation`
   i think we should align it.



-- 
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-unsubscribe@arrow.apache.org

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