use of alluxio.client.file.cache.PageId in project alluxio by Alluxio.
the class MemoryPageStore method delete.
@Override
public void delete(PageId pageId) throws IOException, PageNotFoundException {
PageId pageKey = getKeyFromPageId(pageId);
if (!mPageStoreMap.containsKey(pageKey)) {
throw new PageNotFoundException(pageId.getFileId() + "_" + pageId.getPageIndex());
}
mPageStoreMap.remove(pageKey);
LOG.info("Remove cached page, size: {}", mPageStoreMap.size());
}
use of alluxio.client.file.cache.PageId in project alluxio by Alluxio.
the class MemoryPageStore method get.
@Override
public int get(PageId pageId, int pageOffset, int bytesToRead, byte[] buffer, int bufferOffset) throws IOException, PageNotFoundException {
Preconditions.checkArgument(buffer != null, "buffer is null");
Preconditions.checkArgument(pageOffset >= 0, "page offset should be non-negative");
Preconditions.checkArgument(buffer.length >= bufferOffset, "page offset %s should be " + "less or equal than buffer length %s", bufferOffset, buffer.length);
PageId pageKey = getKeyFromPageId(pageId);
if (!mPageStoreMap.containsKey(pageKey)) {
throw new PageNotFoundException(pageId.getFileId() + "_" + pageId.getPageIndex());
}
byte[] mPage = mPageStoreMap.get(pageKey);
Preconditions.checkArgument(pageOffset <= mPage.length, "page offset %s exceeded page size %s", pageOffset, mPage.length);
int bytesLeft = (int) Math.min(mPage.length - pageOffset, buffer.length - bufferOffset);
bytesLeft = Math.min(bytesLeft, bytesToRead);
System.arraycopy(mPage, pageOffset, buffer, bufferOffset, bytesLeft);
return bytesLeft;
}
Aggregations