bool IndexCursor::advance() { killCurrentOp.checkForInterrupt(); if ( ok() ) { // Advance one row further, and then check if we've went out of bounds. _advance(); } else { if ( tailable() ) { if ( _currKey < _endKey ) { // Read the most up-to-date minUnsafeKey from the namespace refreshMinUnsafeEndKey(); _advance(); } else { // reset _currKey, we may have accidentally // gone past _endKey when we did our last advance // and saw something we are not allowed to see. _currKey = _endKey; // Read the most up-to-date minUnsafeKey from the namespace refreshMinUnsafeEndKey(); findKey( _currKey.isEmpty() ? minKey : _currKey ); } } else { // Exhausted cursors that are not tailable never advance return false; } } // the key we are now positioned over may or may not be ok to read. // checkCurrentAgainstBounds() will decide. return checkCurrentAgainstBounds(); }
int sed_step(char *p1, char *p2, int circf, step_vars_storage *vars) { int c; if (circf) { vars->loc1 = p1; return (_advance(p1, p2, vars)); } /* fast check for first character */ if (*p2 == CCHR) { c = p2[1]; do { if (*p1 != c) continue; if (_advance(p1, p2, vars)) { vars->loc1 = p1; return (1); } } while (*p1++); return (0); } /* regular algorithm */ do { if (_advance(p1, p2, vars)) { vars->loc1 = p1; return (1); } } while (*p1++); return (0); }
int step(char *p1, char *p2) { int c; wchar_t cl; int n; int ret; /* check if match is restricted to beginning of string */ (void) mutex_lock(&lock); start = p1; if (*p2++) { loc1 = p1; ret = _advance(p1, p2); (void) mutex_unlock(&lock); return (ret); } if (*p2 == CCHR) { /* fast check for first character */ c = p2[1]; do { if (*p1 != c) continue; if (_advance(p1, p2)) { loc1 = p1; (void) mutex_unlock(&lock); return (1); } } while (*p1++); } else if (multibyte) do { if (_advance(p1, p2)) { loc1 = p1; (void) mutex_unlock(&lock); return (1); } n = Popwchar(p1, cl); if (n < 0) /* skip past illegal multibyte characters */ p1++; else p1 += n; } while (n); else /* regular algorithm */ do { if (_advance(p1, p2)) { loc1 = p1; (void) mutex_unlock(&lock); return (1); } } while (*p1++); (void) mutex_unlock(&lock); return (0); }
PlanStage::StageState MultiIteratorStage::work(WorkingSetID* out) { if ( _collection == NULL ) return PlanStage::DEAD; // The DiskLoc we're about to look at it might not be in memory. In this case // we request a yield while we fetch the document. if (!_iterators.empty()) { DiskLoc curr = _iterators.back()->curr(); if (!curr.isNull()) { std::auto_ptr<RecordFetcher> fetcher(_collection->documentNeedsFetch(_txn, curr)); if (NULL != fetcher.get()) { WorkingSetMember* member = _ws->get(_wsidForFetch); member->loc = curr; // Pass the RecordFetcher off to the WSM on which we're performing the fetch. member->setFetcher(fetcher.release()); *out = _wsidForFetch; return NEED_FETCH; } } } DiskLoc next = _advance(); if (next.isNull()) return PlanStage::IS_EOF; *out = _ws->allocate(); WorkingSetMember* member = _ws->get(*out); member->loc = next; member->obj = _collection->docFor(_txn, next); member->state = WorkingSetMember::LOC_AND_UNOWNED_OBJ; return PlanStage::ADVANCED; }
void* read_circular_buffer(CircularBuffer* buffer) { void* data = (buffer->data + buffer->tail); _advance(buffer, &buffer->tail); return data; }
void RuleCharacterIterator::skipIgnored(int32_t options) { if ((options & SKIP_WHITESPACE) != 0) { for (;;) { UChar32 a = _current(); if (!PatternProps::isWhiteSpace(a)) break; _advance(U16_LENGTH(a)); } } }
BSONObj FilteringClientCursor::next(){ assert( ! _next.isEmpty() ); assert( ! _done ); BSONObj ret = _next; _next = BSONObj(); _advance(); return ret; }
bool FilteringClientCursor::more(){ if ( ! _next.isEmpty() ) return true; if ( _done ) return false; _advance(); return ! _next.isEmpty(); }
void Scene::_nextToken( ){ if( !_inputFileStream.eof( ) ){ _advance( ); if( _areMoreTokens( ) ){ _nextOnLine( ); }else{ do{ _inputFileStream.getline( _currentLine, sizeof(_currentLine) ); _lineNumber++; _length = std::strlen( _currentLine ); }while( _length <= 0 ); _i = 0; _j = 0; _advance( ); if( _areMoreTokens( ) ){ _nextOnLine( ); } } } }
int advance(char *lp, char *ep) { int ret; (void) mutex_lock(&lock); /* ignore flag to see if expression is anchored */ start = lp; ret = _advance(lp, ++ep); (void) mutex_unlock(&lock); return (ret); }
UChar32 RuleCharacterIterator::next(int32_t options, UBool& isEscaped, UErrorCode& ec) { if (U_FAILURE(ec)) return DONE; UChar32 c = DONE; isEscaped = FALSE; for (;;) { c = _current(); _advance(U16_LENGTH(c)); if (c == SymbolTable::SYMBOL_REF && buf == 0 && (options & PARSE_VARIABLES) != 0 && sym != 0) { UnicodeString name = sym->parseReference(text, pos, text.length()); // If name is empty there was an isolated SYMBOL_REF; // return it. Caller must be prepared for this. if (name.length() == 0) { break; } bufPos = 0; buf = sym->lookup(name); if (buf == 0) { ec = U_UNDEFINED_VARIABLE; return DONE; } // Handle empty variable value if (buf->length() == 0) { buf = 0; } continue; } if ((options & SKIP_WHITESPACE) != 0 && PatternProps::isWhiteSpace(c)) { continue; } if (c == 0x5C /*'\\'*/ && (options & PARSE_ESCAPES) != 0) { UnicodeString tempEscape; int32_t offset = 0; c = lookahead(tempEscape, MAX_U_NOTATION_LEN).unescapeAt(offset); jumpahead(offset); isEscaped = TRUE; if (c < 0) { ec = U_MALFORMED_UNICODE_ESCAPE; return DONE; } } break; } return c; }
virtual RunnerState getNext(BSONObj* objOut, DiskLoc* dlOut) { if ( _collection == NULL ) return RUNNER_DEAD; DiskLoc next = _advance(); if (next.isNull()) return RUNNER_EOF; if ( objOut ) *objOut = _collection->docFor( next ); if ( dlOut ) *dlOut = next; return RUNNER_ADVANCED; }
IndigoObject * IndigoMultilineSmilesLoader::at (int index) { if (index < _offsets.size()) { _scanner->seek(_offsets[index], SEEK_SET); _current_number = index; return next(); } _scanner->seek(_max_offset, SEEK_SET); _current_number = _offsets.size(); while (index > _offsets.size()) _advance(); return next(); }
IndigoObject * IndigoMultilineSmilesLoader::next () { if (_scanner->isEOF()) return 0; long long offset = _scanner->tell(); int counter = _current_number; _advance(); if (_str.find('>') == -1) return new IndigoSmilesMolecule(_str, counter, offset); else return new IndigoSmilesReaction(_str, counter, offset); }
void QueryOptimizerCursorImpl::recoverFromYield() { if ( _takeover ) { _takeover->recoverFromYield(); return; } if ( _currRunner ) { _mps->recoverFromYield(); if ( _currRunner->error() || !ok() ) { // Advance to a non error op if one of the ops errored out. // Advance to a following $or clause if the $or clause returned all results. verify( !_mps->doneRunners() ); _advance( true ); } } }
bool skipUnusedKeys() { int u = 0; while ( 1 ) { if ( !ok() ) break; const _KeyNode& kn = keyNode(keyOfs); if ( kn.isUsed() ) break; bucket = _advance(bucket, keyOfs, _direction, "skipUnusedKeys"); u++; //don't include unused keys in nscanned //++_nscanned; } if ( u > 10 ) OCCASIONALLY log() << "btree unused skipped:" << u << '\n'; return u; }
void GDTokenizerText::set_code(const String& p_code) { code=p_code; len = p_code.length(); if (len) { _code=&code[0]; } else { _code=NULL; } code_pos=0; line=1; //it is stand-ar-ized that lines begin in 1 in code.. column=0; tk_rb_pos=0; error_flag=false; last_error=""; for(int i=0;i<MAX_LOOKAHEAD+1;i++) _advance(); }
bool BtreeCursor::advance() { killCurrentOp.checkForInterrupt(); if ( bucket.isNull() ) return false; bucket = _advance(bucket, keyOfs, _direction, "BtreeCursor::advance"); if ( !_independentFieldRanges ) { skipUnusedKeys(); checkEnd(); if ( ok() ) { ++_nscanned; } } else { skipAndCheck(); } return ok(); }
/* skip unused keys. */ bool BtreeCursor::skipUnusedKeys( bool mayJump ) { int u = 0; while ( 1 ) { if ( !ok() ) break; const _KeyNode& kn = keyNode(keyOfs); if ( kn.isUsed() ) break; bucket = _advance(bucket, keyOfs, _direction, "skipUnusedKeys"); u++; //don't include unused keys in nscanned //++_nscanned; if ( mayJump && ( u % 10 == 0 ) ) { skipOutOfRangeKeysAndCheckEnd(); } } if ( u > 10 ) OCCASIONALLY log() << "btree unused skipped:" << u << '\n'; return u; }
bool BtreeCursor::advance() { // Reset this flag at the start of a new iteration. _boundsMustMatch = true; killCurrentOp.checkForInterrupt(); if ( bucket.isNull() ) return false; bucket = _advance(bucket, keyOfs, _direction, "BtreeCursor::advance"); if ( !_independentFieldRanges ) { skipUnusedKeys(); checkEnd(); if ( ok() ) { ++_nscanned; } } else { skipAndCheck(); } return ok(); }
int IndigoMultilineSmilesLoader::count () { long long offset = _scanner->tell(); int cn = _current_number; if (offset != _max_offset) { _scanner->seek(_max_offset, SEEK_SET); _current_number = _offsets.size(); } while (!_scanner->isEOF()) _advance(); int res = _current_number; if (res != cn) { _scanner->seek(offset, SEEK_SET); _current_number = cn; } return res; }
CursorIterator::CursorIterator( shared_ptr<Cursor> c , BSONObj filter ) : _cursor( c ){ if ( ! filter.isEmpty() ) _matcher.reset( new CoveredIndexMatcher( filter , BSONObj() ) ); _advance(); }
static int _advance(char *lp, char *ep) { char *rp; char *curlp; wchar_t c, d; int n; wchar_t cl; int neg; char *bbeg; int ct; for (;;) { neg = 0; switch (*ep++) { case CCHR: if (*ep++ == *lp++) continue; return (0); case MCCHR: ep += Popwchar(ep, cl); c = cl; if ((n = Popwchar(lp, cl)) <= 0 || c != cl) return (0); lp += n; continue; case CDOT: /* * match any characters except NULL */ if ((n = Popwchar(lp, cl)) > 0) { lp += n; continue; } else if (n < 0) { lp++; continue; } else { return (0); } case CDOL: if (*lp == 0) continue; return (0); case CCEOF: loc2 = lp; return (1); case CCL: c = (unsigned char)*lp++; if (ISTHERE(c)) { ep += 32; continue; } return (0); case NMCCL: neg = 1; /* FALLTHRU */ case MCCL: rp = lp; if (cclass(ep, &rp, neg) != 1) return (0); ep += *(ep + 32) + 32; lp = rp; continue; case CBRA: braslist[*ep++] = lp; continue; case CKET: braelist[*ep++] = lp; continue; case MCCHR | RNGE: ep += Popwchar(ep, cl); c = cl; getrnge(ep); while (low--) { if ((n = Popwchar(lp, cl)) <= 0 || cl != c) return (0); lp += n; } curlp = lp; while (size--) { if ((n = Popwchar(lp, cl)) <= 0 || cl != c) break; lp += n; } if (size < 0) n = Popwchar(lp, cl); if (n == -1) return (0); lp += (n ? n : 1); ep += 2; goto mstar; case CCHR | RNGE: c = *ep++; getrnge(ep); while (low--) if (*lp++ != c) return (0); curlp = lp; while (size--) if (*lp++ != c) break; if (size < 0) lp++; ep += 2; goto star; case CDOT | RNGE: getrnge(ep); while (low--) { if ((n = Popwchar(lp, cl)) > 0) { lp += n; } else if (n < 0) { lp++; } else { return (0); } } curlp = lp; while (size--) { if ((n = Popwchar(lp, cl)) > 0) { lp += n; } else if (n < 0) { lp++; } else { break; } } if (size < 0) n = Popwchar(lp, cl); if (n > 0) { lp += n; } else { lp++; } ep += 2; goto mstar; case NMCCL | RNGE: neg = 1; /* FALLTHRU */ case MCCL | RNGE: getrnge(ep + *(ep + 32) + 32); rp = lp; while (low--) { if (cclass(ep, &rp, neg) != 1) return (0); } curlp = rp; while (size-- && (c = (cclass(ep, &rp, neg))) == 1) ; if (c == -1) return (0); lp = rp; if (size < 0) { if ((n = Popwchar(lp, cl)) == -1) return (0); lp += (n ? n : 1); } ep += *(ep + 32) + 34; goto mstar; case CCL | RNGE: getrnge(ep + 32); while (low--) { c = (unsigned char)*lp++; if (!ISTHERE(c)) return (0); } curlp = lp; while (size--) { c = (unsigned char)*lp++; if (!ISTHERE(c)) break; } if (size < 0) lp++; ep += 34; /* 32 + 2 */ goto star; case CBACK: bbeg = braslist[*ep]; ct = (int)(braelist[*ep++] - bbeg); if (ecmp(bbeg, lp, ct)) { lp += ct; continue; } return (0); case CBACK | STAR: bbeg = braslist[*ep]; ct = (int)(braelist[*ep++] - bbeg); curlp = lp; while (ecmp(bbeg, lp, ct)) lp += ct; while (lp >= curlp) { if (_advance(lp, ep)) return (1); lp -= ct; } return (0); case CDOT | STAR: curlp = lp; if (!multibyte) while (*lp++) ; else { for (;;) { n = Popwchar(lp, cl); if (n > 0) { lp += n; } else if (n < 0) { lp++; } else { lp++; break; } } } goto mstar; case CCHR | STAR: curlp = lp; while (*lp++ == *ep) ; ep++; goto star; case MCCHR | STAR: curlp = lp; ep += Popwchar(ep, cl); c = cl; while ((n = Popwchar(lp, cl)) > 0 && cl == c) lp += n; if (n == -1) return (0); lp += (n ? n : 1); goto mstar; case NMCCL | STAR: neg = 1; /* FALLTHRU */ case MCCL | STAR: curlp = rp = lp; while ((d = cclass(ep, &rp, neg)) == 1) ; if (d == -1) return (0); lp = rp; ep += *(ep + 32) + 32; goto mstar; case CCL | STAR: curlp = lp; do { c = (unsigned char)*lp++; } while (ISTHERE(c)); ep += 32; goto star; case CBRC: if (lp == start && locs == (char *)0) continue; c = (unsigned char)*lp; d = (unsigned char)*(lp-1); if ((isdigit((int)c) || uletter((int)c) || c >= 0200 && MB_CUR_MAX > 1) && !isdigit((int)d) && !uletter((int)d) && (d < 0200 || MB_CUR_MAX == 1)) continue; return (0); case CLET: d = (unsigned char)*lp; if (!isdigit((int)d) && !uletter((int)d) && (d < 0200 || MB_CUR_MAX == 1)) continue; return (0); default: return (0); } } mstar: if (multibyte) { /* MB_CUR_MAX > 1 */ if ((eucw1 != 0) || (eucw2 != 0) || (eucw3 != 0)) { /* EUC locale */ do { char *p1, *p2; lp--; p1 = lp - eucw2; p2 = lp - eucw3; /* check if previous character is from */ /* supplementary code sets 1, 2, or 3 and */ /* back up appropriate number of bytes */ if ((unsigned char)*lp >= 0200) { if (p1 >= curlp && (unsigned char)*p1 == SS2) lp = p1; else if (p2 >= curlp && (unsigned char)*p2 == SS3) lp = p2; else lp = lp - eucw1 + 1; } if (lp == locs) break; if (_advance(lp, ep)) return (1); } while (lp > curlp); return (0); } else { /* Anything else */ do { int len; char *p1, *p2; p2 = curlp; do { p1 = p2; if (isascii(*p1)) { p2 = p1 + 1; } else { len = mblen(p1, MB_CUR_MAX); if (len == -1) { len = 1; } p2 = p1 + len; } if (p2 > lp) { /* something is wrong */ return (0); } } while (p2 != lp); lp = p1; if (lp == locs) break; if (_advance(lp, ep)) return (1); } while (lp > curlp); return (0); } } star: do { if (--lp == locs) break; if (_advance(lp, ep)) return (1); } while (lp > curlp); return (0); }
BSONObj FilteringClientCursor::peek(){ if ( _next.isEmpty() ) _advance(); return _next; }
void write_circular_buffer(CircularBuffer* buffer, void* data) { memcpy(buffer->data + buffer->head, data, buffer->size); _advance(buffer, &buffer->head); }
static int _advance(char *lp, char *ep, step_vars_storage *vars) { char *curlp; int c; char *bbeg; char neg; int ct; int epint; /* int value of *ep */ while (1) { neg = 0; switch (*ep++) { case CCHR: if (*ep++ == *lp++) continue; return (0); case CDOT: if (*lp++) continue; return (0); case CDOL: if (*lp == 0) continue; return (0); case CCEOF: vars->loc2 = lp; return (1); case CXCL: c = (unsigned char)*lp++; if (ISTHERE(c)) { ep += 32; continue; } return (0); case NCCL: neg = 1; case CCL: c = *lp++; if (((c & 0200) == 0 && ISTHERE(c)) ^ neg) { ep += 16; continue; } return (0); case CBRA: epint = (int) *ep; vars->braslist[epint] = lp; ep++; continue; case CKET: epint = (int) *ep; vars->braelist[epint] = lp; ep++; continue; case CCHR | RNGE: c = *ep++; getrnge(ep, vars); while (vars->low--) if (*lp++ != c) return (0); curlp = lp; while (vars->size--) if (*lp++ != c) break; if (vars->size < 0) lp++; ep += 2; goto star; case CDOT | RNGE: getrnge(ep, vars); while (vars->low--) if (*lp++ == '\0') return (0); curlp = lp; while (vars->size--) if (*lp++ == '\0') break; if (vars->size < 0) lp++; ep += 2; goto star; case CXCL | RNGE: getrnge(ep + 32, vars); while (vars->low--) { c = (unsigned char)*lp++; if (!ISTHERE(c)) return (0); } curlp = lp; while (vars->size--) { c = (unsigned char)*lp++; if (!ISTHERE(c)) break; } if (vars->size < 0) lp++; ep += 34; /* 32 + 2 */ goto star; case NCCL | RNGE: neg = 1; case CCL | RNGE: getrnge(ep + 16, vars); while (vars->low--) { c = *lp++; if (((c & 0200) || !ISTHERE(c)) ^ neg) return (0); } curlp = lp; while (vars->size--) { c = *lp++; if (((c & 0200) || !ISTHERE(c)) ^ neg) break; } if (vars->size < 0) lp++; ep += 18; /* 16 + 2 */ goto star; case CBACK: epint = (int) *ep; bbeg = vars->braslist[epint]; ct = vars->braelist[epint] - bbeg; ep++; if (ecmp(bbeg, lp, ct)) { lp += ct; continue; } return (0); case CBACK | STAR: epint = (int) *ep; bbeg = vars->braslist[epint]; ct = vars->braelist[epint] - bbeg; ep++; curlp = lp; while (ecmp(bbeg, lp, ct)) lp += ct; while (lp >= curlp) { if (_advance(lp, ep, vars)) return (1); lp -= ct; } return (0); case CDOT | STAR: curlp = lp; while (*lp++); goto star; case CCHR | STAR: curlp = lp; while (*lp++ == *ep); ep++; goto star; case CXCL | STAR: curlp = lp; do { c = (unsigned char)*lp++; } while (ISTHERE(c)); ep += 32; goto star; case NCCL | STAR: neg = 1; case CCL | STAR: curlp = lp; do { c = *lp++; } while (((c & 0200) == 0 && ISTHERE(c)) ^ neg); ep += 16; goto star; star: do { if (--lp == vars->locs) break; if (_advance(lp, ep, vars)) return (1); } while (lp > curlp); return (0); } } }
BSONObj CursorIterator::next(){ BSONObj o = _o; _advance(); return o; }
void RuleCharacterIterator::jumpahead(int32_t count) { _advance(count); }
bool QueryOptimizerCursorImpl::advance() { return _advance( false ); }
void GDTokenizerText::advance(int p_amount) { ERR_FAIL_COND( p_amount <=0 ); for(int i=0;i<p_amount;i++) _advance(); }