Skip to content

Commit

Permalink
support int128 in structured log infra as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalani Thielen committed Sep 19, 2018
1 parent 26fa9ba commit 41a28d3
Show file tree
Hide file tree
Showing 11 changed files with 2,901 additions and 2,867 deletions.
996 changes: 500 additions & 496 deletions bin/hog/boot/gen/bootdata.H

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions bin/hog/boot/read.hob
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ instance FixedWidth int where
fixedWidth = 4L
instance FixedWidth long where
fixedWidth = 8L
instance FixedWidth int128 where
fixedWidth = 16L
instance FixedWidth float where
fixedWidth = 4L
instance FixedWidth double where
Expand Down
4,752 changes: 2,382 additions & 2,370 deletions include/hobbes/boot/gen/bootdata.H

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions include/hobbes/cfregion.H
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ template <> struct compress<uint32_t> : public compressByteSeq<uint32_t> { };
template <> struct compress<int> : public compressByteSeq<int> { };
template <> struct compress<uint64_t> : public compressByteSeq<uint64_t> { };
template <> struct compress<long> : public compressByteSeq<long> { };
template <> struct compress<__int128> : public compressByteSeq<__int128> { };

#if defined(__APPLE__) && defined(__MACH__)
template <> struct compress<size_t> : public compressByteSeq<size_t> { };
Expand Down
1 change: 1 addition & 0 deletions include/hobbes/fregion.H
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,7 @@ PRIV_HFREGION_DEFINE_PRIMTYS(uint64_t, "long");
#if defined(__APPLE__) && defined(__MACH__)
PRIV_HFREGION_DEFINE_PRIMTYS(size_t, "long");
#endif
PRIV_HFREGION_DEFINE_PRIMTYS(__int128, "int128");
PRIV_HFREGION_DEFINE_PRIMTYS(float, "float");
PRIV_HFREGION_DEFINE_PRIMTYS(double, "double");

Expand Down
1 change: 1 addition & 0 deletions include/hobbes/storage.H
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,7 @@ PRIV_HSTORE_DEFINE_PRIMTYS(uint64_t, "long");
#if defined(__APPLE__) && defined(__MACH__)
PRIV_HSTORE_DEFINE_PRIMTYS(size_t, "long");
#endif
PRIV_HSTORE_DEFINE_PRIMTYS(__int128, "int128");
PRIV_HSTORE_DEFINE_PRIMTYS(float, "float");
PRIV_HSTORE_DEFINE_PRIMTYS(double, "double");

Expand Down
4 changes: 4 additions & 0 deletions lib/hobbes/boot/proccodec.hob
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ instance BlockCodec long where
readFrom = fdReadLong
writeTo = fdWriteLong

instance BlockCodec int128 where
readFrom = fdReadInt128
writeTo = fdWriteInt128

instance BlockCodec float where
readFrom = fdReadFloat
writeTo = fdWriteFloat
Expand Down
1 change: 1 addition & 0 deletions lib/hobbes/boot/storage.hob
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ instance StorePrim char
instance StorePrim short
instance StorePrim int
instance StorePrim long
instance StorePrim int128
instance StorePrim float
instance StorePrim double
instance StorePrim time
Expand Down
1 change: 1 addition & 0 deletions lib/hobbes/boot/zstorage.hob
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ instance UCMSized char 1
instance UCMSized short 2
instance UCMSized int 4
instance UCMSized long 8
instance UCMSized int128 16
instance UCMSized float 4
instance UCMSized double 8

Expand Down
2 changes: 2 additions & 0 deletions lib/hobbes/eval/funcdefs.C
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,8 @@ void initStdFuncDefs(cc& ctx) {
ctx.bind("fdWriteInt", &fdWrite<int>);
ctx.bind("fdReadLong", &fdRead<long>);
ctx.bind("fdWriteLong", &fdWrite<long>);
ctx.bind("fdReadInt128", &fdRead<int128_t>);
ctx.bind("fdWriteInt128", &fdWrite<int128_t>);
ctx.bind("fdReadFloat", &fdRead<float>);
ctx.bind("fdWriteFloat", &fdWrite<float>);
ctx.bind("fdReadDouble", &fdRead<double>);
Expand Down
7 changes: 6 additions & 1 deletion test/Storage.C
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ DEFINE_STRUCT(
MyStruct,
(int, x),
(uint8_t, y),
(int128_t, z),
(MyColor, c),
(MyVariant, v),
(strs, f)
Expand All @@ -504,6 +505,7 @@ TEST(Storage, CFRegion_C2C) {
MyStruct s;
s.x = i;
s.y = i;
s.z = i;
s.c = static_cast<MyColor::Enum>(i%4);
if (i%2 == 0) {
s.v = MyVariant::jimmy(static_cast<int>(42.0*sin(i)));
Expand All @@ -527,6 +529,7 @@ TEST(Storage, CFRegion_C2C) {
while (xs.next(&s)) {
EXPECT_EQ(size_t(s.x), i);
EXPECT_EQ(s.y, uint8_t(i));
EXPECT_EQ(s.z, int128_t(i));
EXPECT_EQ(s.c, MyColor(static_cast<MyColor::Enum>(i%4)));
if (i%2 == 0) {
EXPECT_EQ(s.v, MyVariant::jimmy(static_cast<int>(42.0*sin(i))));
Expand Down Expand Up @@ -559,6 +562,7 @@ TEST(Storage, CFRegion_C2H) {
MyStruct s;
s.x = i;
s.y = i;
s.z = i;
s.c = static_cast<MyColor::Enum>(i%4);
if (i%2 == 0) {
s.v = MyVariant::jimmy(static_cast<int>(42.0*sin(i)));
Expand Down Expand Up @@ -598,7 +602,7 @@ TEST(Storage, CFRegion_H2C) {
c.defineTypeAlias("MyStruct", hobbes::str::seq(), hobbes::decode(tdef));
c.define("cdb", "writeFile(\"" + fname + "\")::(UCModel MyStruct sm _)=>(file _ {xs:(cseq MyStruct sm 100000)})");
c.compileFn<void()>("cdb.xs <- initCSeq(cdb)")();
c.compileFn<void()>("cseqPut(cdb.xs, [{x=i, y=ti2b(i), c=unsafeCast({t=i%4}), v=if (i%2==0) then |jimmy=tl2i(truncd(42.0*sine(i)))| else |bob=\"bob #\"++show(i)|, f=[show(k)++\" Yellowstone bears\"|k<-[0..(i%10)-1]]} |i<-[0..99]])")();
c.compileFn<void()>("cseqPut(cdb.xs, [{x=i, y=ti2b(i), z=convert(i)::int128, c=unsafeCast({t=i%4}), v=if (i%2==0) then |jimmy=tl2i(truncd(42.0*sine(i)))| else |bob=\"bob #\"++show(i)|, f=[show(k)++\" Yellowstone bears\"|k<-[0..(i%10)-1]]} |i<-[0..99]])")();

// verify that it reads back in-order correctly
{
Expand All @@ -609,6 +613,7 @@ TEST(Storage, CFRegion_H2C) {
while (xs.next(&s)) {
EXPECT_EQ(size_t(s.x), i);
EXPECT_EQ(s.y, uint8_t(i));
EXPECT_EQ(s.z, int128_t(i));
EXPECT_EQ(s.c, MyColor(static_cast<MyColor::Enum>(i%4)));
if (i%2 == 0) {
EXPECT_EQ(s.v, MyVariant::jimmy(static_cast<int>(42.0*sin(i))));
Expand Down

0 comments on commit 41a28d3

Please sign in to comment.