2 * Copyright (c) 2007, Solido Systems
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
15 * Neither the name of Solido Systems nor the names of its contributors may be
16 * used to endorse or promote products derived from this software without
17 * specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 package com.solidosystems.tuplesoup.core;
36 import java.nio.channels.*;
37 import com.solidosystems.tuplesoup.filter.*;
40 * The table stores a group of rows.
41 * Every row must have a unique id within a table.
43 public interface Table{
44 // Index type constants
45 public static final int MEMORY=0;
46 public static final int FLAT=1;
47 public static final int PAGED=2;
49 // Row location constants
50 public static final int FILEA=0;
51 public static final int FILEB=1;
52 public static final int DELETE=2;
53 public static final int INDEX=3;
56 * Return the current values of the statistic counters and reset them.
57 * The current counters are:
60 * <li>stat_table_update
61 * <li>stat_table_delete
62 * <li>stat_table_add_size
63 * <li>stat_table_update_size
64 * <li>stat_table_read_size
66 * <li>stat_table_cache_hit
67 * <li>stat_table_cache_miss
68 * <li>stat_table_cache_drop
70 * Furthermore, the index will be asked to deliver separate index specific counters
72 public Hashtable<String,Long> readStatistics();
75 * Set the maximal allowable size of the index cache.
77 public void setIndexCacheSize(int newsize);
80 * Close all open file streams
85 * Returns the name of this table
87 public String getTitle();
90 * Returns the location of this tables datafiles
92 public String getLocation();
95 * Delete the files created by this table object.
96 * Be aware that this will delete any data stored in this table!
98 public void deleteFiles();
101 * Adds a row of data to this table.
103 public void addRow(Row row) throws IOException;
106 * Adds a row to this table if it doesn't already exist, if it does it updates the row instead.
107 * This method is much slower than directly using add or update, so only use it if you don't know wether or not the row already exists.
109 public void addOrUpdateRow(Row row) throws IOException;
112 * Updates a row stored in this table.
114 public void updateRow(Row row) throws IOException;
117 * Marks a row as deleted in the index.
118 * Be aware that the space consumed by the row is not actually reclaimed.
120 public void deleteRow(Row row) throws IOException;
123 * Returns a tuplestream containing the given list of rows
125 public TupleStream getRows(List<String> rows) throws IOException;
128 * Returns a tuplestream containing the rows matching the given rowmatcher
130 public TupleStream getRows(RowMatcher matcher) throws IOException;
133 * Returns a tuplestream containing those rows in the given list that matches the given RowMatcher
135 public TupleStream getRows(List<String> rows,RowMatcher matcher) throws IOException;
138 * Returns a tuplestream of all rows in this table.
140 public TupleStream getRows() throws IOException;
143 * Returns a single row stored in this table.
144 * If the row does not exist in the table, null will be returned.
146 public Row getRow(String id) throws IOException;