Struct ParallelWriter

Source
pub struct ParallelWriter { /* private fields */ }
Expand description

Write *.osm.pbf file while performing concurrently significant parts of work.

The parallel writer accepts somewhat unordered stream of elements, orders these elements, splits them into FileBlocks and writes them to the target file. The writer is composed from an ordering thread that maintains a large enough buffer to provide high probability of restoring the order, multiple encoding threads that do the heavy lifting of encoding the PBF and compressing, and finally the writing thread tht writes encoded blobs to file. The ParallelWriter uses more memory because of the internal ordering buffers controlled by the element_ordering_buffer_size parameter to constructor. It is limited to use cases where the processing of each element takes roughly the same time, as in simple filtering tasks or that elements were ordered before calling the writer. For example please see ./examples/parallel-bf-io.rs

Implementations§

Source§

impl ParallelWriter

Source

pub fn from_file_info( element_ordering_buffer_size: usize, file_block_size: usize, path: PathBuf, file_info: FileInfo, compression_type: CompressionType, ) -> Result<ParallelWriter, Error>

Source

pub fn write_header(&mut self) -> Result<(), Error>

Write the *.osm.pbf header.

Must be called before writing the first element.

Source

pub fn write_element(&mut self, element: Element) -> Result<(), Error>

Write an Element

Source

pub fn write_elements(&mut self, elements: Vec<Element>) -> Result<(), Error>

Write list of Elements

Source

pub fn close(&mut self) -> Result<(), Error>

Flush internal buffers.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V