-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to compress slog file with enum type #398
Comments
it seems need change here: hobbes/lib/hobbes/db/cbindings.C Line 17 in 90c9865
right now hobbes only support the enum without customized values |
Your enum here is an Int in disguise, not a variant. With the changes made here, you can keep your type as enums while keeping the static information as well. Is this something you can do?
|
seem use fregion is an options. will have a try |
Here is the test case, you can see there is no issue for raw storage, but will generate core dump(not always but very offen) file for compressd file :
`
#include
#include <hobbes/hobbes.H>
#include <hobbes/storage.H>
#include <hobbes/db/file.H>
#include <hobbes/db/series.H>
#include <hobbes/lang/tylift.H>
const int option = 100;
struct TestEnum {
enum Enum : uint32_t{
Invalid = 0,
Option = option
};
Enum _value;
using is_enum = void;
};
namespace hobbes {
template
struct liftTestEnum
{
static MonoTypePtr type(typedb&) {
Variant::Members vms;
auto i = 0;
vms.push_back(Variant::Member("Invalid", primty("unit"), 0));
vms.push_back(Variant::Member("Option", primty("unit"), option));
return MonoTypePtr(Variant::make(vms));
}
};
template
struct lift<T*, false, typename T::is_enum> : public liftTestEnum {};
template
struct lift<T, true, typename T::is_enum> : public liftTestEnum {};
}
DEFINE_STRUCT(
FixarrayS,
(TestEnum, value),
(const hobbes::array*, body)
);
void run(const std::string& fname, bool compressed) {
hobbes::cc c;
FixarrayS v1;
v1.body = hobbes::makeString("Hello world!");
v1.value._value = TestEnum::Option;
hobbes::writer writer{fname};
hobbes::series ss1(&c, &writer, "udata", 10000, compressed? hobbes::StoredSeries::Compressed : hobbes::StoredSeries::Raw);
ss1(v1);
std::cout << "------------testing -----------------" << std::endl;
c.define("f", "inputFile :: (LoadFile "" + fname + "" w) => w");
c.compileFn<void()>("print([(x.value, (unsafeCast(x.value)::{t:int}).t) | x<-f.udata])")();
}
int main()
{
std::cout << "=============Create Raw Stream [OK]=============" << std::endl;
run("/var/tmp/test.log", false);
std::cout << "=============Create Compressed Stream [Failed]=============" << std::endl;
run("/var/tmp/testc.log", true);
return 0;
}
`
The text was updated successfully, but these errors were encountered: