@Override public int read(byte[] b, int off, int len) throws IOException { int l; try { l = store.readBlob(id, pos, b, off, len); } catch (Exception e) { throw new IOException(e); } if (l < 0) { return l; } pos += l; return l; }
@Override public int read(byte[] b, int off, int len) throws IOException { int l; try { l = store.readBlob(id, pos, b, off, len); } catch (Exception e) { throw new IOException(e); } if (l < 0) { return l; } pos += l; return l; }
@Override public int read(byte[] b, int off, int len) throws IOException { int l; try { l = store.readBlob(id, pos, b, off, len); } catch (Exception e) { throw new IOException(e); } if (l < 0) { return l; } pos += l; return l; }
@Override public int readBlob(String blobId, long pos, byte[] buff, int off, int length) throws IOException { return chooseBlobStoreByBlobId(blobId).readBlob(blobId, pos, buff, off, length); }
@Override public int readBlob(String blobId, long pos, byte[] buff, int off, int length) throws IOException { return chooseBlobStoreByBlobId(blobId).readBlob(blobId, pos, buff, off, length); }
@Override public int readBlob(String blobId, long pos, byte[] buff, int off, int length) throws IOException { return chooseBlobStoreByBlobId(blobId).readBlob(blobId, pos, buff, off, length); }
public int read(String blobId, long pos, byte[] buff, int off, int length) throws MicroKernelException { if (rep == null) { throw new IllegalStateException("this instance has already been disposed"); } try { int read = rep.getBlobStore().readBlob(blobId, pos, buff, off, length); return read < 0 ? 0 : read; } catch (Exception e) { throw new MicroKernelException(e); } }
public int read(String blobId, long pos, byte[] buff, int off, int length) throws DocumentStoreException { try { int read = nodeStore.getBlobStore().readBlob(blobId, pos, buff, off, length); return read < 0 ? 0 : read; } catch (Exception e) { throw new DocumentStoreException(e); } }
@Test public void testReadByte() throws IOException { byte[] expected = new byte[LENGTH]; byte[] actual = new byte[LENGTH]; for (String id : oldBlobIds) { oldBlobStore.readBlob(id, 0, expected, 0, LENGTH); splitBlobStore.readBlob(id, 0, actual, 0, LENGTH); assertArrayEquals(expected, actual); } for (String id : newBlobIds) { newBlobStore.readBlob(id, 0, expected, 0, LENGTH); splitBlobStore.readBlob(id, 0, actual, 0, LENGTH); assertArrayEquals(expected, actual); } }
when: final int numberOfBytesRead = blobStore.readBlob( blobId, offsetToRead, buffer, bufOffset, lengthToRead); and:
@Test(expected = IllegalArgumentException.class) @Parameters(method = "blobIdsFailedOffsetReadsCases") public void getInputStreamShouldAlwaysReturnExceptionIfBinaryOffsetIsBad( final String blobId, int offsetToRead, int bufSize, int bufOffset, int lengthToRead) throws IOException { given: { final BlobStore store = new LoopbackBlobStore(); final byte[] buffer = new byte[bufSize]; when: { store.readBlob( blobId, offsetToRead, buffer, bufOffset, lengthToRead); } } }
@Test(expected = UnsupportedOperationException.class) @Parameters(method = "blobIdsFailedBufferReadsCases") public void getInputStreamShouldAlwaysReturnExceptionIfBufferTooSmall( final String blobId, int offsetToRead, int bufSize, int bufOffset, int lengthToRead) throws IOException { given: { final BlobStore store = new LoopbackBlobStore(); final byte[] buffer = new byte[bufSize]; when: { store.readBlob( blobId, offsetToRead, buffer, bufOffset, lengthToRead); } } }