Struct tvix_castore::import::archive::IngestionEntryGraph
source · struct IngestionEntryGraph {
graph: DiGraph<IngestionEntry, ()>,
path_to_index: HashMap<PathBuf, NodeIndex>,
root_node: Option<NodeIndex>,
}
Expand description
Keep track of the directory structure of a file tree being ingested. This is used for ingestion sources which do not provide any ordering or uniqueness guarantees like tarballs.
If we ingest multiple entries with the same paths and both entries are not directories, the newer entry will replace the latter entry, disconnecting the old node’s children from the graph.
Once all nodes are ingested a call to IngestionEntryGraph::finalize will return a list of entries compute by performaing a DFS post order traversal of the graph from the top-level directory entry.
This expects the directory structure to contain a single top-level directory entry. An error is returned if this is not the case and ingestion will fail.
Fields§
§graph: DiGraph<IngestionEntry, ()>
§path_to_index: HashMap<PathBuf, NodeIndex>
§root_node: Option<NodeIndex>
Implementations§
source§impl IngestionEntryGraph
impl IngestionEntryGraph
sourcepub fn add(&mut self, entry: IngestionEntry) -> Result<NodeIndex, Error>
pub fn add(&mut self, entry: IngestionEntry) -> Result<NodeIndex, Error>
Adds a new entry to the graph. Parent directories are automatically inserted. If a node exists in the graph with the same name as the new entry and both the old and new nodes are not directories, the node is replaced and is disconnected from its children.
sourcepub fn finalize(self) -> Result<Vec<IngestionEntry>, Error>
pub fn finalize(self) -> Result<Vec<IngestionEntry>, Error>
Traverses the graph in DFS post order and collects the entries into a Vec
Unreachable parts of the graph are not included in the result.
sourcefn replace_node(&mut self, index: NodeIndex, new_entry: IngestionEntry)
fn replace_node(&mut self, index: NodeIndex, new_entry: IngestionEntry)
Replaces the node with the specified entry. The node’s children are disconnected.
This should never be called if both the old and new nodes are directories.
fn get_node(&self, index: NodeIndex) -> &IngestionEntry
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IngestionEntryGraph
impl RefUnwindSafe for IngestionEntryGraph
impl Send for IngestionEntryGraph
impl Sync for IngestionEntryGraph
impl Unpin for IngestionEntryGraph
impl UnwindSafe for IngestionEntryGraph
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request