1 14 15 package org.apache.activemq.kaha.impl.index.hash; 16 17 import java.io.IOException ; 18 19 24 class HashPageInfo{ 25 26 private HashIndex hashIndex; 27 private long id; 28 private int size; 29 private HashPage page; 30 private boolean dirty=false; 31 32 HashPageInfo(HashIndex index){ 33 this.hashIndex=index; 34 } 35 36 39 long getId(){ 40 return this.id; 41 } 42 43 46 void setId(long id){ 47 this.id=id; 48 } 49 50 53 int size(){ 54 return this.size; 55 } 56 57 60 void setSize(int size){ 61 this.size=size; 62 } 63 64 void addHashEntry(int index,HashEntry entry) throws IOException { 65 page.addHashEntry(index,entry); 66 size++; 67 dirty=true; 68 } 69 70 HashEntry getHashEntry(int index) throws IOException { 71 return page.getHashEntry(index); 72 } 73 74 HashEntry removeHashEntry(int index) throws IOException { 75 HashEntry result=page.removeHashEntry(index); 76 if(result!=null){ 77 size--; 78 dirty=true; 79 } 80 return result; 81 } 82 83 void dump(){ 84 page.dump(); 85 } 86 87 void begin() throws IOException { 88 if(page==null){ 89 page=hashIndex.getFullPage(id); 90 } 91 } 92 93 void end() throws IOException { 94 if(page!=null){ 95 if(dirty){ 96 hashIndex.writeFullPage(page); 97 } 98 } 99 page=null; 100 dirty=false; 101 } 102 103 HashPage getPage(){ 104 return page; 105 } 106 107 void setPage(HashPage page){ 108 this.page=page; 109 } 110 } 111 | Popular Tags |