Skip to main content

harmos_storage/writes/
decoded.rs

1/* ***
2 *
3 * Harmos
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * ***
8 */
9
10/* === Modules === */
11
12/* === Re-Exports === */
13
14/* === Imports === */
15
16// Standard Library Imports
17
18// Third Party Imports
19
20// Local Imports
21use super::DataBatch;
22use crate::Result;
23use crate::arrow::ArrowBatch;
24
25/* === Constants === */
26
27/* === Macros === */
28
29/* === Type Aliases === */
30
31/* === Structs === */
32
33// A Write Batch Whose Arrow IPC Data Has Been Decoded For Admission.
34pub struct DecodedBatch {
35    pub destination: crate::Identifier,
36    pub schema: crate::storage::SchemaKey,
37    pub data: ArrowBatch,
38}
39
40/* === Enums === */
41
42/* === Traits === */
43
44/* === Implementations === */
45
46impl DecodedBatch {
47    pub fn of(batch: DataBatch) -> Result<Self> {
48        Ok(Self {
49            data: ArrowBatch::from_ipc(batch.data.into_bytes())?,
50            destination: batch.destination,
51            schema: batch.schema,
52        })
53    }
54}
55
56/* === Public Functions === */
57
58/* === Private Functions === */
59
60/* === Tests === */