1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.mavibot.btree; 21 22 23 import java.io.IOException; 24 25 import org.apache.directory.mavibot.btree.exception.EndOfFileExceededException; 26 27 28 /** 29 * A Cursor is used to fetch elements in a BTree and is returned by the 30 * @see BTree#browse method. The cursor <strng>must</strong> be closed 31 * when the user is done with it. 32 * <p> 33 * 34 * @param <K> The type for the Key 35 * @param <V> The type for the stored value 36 * 37 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 38 */ 39 public interface TupleCursor<K, V> extends Cursor<K> 40 { 41 /** 42 * Find the next key/value 43 * 44 * @return A Tuple containing the found key and value 45 * @throws IOException 46 * @throws EndOfFileExceededException 47 */ 48 Tuple<K, V> next() throws EndOfFileExceededException, IOException; 49 50 51 /** 52 * Find the previous key/value 53 * 54 * @return A Tuple containing the found key and value 55 * @throws IOException 56 * @throws EndOfFileExceededException 57 */ 58 Tuple<K, V> prev() throws EndOfFileExceededException, IOException; 59 60 61 /** 62 * @return The revision this cursor is based on 63 */ 64 long getRevision(); 65 66 67 /** 68 * @return The creation date for this cursor 69 */ 70 long getCreationDate(); 71 72 73 /** 74 * Moves the cursor to the next non-duplicate key. 75 76 * If the BTree contains 77 * 78 * <ul> 79 * <li><1,0></li> 80 * <li><1,1></li> 81 * <li><2,0></li> 82 * <li><2,1></li> 83 * </ul> 84 * 85 * and cursor is present at <1,0> then the cursor will move to <2,0> 86 * 87 * @throws EndOfFileExceededException 88 * @throws IOException 89 */ 90 void moveToNextNonDuplicateKey() throws EndOfFileExceededException, IOException; 91 92 93 /** 94 * Moves the cursor to the previous non-duplicate key 95 * If the BTree contains 96 * 97 * <ul> 98 * <li><1,0></li> 99 * <li><1,1></li> 100 * <li><2,0></li> 101 * <li><2,1></li> 102 * </ul> 103 * 104 * and cursor is present at <2,1> then the cursor will move to <1,1> 105 * 106 * @throws EndOfFileExceededException 107 * @throws IOException 108 */ 109 void moveToPrevNonDuplicateKey() throws EndOfFileExceededException, IOException; 110 }