01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: KeySelector.java,v 1.6.2.2 2008/01/07 15:14:18 cwl Exp $
07: */
08:
09: 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: }
|