2009-10-10 01:32:08 +02:00
// ObjectIndex.java
2005-10-26 14:37:22 +02:00
// ------------------
// part of the Kelondro Database
2008-07-20 19:14:51 +02:00
// (C) by Michael Peter Christen; mc@yacy.net
2005-10-26 14:37:22 +02:00
// first published on http://www.anomic.de
// Frankfurt, Germany, 2005
// created: 26.10.2005
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2005-10-27 02:42:08 +02:00
/ * A kelondroIndex is a table with indexed access on the first column
2005-10-26 14:37:22 +02:00
Elements may be selected from the table with logarithmic computation time
using the get - method . Inserts have also the same computation order and
can be done with the put - method .
The kelondro Database provides two implementations of this interface :
kelondroTree and kelondroHashtable
* /
2009-10-10 01:32:08 +02:00
package net.yacy.kelondro.index ;
2005-10-26 14:37:22 +02:00
import java.io.IOException ;
2008-01-20 02:22:46 +01:00
import java.util.ArrayList ;
2009-10-12 10:06:35 +02:00
import java.util.Iterator ;
2005-10-26 14:37:22 +02:00
2009-10-10 01:22:22 +02:00
import net.yacy.kelondro.order.CloneableIterator ;
2009-01-30 16:33:00 +01:00
public interface ObjectIndex {
2005-10-26 14:37:22 +02:00
2007-03-06 23:43:32 +01:00
public String filename ( ) ; // returns a unique identified for this index; can be a real or artificial file name
2007-04-19 15:37:02 +02:00
public int size ( ) ;
2009-12-02 01:37:59 +01:00
public boolean isEmpty ( ) ;
2009-01-30 16:33:00 +01:00
public Row row ( ) ;
2008-06-18 01:56:39 +02:00
public boolean has ( byte [ ] key ) ; // use this only if there is no get in case that has returns true
2009-01-30 16:33:00 +01:00
public Row . Entry get ( byte [ ] key ) throws IOException ;
2009-12-10 00:27:26 +01:00
public Row . Entry replace ( Row . Entry row ) throws IOException , RowSpaceExceededException ;
public void put ( Row . Entry row ) throws IOException , RowSpaceExceededException ;
public void addUnique ( Row . Entry row ) throws IOException , RowSpaceExceededException ; // no double-check
public ArrayList < RowCollection > removeDoubles ( ) throws IOException , RowSpaceExceededException ; // removes all elements that are double (to be used after all addUnique)
2009-01-30 16:33:00 +01:00
public Row . Entry remove ( byte [ ] key ) throws IOException ;
public Row . Entry removeOne ( ) throws IOException ;
2009-01-30 23:08:08 +01:00
public CloneableIterator < byte [ ] > keys ( boolean up , byte [ ] firstKey ) throws IOException ; // iterates only the key
2009-02-24 11:40:20 +01:00
public CloneableIterator < Row . Entry > rows ( boolean up , byte [ ] firstKey ) throws IOException ; // iterates the whole row using the order of the keys
public CloneableIterator < Row . Entry > rows ( ) throws IOException ; // iterates the whole row without any order
2009-10-12 10:06:35 +02:00
public Iterator < Row . Entry > iterator ( ) ;
2008-09-12 13:51:48 +02:00
public void deleteOnExit ( ) ;
2008-05-24 14:30:50 +02:00
public void clear ( ) throws IOException ;
2007-03-09 09:48:47 +01:00
public void close ( ) ;
2005-10-26 14:37:22 +02:00
}