Skip to content

Remove duplicated code for processing event #201

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

Merged
merged 1 commit into from
Nov 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions server/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl Event {
// schema is then enforced on rest of the events sent to this log stream.
fn process_first_event<S: ObjectStorage, R: std::io::Read>(
&self,
mut event: json::Reader<R>,
event: json::Reader<R>,
schema: Schema,
) -> Result<(), EventError> {
// note for functions _schema_with_map and _set_schema_with_map,
Expand All @@ -256,8 +256,7 @@ impl Event {

// Store record batch on local cache
log::info!("creating local writer for this first event");
let rb = event.next()?.ok_or(EventError::MissingRecord)?;
STREAM_WRITERS::append_to_local(stream_name, &rb)?;
self.process_event(event)?;

log::info!("schema is set in memory map for logstream {}", stream_name);
_set_schema_with_map(stream_name, schema.clone(), &mut stream_metadata);
Expand Down Expand Up @@ -298,10 +297,7 @@ impl Event {
mut event: json::Reader<R>,
) -> Result<(), EventError> {
let rb = event.next()?.ok_or(EventError::MissingRecord)?;
let stream_name = &self.stream_name;

STREAM_WRITERS::append_to_local(stream_name, &rb)?;

STREAM_WRITERS::append_to_local(&self.stream_name, &rb)?;
Ok(())
}

Expand Down