use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class BufferedBlockInStreamIntegrationTest method skip.
/**
* Tests {@link alluxio.client.block.BufferedBlockInStream#skip(long)}.
*/
@Test
public void skip() throws IOException, AlluxioException {
for (int k = MIN_LEN + DELTA; k <= MAX_LEN; k += DELTA) {
for (CreateFilePOptions op : getOptionSet()) {
AlluxioURI path = new AlluxioURI(sTestPath + "/file_" + k + "_" + op.hashCode());
FileInStream is = sFileSystem.openFile(path, FileSystemTestUtils.toOpenFileOptions(op));
Assert.assertEquals(k / 2, is.skip(k / 2));
Assert.assertEquals(k / 2, is.read());
is.close();
is = sFileSystem.openFile(path, FileSystemTestUtils.toOpenFileOptions(op));
int t = k / 3;
Assert.assertEquals(t, is.skip(t));
Assert.assertEquals(t, is.read());
Assert.assertEquals(t, is.skip(t));
Assert.assertEquals(2 * t + 1, is.read());
is.close();
}
}
}
use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class BufferedBlockInStreamIntegrationTest method getOptionSet.
private static List<CreateFilePOptions> getOptionSet() {
List<CreateFilePOptions> ret = new ArrayList<>(3);
CreateFilePOptions optionsDefault = CreateFilePOptions.getDefaultInstance();
ret.add(optionsDefault.toBuilder().setWriteType(WritePType.CACHE_THROUGH).setRecursive(true).build());
ret.add(optionsDefault.toBuilder().setWriteType(WritePType.MUST_CACHE).setRecursive(true).build());
ret.add(optionsDefault.toBuilder().setWriteType(WritePType.THROUGH).setRecursive(true).build());
return ret;
}
use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class FileInStreamIntegrationTest method positionedReadWithoutCaching.
@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.USER_FILE_READ_TYPE_DEFAULT, "NO_CACHE" })
public void positionedReadWithoutCaching() throws Exception {
for (CreateFilePOptions op : getOptionSet()) {
String filename = mTestPath + "/file_" + MIN_LEN + "_" + op.hashCode();
AlluxioURI uri = new AlluxioURI(filename);
FileInStream is = mFileSystem.openFile(uri, FileSystemTestUtils.toOpenFileOptions(op));
byte[] ret = new byte[DELTA - 1];
Assert.assertEquals(DELTA - 1, is.positionedRead(MIN_LEN - DELTA + 1, ret, 0, DELTA));
Assert.assertTrue(BufferUtils.equalIncreasingByteArray(MIN_LEN - DELTA + 1, DELTA - 1, ret));
is.close();
}
}
use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class FileInStreamIntegrationTest method positionedReadWithLargeThreshold.
@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.USER_FILE_SEQUENTIAL_PREAD_THRESHOLD, "700KB" })
public void positionedReadWithLargeThreshold() throws Exception {
List<CreateFilePOptions> optionSet = new ArrayList<>(2);
optionSet.add(mWriteBoth);
optionSet.add(mWriteUnderStore);
for (CreateFilePOptions op : optionSet) {
String filename = mTestPath + "/file_" + MIN_LEN + "_" + op.hashCode();
AlluxioURI uri = new AlluxioURI(filename);
try (FileInStream is = mFileSystem.openFile(uri, FileSystemTestUtils.toOpenFileOptions(op))) {
byte[] ret = new byte[DELTA - 1];
Assert.assertEquals(DELTA - 1, is.positionedRead(MIN_LEN - DELTA + 1, ret, 0, DELTA));
Assert.assertTrue(BufferUtils.equalIncreasingByteArray(MIN_LEN - DELTA + 1, DELTA - 1, ret));
}
}
}
use of alluxio.grpc.CreateFilePOptions in project alluxio by Alluxio.
the class FileInStreamIntegrationTest method skip.
/**
* Tests {@link FileInStream#skip(long)}.
*/
@Test
public void skip() throws Exception {
for (int k = MIN_LEN; k <= MAX_LEN; k += DELTA) {
for (CreateFilePOptions op : getOptionSet()) {
String filename = mTestPath + "/file_" + k + "_" + op.hashCode();
AlluxioURI uri = new AlluxioURI(filename);
FileInStream is = mFileSystem.openFile(uri, FileSystemTestUtils.toOpenFileOptions(op));
Assert.assertEquals(k / 2, is.skip(k / 2));
Assert.assertEquals(BufferUtils.intAsUnsignedByteValue(k / 2), is.read());
Assert.assertEquals(k / 3, is.skip(k / 3));
// position is k / 2 (skip) + k / 3 (skip) + 1 (read)
Assert.assertEquals(BufferUtils.intAsUnsignedByteValue(k / 2 + k / 3 + 1), is.read());
is.close();
}
}
}
Aggregations