Struct parquet::memory::Buffer [−][src]
pub struct Buffer<T: Clone> { /* fields omitted */ }
A resize-able buffer class with generic member, with optional memory tracker.
Note that a buffer has two attributes:
capacity and size: the former is the total number of space reserved for
the buffer, while the latter is the actual number of elements.
Invariant: capacity >= size.
The total allocated bytes for a buffer equals to capacity * sizeof<T>().
Methods
impl<T: Clone> Buffer<T>[src]
impl<T: Clone> Buffer<T>pub fn new() -> Self[src]
pub fn new() -> SelfCreates new empty buffer.
pub fn with_mem_tracker(self, mc: MemTrackerPtr) -> Self[src]
pub fn with_mem_tracker(self, mc: MemTrackerPtr) -> SelfAdds MemTracker for this buffer.
pub fn data(&self) -> &[T][src]
pub fn data(&self) -> &[T]Returns slice of data in this buffer.
pub fn set_data(&mut self, new_data: Vec<T>)[src]
pub fn set_data(&mut self, new_data: Vec<T>)Sets data for this buffer.
pub fn resize(&mut self, new_size: usize, init_value: T)[src]
pub fn resize(&mut self, new_size: usize, init_value: T)Resizes underlying data in place to a new length new_size.
If new_size is less than current length, data is truncated, otherwise, it is
extended to new_size with provided default value init_value.
Memory tracker is also updated, if available.
pub fn clear(&mut self)[src]
pub fn clear(&mut self)Clears underlying data.
pub fn reserve(&mut self, additional_capacity: usize)[src]
pub fn reserve(&mut self, additional_capacity: usize)Reserves capacity additional_capacity for underlying data vector.
Memory tracker is also updated, if available.
pub fn consume(&mut self) -> BufferPtr<T>[src]
pub fn consume(&mut self) -> BufferPtr<T>Returns BufferPtr with buffer data.
Buffer data is reset.
pub fn push(&mut self, value: T)[src]
pub fn push(&mut self, value: T)Adds value to the buffer.
pub fn capacity(&self) -> usize[src]
pub fn capacity(&self) -> usizeReturns current capacity for the buffer.
pub fn size(&self) -> usize[src]
pub fn size(&self) -> usizeReturns current size for the buffer.
pub fn is_mem_tracked(&self) -> bool[src]
pub fn is_mem_tracked(&self) -> boolReturns true if memory tracker is added to buffer, false otherwise.
pub fn mem_tracker(&self) -> &MemTrackerPtr[src]
pub fn mem_tracker(&self) -> &MemTrackerPtrReturns memory tracker associated with this buffer. This may panic, if memory tracker is not set, use method above to check if memory tracker is available.
Trait Implementations
impl<T: Sized + Clone> Index<usize> for Buffer<T>[src]
impl<T: Sized + Clone> Index<usize> for Buffer<T>type Output = T
The returned type after indexing.
fn index(&self, index: usize) -> &T[src]
fn index(&self, index: usize) -> &TPerforms the indexing (container[index]) operation.
impl<T: Sized + Clone> IndexMut<usize> for Buffer<T>[src]
impl<T: Sized + Clone> IndexMut<usize> for Buffer<T>fn index_mut(&mut self, index: usize) -> &mut T[src]
fn index_mut(&mut self, index: usize) -> &mut TPerforms the mutable indexing (container[index]) operation.
impl Write for Buffer<u8>[src]
impl Write for Buffer<u8>fn write(&mut self, buf: &[u8]) -> IoResult<usize>[src]
fn write(&mut self, buf: &[u8]) -> IoResult<usize>Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> IoResult<()>[src]
fn flush(&mut self) -> IoResult<()>Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>1.0.0[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>1.0.0[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self1.0.0[src]
fn by_ref(&mut self) -> &mut SelfCreates a "by reference" adaptor for this instance of Write. Read more
impl AsRef<[u8]> for Buffer<u8>[src]
impl AsRef<[u8]> for Buffer<u8>impl<T: Clone> Drop for Buffer<T>[src]
impl<T: Clone> Drop for Buffer<T>