Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into treemap-select-none
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Feb 13, 2024
2 parents 0cc06e8 + a2aa2a5 commit 678356f
Show file tree
Hide file tree
Showing 36 changed files with 170 additions and 129 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- stable
- beta
- nightly
- 1.65.0
- 1.66.0
env:
RUSTFLAGS: "-C target-cpu=native -C opt-level=3"
ROARINGRS_BENCH_OFFLINE: "true"
Expand Down
13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]
bytemuck = "1.7.3"
byteorder = "1.4.3"
serde = { version = "1.0.139", optional = true }
bytemuck = { version = "1.14.3", optional = true }
byteorder = { version = "1.5.0", optional = true }
serde = { version = "1.0.196", optional = true }

[features]
default = ["std"]
serde = ["dep:serde", "std"]
simd = []
std = ["dep:bytemuck", "dep:byteorder"]

[dev-dependencies]
proptest = "1.2.0"
serde_json = "1.0.85"
proptest = "1.4.0"
serde_json = "1.0.113"
bincode = "1.3.3"

[profile.test]
Expand Down
10 changes: 6 additions & 4 deletions src/bitmap/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ mod test {
use crate::bitmap::container::Container;
use crate::bitmap::store::{ArrayStore, BitmapStore, Store};
use crate::RoaringBitmap;
use alloc::boxed::Box;
use alloc::vec::Vec;
use core::fmt::{Debug, Formatter};
use proptest::bits::{BitSetLike, BitSetStrategy, SampledBitSetStrategy};
use proptest::collection::{vec, SizeRange};
use proptest::prelude::*;
use std::fmt::{Debug, Formatter};

impl Debug for BitmapStore {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
if self.len() < 16 {
write!(f, "BitmapStore<{:?}>", self.iter().collect::<Vec<u16>>())
} else {
Expand Down Expand Up @@ -82,7 +84,7 @@ mod test {
}

impl Debug for ArrayStore {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
if self.len() < 16 {
write!(f, "ArrayStore<{:?}>", self.as_slice())
} else {
Expand Down Expand Up @@ -151,7 +153,7 @@ mod test {
}

impl Debug for Store {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self {
Store::Array(a) => write!(f, "Store({:?})", a),
Store::Bitmap(b) => write!(f, "Store({:?})", b),
Expand Down
6 changes: 3 additions & 3 deletions src/bitmap/cmp.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::borrow::Borrow;
use std::cmp::Ordering;
use std::iter::Peekable;
use core::borrow::Borrow;
use core::cmp::Ordering;
use core::iter::Peekable;

use super::container::Container;
use crate::RoaringBitmap;
Expand Down
6 changes: 4 additions & 2 deletions src/bitmap/container.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use std::fmt;
use std::ops::{
use core::fmt;
use core::ops::{
BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, RangeInclusive, Sub, SubAssign,
};

use alloc::vec::Vec;

use super::store::{self, Store};
use super::util;

Expand Down
4 changes: 3 additions & 1 deletion src/bitmap/fmt.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::fmt;
use core::fmt;

use alloc::vec::Vec;

use crate::RoaringBitmap;

Expand Down
6 changes: 4 additions & 2 deletions src/bitmap/inherent.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::cmp::Ordering;
use std::ops::RangeBounds;
use core::cmp::Ordering;
use core::ops::RangeBounds;

use alloc::vec::Vec;

use crate::RoaringBitmap;

Expand Down
7 changes: 4 additions & 3 deletions src/bitmap/iter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::iter::{self, FromIterator};
use std::{slice, vec};
use alloc::vec::{self, Vec};
use core::iter::{self, FromIterator};
use core::slice;

use super::container::Container;
use crate::{NonSortedIntegers, RoaringBitmap};
Expand Down Expand Up @@ -99,7 +100,7 @@ impl RoaringBitmap {
///
/// ```rust
/// use roaring::RoaringBitmap;
/// use std::iter::FromIterator;
/// use core::iter::FromIterator;
///
/// let bitmap = (1..3).collect::<RoaringBitmap>();
/// let mut iter = bitmap.iter();
Expand Down
3 changes: 3 additions & 0 deletions src/bitmap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ mod iter;
mod ops;
#[cfg(feature = "serde")]
mod serde;
#[cfg(feature = "std")]
mod serialization;

use alloc::vec::Vec;

use self::cmp::Pairs;
pub use self::iter::IntoIter;
pub use self::iter::Iter;
Expand Down
5 changes: 3 additions & 2 deletions src/bitmap/multiops.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::{
borrow::Cow,
use core::{
cmp::Reverse,
convert::Infallible,
mem,
ops::{BitOrAssign, BitXorAssign},
};

use alloc::{borrow::Cow, vec::Vec};

use crate::{MultiOps, RoaringBitmap};

use super::{container::Container, store::Store};
Expand Down
8 changes: 5 additions & 3 deletions src/bitmap/ops.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::mem;
use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Sub, SubAssign};
use core::mem;
use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Sub, SubAssign};

use alloc::vec::Vec;

use crate::bitmap::container::Container;
use crate::bitmap::Pairs;
Expand Down Expand Up @@ -440,8 +442,8 @@ impl BitXorAssign<&RoaringBitmap> for RoaringBitmap {
#[cfg(test)]
mod test {
use crate::{MultiOps, RoaringBitmap};
use core::convert::Infallible;
use proptest::prelude::*;
use std::convert::Infallible;

// fast count tests
proptest! {
Expand Down
2 changes: 1 addition & 1 deletion src/bitmap/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl<'de> Deserialize<'de> for RoaringBitmap {
impl<'de> Visitor<'de> for BitmapVisitor {
type Value = RoaringBitmap;

fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result {
formatter.write_str("roaring bitmap")
}

Expand Down
4 changes: 2 additions & 2 deletions src/bitmap/serialization.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use bytemuck::cast_slice_mut;
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use std::convert::{Infallible, TryFrom};
use core::convert::{Infallible, TryFrom};
use core::ops::RangeInclusive;
use std::error::Error;
use std::io;
use std::ops::RangeInclusive;

use crate::bitmap::container::{Container, ARRAY_LIMIT};
use crate::bitmap::store::{ArrayStore, BitmapStore, Store, BITMAP_LENGTH};
Expand Down
20 changes: 12 additions & 8 deletions src/bitmap/store/array_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ mod scalar;
mod vector;
mod visitor;

use alloc::boxed::Box;
use alloc::vec::Vec;

use crate::bitmap::store::array_store::visitor::{CardinalityCounter, VecWriter};
use std::cmp::Ordering;
use std::cmp::Ordering::*;
use std::convert::{TryFrom, TryInto};
use std::fmt::{Display, Formatter};
use std::ops::{BitAnd, BitAndAssign, BitOr, BitXor, RangeInclusive, Sub, SubAssign};
use core::cmp::Ordering;
use core::cmp::Ordering::*;
use core::convert::TryFrom;
use core::fmt::{Display, Formatter};
use core::ops::{BitAnd, BitAndAssign, BitOr, BitXor, RangeInclusive, Sub, SubAssign};

use super::bitmap_store::{bit, key, BitmapStore, BITMAP_LENGTH};

Expand Down Expand Up @@ -214,11 +217,11 @@ impl ArrayStore {
self.vec.get(n as usize).cloned()
}

pub fn iter(&self) -> std::slice::Iter<u16> {
pub fn iter(&self) -> core::slice::Iter<u16> {
self.vec.iter()
}

pub fn into_iter(self) -> std::vec::IntoIter<u16> {
pub fn into_iter(self) -> alloc::vec::IntoIter<u16> {
self.vec.into_iter()
}

Expand Down Expand Up @@ -263,7 +266,7 @@ pub enum ErrorKind {
}

impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self.kind {
ErrorKind::Duplicate => {
write!(f, "Duplicate element found at index: {}", self.index)
Expand All @@ -275,6 +278,7 @@ impl Display for Error {
}
}

#[cfg(feature = "std")]
impl std::error::Error for Error {}

impl TryFrom<Vec<u16>> for ArrayStore {
Expand Down
2 changes: 1 addition & 1 deletion src/bitmap/store/array_store/scalar.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Scalar arithmetic binary set operations on `ArrayStore`'s inner types
use crate::bitmap::store::array_store::visitor::BinaryOperationVisitor;
use std::cmp::Ordering::*;
use core::cmp::Ordering::*;

#[inline]
pub fn or(lhs: &[u16], rhs: &[u16], visitor: &mut impl BinaryOperationVisitor) {
Expand Down
Loading

0 comments on commit 678356f

Please sign in to comment.