Skip to content
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

F.serializer #422

Merged
merged 5 commits into from Jul 22, 2021
Merged

F.serializer #422

merged 5 commits into from Jul 22, 2021

Conversation

joka921
Copy link
Member

@joka921 joka921 commented Jul 16, 2021

TODO comment.

@joka921 joka921 marked this pull request as ready for review July 16, 2021 09:16
Copy link
Member

@hannahbast hannahbast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review in 1-1 with Johannes, thanks for the great mini library!

Johannes said: add some tests also for serializing hash maps and strings.

Storage&& data() && { return std::move(_data); }

private:
std::vector<char> _data;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storage _data;


SerializationPosition getCurrentPosition() const { return _file.tell(); }

File&& moveFileOut() && { return std::move(_file); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moveFileOut -> file

_file.seek(position, SEEK_SET);
}

File&& moveFileOut() && { return std::move(_file); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dito

@@ -131,7 +131,7 @@ void Index::passContextFileIntoVector(const string& contextFile,
// this has to be repeated completely here because we have the possibility to
// only add a text index. In that case the Vocabulary has never been
// initialized before
_vocab = Vocabulary<CompressedString, TripleComponentComparator>();
_vocab = std::move(Vocabulary<CompressedString, TripleComponentComparator>());
readConfiguration();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Was there a problem before?

Comment on lines 103 to 122
ASSERT_EQ(Id(0), *reinterpret_cast<Id*>(buf + bytesDone));
EXPECT_EQ(Id(0), *reinterpret_cast<Id*>(buf + bytesDone));
bytesDone += sizeof(Id);
ASSERT_EQ(4u, *reinterpret_cast<Id*>(buf + bytesDone));
EXPECT_EQ(4u, *reinterpret_cast<Id*>(buf + bytesDone));
bytesDone += sizeof(Id);
ASSERT_EQ(0u, *reinterpret_cast<Id*>(buf + bytesDone));
EXPECT_EQ(0u, *reinterpret_cast<Id*>(buf + bytesDone));
bytesDone += sizeof(Id);
ASSERT_EQ(5u, *reinterpret_cast<Id*>(buf + bytesDone));
EXPECT_EQ(5u, *reinterpret_cast<Id*>(buf + bytesDone));
bytesDone += sizeof(Id);

// Relation b2
ASSERT_EQ(Id(0), *reinterpret_cast<Id*>(buf + bytesDone));
EXPECT_EQ(Id(0), *reinterpret_cast<Id*>(buf + bytesDone));
bytesDone += sizeof(Id);
ASSERT_EQ(4u, *reinterpret_cast<Id*>(buf + bytesDone));
EXPECT_EQ(4u, *reinterpret_cast<Id*>(buf + bytesDone));
bytesDone += sizeof(Id);
ASSERT_EQ(1u, *reinterpret_cast<Id*>(buf + bytesDone));
EXPECT_EQ(1u, *reinterpret_cast<Id*>(buf + bytesDone));
bytesDone += sizeof(Id);
ASSERT_EQ(5u, *reinterpret_cast<Id*>(buf + bytesDone));
EXPECT_EQ(5u, *reinterpret_cast<Id*>(buf + bytesDone));
bytesDone += sizeof(Id);
// No LHS & RHS
ASSERT_EQ(index._PSO.metaData().getOffsetAfter(), bytesDone);
EXPECT_EQ(index._PSO.metaData().getOffsetAfter(), bytesDone);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Back to ASSERT_EQ

};

auto testWithFileSerialization = [](auto testFunction) {
const std::string filename = "serializationTestTmpt.txtx";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serializationTest.tmp

};

TEST(Serializer, Simple) {
auto simpleIntTest = [](auto& writer, auto makeReader) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeReaderFromWriter ?

};

testWithAllSerializers(testmanyPrimitives);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline

- It has a symmetric interface, similar to boost::serialization etc. That
  way, typically only one function has to be written for a type to handle
  reading AND writing.
- It avoids the error-prone handling of manual calls to writing and reading
  of single bytes

- We currently use it for the writing of the IndexMetaData, but it can be
  used in several more places (e.g. the Vocabulary) in the future.
@joka921 joka921 merged commit 0630290 into ad-freiburg:master Jul 22, 2021
@joka921 joka921 deleted the f.serializer branch July 22, 2021 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants