diff --git a/fbpcf/mpc_std_lib/unified_data_process/serialization/IRowStructureDefinition.h b/fbpcf/mpc_std_lib/unified_data_process/serialization/IRowStructureDefinition.h new file mode 100644 index 00000000..4f7460f9 --- /dev/null +++ b/fbpcf/mpc_std_lib/unified_data_process/serialization/IRowStructureDefinition.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include +#include +#include "IColumnDefinition.h" +#include "fbpcf/frontend/BitString.h" + +namespace fbpcf::mpc_std_lib::unified_data_process::serialization { + +template +class IRowStructureDefinition { + public: + using SecString = frontend::BitString; + + using InputColumnDataType = std::variant< + std::vector, + std::vector, + std::vector, + std::vector, + std::vector>, + std::vector>, + std::vector>, + std::vector>>; + + virtual ~IRowStructureDefinition() = default; + + /* Returns the number of bytes to serialize a single row */ + virtual size_t getRowSizeBytes() const = 0; + + // Serialize each column's worth of data according to the structure + // definition. Each key must match the name of a column in the definition and + // the value contains the data for that column + virtual std::vector> serializeDataAsBytesForUDP( + const std::unordered_map& data, + int numRows) const = 0; + + // Following a run of the UDP protocol, deserialize the batched BitString + // containing encrypted columns into private MPC types. + virtual std::unordered_map< + std::string, + typename IColumnDefinition::DeserializeType> + deserializeUDPOutputIntoMPCTypes(const SecString& secretSharedData) const = 0; +}; + +} // namespace fbpcf::mpc_std_lib::unified_data_process::serialization diff --git a/fbpcf/mpc_std_lib/unified_data_process/serialization/test/SerializationTest.cpp b/fbpcf/mpc_std_lib/unified_data_process/serialization/test/ColumnSerializationTest.cpp similarity index 98% rename from fbpcf/mpc_std_lib/unified_data_process/serialization/test/SerializationTest.cpp rename to fbpcf/mpc_std_lib/unified_data_process/serialization/test/ColumnSerializationTest.cpp index 701bb3fc..f3866f29 100644 --- a/fbpcf/mpc_std_lib/unified_data_process/serialization/test/SerializationTest.cpp +++ b/fbpcf/mpc_std_lib/unified_data_process/serialization/test/ColumnSerializationTest.cpp @@ -103,7 +103,7 @@ static std::vector> deserializeAndRevealPackedBits( return rst; } -TEST(SerializationTest, IntegerColumnTest) { +TEST(ColumnSerializationTest, IntegerColumnTest) { auto factories = fbpcf::engine::communication::getInMemoryAgentFactory(2); auto schedulerFactory0 = @@ -160,7 +160,7 @@ TEST(SerializationTest, IntegerColumnTest) { testVectorEq(vals, rst); } -TEST(SerializationTest, ArrayColumnTest) { +TEST(ColumnSerializationTest, ArrayColumnTest) { auto factories = fbpcf::engine::communication::getInMemoryAgentFactory(2); auto schedulerFactory0 = @@ -235,7 +235,7 @@ TEST(SerializationTest, ArrayColumnTest) { } } -TEST(SerializationTest, PackedBitFieldColumnTest) { +TEST(ColumnSerializationTest, PackedBitFieldColumnTest) { auto factories = fbpcf::engine::communication::getInMemoryAgentFactory(2); auto schedulerFactory0 = @@ -334,4 +334,5 @@ TEST(erializationTest, ColumnTypeTest) { "col4", std::make_unique>("test"), 4); EXPECT_EQ(col6->getColumnType(), ColType::UInt32Vec); } + } // namespace fbpcf::mpc_std_lib::unified_data_process::serialization