Esempio n. 1
0
std::vector<unsigned int>* static_selfindex::locate(unsigned char* pattern, unsigned int plen, unsigned int* count, unsigned int max_occs) {
    //unsigned int plen = strlen((char*)pattern);
    if(sigma_mapper->map(pattern,plen+1)!=0) { //the pattern has letters which are not present in the text
        *count=0;
        return NULL;
    }
    return _locate(pattern,plen,count,max_occs);
}
Esempio n. 2
0
        /* Since the last noteLocation(), our key may have moved around, and that old cached
           information may thus be stale and wrong (although often it is right).  We check
           that here; if we have moved, we have to search back for where we were at.

           i.e., after operations on the index, the BtreeCursor's cached location info may
           be invalid.  This function ensures validity, so you should call it before using
           the cursor if other writers have used the database since the last noteLocation
           call.
        */
        void checkLocation() {
            if ( eof() )
                return;

            _multikey = d->isMultikey(idxNo);

            if ( keyOfs >= 0 ) {
                assert( !keyAtKeyOfs.isEmpty() );

                try {
                    // Note keyAt() returns an empty BSONObj if keyOfs is now out of range,
                    // which is possible as keys may have been deleted.
                    int x = 0;
                    while( 1 ) {
                        //  if ( b->keyAt(keyOfs).woEqual(keyAtKeyOfs) &&
                        //       b->k(keyOfs).recordLoc == locAtKeyOfs ) {
                        if ( keyAt(keyOfs).binaryEqual(keyAtKeyOfs) ) {
                            const _KeyNode& kn = keyNode(keyOfs);
                            if( kn.recordLoc == locAtKeyOfs ) {
                                if ( !kn.isUsed() ) {
                                    // we were deleted but still exist as an unused
                                    // marker key. advance.
                                    skipUnusedKeys();
                                }
                                return;
                            }
                        }

                        // we check one key earlier too, in case a key was just deleted.  this is
                        // important so that multi updates are reasonably fast.
                        if( keyOfs == 0 || x++ )
                            break;
                        keyOfs--;
                    }
                }
                catch(UserException& e) { 
                    if( e.getCode() != 15850 )
                        throw;
                    // hack: fall through if bucket was just deleted. should only happen under deleteObjects()
                    DEV log() << "debug info: bucket was deleted" << endl;
                }
            }

            /* normally we don't get to here.  when we do, old position is no longer
                valid and we must refind where we left off (which is expensive)
            */

            /* TODO: Switch to keep indexdetails and do idx.head! */
            bucket = _locate(keyAtKeyOfs, locAtKeyOfs);
            RARELY log() << "key seems to have moved in the index, refinding. " << bucket.toString() << endl;
            if ( ! bucket.isNull() )
                skipUnusedKeys();

        }
Esempio n. 3
0
 void BtreeCursor::initWithoutIndependentFieldRanges() {
     if ( indexDetails.getSpec().getType() ) {
         startKey = indexDetails.getSpec().getType()->fixKey( startKey );
         endKey = indexDetails.getSpec().getType()->fixKey( endKey );
     }
     bucket = _locate(startKey, _direction > 0 ? minDiskLoc : maxDiskLoc);
     if ( ok() ) {
         _nscanned = 1;
     }
     skipUnusedKeys();
     checkEnd();
 }
Esempio n. 4
0
 void BtreeCursor::init() {
     if ( _spec.getType() ) {
         startKey = _spec.getType()->fixKey( startKey );
         endKey = _spec.getType()->fixKey( endKey );
     }
     bucket = _locate(startKey, _direction > 0 ? minDiskLoc : maxDiskLoc);
     if ( ok() ) {
         _nscanned = 1;
     }
     skipUnusedKeys();
     checkEnd();
 }
Esempio n. 5
0
	bool _locate(int gp, const _branch *br, std::string &fn, int &lp) const {
		if(gp < br->pos || gp >= br->pos + br->size) {
			return false;
		}
		int shift = gp - br->pos;
		for(const _branch *b : br->inner) {
			if(gp < b->pos) {
				break;
			}
			if(_locate(gp, b, fn, lp)) {
				return true;
			}
			shift -= b->size;
		}
		lp = shift;
		fn = br->fullname;
		return true;
	}
Esempio n. 6
0
int VEditDLL::EDITLocate( long row, int col, int len ) {
    if( _locate == NULL ) return( TRUE );
    return( _locate( row, col, len ) );
}
Esempio n. 7
0
	bool locate(int gpos, std::string &fullname, int &lpos) const {
		return _locate(gpos, &_trunk, fullname, lpos);
	}