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

Markstream to enable 1-producer-1-consumer on server side #138

Merged
merged 4 commits into from
Jan 8, 2021

Conversation

andydiwenzhu
Copy link
Collaborator

@andydiwenzhu andydiwenzhu commented Jan 8, 2021

What do these changes do?

Related issue number

Fixes #133

Copy link
Member

@sighingnow sighingnow left a comment

Choose a reason for hiding this comment

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

I prefer to rename MarkStream as OpenStream, add define an enumeration

enum class OpenStreamMode {
   read = 1,
   write = 2,
}

in a newly added stream_utils.h or somewhere like that, then replace magic 1 and 2 in OpenReader/OpenWriter with the enum, for better code readability and maintain-ability.

return std::unique_ptr<ByteStreamReader>(
new ByteStreamReader(client, id_, meta_));
}
return nullptr;
}
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to have API like

Status OpenReader(Client &client, std::unique_ptr<ByteStreamReader> &r) {
   RETURN_ON_ERROR(client.MarkStream(id_, 2))....
   r = ...
   return Status::OK();
}

which will be more consistent will the style of our other APIs, and more importantly, let user know why the operation fail. Return nullptr sliently usually the root of many unintended bugs.

@@ -86,6 +88,7 @@ class StreamStore {
std::shared_ptr<BulkStore> store_;
size_t threshold_;
std::unordered_map<ObjectID, std::shared_ptr<StreamHolder>> streams_;
std::unordered_map<ObjectID, int64_t> stream_marks_;
Copy link
Member

Choose a reason for hiding this comment

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

Could we use the mark as an attribute of StreamHolder? without introduce an extra map. Considering that when deleting a stream, we need an extra deletion and may lead to inconsistency.

@@ -83,6 +86,9 @@ int main(int argc, char** argv) {
CHECK(byte_stream != nullptr);

auto writer = byte_stream->OpenWriter(writer_client);
auto failed_writer = byte_stream->OpenWriter(writer_client);
CHECK(failed_writer == nullptr);
Copy link
Member

Choose a reason for hiding this comment

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

For the check, you may also need to consider all places the OpenReader/OpenWriter are called, not merely the test case.

@sighingnow
Copy link
Member

LGTM.

@andydiwenzhu andydiwenzhu merged commit b80529a into v6d-io:main Jan 8, 2021
@andydiwenzhu andydiwenzhu deleted the dj/mark_stream branch January 8, 2021 14:17
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.

stream one producer one consumer control on server side
2 participants