1 21 22 package org.apache.derby.iapi.store.raw; 23 24 import org.apache.derby.iapi.store.raw.ContainerKey; 25 26 import org.apache.derby.iapi.services.sanity.SanityManager; 27 import org.apache.derby.iapi.services.io.CompressedNumber; 28 29 import java.io.ObjectOutput ; 30 import java.io.ObjectInput ; 31 import java.io.IOException ; 32 33 38 39 40 public class PageKey 41 { 42 private final ContainerKey container; 43 private final long pageNumber; 45 public PageKey(ContainerKey key, long pageNumber) { 46 container = key; 47 this.pageNumber = pageNumber; 48 } 49 50 public long getPageNumber() { 51 return pageNumber; 52 } 53 54 public ContainerKey getContainerId() { 55 return container; 56 } 57 58 61 62 public void writeExternal(ObjectOutput out) throws IOException 63 { 64 container.writeExternal(out); 65 CompressedNumber.writeLong(out, pageNumber); 66 } 67 68 public static PageKey read(ObjectInput in) throws IOException 69 { 70 ContainerKey c = ContainerKey.read(in); 71 long pn = CompressedNumber.readLong(in); 72 73 return new PageKey(c, pn); 74 } 75 76 77 80 81 public boolean equals(Object other) { 82 83 if (other instanceof PageKey) { 84 PageKey otherKey = (PageKey) other; 85 86 return (pageNumber == otherKey.pageNumber) && 87 container.equals(otherKey.container); 88 } 89 90 return false; 91 } 92 93 94 public int hashCode() { 95 96 return (int) (pageNumber ^ container.hashCode()); 97 } 98 99 public String toString() { 100 return "Page(" + pageNumber + "," + container.toString() + ")"; 101 } 102 103 } 104 | Popular Tags |