当前位置: 首页>>代码示例>>Java>>正文


Java SecondaryConfig.setSortedDuplicates方法代码示例

本文整理汇总了Java中com.sleepycat.je.SecondaryConfig.setSortedDuplicates方法的典型用法代码示例。如果您正苦于以下问题:Java SecondaryConfig.setSortedDuplicates方法的具体用法?Java SecondaryConfig.setSortedDuplicates怎么用?Java SecondaryConfig.setSortedDuplicates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sleepycat.je.SecondaryConfig的用法示例。


在下文中一共展示了SecondaryConfig.setSortedDuplicates方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: open

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
public void open() {
	sort_duplicates = false;
	super.open();

	try {
		SecondaryConfig dbConfig = new SecondaryConfig();
		dbConfig.setAllowCreate(true);
		
		if (storage.getBerkleyEnvironment().getConfig().getTransactional()) {
			dbConfig.setTransactional(true);
		}
		
		dbConfig.setKeyCreator(PlainSecondaryKeyCreator.getInstance());
		dbConfig.setSortedDuplicates(true);
		secondaryDb = storage.getBerkleyEnvironment().openSecondaryDatabase(null, SECONDARY_DB_NAME_PREFIX + name, 
						db, dbConfig);
	}
	catch (Throwable t) {
		throw new HGException("While attempting to open index ;" + name + "': " + t.toString(), t);
	}
}
 
开发者ID:hypergraphdb,项目名称:hypergraphdb,代码行数:22,代码来源:DefaultBiIndexImpl.java

示例2: open

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
private void open()
    throws DatabaseException {

    EnvironmentConfig envConfig = TestUtils.initEnvConfig();
    envConfig.setAllowCreate(true);

    env = new Environment(envHome, envConfig);

    DatabaseConfig priConfig = new DatabaseConfig();
    priConfig.setAllowCreate(true);

    priDb = env.openDatabase(null, "pri", priConfig);

    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);
    secConfig.setKeyCreator(new KeyCreator());

    secDb = env.openSecondaryDatabase(null, "sec", priDb, secConfig);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:21,代码来源:SecondarySplitTestMain.java

