Quadcap Embeddable Database

com/quadcap/sql/file/Page.java

Go to the documentation of this file.
00001 package com.quadcap.sql.file; 00002 00003 /* Copyright 1999 - 2003 Quadcap Software. All rights reserved. 00004 * 00005 * This software is distributed under the Quadcap Free Software License. 00006 * This software may be used or modified for any purpose, personal or 00007 * commercial. Open Source redistributions are permitted. Commercial 00008 * redistribution of larger works derived from, or works which bundle 00009 * this software requires a "Commercial Redistribution License"; see 00010 * http://www.quadcap.com/purchase. 00011 * 00012 * Redistributions qualify as "Open Source" under one of the following terms: 00013 * 00014 * Redistributions are made at no charge beyond the reasonable cost of 00015 * materials and delivery. 00016 * 00017 * Redistributions are accompanied by a copy of the Source Code or by an 00018 * irrevocable offer to provide a copy of the Source Code for up to three 00019 * years at the cost of materials and delivery. Such redistributions 00020 * must allow further use, modification, and redistribution of the Source 00021 * Code under substantially the same terms as this license. 00022 * 00023 * Redistributions of source code must retain the copyright notices as they 00024 * appear in each source code file, these license terms, and the 00025 * disclaimer/limitation of liability set forth as paragraph 6 below. 00026 * 00027 * Redistributions in binary form must reproduce this Copyright Notice, 00028 * these license terms, and the disclaimer/limitation of liability set 00029 * forth as paragraph 6 below, in the documentation and/or other materials 00030 * provided with the distribution. 00031 * 00032 * The Software is provided on an "AS IS" basis. No warranty is 00033 * provided that the Software is free of defects, or fit for a 00034 * particular purpose. 00035 * 00036 * Limitation of Liability. Quadcap Software shall not be liable 00037 * for any damages suffered by the Licensee or any third party resulting 00038 * from use of the Software. 00039 */ 00040 00041 /** 00042 * This interface models a page of data in a block file, either a main page 00043 * (aka a Block) or a sub-page. 00044 * 00045 * @author Stan Bailes 00046 */ 00047 public interface Page { 00048 /** 00049 * Return this page's block number 00050 */ 00051 public long getPageNum(); 00052 00053 /** 00054 * An artifact of the Cacheable interface implemented by the Block 00055 * class, we need to keep track of which objects are actually being 00056 * used so unused objects can be flushed from the cache to make room 00057 * for new objects. At some point, we can get rid of this in favor 00058 * of weak references. 00059 */ 00060 public void decrRefCount(); 00061 00062 /** 00063 * Read a range of bytes from the page. 00064 * 00065 * @param pos the offset in the page of the first byte to read 00066 * @param pbuf the buffer into which the bytes are placed. 00067 * @param offset the offset in <code>pbuf</code> where the first byte 00068 * is placed. 00069 * @param len the number of bytes to read 00070 */ 00071 public int read(int pos, byte[] pbuf, int offset, int len); 00072 00073 /** 00074 * Write a range of bytes to the page. 00075 * 00076 * @param pos the offset in the page of the first byte to write 00077 * @param pbuf the buffer from which the bytes are obtained 00078 * @param offset the offset in <code>pbuf</code> of the first byte 00079 * to write 00080 * @param len the number of bytes to write 00081 */ 00082 public int write(int pos, byte[] pbuf, int offset, int len); 00083 00084 /** 00085 * Read an integer (4-byte) value from the page. 00086 * 00087 * @param pos the offset in the page of the integer. 00088 */ 00089 public int readInt(int pos); 00090 00091 /** 00092 * Write an integer (4-byte) value to the page. 00093 * 00094 * @param pos the offset in the page of the integer. 00095 * @param val the integer value to write. 00096 */ 00097 public void writeInt(int pos, int val); 00098 00099 /** 00100 * Read an long (8-byte) value from the page. 00101 * 00102 * @param pos the offset in the page of the long. 00103 */ 00104 public long readLong(int pos); 00105 00106 /** 00107 * Write an long (8-byte) value to the page. 00108 * 00109 * @param pos the offset in the page of the long. 00110 * @param val the long value to write. 00111 */ 00112 public void writeLong(int pos, long val); 00113 00114 /** 00115 * Move the contents of the other page to this page, and zero out 00116 * the other page. 00117 */ 00118 public void takeData(Page p); 00119 00120 /** 00121 * Zero this page 00122 */ 00123 public void clear(); 00124 00125 }