}
/* We need to descend down into a duplicate tree. */
DIN duplicateRoot = null;
DBIN duplicateBin = null;
BIN bin = (BIN) in;
try {
int index = bin.findEntry(mainKey, false, true);
if (index >= 0) {
Node node = null;
if (!bin.isEntryKnownDeleted(index)) {
/* If fetchTarget returns null, a deleted LN was cleaned. */
node = bin.fetchTarget(index);
}
if (node == null) {
bin.releaseLatch();
return null;
}
if (node.containsDuplicates()) {
/* It's a duplicate tree. */
duplicateRoot = (DIN) node;
duplicateRoot.latch();
bin.releaseLatch();
duplicateBin = (DBIN) tree.searchSubTree
(duplicateRoot, dupKey, SearchType.NORMAL, -1, null,
false /*updateGeneration*/);
return duplicateBin;
} else {
/* We haven't migrated to a duplicate tree yet.
* XXX, isn't this taken care of above? */
return bin;
}
} else {
bin.releaseLatch();
return null;
}
} catch (DatabaseException DBE) {
if (bin != null) {
bin.releaseLatchIfOwner();
}
if (duplicateRoot != null) {
duplicateRoot.releaseLatchIfOwner();
}