示例3: openSecondary

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
private SecondaryDatabase openSecondary(Database priDb, String dbName,
                                        boolean dups, int keyId)
    throws DatabaseException {

    SecondaryConfig dbConfig = new SecondaryConfig();
    dbConfig.setTransactional(isTransactional);
    dbConfig.setAllowCreate(true);
    dbConfig.setSortedDuplicates(dups);
    if (useMultiKey) {
        dbConfig.setMultiKeyCreator
            (new SimpleMultiKeyCreator(new MyKeyCreator(keyId)));
    } else {
        dbConfig.setKeyCreator(new MyKeyCreator(keyId));
    }

    Transaction txn = txnBegin();
    try {
        return env.openSecondaryDatabase(txn, dbName, priDb, dbConfig);
    } finally {
        txnCommit(txn);
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:23,代码来源:JoinTest.java

示例4: openSecondary

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
 * Opens the secondary database.
 */
private SecondaryDatabase openSecondary(Database priDb, String dbName,
                                        boolean allowDuplicates)
    throws DatabaseException {

    SecondaryConfig dbConfig = new SecondaryConfig();
    dbConfig.setTransactional(isTransactional);
    dbConfig.setAllowCreate(true);
    dbConfig.setSortedDuplicates(allowDuplicates);
    if (useMultiKey) {
        dbConfig.setMultiKeyCreator
            (new SimpleMultiKeyCreator(new MyKeyCreator()));
    } else {
        dbConfig.setKeyCreator(new MyKeyCreator());
    }
    Transaction txn = txnBegin();
    SecondaryDatabase secDb;
    try {
        secDb = env.openSecondaryDatabase(txn, dbName, priDb, dbConfig);
    } finally {
        txnCommit(txn);
    }
    return secDb;
}
 
开发者ID:nologic,项目名称:nabs,代码行数:27,代码来源:SecondaryDirtyReadTest.java

示例5: openSecondary

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
private SecondaryDatabase openSecondary(Database priDb,
                                        String dbName,
                                        boolean dups)
    throws DatabaseException {

    SecondaryConfig dbConfig = new SecondaryConfig();
    dbConfig.setTransactional(isTransactional);
    dbConfig.setAllowCreate(true);
    dbConfig.setSortedDuplicates(dups);
    dbConfig.setMultiKeyCreator(new MyKeyCreator());

    Transaction txn = txnBegin();
    try {
        return env.openSecondaryDatabase(txn, dbName, priDb, dbConfig);
    } finally {
        txnCommit(txn);
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:19,代码来源:ToManyTest.java

示例6: defaultSecondaryConfig

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
 * Default {@link SecondaryConfig}, {allowCreate: true, sortedDuplicates: true} with given {@link SecondaryKeyCreator}
 * @param keyCreator
 * @return
 */
public static SecondaryConfig defaultSecondaryConfig(SecondaryKeyCreator keyCreator) {
    SecondaryConfig cfg = new SecondaryConfig();
    cfg.setAllowCreate(true);
    //Duplicates are frequently required for secondary databases
    cfg.setSortedDuplicates(true);
    cfg.setTransactional(true);
    cfg.setKeyCreator(checkNotNull(keyCreator, "SecondaryKeyCreator cannot be null"));
    return cfg;
}
 
开发者ID:jronrun,项目名称:benayn,代码行数:15,代码来源:Berkeley.java

示例7: init

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
@Override
public void init() throws DatabaseException {
	
	SecondaryConfig config = new SecondaryConfig();
	config.setAllowCreate(true);
	config.setAllowPopulate(true);
	config.setTransactional(true);
	config.setImmutableSecondaryKey(immutableSecondaryKey);
	config.setSortedDuplicates(sortedDuplicates);
	
	config.setMultiKeyCreator(keyCreator);
	
	db = primary.envWrap.env.openSecondaryDatabase(null, name, primary.db, config);
}
 
开发者ID:mosscode,项目名称:bdbwrap,代码行数:15,代码来源:MultiKeySecondaryDbWrap.java

示例8: init

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
@Override
public void init() throws DatabaseException {
	
	SecondaryConfig config = new SecondaryConfig();
	config.setAllowCreate(true);
	config.setAllowPopulate(true);
	config.setTransactional(true);
	config.setImmutableSecondaryKey(immutableSecondaryKey);
	config.setSortedDuplicates(allowDuplicates);
	config.setKeyCreator(keyCreator);
	
	db = primary.envWrap.env.openSecondaryDatabase(null, name, primary.db, config);
}
 
开发者ID:mosscode,项目名称:bdbwrap,代码行数:14,代码来源:SingleKeySecondaryDbWrap.java

示例9: init

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/** 
 * Create all primary and secondary indices.
 */
private void init() 
    throws DatabaseException {

    System.out.println("-> Creating a JE database");
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true); 
    dbConfig.setAllowCreate(true);
    eventDb = env.openDatabase(null,      // use auto-commit txn
                                 "eventDb", // database name
                                 dbConfig);


    /* 
     * In our example, the database record is composed of a key portion
     * which represents the event timestamp, and a data portion holds an
     * instance of the Event class.
     *
     * JE's base api accepts and returns key and data as byte arrays, so we
     * need some support for marshaling between objects and byte arrays. We
     * call this binding, and supply a package of helper classes to support
     * this. It's entirely possible to do all binding on your own.
     *
     * A class catalog database is needed for storing class descriptions
     * for the serial binding used below. This avoids storing class
     * descriptions redundantly in each record.
     */
    DatabaseConfig catalogConfig = new DatabaseConfig();
    catalogConfig.setTransactional(true); 
    catalogConfig.setAllowCreate(true);
    catalogDb = env.openDatabase(null, "catalogDb", catalogConfig);
    StoredClassCatalog catalog = new StoredClassCatalog(catalogDb);

    /* 
     * Create a serial binding for Event data objects.  Serial
     * bindings can be used to store any Serializable object.
     * We can use some pre-defined binding classes to convert 
     * primitives like the long key value to the a byte array.
     */
    eventBinding = new SerialBinding(catalog, Event.class);

    /*
     * Open a secondary database to allow accessing the primary
     * database a secondary key value. In this case, access events
     * by price.
     */
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(true); 
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);
    secConfig.setKeyCreator(new PriceKeyCreator(eventBinding));
    eventByPriceDb = env.openSecondaryDatabase(null,
                                               "priceDb",
                                               eventDb,
                                               secConfig);

}
 
开发者ID:nologic,项目名称:nabs,代码行数:60,代码来源:EventExample.java

示例10: setup

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
public void setup(File envHome, boolean readOnly) 
    throws DatabaseException {

    EnvironmentConfig myEnvConfig = new EnvironmentConfig();
    DatabaseConfig myDbConfig = new DatabaseConfig();
    SecondaryConfig mySecConfig = new SecondaryConfig();

    // If the environment is read-only, then
    // make the databases read-only too.
    myEnvConfig.setReadOnly(readOnly);
    myDbConfig.setReadOnly(readOnly);
    mySecConfig.setReadOnly(readOnly);

    // If the environment is opened for write, then we want to be 
    // able to create the environment and databases if 
    // they do not exist.
    myEnvConfig.setAllowCreate(!readOnly);
    myDbConfig.setAllowCreate(!readOnly);
    mySecConfig.setAllowCreate(!readOnly);

    // Allow transactions if we are writing to the database
    myEnvConfig.setTransactional(!readOnly);
    myDbConfig.setTransactional(!readOnly);
    mySecConfig.setTransactional(!readOnly);

    // Open the environment
    myEnv = new Environment(envHome, myEnvConfig);

    // Now open, or create and open, our databases
    // Open the vendors and inventory databases
    vendorDb = myEnv.openDatabase(null, 
                                  "VendorDB",
                                   myDbConfig);

    inventoryDb = myEnv.openDatabase(null, 
                                    "InventoryDB",
                                     myDbConfig);
    
    // Open the class catalog db. This is used to 
    // optimize class serialization.
    classCatalogDb = 
        myEnv.openDatabase(null, 
                           "ClassCatalogDB",
                           myDbConfig);

    // Create our class catalog
    classCatalog = new StoredClassCatalog(classCatalogDb);

    // Need a tuple binding for the Inventory class. 
    // We use the InventoryBinding class
    // that we implemented for this purpose.
    TupleBinding inventoryBinding = new InventoryBinding();
                                                                                                                              
    // Open the secondary database. We use this to create a
    // secondary index for the inventory database

    // We want to maintain an index for the inventory entries based 
    // on the item name. So, instantiate the appropriate key creator 
    // and open a secondary database.
    ItemNameKeyCreator keyCreator = 
        new ItemNameKeyCreator(new InventoryBinding());

   
    // Set up additional secondary properties
    // Need to allow duplicates for our secondary database
    mySecConfig.setSortedDuplicates(true);
    mySecConfig.setAllowPopulate(true); // Allow autopopulate
    mySecConfig.setKeyCreator(keyCreator);

    // Now open it
    itemNameIndexDb = 
        myEnv.openSecondaryDatabase(
                null,     
                "itemNameIndex", // index name
                inventoryDb,     // the primary db that we're indexing
                mySecConfig);    // the secondary config 
}
 
开发者ID:nologic,项目名称:nabs,代码行数:78,代码来源:MyDbEnv.java

示例11: SampleDatabase

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
 * Open all storage containers, indices, and catalogs.
 */
public SampleDatabase(String homeDirectory)
    throws DatabaseException, FileNotFoundException {

    // Open the Berkeley DB environment in transactional mode.
    //
    System.out.println("Opening environment in: " + homeDirectory);
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setTransactional(true);
    envConfig.setAllowCreate(true);
    env = new Environment(new File(homeDirectory), envConfig);

    // Set the Berkeley DB config for opening all stores.
    //
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true);
    dbConfig.setAllowCreate(true);

    // Create the Serial class catalog.  This holds the serialized class
    // format for all database records of serial format.
    //
    Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
    javaCatalog = new StoredClassCatalog(catalogDb);

    // Open the Berkeley DB database for the part, supplier and shipment
    // stores.  The stores are opened with no duplicate keys allowed.
    //
    partDb = env.openDatabase(null, PART_STORE, dbConfig);

    supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);

    shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
    
    // Open the SecondaryDatabase for the city index of the supplier store,
    // and for the part and supplier indices of the shipment store.
    // Duplicate keys are allowed since more than one supplier may be in
    // the same city, and more than one shipment may exist for the same
    // supplier or part.  A foreign key constraint is defined for the
    // supplier and part indices to ensure that a shipment only refers to
    // existing part and supplier keys.  The CASCADE delete action means
    // that shipments will be deleted if their associated part or supplier
    // is deleted.
    //
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(true);
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);

    secConfig.setKeyCreator(
        new SupplierByCityKeyCreator(javaCatalog,
                                     SupplierKey.class,
                                     SupplierData.class,
                                     String.class));
    supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
                                                 supplierDb, secConfig);

    secConfig.setForeignKeyDatabase(partDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(
        new ShipmentByPartKeyCreator(javaCatalog,
                                     ShipmentKey.class,
                                     ShipmentData.class,
                                     PartKey.class));
    shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
                                                 shipmentDb, secConfig);

    secConfig.setForeignKeyDatabase(supplierDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(
        new ShipmentBySupplierKeyCreator(javaCatalog,
                                         ShipmentKey.class,
                                         ShipmentData.class,
                                         SupplierKey.class));
    shipmentBySupplierDb = env.openSecondaryDatabase(null,
                                                 SHIPMENT_SUPPLIER_INDEX,
                                                 shipmentDb, secConfig);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:80,代码来源:SampleDatabase.java

示例12: setup

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
public void setup(File envHome, boolean readOnly)
    throws DatabaseException {

    EnvironmentConfig myEnvConfig = new EnvironmentConfig();
    DatabaseConfig myDbConfig = new DatabaseConfig();
    SecondaryConfig mySecConfig = new SecondaryConfig();

    // If the environment is read-only, then
    // make the databases read-only too.
    myEnvConfig.setReadOnly(readOnly);
    myDbConfig.setReadOnly(readOnly);
    mySecConfig.setReadOnly(readOnly);

    // If the environment is opened for write, then we want to be
    // able to create the environment and databases if
    // they do not exist.
    myEnvConfig.setAllowCreate(!readOnly);
    myDbConfig.setAllowCreate(!readOnly);
    mySecConfig.setAllowCreate(!readOnly);

    // Allow transactions if we are writing to the database
    myEnvConfig.setTransactional(!readOnly);
    myDbConfig.setTransactional(!readOnly);
    mySecConfig.setTransactional(!readOnly);

    // Open the environment
    myEnv = new Environment(envHome, myEnvConfig);

    // Now open, or create and open, our databases
    // Open the vendors and inventory databases
    vendorDb = myEnv.openDatabase(null,
                                  "VendorDB",
                                   myDbConfig);

    inventoryDb = myEnv.openDatabase(null,
                                    "InventoryDB",
                                     myDbConfig);

    // Open the class catalog db. This is used to
    // optimize class serialization.
    classCatalogDb =
        myEnv.openDatabase(null,
                           "ClassCatalogDB",
                           myDbConfig);

    // Create our class catalog
    classCatalog = new StoredClassCatalog(classCatalogDb);

    // Need a tuple binding for the Inventory class.
    // We use the InventoryBinding class
    // that we implemented for this purpose.
    TupleBinding inventoryBinding = new InventoryBinding();

    // Open the secondary database. We use this to create a
    // secondary index for the inventory database

    // We want to maintain an index for the inventory entries based
    // on the item name. So, instantiate the appropriate key creator
    // and open a secondary database.
    ItemNameKeyCreator keyCreator =
        new ItemNameKeyCreator(inventoryBinding);

    // Set up additional secondary properties
    // Need to allow duplicates for our secondary database
    mySecConfig.setSortedDuplicates(true);
    mySecConfig.setAllowPopulate(true); // Allow autopopulate
    mySecConfig.setKeyCreator(keyCreator);

    // Now open it
    itemNameIndexDb =
        myEnv.openSecondaryDatabase(
                null,
                "itemNameIndex", // index name
                inventoryDb,     // the primary db that we're indexing
                mySecConfig);    // the secondary config
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:77,代码来源:MyDbEnv.java

示例13: SampleDatabase

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
 * Open all storage containers, indices, and catalogs.
 */
public SampleDatabase(String homeDirectory)
    throws DatabaseException, FileNotFoundException {

    // Open the Berkeley DB environment in transactional mode.
    //
    System.out.println("Opening environment in: " + homeDirectory);
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setTransactional(true);
    envConfig.setAllowCreate(true);
    env = new Environment(new File(homeDirectory), envConfig);

    // Set the Berkeley DB config for opening all stores.
    //
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true);
    dbConfig.setAllowCreate(true);

    // Create the Serial class catalog.  This holds the serialized class
    // format for all database records of serial format.
    //
    Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
    javaCatalog = new StoredClassCatalog(catalogDb);

    // Use the TupleSerialDbFactory for a Serial/Tuple-based database
    // where marshalling interfaces are used.
    //
    factory = new TupleSerialFactory(javaCatalog);

    // Open the Berkeley DB database for the part, supplier and shipment
    // stores.  The stores are opened with no duplicate keys allowed.
    //
    partDb = env.openDatabase(null, PART_STORE, dbConfig);

    supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);

    shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);

    // Open the SecondaryDatabase for the city index of the supplier store,
    // and for the part and supplier indices of the shipment store.
    // Duplicate keys are allowed since more than one supplier may be in
    // the same city, and more than one shipment may exist for the same
    // supplier or part.  A foreign key constraint is defined for the
    // supplier and part indices to ensure that a shipment only refers to
    // existing part and supplier keys.  The CASCADE delete action means
    // that shipments will be deleted if their associated part or supplier
    // is deleted.
    //
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(true);
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);

    secConfig.setKeyCreator(factory.getKeyCreator(Supplier.class,
                                                  Supplier.CITY_KEY));
    supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
                                                 supplierDb, secConfig);

    secConfig.setForeignKeyDatabase(partDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(factory.getKeyCreator(Shipment.class,
                                                  Shipment.PART_KEY));
    shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
                                                 shipmentDb, secConfig);

    secConfig.setForeignKeyDatabase(supplierDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(factory.getKeyCreator(Shipment.class,
                                                  Shipment.SUPPLIER_KEY));
    shipmentBySupplierDb = env.openSecondaryDatabase(null,
                                                 SHIPMENT_SUPPLIER_INDEX,
                                                 shipmentDb, secConfig);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:76,代码来源:SampleDatabase.java

示例14: SampleDatabase

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
 * Open all storage containers, indices, and catalogs.
 */
public SampleDatabase(String homeDirectory)
    throws DatabaseException, FileNotFoundException {

    // Open the Berkeley DB environment in transactional mode.
    //
    System.out.println("Opening environment in: " + homeDirectory);
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setTransactional(true);
    envConfig.setAllowCreate(true);
    env = new Environment(new File(homeDirectory), envConfig);

    // Set the Berkeley DB config for opening all stores.
    //
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true);
    dbConfig.setAllowCreate(true);

    // Create the Serial class catalog.  This holds the serialized class
    // format for all database records of serial format.
    //
    Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
    javaCatalog = new StoredClassCatalog(catalogDb);

    // Open the Berkeley DB database for the part, supplier and shipment
    // stores.  The stores are opened with no duplicate keys allowed.
    //
    partDb = env.openDatabase(null, PART_STORE, dbConfig);

    supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);

    shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
    
    // Open the SecondaryDatabase for the city index of the supplier store,
    // and for the part and supplier indices of the shipment store.
    // Duplicate keys are allowed since more than one supplier may be in
    // the same city, and more than one shipment may exist for the same
    // supplier or part.  A foreign key constraint is defined for the
    // supplier and part indices to ensure that a shipment only refers to
    // existing part and supplier keys.  The CASCADE delete action means
    // that shipments will be deleted if their associated part or supplier
    // is deleted.
    //
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(true);
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);

    secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
                                                     Supplier.class,
                                                     Supplier.CITY_KEY));
    supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
                                                 supplierDb, secConfig);

    secConfig.setForeignKeyDatabase(partDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
                                                     Shipment.class,
                                                     Shipment.PART_KEY));
    shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
                                                 shipmentDb, secConfig);

    secConfig.setForeignKeyDatabase(supplierDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new MarshalledKeyCreator(javaCatalog,
                                                     Shipment.class,
                                                 Shipment.SUPPLIER_KEY));
    shipmentBySupplierDb = env.openSecondaryDatabase(null,
                                                 SHIPMENT_SUPPLIER_INDEX,
                                                 shipmentDb, secConfig);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:74,代码来源:SampleDatabase.java

