• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/db-4.8.30/java/src/com/sleepycat/db/
1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002-2009 Oracle.  All rights reserved.
5 *
6 * $Id$
7 */
8
9package com.sleepycat.db;
10
11import com.sleepycat.db.internal.DbConstants;
12
13/**
14The configuration properties of a <code>JoinCursor</code>.
15The join cursor configuration is specified when calling {@link
16Database#join Database.join}.
17<p>
18To create a configuration object with default attributes:
19<pre>
20    JoinConfig config = new JoinConfig();
21</pre>
22To set custom attributes:
23<pre>
24    JoinConfig config = new JoinConfig();
25    config.setNoSort(true);
26</pre>
27<p>
28@see Database#join Database.join
29@see JoinCursor
30*/
31public class JoinConfig implements Cloneable {
32    /**
33    Default configuration used if null is passed to {@link com.sleepycat.db.Database#join Database.join}
34    */
35   public static final JoinConfig DEFAULT = new JoinConfig();
36
37    /* package */
38    static JoinConfig checkNull(JoinConfig config) {
39        return (config == null) ? DEFAULT : config;
40    }
41
42    private boolean noSort;
43
44    /**
45    Creates an instance with the system's default settings.
46    */
47    public JoinConfig() {
48    }
49
50    /**
51    Specifies whether automatic sorting of the input cursors is disabled.
52    <p>
53    Joined values are retrieved by doing a sequential iteration over the
54    first cursor in the cursor array, and a nested iteration over each
55    following cursor in the order they are specified in the array. This
56    requires database traversals to search for the current datum in all the
57    cursors after the first. For this reason, the best join performance
58    normally results from sorting the cursors from the one that refers to
59    the least number of data items to the one that refers to the most.
60    Unless this method is called with true, <code>Database.join</code> does
61    this sort on behalf of its caller.
62    <p>
63    If the data are structured so that cursors with many data items also
64    share many common elements, higher performance will result from listing
65    those cursors before cursors with fewer data items; that is, a sort
66    order other than the default. Calling this method permits applications
67    to perform join optimization prior to calling
68    <code>Database.join</code>.
69    <p>
70    @param noSort whether automatic sorting of the input cursors is disabled.
71    <p>
72    @see Database#join Database.join
73    */
74    public void setNoSort(final boolean noSort) {
75        this.noSort = noSort;
76    }
77
78    /**
79    Returns whether automatic sorting of the input cursors is disabled.
80    <p>
81    @return whether automatic sorting of the input cursors is disabled.
82    <p>
83    @see #setNoSort
84    */
85    public boolean getNoSort() {
86        return noSort;
87    }
88
89    /* package */
90    int getFlags() {
91        return noSort ? DbConstants.DB_JOIN_NOSORT : 0;
92    }
93}
94