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: import java.util.Enumeration;
043:
044: /**
045: * An index is simply a map, with byte arrays as keys.
046: *
047: * @author Stan Bailes
048: */
049: public interface BIndex {
050: /**
051: * Return this index's comparator
052: */
053: public Comparator getComparator();
054:
055: /**
056: * Delete this index
057: */
058: public void free() throws IOException;
059:
060: /**
061: * Get the data bytes for the specified key. If the key is found, return
062: * the length of the data portion and place as many bytes as will fit in the
063: * data array. If the key isn't found, return -1.
064: */
065: public int get(byte[] key, int len, byte[] data) throws IOException;
066:
067: /**
068: * Delete the specified key. Return true if the key was deleted.
069: */
070: public boolean delete(byte[] key) throws IOException;
071:
072: /**
073: * Add a new key. If the index is a UNIQUE index, then
074: * the new key/data pair will only be added if the key does not already
075: * exist, otherwise, insert will do nothing and return <b>false</b>
076: * The existing value must not exist or an IOException will be thrown.
077: * Otherwise, the new key/data pair is added regardless.
078: */
079: public void insert(byte[] key, int klen, byte[] data, int off,
080: int len) throws IOException;
081:
082: /**
083: * Update the data value for an existing key. This only works for
084: * UNIQUE indexes, and only if the specified key already exists.
085: *
086: * @exception IOException may be thrown.
087: */
088: public void update(byte[] key, int klen, byte[] data, int off,
089: int len) throws IOException;
090:
091: /**
092: * Set the key/data pair, replacing any any value it may present in
093: * a unique index, inserting a new values, whatever. Return
094: * true if the key already existed before this operation.
095: */
096: public boolean set(byte[] key, int klen, byte[] data, int off,
097: int len) throws IOException;
098:
099: /**
100: * Obtain a cursor for most wondrously manipulating this index.
101: */
102: public BCursor getCursor(boolean skipSetup) throws IOException;
103:
104: // /**
105: // * Close this index
106: // */
107: // public void close() throws IOException;
108: }
|