示例15: SampleDatabase

import com.sleepycat.je.SecondaryConfig; //导入方法依赖的package包/类
/**
 * Open all storage containers, indices, and catalogs.
 */
public SampleDatabase(String homeDirectory)
    throws DatabaseException, FileNotFoundException {

    // Open the Berkeley DB environment in transactional mode.
    //
    System.out.println("Opening environment in: " + homeDirectory);
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setTransactional(true);
    envConfig.setAllowCreate(true);
    env = new Environment(new File(homeDirectory), envConfig);

    // Set the Berkeley DB config for opening all stores.
    //
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true);
    dbConfig.setAllowCreate(true);

    // Create the Serial class catalog.  This holds the serialized class
    // format for all database records of serial format.
    //
    Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
    javaCatalog = new StoredClassCatalog(catalogDb);

    // Open the Berkeley DB database for the part, supplier and shipment
    // stores.  The stores are opened with no duplicate keys allowed.
    //
    partDb = env.openDatabase(null, PART_STORE, dbConfig);

    supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);

    shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
    
    // Open the SecondaryDatabase for the city index of the supplier store,
    // and for the part and supplier indices of the shipment store.
    // Duplicate keys are allowed since more than one supplier may be in
    // the same city, and more than one shipment may exist for the same
    // supplier or part.  A foreign key constraint is defined for the
    // supplier and part indices to ensure that a shipment only refers to
    // existing part and supplier keys.  The CASCADE delete action means
    // that shipments will be deleted if their associated part or supplier
    // is deleted.
    //
    SecondaryConfig secConfig = new SecondaryConfig();
    secConfig.setTransactional(true);
    secConfig.setAllowCreate(true);
    secConfig.setSortedDuplicates(true);

    secConfig.setKeyCreator(new SupplierByCityKeyCreator(javaCatalog,
                                                         Supplier.class));
    supplierByCityDb = env.openSecondaryDatabase(null, SUPPLIER_CITY_INDEX,
                                                 supplierDb, secConfig);

    secConfig.setForeignKeyDatabase(partDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new ShipmentByPartKeyCreator(javaCatalog,
                                                         Shipment.class));
    shipmentByPartDb = env.openSecondaryDatabase(null, SHIPMENT_PART_INDEX,
                                                 shipmentDb, secConfig);

    secConfig.setForeignKeyDatabase(supplierDb);
    secConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.CASCADE);
    secConfig.setKeyCreator(new ShipmentBySupplierKeyCreator(javaCatalog,
                                                          Shipment.class));
    shipmentBySupplierDb = env.openSecondaryDatabase(null,
                                                 SHIPMENT_SUPPLIER_INDEX,
                                                 shipmentDb, secConfig);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:71,代码来源:SampleDatabase.java


注:本文中的com.sleepycat.je.SecondaryConfig.setSortedDuplicates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。