/** * Initialize the BTree. * * @throws IOException If we get some exception while initializing the BTree */ public void init( BTree<K, V> parentBTree ) { if ( parentBTree == null ) { // This is not a subBtree, we have to initialize the cache // Create the queue containing the pending read transactions readTransactions = new ConcurrentLinkedQueue<ReadTransaction<K, V>>(); if ( cacheSize < 1 ) { cacheSize = DEFAULT_CACHE_SIZE; } cache = new LRUMap( cacheSize ); } else { this.cache = ( ( PersistedBTree<K, V> ) parentBTree ).getCache(); this.readTransactions = ( ( PersistedBTree<K, V> ) parentBTree ).getReadTransactions(); } // Initialize the txnManager thread //FIXME we should NOT create a new transaction manager thread for each BTree //createTransactionManager(); }
/** * Create a new holder storing an offset and a SoftReference containing the element. * * @param page The element to store into a SoftReference */ public PersistedPageHolder( BTree<K, V> btree, Page<K, V> page, long offset, long lastOffset ) { // DO NOT keep the reference to Page, it will be fetched from cache when needed super( btree, null ); cache = ( ( PersistedBTree<K, V> ) btree ).getCache(); recordManager = ( ( PersistedBTree<K, V> ) btree ).getRecordManager(); this.offset = offset; this.lastOffset = lastOffset; if ( page != null ) { ( ( AbstractPage<K, V> ) page ).setOffset( offset ); ( ( AbstractPage<K, V> ) page ).setLastOffset( lastOffset ); } cache.put( offset, page ); }
/** * Create a new holder storing an offset and a SoftReference containing the element. * * @param page The element to store into a SoftReference */ public PersistedPageHolder( BTree<K, V> btree, Page<K, V> page ) { // DO NOT keep the reference to Page, it will be fetched from cache when needed super( btree, null ); cache = ( ( PersistedBTree<K, V> ) btree ).getCache(); recordManager = ( ( PersistedBTree<K, V> ) btree ).getRecordManager(); offset = ( ( AbstractPage<K, V> ) page ).getOffset(); lastOffset = ( ( AbstractPage<K, V> ) page ).getLastOffset(); ( ( AbstractPage<K, V> ) page ).setOffset( offset ); ( ( AbstractPage<K, V> ) page ).setLastOffset( lastOffset ); cache.put( offset, page ); }