-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alex Chi <[email protected]>
- Loading branch information
Showing
10 changed files
with
265 additions
and
64 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
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,25 @@ | ||
use anyhow::anyhow; | ||
use bytes::{Buf, BufMut}; | ||
|
||
use super::StorageResult; | ||
use crate::array::{Array, ArrayBuilder, I32Array, I32ArrayBuilder}; | ||
|
||
/// Encode an `I32Array` into a `Vec<u8>`. | ||
pub fn encode_int32_column(a: &I32Array, mut buffer: impl BufMut) -> StorageResult<()> { | ||
for item in a.iter() { | ||
if let Some(item) = item { | ||
buffer.put_i32_le(*item); | ||
} else { | ||
return Err(anyhow!("nullable encoding not supported!").into()); | ||
} | ||
} | ||
Ok(()) | ||
} | ||
|
||
pub fn decode_int32_column(mut data: impl Buf) -> StorageResult<I32Array> { | ||
let mut builder = I32ArrayBuilder::with_capacity(data.remaining() / 4); | ||
while data.has_remaining() { | ||
builder.push(Some(&data.get_i32_le())); | ||
} | ||
Ok(builder.finish()) | ||
} |
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
Oops, something went wrong.