use of alluxio.client.file.cache.PageId in project alluxio by Alluxio.
the class MemoryPageStoreTest method helloWorldTest.
private void helloWorldTest(PageStore store) throws Exception {
String msg = "Hello, World!";
PageId id = new PageId("0", 0);
store.put(id, msg.getBytes());
byte[] buf = new byte[1024];
assertEquals(msg.getBytes().length, store.get(id, buf));
assertArrayEquals(msg.getBytes(), Arrays.copyOfRange(buf, 0, msg.getBytes().length));
}
use of alluxio.client.file.cache.PageId in project alluxio by Alluxio.
the class LocalPageStoreTest method testMultiFileBucket.
@Test
public void testMultiFileBucket() throws Exception {
int numBuckets = 10;
mOptions.setFileBuckets(numBuckets);
LocalPageStore pageStore = new LocalPageStore(mOptions);
long numFiles = numBuckets * 10;
for (int i = 0; i < numFiles; i++) {
PageId id = new PageId(Integer.toString(i), 0);
pageStore.put(id, "test".getBytes());
}
long actualCount = 0;
for (Path root : mOptions.getRootDirs()) {
actualCount += Files.list(Paths.get(root.toString(), Long.toString(mOptions.getPageSize()))).count();
}
assertEquals(10, actualCount);
}
use of alluxio.client.file.cache.PageId in project alluxio by Alluxio.
the class LocalPageStoreTest method helloWorldTest.
private void helloWorldTest(PageStore store) throws Exception {
String msg = "Hello, World!";
PageId id = new PageId("0", 0);
store.put(id, msg.getBytes());
byte[] buf = new byte[1024];
assertEquals(msg.getBytes().length, store.get(id, buf));
assertArrayEquals(msg.getBytes(), Arrays.copyOfRange(buf, 0, msg.getBytes().length));
}
use of alluxio.client.file.cache.PageId in project alluxio by Alluxio.
the class PageStoreTest method getSmallLen.
@Test
public void getSmallLen() throws Exception {
int len = 32;
PageId id = new PageId("0", 0);
mPageStore.put(id, BufferUtils.getIncreasingByteArray(len));
byte[] buf = new byte[1024];
for (int b = 1; b < len; b++) {
int bytesRead = mPageStore.get(id, 0, b, buf, 0);
assertEquals(b, bytesRead);
assertArrayEquals(BufferUtils.getIncreasingByteArray(b), Arrays.copyOfRange(buf, 0, bytesRead));
}
}
use of alluxio.client.file.cache.PageId in project alluxio by Alluxio.
the class PageStoreTest method getOffset.
@Test
public void getOffset() throws Exception {
int len = 32;
PageId id = new PageId("0", 0);
mPageStore.put(id, BufferUtils.getIncreasingByteArray(len));
byte[] buf = new byte[len];
for (int offset = 1; offset < len; offset++) {
int bytesRead = mPageStore.get(id, offset, len, buf, 0);
assertEquals(len - offset, bytesRead);
assertArrayEquals(BufferUtils.getIncreasingByteArray(offset, len - offset), Arrays.copyOfRange(buf, 0, bytesRead));
}
}
Aggregations