00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 package com.sleepycat.collections;
00011
00012 import com.sleepycat.compat.DbCompat;
00013 import com.sleepycat.db.Cursor;
00014 import com.sleepycat.db.CursorConfig;
00015 import com.sleepycat.db.DatabaseEntry;
00016 import com.sleepycat.db.DatabaseException;
00017 import com.sleepycat.db.LockMode;
00018 import com.sleepycat.db.OperationStatus;
00019 import com.sleepycat.db.SecondaryCursor;
00020
00032 class RangeCursor implements Cloneable {
00033
00038 private Cursor cursor;
00039 private SecondaryCursor secCursor;
00040 private CurrentTransaction currentTxn;
00041 private boolean writeCursor;
00042
00047 private KeyRange range;
00048
00057 private boolean isRecnoOrQueue;
00058
00066 private DatabaseEntry privKey;
00067 private DatabaseEntry privPKey;
00068 private DatabaseEntry privData;
00069
00079 private boolean initialized;
00080
00084 RangeCursor(DataView view, KeyRange range, boolean writeAllowed)
00085 throws DatabaseException {
00086
00087 this.range = range;
00088 this.currentTxn = view.currentTxn;
00089 isRecnoOrQueue = view.recNumAllowed && !view.btreeRecNumDb;
00090
00091
00092
00093
00094
00095
00096
00097 writeCursor = DbCompat.getWriteCursor(view.cursorConfig) ||
00098 (view.cursorConfig == CursorConfig.DEFAULT && writeAllowed);
00099
00100 cursor = currentTxn.openCursor(view.db, view.cursorConfig, writeCursor,
00101 view.useTransaction());
00102 init();
00103 }
00104
00110 RangeCursor dup(boolean samePosition)
00111 throws DatabaseException {
00112
00113 try {
00114 RangeCursor c = (RangeCursor) super.clone();
00115 c.cursor = currentTxn.dupCursor(cursor, writeCursor,
00116 samePosition);
00117 c.init();
00118 return c;
00119 } catch (CloneNotSupportedException neverHappens) {
00120 return null;
00121 }
00122 }
00123
00127 private void init() {
00128
00129 if (cursor instanceof SecondaryCursor) {
00130 secCursor = (SecondaryCursor) cursor;
00131 } else {
00132 secCursor = null;
00133 }
00134
00135 if (range.hasBound()) {
00136 privKey = new DatabaseEntry();
00137 privPKey = new DatabaseEntry();
00138 privData = new DatabaseEntry();
00139 } else {
00140 privKey = null;
00141 privPKey = null;
00142 privData = null;
00143 }
00144 }
00145
00149 Cursor getCursor() {
00150 return cursor;
00151 }
00152
00158 private void setParams(DatabaseEntry key, DatabaseEntry pKey,
00159 DatabaseEntry data) {
00160 privKey = key;
00161 privPKey = pKey;
00162 privData = data;
00163 }
00164
00174 private Cursor beginOperation()
00175 throws DatabaseException {
00176
00177 Cursor oldCursor = cursor;
00178 if (initialized) {
00179 cursor = currentTxn.dupCursor(cursor, writeCursor, true);
00180 if (secCursor != null) {
00181 secCursor = (SecondaryCursor) cursor;
00182 }
00183 } else {
00184 return cursor;
00185 }
00186 return oldCursor;
00187 }
00188
00197 private void endOperation(Cursor oldCursor, OperationStatus status,
00198 DatabaseEntry key, DatabaseEntry pKey,
00199 DatabaseEntry data)
00200 throws DatabaseException {
00201
00202 if (status == OperationStatus.SUCCESS) {
00203 if (oldCursor != null && oldCursor != cursor) {
00204 currentTxn.closeCursor(oldCursor);
00205 }
00206 if (key != null) {
00207 swapData(key, privKey);
00208 }
00209 if (pKey != null && secCursor != null) {
00210 swapData(pKey, privPKey);
00211 }
00212 if (data != null) {
00213 swapData(data, privData);
00214 }
00215 initialized = true;
00216 } else {
00217 if (oldCursor != null && oldCursor != cursor) {
00218 currentTxn.closeCursor(cursor);
00219 cursor = oldCursor;
00220 if (secCursor != null) {
00221 secCursor = (SecondaryCursor) cursor;
00222 }
00223 }
00224 }
00225 }
00226
00231 private static void swapData(DatabaseEntry e1, DatabaseEntry e2) {
00232
00233 byte[] d1 = e1.getData();
00234 int o1 = e1.getOffset();
00235 int s1 = e1.getSize();
00236
00237 e1.setData(e2.getData(), e2.getOffset(), e2.getSize());
00238 e2.setData(d1, o1, s1);
00239 }
00240
00247 private static void shareData(DatabaseEntry from, DatabaseEntry to) {
00248
00249 if (from != null) {
00250 to.setData(from.getData(), from.getOffset(), from.getSize());
00251 }
00252 }
00253
00254 public OperationStatus getFirst(DatabaseEntry key,
00255 DatabaseEntry pKey,
00256 DatabaseEntry data,
00257 LockMode lockMode)
00258 throws DatabaseException {
00259
00260 OperationStatus status;
00261 if (!range.hasBound()) {
00262 setParams(key, pKey, data);
00263 status = doGetFirst(lockMode);
00264 endOperation(null, status, null, null, null);
00265 return status;
00266 }
00267 if (range.singleKey) {
00268 KeyRange.copy(range.beginKey, privKey);
00269 status = doGetSearchKey(lockMode);
00270 endOperation(null, status, key, pKey, data);
00271 } else {
00272 status = OperationStatus.NOTFOUND;
00273 Cursor oldCursor = beginOperation();
00274 try {
00275 if (range.beginKey == null) {
00276 status = doGetFirst(lockMode);
00277 } else {
00278 KeyRange.copy(range.beginKey, privKey);
00279 status = doGetSearchKeyRange(lockMode);
00280 if (status == OperationStatus.SUCCESS &&
00281 !range.beginInclusive &&
00282 range.compare(privKey, range.beginKey) == 0) {
00283 status = doGetNext(lockMode);
00284 }
00285 }
00286 if (status == OperationStatus.SUCCESS &&
00287 !range.check(privKey)) {
00288 status = OperationStatus.NOTFOUND;
00289 }
00290 } finally {
00291 endOperation(oldCursor, status, key, pKey, data);
00292 }
00293 }
00294 return status;
00295 }
00296
00297 public OperationStatus getLast(DatabaseEntry key,
00298 DatabaseEntry pKey,
00299 DatabaseEntry data,
00300 LockMode lockMode)
00301 throws DatabaseException {
00302
00303 OperationStatus status = OperationStatus.NOTFOUND;
00304 if (!range.hasBound()) {
00305 setParams(key, pKey, data);
00306 status = doGetLast(lockMode);
00307 endOperation(null, status, null, null, null);
00308 return status;
00309 }
00310 Cursor oldCursor = beginOperation();
00311 try {
00312 if (range.endKey == null) {
00313 status = doGetLast(lockMode);
00314 } else {
00315 KeyRange.copy(range.endKey, privKey);
00316 status = doGetSearchKeyRange(lockMode);
00317 if (status == OperationStatus.SUCCESS) {
00318 if (range.endInclusive &&
00319 range.compare(range.endKey, privKey) == 0) {
00320 status = doGetNextNoDup(lockMode);
00321 if (status == OperationStatus.SUCCESS) {
00322 status = doGetPrev(lockMode);
00323 } else {
00324 status = doGetLast(lockMode);
00325 }
00326 } else {
00327 status = doGetPrev(lockMode);
00328 }
00329 } else {
00330 status = doGetLast(lockMode);
00331 }
00332 }
00333 if (status == OperationStatus.SUCCESS &&
00334 !range.checkBegin(privKey, true)) {
00335 status = OperationStatus.NOTFOUND;
00336 }
00337 } finally {
00338 endOperation(oldCursor, status, key, pKey, data);
00339 }
00340 return status;
00341 }
00342
00343 public OperationStatus getNext(DatabaseEntry key,
00344 DatabaseEntry pKey,
00345 DatabaseEntry data,
00346 LockMode lockMode)
00347 throws DatabaseException {
00348
00349 OperationStatus status;
00350 if (!initialized) {
00351 return getFirst(key, pKey, data, lockMode);
00352 }
00353 if (!range.hasBound()) {
00354 setParams(key, pKey, data);
00355 status = doGetNext(lockMode);
00356 endOperation(null, status, null, null, null);
00357 return status;
00358 }
00359 if (range.singleKey) {
00360 status = doGetNextDup(lockMode);
00361 endOperation(null, status, key, pKey, data);
00362 } else {
00363 status = OperationStatus.NOTFOUND;
00364 Cursor oldCursor = beginOperation();
00365 try {
00366 status = doGetNext(lockMode);
00367 if (status == OperationStatus.SUCCESS &&
00368 !range.check(privKey)) {
00369 status = OperationStatus.NOTFOUND;
00370 }
00371 } finally {
00372 endOperation(oldCursor, status, key, pKey, data);
00373 }
00374 }
00375 return status;
00376 }
00377
00378 public OperationStatus getNextNoDup(DatabaseEntry key,
00379 DatabaseEntry pKey,
00380 DatabaseEntry data,
00381 LockMode lockMode)
00382 throws DatabaseException {
00383
00384 OperationStatus status;
00385 if (!initialized) {
00386 return getFirst(key, pKey, data, lockMode);
00387 }
00388 if (!range.hasBound()) {
00389 setParams(key, pKey, data);
00390 status = doGetNextNoDup(lockMode);
00391 endOperation(null, status, null, null, null);
00392 return status;
00393 }
00394 if (range.singleKey) {
00395 status = OperationStatus.NOTFOUND;
00396 } else {
00397 status = OperationStatus.NOTFOUND;
00398 Cursor oldCursor = beginOperation();
00399 try {
00400 status = doGetNextNoDup(lockMode);
00401 if (status == OperationStatus.SUCCESS &&
00402 !range.check(privKey)) {
00403 status = OperationStatus.NOTFOUND;
00404 }
00405 } finally {
00406 endOperation(oldCursor, status, key, pKey, data);
00407 }
00408 }
00409 return status;
00410 }
00411
00412 public OperationStatus getPrev(DatabaseEntry key,
00413 DatabaseEntry pKey,
00414 DatabaseEntry data,
00415 LockMode lockMode)
00416 throws DatabaseException {
00417
00418 OperationStatus status;
00419 if (!initialized) {
00420 return getLast(key, pKey, data, lockMode);
00421 }
00422 if (!range.hasBound()) {
00423 setParams(key, pKey, data);
00424 status = doGetPrev(lockMode);
00425 endOperation(null, status, null, null, null);
00426 return status;
00427 }
00428 if (range.singleKey) {
00429 status = doGetPrevDup(lockMode);
00430 endOperation(null, status, key, pKey, data);
00431 } else {
00432 status = OperationStatus.NOTFOUND;
00433 Cursor oldCursor = beginOperation();
00434 try {
00435 status = doGetPrev(lockMode);
00436 if (status == OperationStatus.SUCCESS &&
00437 !range.check(privKey)) {
00438 status = OperationStatus.NOTFOUND;
00439 }
00440 } finally {
00441 endOperation(oldCursor, status, key, pKey, data);
00442 }
00443 }
00444 return status;
00445 }
00446
00447 public OperationStatus getPrevNoDup(DatabaseEntry key,
00448 DatabaseEntry pKey,
00449 DatabaseEntry data,
00450 LockMode lockMode)
00451 throws DatabaseException {
00452
00453 OperationStatus status;
00454 if (!initialized) {
00455 return getLast(key, pKey, data, lockMode);
00456 }
00457 if (!range.hasBound()) {
00458 setParams(key, pKey, data);
00459 status = doGetPrevNoDup(lockMode);
00460 endOperation(null, status, null, null, null);
00461 return status;
00462 }
00463 if (range.singleKey) {
00464 status = OperationStatus.NOTFOUND;
00465 } else {
00466 status = OperationStatus.NOTFOUND;
00467 Cursor oldCursor = beginOperation();
00468 try {
00469 status = doGetPrevNoDup(lockMode);
00470 if (status == OperationStatus.SUCCESS &&
00471 !range.check(privKey)) {
00472 status = OperationStatus.NOTFOUND;
00473 }
00474 } finally {
00475 endOperation(oldCursor, status, key, pKey, data);
00476 }
00477 }
00478 return status;
00479 }
00480
00481 public OperationStatus getSearchKey(DatabaseEntry key,
00482 DatabaseEntry pKey,
00483 DatabaseEntry data,
00484 LockMode lockMode)
00485 throws DatabaseException {
00486
00487 OperationStatus status;
00488 if (!range.hasBound()) {
00489 setParams(key, pKey, data);
00490 status = doGetSearchKey(lockMode);
00491 endOperation(null, status, null, null, null);
00492 return status;
00493 }
00494 if (!range.check(key)) {
00495 status = OperationStatus.NOTFOUND;
00496 } else {
00497 shareData(key, privKey);
00498 status = doGetSearchKey(lockMode);
00499 endOperation(null, status, key, pKey, data);
00500 }
00501 return status;
00502 }
00503
00504 public OperationStatus getSearchBoth(DatabaseEntry key,
00505 DatabaseEntry pKey,
00506 DatabaseEntry data,
00507 LockMode lockMode)
00508 throws DatabaseException {
00509
00510 OperationStatus status;
00511 if (!range.hasBound()) {
00512 setParams(key, pKey, data);
00513 status = doGetSearchBoth(lockMode);
00514 endOperation(null, status, null, null, null);
00515 return status;
00516 }
00517 if (!range.check(key)) {
00518 status = OperationStatus.NOTFOUND;
00519 } else {
00520 shareData(key, privKey);
00521 if (secCursor != null) {
00522 shareData(pKey, privPKey);
00523 } else {
00524 shareData(data, privData);
00525 }
00526 status = doGetSearchBoth(lockMode);
00527 endOperation(null, status, key, pKey, data);
00528 }
00529 return status;
00530 }
00531
00532 public OperationStatus getSearchKeyRange(DatabaseEntry key,
00533 DatabaseEntry pKey,
00534 DatabaseEntry data,
00535 LockMode lockMode)
00536 throws DatabaseException {
00537
00538 OperationStatus status = OperationStatus.NOTFOUND;
00539 if (!range.hasBound()) {
00540 setParams(key, pKey, data);
00541 status = doGetSearchKeyRange(lockMode);
00542 endOperation(null, status, null, null, null);
00543 return status;
00544 }
00545 Cursor oldCursor = beginOperation();
00546 try {
00547 shareData(key, privKey);
00548 status = doGetSearchKeyRange(lockMode);
00549 if (status == OperationStatus.SUCCESS &&
00550 !range.check(privKey)) {
00551 status = OperationStatus.NOTFOUND;
00552 }
00553 } finally {
00554 endOperation(oldCursor, status, key, pKey, data);
00555 }
00556 return status;
00557 }
00558
00559 public OperationStatus getSearchBothRange(DatabaseEntry key,
00560 DatabaseEntry pKey,
00561 DatabaseEntry data,
00562 LockMode lockMode)
00563 throws DatabaseException {
00564
00565 OperationStatus status = OperationStatus.NOTFOUND;
00566 if (!range.hasBound()) {
00567 setParams(key, pKey, data);
00568 status = doGetSearchBothRange(lockMode);
00569 endOperation(null, status, null, null, null);
00570 return status;
00571 }
00572 Cursor oldCursor = beginOperation();
00573 try {
00574 shareData(key, privKey);
00575 if (secCursor != null) {
00576 shareData(pKey, privPKey);
00577 } else {
00578 shareData(data, privData);
00579 }
00580 status = doGetSearchBothRange(lockMode);
00581 if (status == OperationStatus.SUCCESS &&
00582 !range.check(privKey)) {
00583 status = OperationStatus.NOTFOUND;
00584 }
00585 } finally {
00586 endOperation(oldCursor, status, key, pKey, data);
00587 }
00588 return status;
00589 }
00590
00591 public OperationStatus getSearchRecordNumber(DatabaseEntry key,
00592 DatabaseEntry pKey,
00593 DatabaseEntry data,
00594 LockMode lockMode)
00595 throws DatabaseException {
00596
00597 OperationStatus status;
00598 if (!range.hasBound()) {
00599 setParams(key, pKey, data);
00600 status = doGetSearchRecordNumber(lockMode);
00601 endOperation(null, status, null, null, null);
00602 return status;
00603 }
00604 if (!range.check(key)) {
00605 status = OperationStatus.NOTFOUND;
00606 } else {
00607 shareData(key, privKey);
00608 status = doGetSearchRecordNumber(lockMode);
00609 endOperation(null, status, key, pKey, data);
00610 }
00611 return status;
00612 }
00613
00614 public OperationStatus getNextDup(DatabaseEntry key,
00615 DatabaseEntry pKey,
00616 DatabaseEntry data,
00617 LockMode lockMode)
00618 throws DatabaseException {
00619
00620 if (!initialized) {
00621 throw new DatabaseException("Cursor not initialized");
00622 }
00623 OperationStatus status;
00624 if (!range.hasBound()) {
00625 setParams(key, pKey, data);
00626 status = doGetNextDup(lockMode);
00627 endOperation(null, status, null, null, null);
00628 } else {
00629 status = doGetNextDup(lockMode);
00630 endOperation(null, status, key, pKey, data);
00631 }
00632 return status;
00633 }
00634
00635 public OperationStatus getPrevDup(DatabaseEntry key,
00636 DatabaseEntry pKey,
00637 DatabaseEntry data,
00638 LockMode lockMode)
00639 throws DatabaseException {
00640
00641 if (!initialized) {
00642 throw new DatabaseException("Cursor not initialized");
00643 }
00644 OperationStatus status;
00645 if (!range.hasBound()) {
00646 setParams(key, pKey, data);
00647 status = doGetPrevDup(lockMode);
00648 endOperation(null, status, null, null, null);
00649 } else {
00650 status = doGetPrevDup(lockMode);
00651 endOperation(null, status, key, pKey, data);
00652 }
00653 return status;
00654 }
00655
00656 public OperationStatus getCurrent(DatabaseEntry key,
00657 DatabaseEntry pKey,
00658 DatabaseEntry data,
00659 LockMode lockMode)
00660 throws DatabaseException {
00661
00662 if (!initialized) {
00663 throw new DatabaseException("Cursor not initialized");
00664 }
00665 if (secCursor != null && pKey != null) {
00666 return secCursor.getCurrent(key, pKey, data, lockMode);
00667 } else {
00668 return cursor.getCurrent(key, data, lockMode);
00669 }
00670 }
00671
00672
00673
00674
00675
00676 public void close()
00677 throws DatabaseException {
00678
00679 currentTxn.closeCursor(cursor);
00680 }
00681
00682 public int count()
00683 throws DatabaseException {
00684
00685 return cursor.count();
00686 }
00687
00688 public OperationStatus delete()
00689 throws DatabaseException {
00690
00691 return cursor.delete();
00692 }
00693
00694 public OperationStatus put(DatabaseEntry key, DatabaseEntry data)
00695 throws DatabaseException {
00696
00697 return cursor.put(key, data);
00698 }
00699
00700 public OperationStatus putNoOverwrite(DatabaseEntry key,
00701 DatabaseEntry data)
00702 throws DatabaseException {
00703
00704 return cursor.putNoOverwrite(key, data);
00705 }
00706
00707 public OperationStatus putNoDupData(DatabaseEntry key, DatabaseEntry data)
00708 throws DatabaseException {
00709
00710 return cursor.putNoDupData(key, data);
00711 }
00712
00713 public OperationStatus putCurrent(DatabaseEntry data)
00714 throws DatabaseException {
00715
00716 return cursor.putCurrent(data);
00717 }
00718
00719 public OperationStatus putAfter(DatabaseEntry key, DatabaseEntry data)
00720 throws DatabaseException {
00721
00722 return DbCompat.putAfter(cursor, key, data);
00723 }
00724
00725 public OperationStatus putBefore(DatabaseEntry key, DatabaseEntry data)
00726 throws DatabaseException {
00727
00728 return DbCompat.putBefore(cursor, key, data);
00729 }
00730
00731 private OperationStatus doGetFirst(LockMode lockMode)
00732 throws DatabaseException {
00733
00734 if (secCursor != null && privPKey != null) {
00735 return secCursor.getFirst(privKey, privPKey, privData, lockMode);
00736 } else {
00737 return cursor.getFirst(privKey, privData, lockMode);
00738 }
00739 }
00740
00741 private OperationStatus doGetLast(LockMode lockMode)
00742 throws DatabaseException {
00743
00744 if (secCursor != null && privPKey != null) {
00745 return secCursor.getLast(privKey, privPKey, privData, lockMode);
00746 } else {
00747 return cursor.getLast(privKey, privData, lockMode);
00748 }
00749 }
00750
00751 private OperationStatus doGetNext(LockMode lockMode)
00752 throws DatabaseException {
00753
00754 if (secCursor != null && privPKey != null) {
00755 return secCursor.getNext(privKey, privPKey, privData, lockMode);
00756 } else {
00757 return cursor.getNext(privKey, privData, lockMode);
00758 }
00759 }
00760
00761 private OperationStatus doGetNextDup(LockMode lockMode)
00762 throws DatabaseException {
00763
00764 if (secCursor != null && privPKey != null) {
00765 return secCursor.getNextDup(privKey, privPKey, privData, lockMode);
00766 } else {
00767 return cursor.getNextDup(privKey, privData, lockMode);
00768 }
00769 }
00770
00771 private OperationStatus doGetNextNoDup(LockMode lockMode)
00772 throws DatabaseException {
00773
00774 if (secCursor != null && privPKey != null) {
00775 return secCursor.getNextNoDup(privKey, privPKey, privData,
00776 lockMode);
00777 } else {
00778 return cursor.getNextNoDup(privKey, privData, lockMode);
00779 }
00780 }
00781
00782 private OperationStatus doGetPrev(LockMode lockMode)
00783 throws DatabaseException {
00784
00785 if (secCursor != null && privPKey != null) {
00786 return secCursor.getPrev(privKey, privPKey, privData, lockMode);
00787 } else {
00788 return cursor.getPrev(privKey, privData, lockMode);
00789 }
00790 }
00791
00792 private OperationStatus doGetPrevDup(LockMode lockMode)
00793 throws DatabaseException {
00794
00795 if (secCursor != null && privPKey != null) {
00796 return secCursor.getPrevDup(privKey, privPKey, privData, lockMode);
00797 } else {
00798 return cursor.getPrevDup(privKey, privData, lockMode);
00799 }
00800 }
00801
00802 private OperationStatus doGetPrevNoDup(LockMode lockMode)
00803 throws DatabaseException {
00804
00805 if (secCursor != null && privPKey != null) {
00806 return secCursor.getPrevNoDup(privKey, privPKey, privData,
00807 lockMode);
00808 } else {
00809 return cursor.getPrevNoDup(privKey, privData, lockMode);
00810 }
00811 }
00812
00813 private OperationStatus doGetSearchKey(LockMode lockMode)
00814 throws DatabaseException {
00815
00816 if (isRecnoOrQueue && DbCompat.getRecordNumber(privKey) <= 0) {
00817 return OperationStatus.NOTFOUND;
00818 }
00819 if (secCursor != null && privPKey != null) {
00820 return secCursor.getSearchKey(privKey, privPKey, privData,
00821 lockMode);
00822 } else {
00823 return cursor.getSearchKey(privKey, privData, lockMode);
00824 }
00825 }
00826
00827 private OperationStatus doGetSearchKeyRange(LockMode lockMode)
00828 throws DatabaseException {
00829
00830 if (isRecnoOrQueue && DbCompat.getRecordNumber(privKey) <= 0) {
00831 return OperationStatus.NOTFOUND;
00832 }
00833 if (secCursor != null && privPKey != null) {
00834 return secCursor.getSearchKeyRange(privKey, privPKey, privData,
00835 lockMode);
00836 } else {
00837 return cursor.getSearchKeyRange(privKey, privData, lockMode);
00838 }
00839 }
00840
00841 private OperationStatus doGetSearchBoth(LockMode lockMode)
00842 throws DatabaseException {
00843
00844 if (isRecnoOrQueue && DbCompat.getRecordNumber(privKey) <= 0) {
00845 return OperationStatus.NOTFOUND;
00846 }
00847 if (secCursor != null && privPKey != null) {
00848 return secCursor.getSearchBoth(privKey, privPKey, privData,
00849 lockMode);
00850 } else {
00851 return cursor.getSearchBoth(privKey, privData, lockMode);
00852 }
00853 }
00854
00855 private OperationStatus doGetSearchBothRange(LockMode lockMode)
00856 throws DatabaseException {
00857
00858 if (isRecnoOrQueue && DbCompat.getRecordNumber(privKey) <= 0) {
00859 return OperationStatus.NOTFOUND;
00860 }
00861 if (secCursor != null && privPKey != null) {
00862 return secCursor.getSearchBothRange(privKey, privPKey, privData,
00863 lockMode);
00864 } else {
00865 return cursor.getSearchBothRange(privKey, privData, lockMode);
00866 }
00867 }
00868
00869 private OperationStatus doGetSearchRecordNumber(LockMode lockMode)
00870 throws DatabaseException {
00871
00872 if (DbCompat.getRecordNumber(privKey) <= 0) {
00873 return OperationStatus.NOTFOUND;
00874 }
00875 if (secCursor != null && privPKey != null) {
00876 return DbCompat.getSearchRecordNumber(secCursor, privKey, privPKey,
00877 privData, lockMode);
00878 } else {
00879 return DbCompat.getSearchRecordNumber(cursor, privKey, privData,
00880 lockMode);
00881 }
00882 }
00883 }