From 1d278628ad7c16f85484d5315a9e4651b7dc67c2 Mon Sep 17 00:00:00 2001 From: "Jorge C. Leitao" Date: Thu, 2 Dec 2021 19:34:37 +0000 Subject: [PATCH 1/2] Invalidate caches from CI. --- .github/workflows/security.yml | 2 ++ .github/workflows/test.yml | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 6da87c38ea1..d40dea14b86 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -25,6 +25,8 @@ jobs: toolchain: nightly-2021-10-24 override: true - uses: Swatinem/rust-cache@v1 + with: + key: key1 - name: Install Miri run: | rustup component add miri diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 43300789307..1dd6d1aaa9e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,6 +77,8 @@ jobs: toolchain: nightly-2021-10-24 override: true - uses: Swatinem/rust-cache@v1 + with: + key: key1 - name: Install Miri run: | rustup component add miri @@ -96,6 +98,8 @@ jobs: toolchain: nightly-2021-10-24 override: true - uses: Swatinem/rust-cache@v1 + with: + key: key1 - name: Install Miri run: | rustup component add miri From 6e7c5cf0f56579d08da7d8359e592cce7c733444 Mon Sep 17 00:00:00 2001 From: "Jorge C. Leitao" Date: Thu, 2 Dec 2021 19:31:10 +0000 Subject: [PATCH 2/2] Avoid utf8 checks on MutableUtf8 -> Utf8 --- src/array/utf8/mutable.rs | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/array/utf8/mutable.rs b/src/array/utf8/mutable.rs index 4d33a3ef7af..6a269a88761 100644 --- a/src/array/utf8/mutable.rs +++ b/src/array/utf8/mutable.rs @@ -201,21 +201,31 @@ impl MutableArray for MutableUtf8Array { } fn as_box(&mut self) -> Box { - Box::new(Utf8Array::from_data( - Self::default_data_type(), - std::mem::take(&mut self.offsets).into(), - std::mem::take(&mut self.values).into(), - std::mem::take(&mut self.validity).map(|x| x.into()), - )) + // Safety: + // `MutableUtf8Array` has the same invariants as `Utf8Array` and thus + // `Utf8Array` can be safely created from `MutableUtf8Array` without checks. + Box::new(unsafe { + Utf8Array::from_data_unchecked( + self.data_type.clone(), + std::mem::take(&mut self.offsets).into(), + std::mem::take(&mut self.values).into(), + std::mem::take(&mut self.validity).map(|x| x.into()), + ) + }) } fn as_arc(&mut self) -> Arc { - Arc::new(Utf8Array::from_data( - Self::default_data_type(), - std::mem::take(&mut self.offsets).into(), - std::mem::take(&mut self.values).into(), - std::mem::take(&mut self.validity).map(|x| x.into()), - )) + // Safety: + // `MutableUtf8Array` has the same invariants as `Utf8Array` and thus + // `Utf8Array` can be safely created from `MutableUtf8Array` without checks. + Arc::new(unsafe { + Utf8Array::from_data_unchecked( + self.data_type.clone(), + std::mem::take(&mut self.offsets).into(), + std::mem::take(&mut self.values).into(), + std::mem::take(&mut self.validity).map(|x| x.into()), + ) + }) } fn data_type(&self) -> &DataType { @@ -359,7 +369,7 @@ impl MutableUtf8Array { Self::from_data_unchecked(Self::default_data_type(), offsets, values, None) } - /// Creates a new [`Utf8Array`] from a [`TrustedLen`] of `&str`. + /// Creates a new [`MutableUtf8Array`] from a [`TrustedLen`] of `&str`. #[inline] pub fn from_trusted_len_values_iter, I: TrustedLen>( iterator: I,