config = new SecondaryConfig(); config.setTransactional(priConfig.getTransactional()); config.setAllowCreate(!priConfig.getReadOnly()); config.setReadOnly(priConfig.getReadOnly()); DbCompat.setTypeBtree(config); config.setReplicated(priConfig.getReplicated()); config.setTemporary(priConfig.getTemporary()); config.setDeferredWrite(priConfig.getDeferredWrite()); config.setOverrideBtreeComparator(true); config.setOverrideDuplicateComparator(true); config.setAllowPopulate(true); Relationship rel = secKeyMeta.getRelationship(); config.setSortedDuplicates(rel == Relationship.MANY_TO_ONE || rel == Relationship.MANY_TO_MANY); setBtreeComparator(config, keyClassName); config.setDuplicateComparator(priConfig.getBtreeComparator()); PersistKeyCreator keyCreator = new PersistKeyCreator (catalog, entityMeta, keyClassName, secKeyMeta, rawAccess); if (rel == Relationship.ONE_TO_MANY || rel == Relationship.MANY_TO_MANY) { config.setMultiKeyCreator(keyCreator); } else { config.setKeyCreator(keyCreator); config.setForeignKeyDeleteAction(baseDeleteAction); if (deleteAction == DeleteAction.NULLIFY) { config.setForeignMultiKeyNullifier(keyCreator);
public SecondaryConfig getSecondaryConfig() { if (secondaryConfig == null) { secondaryConfig = new SecondaryConfig(); secondaryConfig.setAllowCreate(true); secondaryConfig.setTransactional(true); secondaryConfig.setKeyPrefixing(true); secondaryConfig.setMultiKeyCreator(new KeyCreator()); secondaryConfig.setForeignKeyDatabase(getPrimary().get()); secondaryConfig.setForeignKeyDeleteAction(ForeignKeyDeleteAction.ABORT); secondaryConfig.setBtreeComparator(new FastKeyComparator()); secondaryConfig.setSortedDuplicates(true); } return secondaryConfig; }
protected SecondaryConfig indexConfig(BDBJEConfig bdbConfig, Environment env) { LastModKeyCreator keyCreator = new LastModKeyCreator(); SecondaryConfig secConfig = new SecondaryConfig(); secConfig.setAllowCreate(env.getConfig().getAllowCreate()); secConfig.setTransactional(bdbConfig.useTransactions); // should not need to auto-populate; except if re-creating broken // indexes? (in which case one would have to drop index first, then re-open) secConfig.setAllowPopulate(false); secConfig.setKeyCreator(keyCreator); // important: timestamps are not unique, need to allow dups: secConfig.setSortedDuplicates(true); // no, it is not immutable (entries will be updated with new timestamps) secConfig.setImmutableSecondaryKey(false); secConfig.setDeferredWrite(bdbConfig.useDeferredWritesForEntries()); return secConfig; }
assert config.getAllowPopulate(); assert !config.getExclusiveCreate(); final Database priDb = priIndex.getDatabase(); final ComplexFormat entityFormat = (ComplexFormat) ((PersistEntityBinding) priIndex.getEntityBinding()).entityFormat; final boolean saveAllowCreate = config.getAllowCreate(); config.getOverrideDuplicateComparator(); config.getDuplicateComparator(); try { if (doNotCreate) { config.setAllowCreate(false); if (config.getAllowCreate()) { config.setExclusiveCreate(true); if (config.getDuplicateComparator() != null && entityFormat.setSecKeyCorrectlyOrdered(keyName)) { catalog.flush(txn); config.setAllowCreate(false); config.setAllowPopulate(false); config.setExclusiveCreate(false); if (config.getDuplicateComparator() != null && entityFormat.isSecKeyIncorrectlyOrdered(keyName)) { config.setOverrideDuplicateComparator(false);
SecondaryConfig mySecConfig = new SecondaryConfig(); mySecConfig.setDeferredWrite(true); mySecConfig.setAllowCreate(true); mySecConfig.setSortedDuplicates(true); mySecConfig.setKeyCreator(new BerkeleyIntegerNameKeyCreator(this)); SecondaryConfig mySecConfigRel = new SecondaryConfig(); mySecConfigRel.setDeferredWrite(true); mySecConfigRel.setAllowCreate(true); mySecConfigRel.setSortedDuplicates(true); mySecConfigRel .setKeyCreator(new BerkeleyRelationKeyNameKeyCreator(this));
private void openOrCreate() throws DatabaseException, IllegalStateException, DatabaseExistsException, DatabaseNotFoundException, IllegalArgumentException { // Open the database. Create it if it does not already exist. this.ownerDirectory = env.openDatabase(null, "ownerDirecotry", new DatabaseConfig().setAllowCreate(true).setTransactional(true)); this.ownerIndex = env.openSecondaryDatabase(null, "ownerIndex", ownerDirectory, ((SecondaryConfig) (new SecondaryConfig().setAllowCreate(true).setSortedDuplicates(true).setTransactional(true))).setAllowPopulate(true).setKeyCreator(new OwnerKeyCreator())); this.mainStore = env.openDatabase(null, "mainStore", new DatabaseConfig().setAllowCreate(true).setTransactional(true)); this.allocationDirectory = env.openDatabase(null, "allocationDirectory", new DatabaseConfig().setAllowCreate(true).setTransactional(true)); }
final SecondaryConfig secondaryConfig = new SecondaryConfig();
if (relatedClsName != null) { PrimaryIndex relatedIndex = getRelatedIndex(relatedClsName); config.setForeignKeyDatabase(relatedIndex.getDatabase()); if (config.getTransactional() != priConfig.getTransactional() || DbCompat.getDeferredWrite(config) != DbCompat.getDeferredWrite(priConfig) || config.getReadOnly() != priConfig.getReadOnly()) { throw new IllegalArgumentException ("One of these properties was changed to be inconsistent" +
public Handle<SecondaryDatabase> getSecondary() { Guavas.checkArgument(getSecondaryConfig().getTransactional(), "Secondary must be transactional"); if (secondary.get() == null) { SecondaryDatabase db = env.openSecondaryDatabase(null, secondaryName, getPrimary().get(), secondaryConfig); secondary.set(db); } return secondary; }