Skip to content

Commit

Permalink
fix(datastore): can not load wal after restart (#1223)
Browse files Browse the repository at this point in the history
  • Loading branch information
jialeicui committed Sep 16, 2022
1 parent cafb52b commit ba0710e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public int read() {
if (this.offset >= this.buffer.capacity()) {
return -1;
}
return this.buffer.getByte(this.offset++);
return (this.buffer.getByte(this.offset++) & 0xFF);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.hamcrest.Matchers.is;

import ai.starwhale.mlops.memory.impl.SwByteBufferManager;
import java.io.IOException;
import java.util.Arrays;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -55,4 +56,14 @@ public void testReadBytes() {
assertThat(this.inputStream.read(b, 0, 10), is(-1));
assertThat(this.inputStream.read(b, 0, 10), is(-1));
}

@Test
public void testReadff() throws IOException {
var buf = this.bufferManager.allocate(1);
buf.setByte(0, (byte) 0xFF);
try (var is = new SwBufferInputStream(buf)) {
var b = is.read();
assertThat(b, is(0xFF));
}
}
}

0 comments on commit ba0710e

Please sign in to comment.