|
|
@ -28,10 +28,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
use crate::corestore::heap_array::HeapArray;
|
|
|
|
use crate::corestore::heap_array::HeapArray;
|
|
|
|
use crate::protocol::{ParseError, ParseResult, UnsafeSlice};
|
|
|
|
use crate::protocol::{ParseError, ParseResult, UnsafeSlice};
|
|
|
|
use core::marker::PhantomData;
|
|
|
|
use core::{marker::PhantomData, mem::transmute};
|
|
|
|
#[cfg(test)]
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests;
|
|
|
|
mod tests;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Query {
|
|
|
|
pub struct Query {
|
|
|
|
forward: usize,
|
|
|
|
forward: usize,
|
|
|
|
data: QueryType,
|
|
|
|
data: QueryType,
|
|
|
@ -43,11 +44,13 @@ impl Query {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum QueryType {
|
|
|
|
pub enum QueryType {
|
|
|
|
Simple(SimpleQuery),
|
|
|
|
Simple(SimpleQuery),
|
|
|
|
Pipelined(PipelinedQuery),
|
|
|
|
Pipelined(PipelinedQuery),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct SimpleQuery {
|
|
|
|
pub struct SimpleQuery {
|
|
|
|
data: HeapArray<UnsafeSlice>,
|
|
|
|
data: HeapArray<UnsafeSlice>,
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -70,6 +73,7 @@ struct OwnedSimpleQuery {
|
|
|
|
data: Vec<Vec<u8>>,
|
|
|
|
data: Vec<Vec<u8>>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct PipelinedQuery {
|
|
|
|
pub struct PipelinedQuery {
|
|
|
|
data: HeapArray<HeapArray<UnsafeSlice>>,
|
|
|
|
data: HeapArray<HeapArray<UnsafeSlice>>,
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -207,7 +211,7 @@ impl<'a> Parser<'a> {
|
|
|
|
Ok(UnsafeSlice::new(start_ptr, len))
|
|
|
|
Ok(UnsafeSlice::new(start_ptr, len))
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// just some silly hackery
|
|
|
|
// just some silly hackery
|
|
|
|
Err(*(&(1 & has_lf as u8) as *const u8 as *const ParseError))
|
|
|
|
Err(transmute(has_lf))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -312,7 +316,8 @@ impl<'a> Parser<'a> {
|
|
|
|
unsafe {
|
|
|
|
unsafe {
|
|
|
|
let mut queries = HeapArray::with_capacity(query_count);
|
|
|
|
let mut queries = HeapArray::with_capacity(query_count);
|
|
|
|
for i in 0..query_count {
|
|
|
|
for i in 0..query_count {
|
|
|
|
queries.write_to_index(i, self._next_simple_query()?);
|
|
|
|
let sq = self._next_simple_query()?;
|
|
|
|
|
|
|
|
queries.write_to_index(i, sq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Ok(PipelinedQuery { data: queries })
|
|
|
|
Ok(PipelinedQuery { data: queries })
|
|
|
|
}
|
|
|
|
}
|
|
|
|