Quadcap Embeddable Database

com/quadcap/sql/index/BIndex.java

Go to the documentation of this file.
00001 package com.quadcap.sql.index; 00002 00003 /* Copyright 1997 - 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 import java.io.IOException; 00042 import java.util.Enumeration; 00043 00044 /** 00045 * An index is simply a map, with byte arrays as keys. 00046 * 00047 * @author Stan Bailes 00048 */ 00049 public interface BIndex { 00050 /** 00051 * Return this index's comparator 00052 */ 00053 public Comparator getComparator(); 00054 00055 /** 00056 * Delete this index 00057 */ 00058 public void free() throws IOException; 00059 00060 /** 00061 * Get the data bytes for the specified key. If the key is found, return 00062 * the length of the data portion and place as many bytes as will fit in the 00063 * data array. If the key isn't found, return -1. 00064 */ 00065 public int get(byte[] key, int len, byte[] data) throws IOException; 00066 00067 /** 00068 * Delete the specified key. Return true if the key was deleted. 00069 */ 00070 public boolean delete(byte[] key) throws IOException; 00071 00072 /** 00073 * Add a new key. If the index is a UNIQUE index, then 00074 * the new key/data pair will only be added if the key does not already 00075 * exist, otherwise, insert will do nothing and return <b>false</b> 00076 * The existing value must not exist or an IOException will be thrown. 00077 * Otherwise, the new key/data pair is added regardless. 00078 */ 00079 public void insert(byte[] key, int klen, 00080 byte[] data, int off, int len) throws IOException; 00081 00082 /** 00083 * Update the data value for an existing key. This only works for 00084 * UNIQUE indexes, and only if the specified key already exists. 00085 * 00086 * @exception IOException may be thrown. 00087 */ 00088 public void update(byte[] key, int klen, 00089 byte[] data, int off, int len) throws IOException; 00090 00091 /** 00092 * Set the key/data pair, replacing any any value it may present in 00093 * a unique index, inserting a new values, whatever. Return 00094 * true if the key already existed before this operation. 00095 */ 00096 public boolean set(byte[] key, int klen, 00097 byte[] data, int off, int len) throws IOException; 00098 00099 /** 00100 * Obtain a cursor for most wondrously manipulating this index. 00101 */ 00102 public BCursor getCursor(boolean skipSetup) throws IOException; 00103 00104 // /** 00105 // * Close this index 00106 // */ 00107 // public void close() throws IOException; 00108 }