|
| 1 | +use fastpfor::cpp; |
| 2 | +use fastpfor::rust; |
| 3 | + |
| 4 | +pub type BoxedCppCodec = Box<dyn cpp::Codec32>; |
| 5 | + |
| 6 | +#[derive(arbitrary::Arbitrary)] |
| 7 | +pub struct FuzzInput<C> { |
| 8 | + pub data: Vec<u32>, |
| 9 | + pub codec: C, |
| 10 | +} |
| 11 | + |
| 12 | +impl<C: std::fmt::Debug> std::fmt::Debug for FuzzInput<C> { |
| 13 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 14 | + f.debug_struct("FuzzInput<C>") |
| 15 | + .field("data_length", &self.data.len()) |
| 16 | + .field("codec", &self.codec) |
| 17 | + .finish() |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +#[derive(arbitrary::Arbitrary, Clone, Copy, PartialEq, Eq, Debug)] |
| 22 | +pub enum RustCodec { |
| 23 | + FastPFOR256, |
| 24 | + FastPFOR128, |
| 25 | + VariableByte, |
| 26 | + JustCopy, |
| 27 | +} |
| 28 | + |
| 29 | +impl From<RustCodec> for rust::Codec { |
| 30 | + fn from(codec: RustCodec) -> Self { |
| 31 | + use rust::*; |
| 32 | + match codec { |
| 33 | + RustCodec::FastPFOR256 => Codec::from(FastPFOR::new(DEFAULT_PAGE_SIZE, BLOCK_SIZE_256)), |
| 34 | + RustCodec::FastPFOR128 => Codec::from(FastPFOR::new(DEFAULT_PAGE_SIZE, BLOCK_SIZE_128)), |
| 35 | + RustCodec::VariableByte => Codec::from(VariableByte::new()), |
| 36 | + RustCodec::JustCopy => Codec::from(JustCopy::new()), |
| 37 | + } |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +#[derive(Clone, Copy, Eq, PartialEq, arbitrary::Arbitrary, Debug)] |
| 42 | +pub enum CppCodec { |
| 43 | + BP32, |
| 44 | + Copy, |
| 45 | + FastBinaryPacking8, |
| 46 | + FastPFor128, |
| 47 | + FastPFor256, |
| 48 | + FastBinaryPacking16, |
| 49 | + FastBinaryPacking32, |
| 50 | + MaskedVByte, |
| 51 | + NewPFor, |
| 52 | + OptPFor, |
| 53 | + PFor2008, |
| 54 | + PFor, |
| 55 | + SimdBinaryPacking, |
| 56 | + SimdFastPFor128, |
| 57 | + SimdFastPFor256, |
| 58 | + SimdGroupSimple, |
| 59 | + SimdGroupSimpleRingBuf, |
| 60 | + SimdNewPFor, |
| 61 | + SimdOptPFor, |
| 62 | + SimdPFor, |
| 63 | + SimdSimplePFor, |
| 64 | + // Simple16, // cannot encode arbitrary bytes |
| 65 | + // Simple8b, // cannot encode arbitrary bytes |
| 66 | + // Simple8bRle, // cannot encode arbitrary bytes |
| 67 | + // Simple9, // cannot encode arbitrary bytes |
| 68 | + // Simple9Rle, // cannot encode arbitrary bytes |
| 69 | + // SimplePFor, // cannot encode arbitrary bytes |
| 70 | + // Snappy, // Conditional with #ifdef |
| 71 | + StreamVByte, |
| 72 | + VByte, |
| 73 | + VarInt, |
| 74 | + // VarIntG8iu, // Conditional with #ifdef |
| 75 | + VarIntGb, |
| 76 | + // VsEncoding, // This is leaking memory |
| 77 | +} |
| 78 | + |
| 79 | +impl From<CppCodec> for BoxedCppCodec { |
| 80 | + fn from(codec: CppCodec) -> Self { |
| 81 | + use cpp::*; |
| 82 | + match codec { |
| 83 | + CppCodec::BP32 => Box::new(BP32Codec::default()), |
| 84 | + CppCodec::Copy => Box::new(CopyCodec::default()), |
| 85 | + CppCodec::FastBinaryPacking8 => Box::new(FastBinaryPacking8Codec::default()), |
| 86 | + CppCodec::FastPFor128 => Box::new(FastPFor128Codec::default()), |
| 87 | + CppCodec::FastPFor256 => Box::new(FastPFor256Codec::default()), |
| 88 | + CppCodec::FastBinaryPacking16 => Box::new(FastBinaryPacking16Codec::default()), |
| 89 | + CppCodec::FastBinaryPacking32 => Box::new(FastBinaryPacking32Codec::default()), |
| 90 | + CppCodec::MaskedVByte => Box::new(MaskedVByteCodec::default()), |
| 91 | + CppCodec::NewPFor => Box::new(NewPForCodec::default()), |
| 92 | + CppCodec::OptPFor => Box::new(OptPForCodec::default()), |
| 93 | + CppCodec::PFor2008 => Box::new(PFor2008Codec::default()), |
| 94 | + CppCodec::PFor => Box::new(PForCodec::default()), |
| 95 | + CppCodec::SimdBinaryPacking => Box::new(SimdBinaryPackingCodec::default()), |
| 96 | + CppCodec::SimdFastPFor128 => Box::new(SimdFastPFor128Codec::default()), |
| 97 | + CppCodec::SimdFastPFor256 => Box::new(SimdFastPFor256Codec::default()), |
| 98 | + CppCodec::SimdGroupSimple => Box::new(SimdGroupSimpleCodec::default()), |
| 99 | + CppCodec::SimdGroupSimpleRingBuf => Box::new(SimdGroupSimpleRingBufCodec::default()), |
| 100 | + CppCodec::SimdNewPFor => Box::new(SimdNewPForCodec::default()), |
| 101 | + CppCodec::SimdOptPFor => Box::new(SimdOptPForCodec::default()), |
| 102 | + CppCodec::SimdPFor => Box::new(SimdPForCodec::default()), |
| 103 | + CppCodec::SimdSimplePFor => Box::new(SimdSimplePForCodec::default()), |
| 104 | + // CppCodec::Simple16 => Box::new(Simple16Codec::default()), |
| 105 | + // CppCodec::Simple8b => Box::new(Simple8bCodec::default()), |
| 106 | + // CppCodec::Simple8bRle => Box::new(Simple8bRleCodec::default()), |
| 107 | + // CppCodec::Simple9 => Box::new(Simple9Codec::default()), |
| 108 | + // CppCodec::Simple9Rle => Box::new(Simple9RleCodec::default()), |
| 109 | + // CppCodec::SimplePFor => Box::new(SimplePForCodec::default()), |
| 110 | + // CppCodec::Snappy => Box::new(SnappyCodec::default()), |
| 111 | + CppCodec::StreamVByte => Box::new(StreamVByteCodec::default()), |
| 112 | + CppCodec::VByte => Box::new(VByteCodec::default()), |
| 113 | + CppCodec::VarInt => Box::new(VarIntCodec::default()), |
| 114 | + // CppCodec::VarIntG8iu => Box::new(VarIntG8iuCodec::default()), |
| 115 | + CppCodec::VarIntGb => Box::new(VarIntGbCodec::default()), |
| 116 | + // CppCodec::VsEncoding => Box::new(VsEncodingCodec::default()), |
| 117 | + } |
| 118 | + } |
| 119 | +} |
0 commit comments