Go to the documentation of this file.
6 #include <experimental/filesystem>
11 #include <nlohmann/json.hpp>
20 #ifdef __cpp_lib_filesystem
21 namespace fs = std::filesystem;
22 #elif __cpp_lib_experimental_filesystem
23 namespace fs = std::experimental::filesystem;
25 #error "no filesystem support ='("
33 std::vector<unsigned char>
data;
46 for (
auto &c : columns) {
55 return *
reinterpret_cast<float *
>(
data.data() + i);
58 int getInt(
int i) {
return *
reinterpret_cast<int *
>(
data.data() + i); }
61 return std::string(
data.data() + i,
data.data() + i + length);
65 *
reinterpret_cast<float *
>(
data.data() + i) = value;
69 *
reinterpret_cast<int *
>(
data.data() + i) = value;
73 memcpy(
data.data() + i,
string.c_str(),
string.size());
77 memcpy(
data.data() + i,
string.c_str(),
string.size());
82 operator const char *()
const {
return (
const char *)
data.data(); }
83 operator char *() {
return (
char *)
data.data(); }
97 void read(std::istream &input) { input.read(*
this,
data.size()); }
99 void write(std::ostream &output) { output.write(*
this,
data.size()); }
102 std::vector<DataValue> values;
103 values.reserve(columns.size());
106 for (
int i = 0; i < columns.size(); ++i) {
118 throw std::runtime_error(
"Unknown DataType");
125 for (
int i = 0; i < columns.size(); ++i) {
128 setInt(offset, record[i].as<int>());
131 setFloat(offset, record[i].as<float>());
134 setString(offset, record[i].as<std::string>());
137 throw std::runtime_error(
"Unknown DataType");
148 static std::map<fs::path, std::shared_ptr<MetadataManager>>
metaMap;
151 std::ifstream inp(
file);
161 std::string column_store_path) {
178 std::ofstream o(
file);
189 assert(
metadata[
"projections"].count(projection));
190 return metadata[
"projections"][projection];
210 void update(std::string projection_name) {
211 std::cout <<
"Updating " << projection_name << std::endl;
212 auto &fileData =
manager->getProjectionFileInfo(projection_name);
213 int tuplesMoved = fileData[
"tuples_move_count"];
214 auto &schema =
manager->getProjectionSchemaInfo(projection_name);
215 auto &db_metadata =
manager->getFileMetadata();
216 fs::path file =
manager->getProjectionFileInfo(projection_name)[
"file"];
218 db_metadata[
"source_db_config"][
"db_user"],
219 db_metadata[
"source_db_config"][
"db_password"],
222 postgresql_data_source.
advance(tuplesMoved);
223 std::vector<Parser::Column> projection_columns = schema.get_metadata_columns();
226 std::ofstream o(file, std::ofstream::out | std::ofstream::app);
228 while (postgresql_data_source.
hasNext()) {
229 auto record = postgresql_data_source.
next();
230 projection_data.
set(record, projection_columns);
231 projection_data.
write(o);
234 std::cout << c <<
" records processed" << std::endl;
237 std::cout << c <<
" records processed" << std::endl;
240 int newTotal = tuplesMoved + c;
242 fileData[
"tuples_move_count"] = newTotal;
247 for (
auto &[projection_name, _] :
248 manager->getFileMetadata()[
"projections"].items()) {
ColStoreLoader(std::string column_store_path)
Definition: ProjectionData.h:207
friend std::ostream & operator<<(std::ostream &output, const ColumnStoreData &data)
Definition: ProjectionData.h:85
std::string getString(int i, int length)
Definition: ProjectionData.h:60
bool hasNext()
Definition: PostgreSQLDataGenerator.h:204
void setString(int i, std::string &string)
Definition: ProjectionData.h:72
void advance(int recordCount)
Definition: PostgreSQLDataGenerator.h:194
void read(std::istream &input)
Definition: ProjectionData.h:97
float getFloat(int i)
Definition: ProjectionData.h:54
Definition: ColStoreDataGenerator.h:22
DataRecord next()
Definition: PostgreSQLDataGenerator.h:137
ColumnStoreData(int size=0)
Definition: ProjectionData.h:37
int size() const
Definition: ProjectionData.h:80
DataRecord get(std::vector< Parser::Column > &columns)
Definition: ProjectionData.h:101
Definition: Projection.h:44
ColumnStoreData(std::vector< unsigned char > &data)
Definition: ProjectionData.h:34
Definition: ProjectionData.h:203
MetadataManagerSingleton manager
Definition: ProjectionData.h:204
Stores a row of data.
Definition: DataRecord.h:64
friend std::istream & operator>>(std::istream &input, ColumnStoreData &data)
Definition: ProjectionData.h:91
std::shared_ptr< MetadataManager > MetadataManagerSingleton
Definition: ProjectionData.h:201
ColumnStoreData(DataRecord &record, std::vector< Parser::Column > &columns)
Definition: ProjectionData.h:39
void setFloat(int i, float value)
Definition: ProjectionData.h:64
void initConfig(int ac, char *av[])
Definition: ColumnStoreUpdater.cpp:12
std::vector< unsigned char > data
Definition: ProjectionData.h:33
fs::path getMetaDataPath(std::string column_store_path)
Definition: StoreInitializer.h:28
int getInt(int i)
Definition: ProjectionData.h:58
void write(std::ostream &output)
Definition: ProjectionData.h:99
void set(DataRecord &record, std::vector< Parser::Column > &columns)
Definition: ProjectionData.h:123
void updateAll()
Definition: ProjectionData.h:246
ColumnStoreData(std::vector< Parser::Column > &columns)
Definition: ProjectionData.h:44
Definition: ProjectionData.h:32
void setString(int i, std::string string)
Definition: ProjectionData.h:76
Implementation of a single data element.
Definition: DataRecord.h:28
int size
Definition: Column.h:9
void update(std::string projection_name)
Definition: ProjectionData.h:210
void setInt(int i, int value)
Definition: ProjectionData.h:68
Definition: PostgreSQLDataGenerator.h:24
int main(int argc, char *argv[])
Definition: ColumnStoreUpdater.cpp:44
po::variables_map config
Definition: ColumnStoreUpdater.cpp:10
Definition: PostgreSQLMetaData.h:13