Skip to Main Content

Berkeley DB Family

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Javadoc clarification: SecondaryCursor.dup() fails if not initialized

archie172Feb 24 2009 — edited Feb 24 2009
Problem: the API Javadoc for Cursor.dup() and SecondaryCursor.dup() are basically the same. However, they behave very differently, as shown by the output of the test program below: Cursor.dup(false) succeeds when the cursor is not initialized, while SecondaryCursor.dup(false) throws an exception.

Please fix the Javadoc for SecondaryCursor.dup() to clarify when an exception will be thrown.

Program output:
Testing Cursor.dup(false) on uninitialized cursor: SUCCESS
Testing SecondaryCursor.dup(false) on uninitialized cursor: FAIL: (JE 3.3.75) Cursor Not Initialized.
Test program:
import com.sleepycat.je.*;
import java.io.File;

public class cursortest {
    public static void main(String[] args) throws Exception {

        // Create temp dir
        File dir = new File("/tmp/cursortest");
        if (!dir.mkdir())
            throw new Exception("can't create directory: " + dir);

        // Create environment
        EnvironmentConfig envConfig = new EnvironmentConfig();
        envConfig.setAllowCreate(true);
        envConfig.setTransactional(true);
        Environment env = new Environment(dir, envConfig);

        // Open primary db
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setAllowCreate(true);
        dbConfig.setTransactional(true);
        Database db = env.openDatabase(null, "primary", dbConfig);

        // Open secondary db
        SecondaryConfig sdbConfig = new SecondaryConfig();
        sdbConfig.setAllowCreate(true);
        sdbConfig.setAllowPopulate(true);
        sdbConfig.setTransactional(true);
        sdbConfig.setKeyCreator(new SecondaryKeyCreator() {
            public boolean createSecondaryKey(SecondaryDatabase sdb,
              DatabaseEntry key, DatabaseEntry data, DatabaseEntry result) {
                return false;
            }
        });
        SecondaryDatabase sdb = env.openSecondaryDatabase(null, "secondary", db, sdbConfig);

        // Test primary cursor
        Cursor cursor = db.openCursor(null, new CursorConfig());
        testDup(cursor);
        cursor.close();

        // Test secondary cursor
        cursor = sdb.openSecondaryCursor(null, new CursorConfig());
        testDup(cursor);
        cursor.close();
    }

    public static void testDup(Cursor cursor) throws DatabaseException {
        System.out.print("Testing " + cursor.getClass().getSimpleName() + ".dup(false) on uninitialized cursor: ");
        Cursor dup = null;
        try {
            dup = cursor.dup(false);
            System.out.println("SUCCESS");
        } catch (DatabaseException e) {
            System.out.println("FAIL: " + e.getMessage());
        }
        if (dup != null)
            dup.close();
    }
}
Added better code formatting.
This post has been answered by Greybird-Oracle on Feb 24 2009
Jump to Answer

Comments

981516
hi
you have missing value in weight. if it is low you can replace with values in transform in ODM.
if you have consuming field you can use prediction method and because of type of it(real) regression or neural network suggest.
I think if you can use time series model specially ARCH or GHARCH models, your result will better but ODM and many other tools don't have it.
Mark Kelly-Oracle
FYI.
If you are interested in time series, that is indeed included in the Oracle Advanced Analtyics option. The option includes both Data Mining (ODM) and Oracle R Enterprise. Oracle R includes time series. At some point, you will also be able to run Oracle R scripts within Data Miner. See link below for more info on R/Timeseries.
Thanks, Mark
http://www.oracle.com/technetwork/database/options/advanced-analytics/r-enterprise/index.html
1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 24 2009
Added on Feb 24 2009
4 comments
3,111 views