KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > persist > KeySelector


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: KeySelector.java,v 1.6 2006/10/30 21:14:30 bostic Exp $
7  */

8
9 package com.sleepycat.persist;
10
11 /**
12  * This is package-private to hide it until we implemented unsorted access.
13  *
14  * Implemented to select keys to be returned by an unsorted {@code
15  * ForwardCursor}.
16  *
17  * <p>The reason for implementing a selector, rather than filtering the objects
18  * returned by the {@link ForwardCursor}, is to improve performance when not
19  * all keys are to be processed. Keys are passed to this interface without
20  * retrieving record data or locking, so it is less expensive to return false
21  * from this method than to retrieve the object from the cursor.</p>
22  *
23  * @see EntityIndex#unsortedKeys
24  * @see EntityIndex#unsortedEntities
25  *
26  * @author Mark Hayes
27  */

28 interface KeySelector<K> {
29
30     /**
31      * Returns whether a given key should be returned via the cursor.
32      *
33      * <p>This method should not assume that the given key is for a committed
34      * record or not, nor should it assume that the key will be returned via
35      * the cursor if this method returns true. The record for this key will
36      * not be locked until this method returns. If, when the record is locked,
37      * the record is found to be uncommitted or deleted, the key will not be
38      * returned via the cursor.</p>
39      */

40     boolean selectKey(K key);
41 }
42
Popular Tags