001: package com.quadcap.sql.index;
002:
003: /* Copyright 1997 - 2003 Quadcap Software. All rights reserved.
004: *
005: * This software is distributed under the Quadcap Free Software License.
006: * This software may be used or modified for any purpose, personal or
007: * commercial. Open Source redistributions are permitted. Commercial
008: * redistribution of larger works derived from, or works which bundle
009: * this software requires a "Commercial Redistribution License"; see
010: * http://www.quadcap.com/purchase.
011: *
012: * Redistributions qualify as "Open Source" under one of the following terms:
013: *
014: * Redistributions are made at no charge beyond the reasonable cost of
015: * materials and delivery.
016: *
017: * Redistributions are accompanied by a copy of the Source Code or by an
018: * irrevocable offer to provide a copy of the Source Code for up to three
019: * years at the cost of materials and delivery. Such redistributions
020: * must allow further use, modification, and redistribution of the Source
021: * Code under substantially the same terms as this license.
022: *
023: * Redistributions of source code must retain the copyright notices as they
024: * appear in each source code file, these license terms, and the
025: * disclaimer/limitation of liability set forth as paragraph 6 below.
026: *
027: * Redistributions in binary form must reproduce this Copyright Notice,
028: * these license terms, and the disclaimer/limitation of liability set
029: * forth as paragraph 6 below, in the documentation and/or other materials
030: * provided with the distribution.
031: *
032: * The Software is provided on an "AS IS" basis. No warranty is
033: * provided that the Software is free of defects, or fit for a
034: * particular purpose.
035: *
036: * Limitation of Liability. Quadcap Software shall not be liable
037: * for any damages suffered by the Licensee or any third party resulting
038: * from use of the Software.
039: */
040:
041: import java.io.IOException;
042:
043: /**
044: * BCursor
045: *
046: * @author Stan Bailes
047: */
048: public interface BCursor {
049: // Cursor positioning
050:
051: /**
052: * Seek to (before) the specified key
053: */
054: boolean seek(byte[] key, int len) throws IOException;
055:
056: /**
057: * Seek to (before) the specified key
058: */
059: boolean seek(byte[] buf) throws IOException;
060:
061: /**
062: * Position cursor before the first record
063: */
064: void beforeFirst() throws IOException;
065:
066: /**
067: * Position the cursor after the last record
068: */
069: void afterLast() throws IOException;
070:
071: /**
072: * Move to the specified record; one-based.
073: * -1 means last record, -2 means next to last, etc.
074: * @return <b>true</b> if the specified record exists.
075: */
076: boolean absolute(int x) throws IOException;
077:
078: /**
079: * Move past the next record and return true the cursor is
080: * now pointed at a valid record.
081: */
082: boolean next() throws IOException;
083:
084: /**
085: * Move before the previous record and return true the cursor is
086: * now pointed at a valid record.
087: */
088: boolean prev() throws IOException;
089:
090: int getKey(byte[] buf) throws IOException;
091:
092: byte[] getKeyBuf();
093:
094: void setKeyBuf(byte[] buf);
095:
096: int getKeyLen();
097:
098: byte[] getKey(); // XXX a crutch.
099:
100: int getVal(byte[] buf) throws IOException;
101:
102: byte[] getValBuf();
103:
104: void setValBuf(byte[] buf);
105:
106: int getValLen();
107:
108: byte[] getVal(); // XXX a crutch.
109:
110: long getValAsLong() throws IOException;
111:
112: long size() throws IOException;
113:
114: long position() throws IOException;
115:
116: /**
117: * Release this cursor back to the pool
118: */
119: void release();
120:
121: /**
122: * Release any resources held by this cursor (but maintain ownership of
123: * it -- it can be resurrected by another positioning call.
124: */
125: void close() throws IOException;
126:
127: /**
128: * Delete the currently positioned record
129: */
130: boolean delete() throws IOException;
131:
132: /**
133: * Insert a new key/data pair. We are presumably positioned just before
134: * the spot where the new record should go, but we will check, anyway.
135: */
136: boolean insert(byte[] key, int klen, byte[] data, int doff, int dlen)
137: throws IOException;
138:
139: boolean insert(byte[] key, byte[] data) throws IOException;
140:
141: /**
142: * Replace the data portion of the current item with the specified data
143: */
144: boolean replace(byte[] data, int doff, int dlen) throws IOException;
145:
146: boolean replace(byte[] data) throws IOException;
147:
148: }
|