@Test public void testReadEmpty() { MemorySnapshot snapshot = new MemorySnapshot(0, 0); snapshot.readData(0, 10); }
@Override @Nonnull public SnapshotChunk readData(int offset, int length) { if (offset < 0 || offset > data.length) { throw new IndexOutOfBoundsException("offset " + offset + " out of bound"); } int bufferLength = Math.min(data.length - offset, length); byte[] buffer = new byte[bufferLength]; System.arraycopy(data, offset, buffer, 0, bufferLength); return new SnapshotChunk(buffer, offset + length >= this.data.length); }
MemorySnapshot implements Snapshot { @Override @Nonnull public SnapshotChunk readData(int offset, int length) { if (offset < 0 || offset > data.length) { throw new IndexOutOfBoundsException("offset " + offset + " out of bound"); } int bufferLength = Math.min(data.length - offset, length); byte[] buffer = new byte[bufferLength]; System.arraycopy(data, offset, buffer, 0, bufferLength); return new SnapshotChunk(buffer, offset + length >= this.data.length); } }
MemorySnapshot implements Snapshot { @Override @Nonnull public SnapshotChunk readData(int offset, int length) { if (offset < 0 || offset > data.length) { throw new IndexOutOfBoundsException("offset " + offset + " out of bound"); } int bufferLength = Math.min(data.length - offset, length); byte[] buffer = new byte[bufferLength]; System.arraycopy(data, offset, buffer, 0, bufferLength); return new SnapshotChunk(buffer, offset + length >= this.data.length); } MemorySnapshot(int lastIncludedIndex, int lastIncludedTerm);  MemorySnapshot(int lastIncludedIndex, int lastIncludedTerm, byte[] data, Set<NodeEndpoint> lastConfig); }
MemorySnapshot implements Snapshot { @Override @Nonnull public SnapshotChunk readData(int offset, int length) { if (offset < 0 || offset > data.length) { throw new IndexOutOfBoundsException("offset " + offset + " out of bound"); } int bufferLength = Math.min(data.length - offset, length); byte[] buffer = new byte[bufferLength]; System.arraycopy(data, offset, buffer, 0, bufferLength); return new SnapshotChunk(buffer, offset + length >= this.data.length); } MemorySnapshot(int lastIncludedIndex, int lastIncludedTerm);  MemorySnapshot(int lastIncludedIndex, int lastIncludedTerm, byte[] data, Set<NodeEndpoint> lastConfig); @Override int getLastIncludedIndex(); @Override int getLastIncludedTerm(); @Nonnull @Override Set<NodeEndpoint> getLastConfig(); @Override long getDataSize(); byte[] getData(); @Override @Nonnull SnapshotChunk readData(int offset, int length); @Override @Nonnull InputStream getDataStream(); @Override void close(); @Override String toString(); }
MemorySnapshot implements Snapshot { @Override @Nonnull public SnapshotChunk readData(int offset, int length) { if (offset < 0 || offset > data.length) { throw new IndexOutOfBoundsException("offset " + offset + " out of bound"); } int bufferLength = Math.min(data.length - offset, length); byte[] buffer = new byte[bufferLength]; System.arraycopy(data, offset, buffer, 0, bufferLength); return new SnapshotChunk(buffer, offset + length >= this.data.length); } MemorySnapshot(int lastIncludedIndex, int lastIncludedTerm);  MemorySnapshot(int lastIncludedIndex, int lastIncludedTerm, byte[] data, Set<NodeEndpoint> lastConfig); @Override int getLastIncludedIndex(); @Override int getLastIncludedTerm(); @Nonnull @Override Set<NodeEndpoint> getLastConfig(); @Override long getDataSize(); byte[] getData(); @Override @Nonnull SnapshotChunk readData(int offset, int length); @Override @Nonnull InputStream getDataStream(); @Override void close(); @Override String toString();  }