From 3846719b53933e3bf31d0843ace6ca43e7e6f92c Mon Sep 17 00:00:00 2001 From: Ziyang Hu Date: Sat, 30 Jul 2022 18:05:59 +0800 Subject: [PATCH] fix tuple encoding problem --- src/data/tuple.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/data/tuple.rs b/src/data/tuple.rs index a9b5b51f..7ecc1c28 100644 --- a/src/data/tuple.rs +++ b/src/data/tuple.rs @@ -1,4 +1,4 @@ -use std::cmp::{min, Ordering}; +use std::cmp::{max, min, Ordering}; use std::fmt::{Debug, Formatter}; use anyhow::Result; @@ -57,7 +57,7 @@ impl Tuple { epoch_bytes[3], ]); ret.extend((len as u16).to_be_bytes()); - ret.resize(4 * (len + 1), 0); + ret.resize(max(6, 4 * (len + 1)), 0); for (idx, val) in self.0.iter().enumerate() { if idx > 0 { let pos = (ret.len() as u32).to_be_bytes(); @@ -166,7 +166,7 @@ impl<'a> EncodedTuple<'a> { }; rmp_serde::from_slice(&self.0[pos..]).unwrap() } - pub(crate) fn get(&self, idx: usize) -> anyhow::Result { + pub(crate) fn get(&self, idx: usize) -> Result { let pos = if idx == 0 { 4 * (self.arity()? + 1) } else { @@ -209,7 +209,7 @@ pub(crate) struct EncodedTupleIter<'a> { } impl<'a> Iterator for EncodedTupleIter<'a> { - type Item = anyhow::Result; + type Item = Result; fn next(&mut self) -> Option { if self.size == 0 {