/** * Frees up a previously allocated page so that it can be re-allocated again. * * @param pageId the page to free up * @throws IOException * If an disk error occurred. * @throws IllegalStateException * if the PageFile is not loaded */ public void free(long pageId) throws IOException { free(load(pageId, null)); }
/** * Frees up a previously allocated sequence of pages so that it can be re-allocated again. * * @param pageId the initial page of the sequence that will be getting freed * @param count the number of pages in the sequence * * @throws IOException * If an disk error occurred. * @throws IllegalStateException * if the PageFile is not loaded */ public void free(long pageId, int count) throws IOException { free(load(pageId, null), count); }
synchronized void load(Transaction tx) throws IOException { if (loaded.compareAndSet(false, true)) { page = tx.load(pageId, null); if (page.getType() == Page.PAGE_FREE_TYPE) { page.set(null); tx.store(page, messageStoreStatisticsMarshaller, true); } } page = tx.load(pageId, messageStoreStatisticsMarshaller); }
synchronized void put(Transaction tx, MessageStoreStatistics storeStatistics) throws IOException { if (page == null) { page = tx.load(pageId, messageStoreStatisticsMarshaller); } page.set(storeStatistics); tx.store(page, messageStoreStatisticsMarshaller, true); } }
private HashBin<Key,Value> getBin(Transaction tx, int i, long basePage) throws IOException { Page<HashBin<Key, Value>> page = tx.load(basePage + i, hashBinMarshaller); HashBin<Key, Value> rc = page.get(); rc.setPage(page); return rc; }
synchronized public void load(Transaction tx) throws IOException { if (loaded.compareAndSet(false, true)) { LOG.debug("loading"); if( keyMarshaller == null ) { throw new IllegalArgumentException("The key marshaller must be set before loading the BTreeIndex"); } if( valueMarshaller == null ) { throw new IllegalArgumentException("The value marshaller must be set before loading the BTreeIndex"); } final Page<BTreeNode<Key,Value>> p = tx.load(pageId, null); if( p.getType() == Page.PAGE_FREE_TYPE ) { // Need to initialize it.. BTreeNode<Key, Value> root = createNode(p, null); storeNode(tx, root, true); } } }
/** * Loads a page from disk. * * @param pageId * the id of the page to load * @param marshaller * the marshaler to use to load the data portion of the Page, may be null if you do not wish to load the data. * @return The page with the given id * @throws IOException * If an disk error occurred. * @throws IllegalStateException * if the PageFile is not loaded */ public <T> Page<T> load(long pageId, Marshaller<T> marshaller) throws IOException { pageFile.assertLoaded(); Page<T> page = new Page<T>(pageId); load(page, marshaller); return page; }
BTreeNode<Key,Value> loadNode(Transaction tx, long pageId, BTreeNode<Key,Value> parent) throws IOException { Page<BTreeNode<Key,Value>> page = tx.load(pageId, marshaller); BTreeNode<Key, Value> node = page.get(); node.setPage(page); node.setParent(parent); return node; }
ListNode<Key,Value> loadNode(Transaction tx, long pageId) throws IOException { Page<ListNode<Key,Value>> page = tx.load(pageId, marshaller); ListNode<Key, Value> node = page.get(); node.setPage(page); node.setContainingList(this); return node; }
private void findNextPage() { if (!pageFile.isLoaded()) { throw new IllegalStateException("Cannot iterate the pages when the page file is not loaded"); } if (nextPage != null) { return; } try { while (nextId < pageFile.getPageCount()) { Page page = load(nextId, null); if (includeFreePages || page.getType() != Page.PAGE_FREE_TYPE) { nextPage = page; return; } else { nextId++; } } } catch (IOException e) { } }
public ListNode<Key,Value> createNode(Transaction tx) throws IOException { return createNode(tx.<ListNode<Key,Value>>load(tx.<ListNode<Key,Value>>allocate().getPageId(), null)); }
/** * @param tx * @param pageId * @throws IOException */ private void clearBinAtPage(Transaction tx, long pageId) throws IOException { Page<HashBin<Key,Value>> page = tx.load(pageId, null); HashBin<Key, Value> bin = new HashBin<Key,Value>(); bin.setPage(page); page.set(bin); store(tx, bin); }
/** * Frees up a previously allocated sequence of pages so that it can be re-allocated again. * * @param page the initial page of the sequence that will be getting freed * @param count the number of pages in the sequence * * @throws IOException * If an disk error occurred. * @throws IllegalStateException * if the PageFile is not loaded */ public <T> void free(Page<T> page, int count) throws IOException { pageFile.assertLoaded(); long offsetPage = page.getPageId(); while (count-- > 0) { if (page == null) { page = load(offsetPage, null); } free(page); page = null; // Increment the offsetPage value since using it depends on the current count. offsetPage++; } }
public synchronized void load(Transaction tx) throws IOException { if (loaded.compareAndSet(false, true)) { final Page<Metadata> metadataPage = tx.load(pageId, metadataMarshaller);
final Page<ListNode<Key,Value>> p = tx.load(getHeadPageId(), null); if( p.getType() == Page.PAGE_FREE_TYPE ) {
Page next; if (current.getType() == Page.PAGE_PART_TYPE) { next = load(current.getNext(), null); } else { next = allocate();
next = load(page.getNext(), null);
private HashBin<Key,Value> getBin(Transaction tx, int i, long basePage) throws IOException { Page<HashBin<Key, Value>> page = tx.load(basePage + i, hashBinMarshaller); HashBin<Key, Value> rc = page.get(); rc.setPage(page); return rc; }
private HashBin<Key,Value> getBin(Transaction tx, int i, long basePage) throws IOException { Page<HashBin<Key, Value>> page = tx.load(basePage + i, hashBinMarshaller); HashBin<Key, Value> rc = page.get(); rc.setPage(page); return rc; }
ListNode<Key,Value> loadNode(Transaction tx, long pageId) throws IOException { Page<ListNode<Key,Value>> page = tx.load(pageId, marshaller); ListNode<Key, Value> node = page.get(); node.setPage(page); node.setContainingList(this); return node; }