Uplifted int32 to int64 and float to double in csv_import.
This commit is contained in:
@@ -38,6 +38,10 @@ using namespace std;
|
||||
|
||||
constexpr char const *_string = "string";
|
||||
|
||||
// Will change all int32 into int64, and all float into double from csv into
|
||||
// database. Uplifting will occure even in arrays.
|
||||
constexpr const bool UPLIFT_PRIMITIVES = true;
|
||||
|
||||
bool equal_str(const char *a, const char *b) { return strcasecmp(a, b) == 0; }
|
||||
|
||||
// CSV importer for importing multiple files regarding same graph.
|
||||
@@ -243,7 +247,8 @@ private:
|
||||
new BoolFiller<TG>(property_key<TG>(name, Flags::Bool)));
|
||||
return make_option(std::move(f));
|
||||
|
||||
} else if (equal_str(type, "double")) {
|
||||
} else if (equal_str(type, "double") ||
|
||||
(UPLIFT_PRIMITIVES && equal_str(type, "float"))) {
|
||||
std::unique_ptr<Filler> f(
|
||||
new DoubleFiller<TG>(property_key<TG>(name, Flags::Double)));
|
||||
return make_option(std::move(f));
|
||||
@@ -253,16 +258,17 @@ private:
|
||||
new FloatFiller<TG>(property_key<TG>(name, Flags::Float)));
|
||||
return make_option(std::move(f));
|
||||
|
||||
} else if (equal_str(type, "long") ||
|
||||
(UPLIFT_PRIMITIVES && equal_str(type, "int"))) {
|
||||
std::unique_ptr<Filler> f(
|
||||
new Int64Filler<TG>(property_key<TG>(name, Flags::Int64)));
|
||||
return make_option(std::move(f));
|
||||
|
||||
} else if (equal_str(type, "int")) {
|
||||
std::unique_ptr<Filler> f(
|
||||
new Int32Filler<TG>(property_key<TG>(name, Flags::Int32)));
|
||||
return make_option(std::move(f));
|
||||
|
||||
} else if (equal_str(type, "long")) {
|
||||
std::unique_ptr<Filler> f(
|
||||
new Int64Filler<TG>(property_key<TG>(name, Flags::Int64)));
|
||||
return make_option(std::move(f));
|
||||
|
||||
} else if (equal_str(type, "string")) {
|
||||
std::unique_ptr<Filler> f(
|
||||
new StringFiller<TG>(property_key<TG>(name, Flags::String)));
|
||||
@@ -273,16 +279,25 @@ private:
|
||||
*this, property_key<TG>(name, Flags::ArrayBool), to_bool));
|
||||
return make_option(std::move(f));
|
||||
|
||||
} else if (equal_str(type, "double[]") ||
|
||||
(UPLIFT_PRIMITIVES && equal_str(type, "float[]"))) {
|
||||
std::unique_ptr<Filler> f(
|
||||
make_array_filler<TG, double, ArrayDouble>(
|
||||
*this, property_key<TG>(name, Flags::ArrayDouble),
|
||||
to_double));
|
||||
return make_option(std::move(f));
|
||||
|
||||
} else if (equal_str(type, "float[]")) {
|
||||
std::unique_ptr<Filler> f(make_array_filler<TG, float, ArrayFloat>(
|
||||
*this, property_key<TG>(name, Flags::ArrayFloat), to_float));
|
||||
return make_option(std::move(f));
|
||||
|
||||
} else if (equal_str(type, "double[]")) {
|
||||
} else if (equal_str(type, "long[]") ||
|
||||
(UPLIFT_PRIMITIVES && equal_str(type, "int[]"))) {
|
||||
std::unique_ptr<Filler> f(
|
||||
make_array_filler<TG, double, ArrayDouble>(
|
||||
*this, property_key<TG>(name, Flags::ArrayDouble),
|
||||
to_double));
|
||||
make_array_filler<TG, int64_t, ArrayInt64>(
|
||||
*this, property_key<TG>(name, Flags::ArrayInt64),
|
||||
to_int64));
|
||||
return make_option(std::move(f));
|
||||
|
||||
} else if (equal_str(type, "int[]")) {
|
||||
@@ -292,13 +307,6 @@ private:
|
||||
to_int32));
|
||||
return make_option(std::move(f));
|
||||
|
||||
} else if (equal_str(type, "long[]")) {
|
||||
std::unique_ptr<Filler> f(
|
||||
make_array_filler<TG, int64_t, ArrayInt64>(
|
||||
*this, property_key<TG>(name, Flags::ArrayInt64),
|
||||
to_int64));
|
||||
return make_option(std::move(f));
|
||||
|
||||
} else if (equal_str(type, "string[]")) {
|
||||
std::unique_ptr<Filler> f(
|
||||
make_array_filler<TG, std::string, ArrayString>(
|
||||
|
||||
@@ -10,6 +10,7 @@ class SnapshotEncoder;
|
||||
class SnapshotDecoder;
|
||||
class Db;
|
||||
class DbTransaction;
|
||||
class DbAccessor;
|
||||
|
||||
// Captures snapshots. Only one per database should exist.
|
||||
class SnapshotEngine
|
||||
@@ -39,7 +40,7 @@ private:
|
||||
tx::TransactionRead const &old_trans);
|
||||
|
||||
// Loads snapshot. True if success
|
||||
bool snapshot_load(DbTransaction const &dt, SnapshotDecoder &snap);
|
||||
bool snapshot_load(DbAccessor &t, SnapshotDecoder &snap);
|
||||
|
||||
std::string snapshot_file(std::time_t const &now, const char *type);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user