This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aafba7b
commit 6b91721
Showing
8 changed files
with
77 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use arrow2::bitmap::utils::fmt; | ||
|
||
struct A<'a>(&'a [u8], usize, usize); | ||
|
||
impl<'a> std::fmt::Debug for A<'a> { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
fmt(self.0, self.1, self.2, f) | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_debug() -> std::fmt::Result { | ||
assert_eq!(format!("{:?}", A(&[1], 0, 0)), "[]"); | ||
assert_eq!(format!("{:?}", A(&[0b11000001], 0, 8)), "[0b11000001]"); | ||
assert_eq!( | ||
format!("{:?}", A(&[0b11000001, 1], 0, 9)), | ||
"[0b11000001, 0b_______1]" | ||
); | ||
assert_eq!(format!("{:?}", A(&[1], 0, 2)), "[0b______01]"); | ||
assert_eq!(format!("{:?}", A(&[1], 1, 2)), "[0b_____00_]"); | ||
assert_eq!(format!("{:?}", A(&[1], 2, 2)), "[0b____00__]"); | ||
assert_eq!(format!("{:?}", A(&[1], 3, 2)), "[0b___00___]"); | ||
assert_eq!(format!("{:?}", A(&[1], 4, 2)), "[0b__00____]"); | ||
assert_eq!(format!("{:?}", A(&[1], 5, 2)), "[0b_00_____]"); | ||
assert_eq!(format!("{:?}", A(&[1], 6, 2)), "[0b00______]"); | ||
assert_eq!( | ||
format!("{:?}", A(&[0b11000001, 1], 1, 9)), | ||
"[0b1100000_, 0b______01]" | ||
); | ||
// extra bytes are ignored | ||
assert_eq!( | ||
format!("{:?}", A(&[0b11000001, 1, 1, 1], 1, 9)), | ||
"[0b1100000_, 0b______01]" | ||
); | ||
assert_eq!( | ||
format!("{:?}", A(&[0b11000001, 1, 1], 2, 16)), | ||
"[0b110000__, 0b00000001, 0b______01]" | ||
); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ mod buffer; | |
mod ffi; | ||
mod scalar; | ||
mod temporal_conversions; | ||
mod types; | ||
|
||
mod io; | ||
mod test_util; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use arrow2::types::{BitChunkIter, BitChunkOnes}; | ||
|
||
#[test] | ||
fn test_basic1() { | ||
let a = [0b00000001, 0b00010000]; // 0th and 13th entry | ||
let a = u16::from_ne_bytes(a); | ||
let iter = BitChunkIter::new(a, 16); | ||
let r = iter.collect::<Vec<_>>(); | ||
assert_eq!(r, (0..16).map(|x| x == 0 || x == 12).collect::<Vec<_>>(),); | ||
} | ||
|
||
#[test] | ||
fn test_ones() { | ||
let a = [0b00000001, 0b00010000]; // 0th and 13th entry | ||
let a = u16::from_ne_bytes(a); | ||
let mut iter = BitChunkOnes::new(a); | ||
assert_eq!(iter.size_hint(), (2, Some(2))); | ||
assert_eq!(iter.next(), Some(0)); | ||
assert_eq!(iter.next(), Some(12)); | ||
} |