This repository contains the files created on completing the screening exercise of "Improve flatbuffer parser support in VowpalWabbit" RLOSF 2022 Project. This is one of the projects of RLOSF to which I am interested in contributing.
Submitted by: Sharvani Laxmi Somayaji
OS used: Windows 10
cmake version: 3.22.0-rc2
g++.exe (GCC): 8.3.0
Create a simple flatbuffer schema file. It should be a table with 3 fields:
a_name – string
a_value – float
a_flag - bool
The flatbuffer schema file has been created and can be found in screening_schema.fbs
Create a C++ command line application that writes data to a file using the flatbuffer schema.
For this purpose, write_data.cpp
has been created.
Create a C++ command line application that reads the file from previous step and writes the contents to stdout.
For this purpose, read_data.cpp
has been created.
All the files created can be found in this repository. For this purpose, none have been added to .gitignore
.
-
Clone this repository and go to the location of the cloned repo.
-
Go to the schema subfolder.
cd schema
-
Get
flatc
. Note that this repository already contains the executable file.- At the beginning we have to get flatc -- FlatBuffers compiler. It can be built from source code hosted in Google's flatbuffers repository.
git clone https://github.com/google/flatbuffers.git cd flatbuffers
- Build using cmake: (Run the command on the basis of your platform. I have used the first command out of the below three)
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release cmake -G "Visual Studio 10" -DCMAKE_BUILD_TYPE=Release cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release
- Build as normal for your platform. This should result in a flatc executable. I have generated the Binaries outside the root repository and built them using the
make
command. After this, I have pasted the generatedflatc.exe
file in theschema
folder in the repository.
-
Generate the C++ header
screening_schema_generated.h
from the schemascreening_schema.fbs
using the compiler as follows:./flatc --cpp screening_schema.fbs
-
As
screening_schema_generated.h
header relies onflatbuffers/flatbuffers.h
, it needs to be in the include path. One of the ways to do this would be by adding it to the environment variable as follows: -
Go back to the root of the repository
cd ..
-
Write the data to a file,
data.bin
using the flatbuffer schema using the following commands:g++ write_data.cpp -o main
./main Sharvani 12.2 1
The above command takes input from the command line as follows:
./main <string> <float> <bool>
-
Read the data to a file,
data.bin
and write the contents to stdout using the following commands:g++ read_data.cpp -o main
./main