001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.activemq.kaha.impl.index;
018
019 import java.io.IOException;
020 import org.apache.activemq.kaha.Marshaller;
021 import org.apache.activemq.kaha.StoreEntry;
022
023 /**
024 * Simplier than a Map
025 *
026 *
027 */
028 public interface Index {
029
030 /**
031 * clear the index
032 *
033 * @throws IOException
034 *
035 */
036 void clear() throws IOException;
037
038 /**
039 * @param key
040 * @return true if it contains the key
041 * @throws IOException
042 */
043 boolean containsKey(Object key) throws IOException;
044
045 /**
046 * remove the index key
047 *
048 * @param key
049 * @return StoreEntry removed
050 * @throws IOException
051 */
052 StoreEntry remove(Object key) throws IOException;
053
054 /**
055 * store the key, item
056 *
057 * @param key
058 * @param entry
059 * @throws IOException
060 */
061 void store(Object key, StoreEntry entry) throws IOException;
062
063 /**
064 * @param key
065 * @return the entry
066 * @throws IOException
067 */
068 StoreEntry get(Object key) throws IOException;
069
070 /**
071 * @return true if the index is transient
072 */
073 boolean isTransient();
074
075 /**
076 * load indexes
077 */
078 void load();
079
080 /**
081 * unload indexes
082 *
083 * @throws IOException
084 */
085 void unload() throws IOException;
086
087 /**
088 * Set the marshaller for key objects
089 *
090 * @param marshaller
091 */
092 void setKeyMarshaller(Marshaller marshaller);
093
094 /**
095 * return the size of the index
096 * @return
097 */
098 int getSize();
099
100 /**
101 * delete all state associated with the index
102 *
103 * @throws IOException
104 */
105 void delete() throws IOException;
106 }