Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb_re2::DFA Class Reference
Collaboration diagram for duckdb_re2::DFA:

Classes

struct  State
struct  StateHash
struct  StateEqual
struct  SearchParams
struct  StartInfo
class  Workq
class  RWLocker
class  StateSaver

Public Types

enum  {
  kByteEndText = 256 , kFlagEmptyMask = 0xFF , kFlagMatch = 0x0100 , kFlagLastWord = 0x0200 ,
  kFlagNeedShift = 16
}
typedef std::unordered_set< State *, StateHash, StateEqual > StateSet

Public Member Functions

 DFA (Prog *prog, Prog::MatchKind kind, int64_t max_mem)
bool ok () const
Prog::MatchKind kind ()
bool Search (const StringPiece &text, const StringPiece &context, bool anchored, bool want_earliest_match, bool run_forward, bool *failed, const char **ep, SparseSet *matches)
int BuildAllStates (const Prog::DFAStateCallback &cb)
bool PossibleMatchRange (std::string *min, std::string *max, int maxlen)

Private Types

enum  {
  kStartBeginText = 0 , kStartBeginLine = 2 , kStartAfterWordChar = 4 , kStartAfterNonWordChar = 6 ,
  kMaxStart = 8 , kStartAnchored = 1
}
using CacheMutex = Mutex

Private Member Functions

void ResetCache (RWLocker *cache_lock)
State * WorkqToCachedState (Workq *q, Workq *mq, uint32_t flag)
State * CachedState (int *inst, int ninst, uint32_t flag)
void ClearCache ()
void StateToWorkq (State *s, Workq *q)
State * RunStateOnByteUnlocked (State *, int)
State * RunStateOnByte (State *, int)
void RunWorkqOnByte (Workq *q, Workq *nq, int c, uint32_t flag, bool *ismatch)
void RunWorkqOnEmptyString (Workq *q, Workq *nq, uint32_t flag)
void AddToQueue (Workq *q, int id, uint32_t flag)
bool AnalyzeSearch (SearchParams *params)
bool AnalyzeSearchHelper (SearchParams *params, StartInfo *info, uint32_t flags)
template<bool can_prefix_accel, bool want_earliest_match, bool run_forward>
bool InlinedSearchLoop (SearchParams *params)
bool SearchFFF (SearchParams *params)
bool SearchFFT (SearchParams *params)
bool SearchFTF (SearchParams *params)
bool SearchFTT (SearchParams *params)
bool SearchTFF (SearchParams *params)
bool SearchTFT (SearchParams *params)
bool SearchTTF (SearchParams *params)
bool SearchTTT (SearchParams *params)
bool FastSearchLoop (SearchParams *params)
int ByteMap (int c)
 DFA (const DFA &)=delete
DFA & operator= (const DFA &)=delete

Static Private Member Functions

static std::string DumpState (State *state)
static std::string DumpWorkq (Workq *q)

Private Attributes

Prog * prog_
Prog::MatchKind kind_
bool init_failed_
Mutex mutex_
Workq * q0_
Workq * q1_
PODArray< int > stack_
CacheMutex cache_mutex_
int64_t mem_budget_
int64_t state_budget_
StateSet state_cache_
StartInfo start_ [kMaxStart]

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
462510 {
462511 kByteEndText = 256, // imaginary byte at end of text
462512
462513 kFlagEmptyMask = 0xFF, // State.flag_: bits holding kEmptyXXX flags
462514 kFlagMatch = 0x0100, // State.flag_: this is a matching state
462515 kFlagLastWord = 0x0200, // State.flag_: last byte was a word char
462516 kFlagNeedShift = 16, // needed kEmpty bits are or'ed in shifted left
462517 };

◆ anonymous enum

anonymous enum
private
462553 {
462554 // Indices into start_ for unanchored searches.
462555 // Add kStartAnchored for anchored searches.
462556 kStartBeginText = 0, // text at beginning of context
462557 kStartBeginLine = 2, // text at beginning of line
462558 kStartAfterWordChar = 4, // text follows a word character
462559 kStartAfterNonWordChar = 6, // text follows non-word character
462560 kMaxStart = 8,
462561
462562 kStartAnchored = 1,
462563 };

Constructor & Destructor Documentation

◆ DFA()

duckdb_re2::DFA::DFA ( Prog * prog,
Prog::MatchKind kind,
int64_t max_mem )
462803 : prog_(prog),
462804 kind_(kind),
462805 init_failed_(false),
462806 q0_(NULL),
462807 q1_(NULL),
462808 mem_budget_(max_mem) {
462809 int nmark = 0;
462810 if (kind_ == Prog::kLongestMatch)
462811 nmark = prog_->size();
462812 // See DFA::AddToQueue() for why this is so.
462813 int nstack = prog_->inst_count(kInstCapture) +
462814 prog_->inst_count(kInstEmptyWidth) +
462815 prog_->inst_count(kInstNop) +
462816 nmark + 1; // + 1 for start inst
462817
462818 // Account for space needed for DFA, q0, q1, stack.
462819 mem_budget_ -= sizeof(DFA);
462820 mem_budget_ -= (prog_->size() + nmark) *
462821 (sizeof(int)+sizeof(int)) * 2; // q0, q1
462822 mem_budget_ -= nstack * sizeof(int); // stack
462823 if (mem_budget_ < 0) {
462824 init_failed_ = true;
462825 return;
462826 }
462827
462828 state_budget_ = mem_budget_;
462829
462830 // Make sure there is a reasonable amount of working room left.
462831 // At minimum, the search requires room for two states in order
462832 // to limp along, restarting frequently. We'll get better performance
462833 // if there is room for a larger number of states, say 20.
462834 // Note that a state stores list heads only, so we use the program
462835 // list count for the upper bound, not the program size.
462836 int nnext = prog_->bytemap_range() + 1; // + 1 for kByteEndText slot
462837 int64_t one_state = sizeof(State) + nnext*sizeof(std::atomic<State*>) +
462838 (prog_->list_count()+nmark)*sizeof(int);
462839 if (state_budget_ < 20*one_state) {
462840 init_failed_ = true;
462841 return;
462842 }
462843
462844 q0_ = new Workq(prog_->size(), nmark);
462845 q1_ = new Workq(prog_->size(), nmark);
462846 stack_ = PODArray<int>(nstack);
462847}
Definition duckdb.cpp:462750
::int64_t int64_t
Definition duckdb.cpp:462495

◆ ~DFA()

duckdb_re2::DFA::~DFA ( )
462849 {
462850 delete q0_;
462851 delete q1_;
462852 ClearCache();
462853}

Member Function Documentation

◆ ok()

bool duckdb_re2::DFA::ok ( ) const
inline
462456{ return !init_failed_; }

◆ kind()

Prog::MatchKind duckdb_re2::DFA::kind ( )
inline
462457{ return kind_; }

◆ Search()

bool duckdb_re2::DFA::Search ( const StringPiece & text,
const StringPiece & context,
bool anchored,
bool want_earliest_match,
bool run_forward,
bool * failed,
const char ** ep,
SparseSet * matches )
464085 {
464086 *epp = NULL;
464087 if (!ok()) {
464088 *failed = true;
464089 return false;
464090 }
464091 *failed = false;
464092
464093 RWLocker l(&cache_mutex_);
464094 SearchParams params(text, context, &l);
464095 params.anchored = anchored;
464096 params.want_earliest_match = want_earliest_match;
464097 params.run_forward = run_forward;
464098 params.matches = matches;
464099
464100 if (!AnalyzeSearch(&params)) {
464101 *failed = true;
464102 return false;
464103 }
464104 if (params.start == DeadState)
464105 return false;
464106 if (params.start == FullMatchState) {
464107 if (run_forward == want_earliest_match)
464108 *epp = text.data();
464109 else
464110 *epp = text.data() + text.size();
464111 return true;
464112 }
464113 bool ret = FastSearchLoop(&params);
464114 if (params.failed) {
464115 *failed = true;
464116 return false;
464117 }
464118 *epp = params.ep;
464119 return ret;
464120}
Definition duckdb.cpp:463478
PyParams params(const std::string &tag, const std::string &model, const std::string &weights, const std::string &device)
Definition duckdb.cpp:462616

◆ BuildAllStates()

int duckdb_re2::DFA::BuildAllStates ( const Prog::DFAStateCallback & cb)
464240 {
464241 if (!ok())
464242 return 0;
464243
464244 // Pick out start state for unanchored search
464245 // at beginning of text.
464246 RWLocker l(&cache_mutex_);
464247 SearchParams params(StringPiece(), StringPiece(), &l);
464248 params.anchored = false;
464249 if (!AnalyzeSearch(&params) ||
464250 params.start == NULL ||
464251 params.start == DeadState)
464252 return 0;
464253
464254 // Add start state to work queue.
464255 // Note that any State* that we handle here must point into the cache,
464256 // so we can simply depend on pointer-as-a-number hashing and equality.
464257 std::unordered_map<State*, int> m;
464258 std::deque<State*> q;
464259 m.emplace(params.start, static_cast<int>(m.size()));
464260 q.push_back(params.start);
464261
464262 // Compute the input bytes needed to cover all of the next pointers.
464263 int nnext = prog_->bytemap_range() + 1; // + 1 for kByteEndText slot
464264 std::vector<int> input(nnext);
464265 for (int c = 0; c < 256; c++) {
464266 int b = prog_->bytemap()[c];
464267 while (c < 256-1 && prog_->bytemap()[c+1] == b)
464268 c++;
464269 input[b] = c;
464270 }
464271 input[prog_->bytemap_range()] = kByteEndText;
464272
464273 // Scratch space for the output.
464274 std::vector<int> output(nnext);
464275
464276 // Flood to expand every state.
464277 bool oom = false;
464278 while (!q.empty()) {
464279 State* s = q.front();
464280 q.pop_front();
464281 for (int c : input) {
464282 State* ns = RunStateOnByteUnlocked(s, c);
464283 if (ns == NULL) {
464284 oom = true;
464285 break;
464286 }
464287 if (ns == DeadState) {
464288 output[ByteMap(c)] = -1;
464289 continue;
464290 }
464291 if (m.find(ns) == m.end()) {
464292 m.emplace(ns, static_cast<int>(m.size()));
464293 q.push_back(ns);
464294 }
464295 output[ByteMap(c)] = m[ns];
464296 }
464297 if (cb)
464298 cb(oom ? NULL : output.data(),
464299 s == FullMatchState || s->IsMatch());
464300 if (oom)
464301 break;
464302 }
464303
464304 return static_cast<int>(m.size());
464305}

◆ PossibleMatchRange()

bool duckdb_re2::DFA::PossibleMatchRange ( std::string * min,
std::string * max,
int maxlen )
464314 {
464315 if (!ok())
464316 return false;
464317
464318 // NOTE: if future users of PossibleMatchRange want more precision when
464319 // presented with infinitely repeated elements, consider making this a
464320 // parameter to PossibleMatchRange.
464321 static int kMaxEltRepetitions = 0;
464322
464323 // Keep track of the number of times we've visited states previously. We only
464324 // revisit a given state if it's part of a repeated group, so if the value
464325 // portion of the map tuple exceeds kMaxEltRepetitions we bail out and set
464326 // |*max| to |PrefixSuccessor(*max)|.
464327 //
464328 // Also note that previously_visited_states[UnseenStatePtr] will, in the STL
464329 // tradition, implicitly insert a '0' value at first use. We take advantage
464330 // of that property below.
464331 std::unordered_map<State*, int> previously_visited_states;
464332
464333 // Pick out start state for anchored search at beginning of text.
464334 RWLocker l(&cache_mutex_);
464335 SearchParams params(StringPiece(), StringPiece(), &l);
464336 params.anchored = true;
464337 if (!AnalyzeSearch(&params))
464338 return false;
464339 if (params.start == DeadState) { // No matching strings
464340 *min = "";
464341 *max = "";
464342 return true;
464343 }
464344 if (params.start == FullMatchState) // Every string matches: no max
464345 return false;
464346
464347 // The DFA is essentially a big graph rooted at params.start,
464348 // and paths in the graph correspond to accepted strings.
464349 // Each node in the graph has potentially 256+1 arrows
464350 // coming out, one for each byte plus the magic end of
464351 // text character kByteEndText.
464352
464353 // To find the smallest possible prefix of an accepted
464354 // string, we just walk the graph preferring to follow
464355 // arrows with the lowest bytes possible. To find the
464356 // largest possible prefix, we follow the largest bytes
464357 // possible.
464358
464359 // The test for whether there is an arrow from s on byte j is
464360 // ns = RunStateOnByteUnlocked(s, j);
464361 // if (ns == NULL)
464362 // return false;
464363 // if (ns != DeadState && ns->ninst > 0)
464364 // The RunStateOnByteUnlocked call asks the DFA to build out the graph.
464365 // It returns NULL only if the DFA has run out of memory,
464366 // in which case we can't be sure of anything.
464367 // The second check sees whether there was graph built
464368 // and whether it is interesting graph. Nodes might have
464369 // ns->ninst == 0 if they exist only to represent the fact
464370 // that a match was found on the previous byte.
464371
464372 // Build minimum prefix.
464373 State* s = params.start;
464374 min->clear();
464375 MutexLock lock(&mutex_);
464376 for (int i = 0; i < maxlen; i++) {
464377 if (previously_visited_states[s] > kMaxEltRepetitions)
464378 break;
464379 previously_visited_states[s]++;
464380
464381 // Stop if min is a match.
464382 State* ns = RunStateOnByte(s, kByteEndText);
464383 if (ns == NULL) // DFA out of memory
464384 return false;
464385 if (ns != DeadState && (ns == FullMatchState || ns->IsMatch()))
464386 break;
464387
464388 // Try to extend the string with low bytes.
464389 bool extended = false;
464390 for (int j = 0; j < 256; j++) {
464391 ns = RunStateOnByte(s, j);
464392 if (ns == NULL) // DFA out of memory
464393 return false;
464394 if (ns == FullMatchState ||
464395 (ns > SpecialStateMax && ns->ninst_ > 0)) {
464396 extended = true;
464397 min->append(1, static_cast<char>(j));
464398 s = ns;
464399 break;
464400 }
464401 }
464402 if (!extended)
464403 break;
464404 }
464405
464406 // Build maximum prefix.
464407 previously_visited_states.clear();
464408 s = params.start;
464409 max->clear();
464410 for (int i = 0; i < maxlen; i++) {
464411 if (previously_visited_states[s] > kMaxEltRepetitions)
464412 break;
464413 previously_visited_states[s] += 1;
464414
464415 // Try to extend the string with high bytes.
464416 bool extended = false;
464417 for (int j = 255; j >= 0; j--) {
464418 State* ns = RunStateOnByte(s, j);
464419 if (ns == NULL)
464420 return false;
464421 if (ns == FullMatchState ||
464422 (ns > SpecialStateMax && ns->ninst_ > 0)) {
464423 extended = true;
464424 max->append(1, static_cast<char>(j));
464425 s = ns;
464426 break;
464427 }
464428 }
464429 if (!extended) {
464430 // Done, no need for PrefixSuccessor.
464431 return true;
464432 }
464433 }
464434
464435 // Stopped while still adding to *max - round aaaaaaaaaa... to aaaa...b
464436 PrefixSuccessor(max);
464437
464438 // If there are no bytes left, we have no way to say "there is no maximum
464439 // string". We could make the interface more complicated and be able to
464440 // return "there is no maximum but here is a minimum", but that seems like
464441 // overkill -- the most common no-max case is all possible strings, so not
464442 // telling the caller that the empty string is the minimum match isn't a
464443 // great loss.
464444 if (max->empty())
464445 return false;
464446
464447 return true;
464448}
static softfloat min()
static softfloat max()

◆ ResetCache()

void duckdb_re2::DFA::ResetCache ( RWLocker * cache_lock)
private
463530 {
463531 // Re-acquire the cache_mutex_ for writing (exclusive use).
463532 cache_lock->LockForWriting();
463533
463534 hooks::GetDFAStateCacheResetHook()({
463535 state_budget_,
463536 state_cache_.size(),
463537 });
463538
463539 // Clear the cache, reset the memory budget.
463540 for (int i = 0; i < kMaxStart; i++)
463541 start_[i].start.store(NULL, std::memory_order_relaxed);
463542 ClearCache();
463543 mem_budget_ = state_budget_;
463544}

◆ WorkqToCachedState()

DFA::State * duckdb_re2::DFA::WorkqToCachedState ( Workq * q,
Workq * mq,
uint32_t flag )
private
462972 {
462973 //mutex_.AssertHeld();
462974
462975 // Construct array of instruction ids for the new state.
462976 // Only ByteRange, EmptyWidth, and Match instructions are useful to keep:
462977 // those are the only operators with any effect in
462978 // RunWorkqOnEmptyString or RunWorkqOnByte.
462979 PODArray<int> inst(q->size());
462980 int n = 0;
462981 uint32_t needflags = 0; // flags needed by kInstEmptyWidth instructions
462982 bool sawmatch = false; // whether queue contains guaranteed kInstMatch
462983 bool sawmark = false; // whether queue contains a Mark
462984
462985 for (Workq::iterator it = q->begin(); it != q->end(); ++it) {
462986 int id = *it;
462987 if (sawmatch && (kind_ == Prog::kFirstMatch || q->is_mark(id)))
462988 break;
462989 if (q->is_mark(id)) {
462990 if (n > 0 && inst[n-1] != Mark) {
462991 sawmark = true;
462992 inst[n++] = Mark;
462993 }
462994 continue;
462995 }
462996 Prog::Inst* ip = prog_->inst(id);
462997 switch (ip->opcode()) {
462998 case kInstAltMatch:
462999 // This state will continue to a match no matter what
463000 // the rest of the input is. If it is the highest priority match
463001 // being considered, return the special FullMatchState
463002 // to indicate that it's all matches from here out.
463003 if (kind_ != Prog::kManyMatch &&
463004 (kind_ != Prog::kFirstMatch ||
463005 (it == q->begin() && ip->greedy(prog_))) &&
463006 (kind_ != Prog::kLongestMatch || !sawmark) &&
463007 (flag & kFlagMatch)) {
463008 return FullMatchState;
463009 }
463010 FALLTHROUGH_INTENDED;
463011 default:
463012 // Record iff id is the head of its list, which must
463013 // be the case if id-1 is the last of *its* list. :)
463014 if (prog_->inst(id-1)->last())
463015 inst[n++] = *it;
463016 if (ip->opcode() == kInstEmptyWidth)
463017 needflags |= ip->empty();
463018 if (ip->opcode() == kInstMatch && !prog_->anchor_end())
463019 sawmatch = true;
463020 break;
463021 }
463022 }
463023 DCHECK_LE(n, q->size());
463024 if (n > 0 && inst[n-1] == Mark)
463025 n--;
463026
463027 // If there are no empty-width instructions waiting to execute,
463028 // then the extra flag bits will not be used, so there is no
463029 // point in saving them. (Discarding them reduces the number
463030 // of distinct states.)
463031 if (needflags == 0)
463032 flag &= kFlagMatch;
463033
463034 // NOTE(rsc): The code above cannot do flag &= needflags,
463035 // because if the right flags were present to pass the current
463036 // kInstEmptyWidth instructions, new kInstEmptyWidth instructions
463037 // might be reached that in turn need different flags.
463038 // The only sure thing is that if there are no kInstEmptyWidth
463039 // instructions at all, no flags will be needed.
463040 // We could do the extra work to figure out the full set of
463041 // possibly needed flags by exploring past the kInstEmptyWidth
463042 // instructions, but the check above -- are any flags needed
463043 // at all? -- handles the most common case. More fine-grained
463044 // analysis can only be justified by measurements showing that
463045 // too many redundant states are being allocated.
463046
463047 // If there are no Insts in the list, it's a dead state,
463048 // which is useful to signal with a special pointer so that
463049 // the execution loop can stop early. This is only okay
463050 // if the state is *not* a matching state.
463051 if (n == 0 && flag == 0) {
463052 return DeadState;
463053 }
463054
463055 // If we're in longest match mode, the state is a sequence of
463056 // unordered state sets separated by Marks. Sort each set
463057 // to canonicalize, to reduce the number of distinct sets stored.
463058 if (kind_ == Prog::kLongestMatch) {
463059 int* ip = inst.data();
463060 int* ep = ip + n;
463061 while (ip < ep) {
463062 int* markp = ip;
463063 while (markp < ep && *markp != Mark)
463064 markp++;
463065 std::sort(ip, markp);
463066 if (markp < ep)
463067 markp++;
463068 ip = markp;
463069 }
463070 }
463071
463072 // If we're in many match mode, canonicalize for similar reasons:
463073 // we have an unordered set of states (i.e. we don't have Marks)
463074 // and sorting will reduce the number of distinct sets stored.
463075 if (kind_ == Prog::kManyMatch) {
463076 int* ip = inst.data();
463077 int* ep = ip + n;
463078 std::sort(ip, ep);
463079 }
463080
463081 // Append MatchSep and the match IDs in mq if necessary.
463082 if (mq != NULL) {
463083 inst[n++] = MatchSep;
463084 for (Workq::iterator i = mq->begin(); i != mq->end(); ++i) {
463085 int id = *i;
463086 Prog::Inst* ip = prog_->inst(id);
463087 if (ip->opcode() == kInstMatch)
463088 inst[n++] = ip->match_id();
463089 }
463090 }
463091
463092 // Save the needed empty-width flags in the top bits for use later.
463093 flag |= needflags << kFlagNeedShift;
463094
463095 State* state = CachedState(inst.data(), n, flag);
463096 return state;
463097}
::uint32_t uint32_t

◆ CachedState()

DFA::State * duckdb_re2::DFA::CachedState ( int * inst,
int ninst,
uint32_t flag )
private
463102 {
463103 //mutex_.AssertHeld();
463104
463105 // Look in the cache for a pre-existing state.
463106 // We have to initialise the struct like this because otherwise
463107 // MSVC will complain about the flexible array member. :(
463108 State state;
463109 state.inst_ = inst;
463110 state.ninst_ = ninst;
463111 state.flag_ = flag;
463112 StateSet::iterator it = state_cache_.find(&state);
463113 if (it != state_cache_.end()) {
463114 return *it;
463115 }
463116
463117 // Must have enough memory for new state.
463118 // In addition to what we're going to allocate,
463119 // the state cache hash table seems to incur about 40 bytes per
463120 // State*, empirically.
463121 const int kStateCacheOverhead = 40;
463122 int nnext = prog_->bytemap_range() + 1; // + 1 for kByteEndText slot
463123 int mem = sizeof(State) + nnext*sizeof(std::atomic<State*>) +
463124 ninst*sizeof(int);
463125 if (mem_budget_ < mem + kStateCacheOverhead) {
463126 mem_budget_ = -1;
463127 return NULL;
463128 }
463129 mem_budget_ -= mem + kStateCacheOverhead;
463130
463131 // Allocate new state along with room for next_ and inst_.
463132 char* space = std::allocator<char>().allocate(mem);
463133 State* s = new (space) State;
463134 s->next_ = new (space + sizeof(State)) std::atomic<State*>[nnext];
463135 // Work around a unfortunate bug in older versions of libstdc++.
463136 // (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64658)
463137 for (int i = 0; i < nnext; i++)
463138 (void) new (s->next_ + i) std::atomic<State*>(NULL);
463139 s->inst_ = new (s->next_ + nnext) int[ninst];
463140 memmove(s->inst_, inst, ninst*sizeof s->inst_[0]);
463141 s->ninst_ = ninst;
463142 s->flag_ = flag;
463143 // Put state in cache and return it.
463144 state_cache_.insert(s);
463145 return s;
463146}

◆ ClearCache()

void duckdb_re2::DFA::ClearCache ( )
private
463149 {
463150 StateSet::iterator begin = state_cache_.begin();
463151 StateSet::iterator end = state_cache_.end();
463152 while (begin != end) {
463153 StateSet::iterator tmp = begin;
463154 ++begin;
463155 // Deallocate the blob of memory that we allocated in DFA::CachedState().
463156 // We recompute mem in order to benefit from sized delete where possible.
463157 int ninst = (*tmp)->ninst_;
463158 int nnext = prog_->bytemap_range() + 1; // + 1 for kByteEndText slot
463159 int mem = sizeof(State) + nnext*sizeof(std::atomic<State*>) +
463160 ninst*sizeof(int);
463161 std::allocator<char>().deallocate(reinterpret_cast<char*>(*tmp), mem);
463162 }
463163 state_cache_.clear();
463164}

◆ StateToWorkq()

void duckdb_re2::DFA::StateToWorkq ( State * s,
Workq * q )
private
463167 {
463168 q->clear();
463169 for (int i = 0; i < s->ninst_; i++) {
463170 if (s->inst_[i] == Mark) {
463171 q->mark();
463172 } else if (s->inst_[i] == MatchSep) {
463173 // Nothing after this is an instruction!
463174 break;
463175 } else {
463176 // Explore from the head of the list.
463177 AddToQueue(q, s->inst_[i], s->flag_ & kFlagEmptyMask);
463178 }
463179 }
463180}

◆ RunStateOnByteUnlocked()

DFA::State * duckdb_re2::DFA::RunStateOnByteUnlocked ( State * state,
int c )
private
463358 {
463359 // Keep only one RunStateOnByte going
463360 // even if the DFA is being run by multiple threads.
463361 MutexLock l(&mutex_);
463362 return RunStateOnByte(state, c);
463363}

◆ RunStateOnByte()

DFA::State * duckdb_re2::DFA::RunStateOnByte ( State * state,
int c )
private
463366 {
463367 //mutex_.AssertHeld();
463368
463369 if (state <= SpecialStateMax) {
463370 if (state == FullMatchState) {
463371 // It is convenient for routines like PossibleMatchRange
463372 // if we implement RunStateOnByte for FullMatchState:
463373 // once you get into this state you never get out,
463374 // so it's pretty easy.
463375 return FullMatchState;
463376 }
463377 if (state == DeadState) {
463378 LOG(DFATAL) << "DeadState in RunStateOnByte";
463379 return NULL;
463380 }
463381 if (state == NULL) {
463382 LOG(DFATAL) << "NULL state in RunStateOnByte";
463383 return NULL;
463384 }
463385 LOG(DFATAL) << "Unexpected special state in RunStateOnByte";
463386 return NULL;
463387 }
463388
463389 // If someone else already computed this, return it.
463390 State* ns = state->next_[ByteMap(c)].load(std::memory_order_relaxed);
463391 if (ns != NULL)
463392 return ns;
463393
463394 // Convert state into Workq.
463395 StateToWorkq(state, q0_);
463396
463397 // Flags marking the kinds of empty-width things (^ $ etc)
463398 // around this byte. Before the byte we have the flags recorded
463399 // in the State structure itself. After the byte we have
463400 // nothing yet (but that will change: read on).
463401 uint32_t needflag = state->flag_ >> kFlagNeedShift;
463402 uint32_t beforeflag = state->flag_ & kFlagEmptyMask;
463403 uint32_t oldbeforeflag = beforeflag;
463404 uint32_t afterflag = 0;
463405
463406 if (c == '\n') {
463407 // Insert implicit $ and ^ around \n
463408 beforeflag |= kEmptyEndLine;
463409 afterflag |= kEmptyBeginLine;
463410 }
463411
463412 if (c == kByteEndText) {
463413 // Insert implicit $ and \z before the fake "end text" byte.
463414 beforeflag |= kEmptyEndLine | kEmptyEndText;
463415 }
463416
463417 // The state flag kFlagLastWord says whether the last
463418 // byte processed was a word character. Use that info to
463419 // insert empty-width (non-)word boundaries.
463420 bool islastword = (state->flag_ & kFlagLastWord) != 0;
463421 bool isword = c != kByteEndText && Prog::IsWordChar(static_cast<uint8_t>(c));
463422 if (isword == islastword)
463423 beforeflag |= kEmptyNonWordBoundary;
463424 else
463425 beforeflag |= kEmptyWordBoundary;
463426
463427 // Okay, finally ready to run.
463428 // Only useful to rerun on empty string if there are new, useful flags.
463429 if (beforeflag & ~oldbeforeflag & needflag) {
463430 RunWorkqOnEmptyString(q0_, q1_, beforeflag);
463431 using std::swap;
463432 swap(q0_, q1_);
463433 }
463434 bool ismatch = false;
463435 RunWorkqOnByte(q0_, q1_, c, afterflag, &ismatch);
463436 using std::swap;
463437 swap(q0_, q1_);
463438
463439 // Save afterflag along with ismatch and isword in new state.
463440 uint32_t flag = afterflag;
463441 if (ismatch)
463442 flag |= kFlagMatch;
463443 if (isword)
463444 flag |= kFlagLastWord;
463445
463446 if (ismatch && kind_ == Prog::kManyMatch)
463447 ns = WorkqToCachedState(q0_, q1_, flag);
463448 else
463449 ns = WorkqToCachedState(q0_, NULL, flag);
463450
463451 // Flush ns before linking to it.
463452 // Write barrier before updating state->next_ so that the
463453 // main search loop can proceed without any locking, for speed.
463454 // (Otherwise it would need one mutex operation per input byte.)
463455 state->next_[ByteMap(c)].store(ns, std::memory_order_release);
463456 return ns;
463457}
void swap(Mat &a, Mat &b)
::uint8_t uint8_t

◆ RunWorkqOnByte()

void duckdb_re2::DFA::RunWorkqOnByte ( Workq * q,
Workq * nq,
int c,
uint32_t flag,
bool * ismatch )
private
463298 {
463299 //mutex_.AssertHeld();
463300
463301 newq->clear();
463302 for (Workq::iterator i = oldq->begin(); i != oldq->end(); ++i) {
463303 if (oldq->is_mark(*i)) {
463304 if (*ismatch)
463305 return;
463306 newq->mark();
463307 continue;
463308 }
463309 int id = *i;
463310 Prog::Inst* ip = prog_->inst(id);
463311 switch (ip->opcode()) {
463312 default:
463313 LOG(DFATAL) << "unhandled opcode: " << ip->opcode();
463314 break;
463315
463316 case kInstFail: // never succeeds
463317 case kInstCapture: // already followed
463318 case kInstNop: // already followed
463319 case kInstAltMatch: // already followed
463320 case kInstEmptyWidth: // already followed
463321 break;
463322
463323 case kInstByteRange: // can follow if c is in range
463324 if (!ip->Matches(c))
463325 break;
463326 AddToQueue(newq, ip->out(), flag);
463327 if (ip->hint() != 0) {
463328 // We have a hint, but we must cancel out the
463329 // increment that will occur after the break.
463330 i += ip->hint() - 1;
463331 } else {
463332 // We have no hint, so we must find the end
463333 // of the current list and then skip to it.
463334 Prog::Inst* ip0 = ip;
463335 while (!ip->last())
463336 ++ip;
463337 i += ip - ip0;
463338 }
463339 break;
463340
463341 case kInstMatch:
463342 if (prog_->anchor_end() && c != kByteEndText &&
463343 kind_ != Prog::kManyMatch)
463344 break;
463345 *ismatch = true;
463346 if (kind_ == Prog::kFirstMatch) {
463347 // Can stop processing work queue since we found a match.
463348 return;
463349 }
463350 break;
463351 }
463352 }
463353
463354}

◆ RunWorkqOnEmptyString()

void duckdb_re2::DFA::RunWorkqOnEmptyString ( Workq * q,
Workq * nq,
uint32_t flag )
private
463283 {
463284 newq->clear();
463285 for (Workq::iterator i = oldq->begin(); i != oldq->end(); ++i) {
463286 if (oldq->is_mark(*i))
463287 AddToQueue(newq, Mark, flag);
463288 else
463289 AddToQueue(newq, *i, flag);
463290 }
463291}

◆ AddToQueue()

void duckdb_re2::DFA::AddToQueue ( Workq * q,
int id,
uint32_t flag )
private
463183 {
463184
463185 // Use stack_ to hold our stack of instructions yet to process.
463186 // It was preallocated as follows:
463187 // one entry per Capture;
463188 // one entry per EmptyWidth; and
463189 // one entry per Nop.
463190 // This reflects the maximum number of stack pushes that each can
463191 // perform. (Each instruction can be processed at most once.)
463192 // When using marks, we also added nmark == prog_->size().
463193 // (Otherwise, nmark == 0.)
463194 int* stk = stack_.data();
463195 int nstk = 0;
463196
463197 stk[nstk++] = id;
463198 while (nstk > 0) {
463199 DCHECK_LE(nstk, stack_.size());
463200 id = stk[--nstk];
463201
463202 Loop:
463203 if (id == Mark) {
463204 q->mark();
463205 continue;
463206 }
463207
463208 if (id == 0)
463209 continue;
463210
463211 // If ip is already on the queue, nothing to do.
463212 // Otherwise add it. We don't actually keep all the
463213 // ones that get added, but adding all of them here
463214 // increases the likelihood of q->contains(id),
463215 // reducing the amount of duplicated work.
463216 if (q->contains(id))
463217 continue;
463218 q->insert_new(id);
463219
463220 // Process instruction.
463221 Prog::Inst* ip = prog_->inst(id);
463222 switch (ip->opcode()) {
463223 default:
463224 LOG(DFATAL) << "unhandled opcode: " << ip->opcode();
463225 break;
463226
463227 case kInstByteRange: // just save these on the queue
463228 case kInstMatch:
463229 if (ip->last())
463230 break;
463231 id = id+1;
463232 goto Loop;
463233
463234 case kInstCapture: // DFA treats captures as no-ops.
463235 case kInstNop:
463236 if (!ip->last())
463237 stk[nstk++] = id+1;
463238
463239 // If this instruction is the [00-FF]* loop at the beginning of
463240 // a leftmost-longest unanchored search, separate with a Mark so
463241 // that future threads (which will start farther to the right in
463242 // the input string) are lower priority than current threads.
463243 if (ip->opcode() == kInstNop && q->maxmark() > 0 &&
463244 id == prog_->start_unanchored() && id != prog_->start())
463245 stk[nstk++] = Mark;
463246 id = ip->out();
463247 goto Loop;
463248
463249 case kInstAltMatch:
463250 DCHECK(!ip->last());
463251 id = id+1;
463252 goto Loop;
463253
463254 case kInstEmptyWidth:
463255 if (!ip->last())
463256 stk[nstk++] = id+1;
463257
463258 // Continue on if we have all the right flag bits.
463259 if (ip->empty() & ~flag)
463260 break;
463261 id = ip->out();
463262 goto Loop;
463263 }
463264 }
463265}

◆ DumpState()

std::string duckdb_re2::DFA::DumpState ( State * state)
staticprivate
462886 {
462887 if (state == NULL)
462888 return "_";
462889 if (state == DeadState)
462890 return "X";
462891 if (state == FullMatchState)
462892 return "*";
462893 std::string s;
462894 const char* sep = "";
462895 s += StringPrintf("(%p)", state);
462896 for (int i = 0; i < state->ninst_; i++) {
462897 if (state->inst_[i] == Mark) {
462898 s += "|";
462899 sep = "";
462900 } else if (state->inst_[i] == MatchSep) {
462901 s += "||";
462902 sep = "";
462903 } else {
462904 s += StringPrintf("%s%d", sep, state->inst_[i]);
462905 sep = ",";
462906 }
462907 }
462908 s += StringPrintf(" flag=%#x", state->flag_);
462909 return s;
462910}

◆ DumpWorkq()

std::string duckdb_re2::DFA::DumpWorkq ( Workq * q)
staticprivate
462870 {
462871 std::string s;
462872 const char* sep = "";
462873 for (Workq::iterator it = q->begin(); it != q->end(); ++it) {
462874 if (q->is_mark(*it)) {
462875 s += "|";
462876 sep = "";
462877 } else {
462878 s += StringPrintf("%s%d", sep, *it);
462879 sep = ",";
462880 }
462881 }
462882 return s;
462883}

◆ AnalyzeSearch()

bool duckdb_re2::DFA::AnalyzeSearch ( SearchParams * params)
private
463977 {
463978 const StringPiece& text = params->text;
463979 const StringPiece& context = params->context;
463980
463981 // Sanity check: make sure that text lies within context.
463982 if (BeginPtr(text) < BeginPtr(context) || EndPtr(text) > EndPtr(context)) {
463983 LOG(DFATAL) << "context does not contain text";
463984 params->start = DeadState;
463985 return true;
463986 }
463987
463988 // Determine correct search type.
463989 int start;
463990 uint32_t flags;
463991 if (params->run_forward) {
463992 if (BeginPtr(text) == BeginPtr(context)) {
463993 start = kStartBeginText;
463994 flags = kEmptyBeginText|kEmptyBeginLine;
463995 } else if (BeginPtr(text)[-1] == '\n') {
463996 start = kStartBeginLine;
463997 flags = kEmptyBeginLine;
463998 } else if (Prog::IsWordChar(BeginPtr(text)[-1] & 0xFF)) {
463999 start = kStartAfterWordChar;
464000 flags = kFlagLastWord;
464001 } else {
464002 start = kStartAfterNonWordChar;
464003 flags = 0;
464004 }
464005 } else {
464006 if (EndPtr(text) == EndPtr(context)) {
464007 start = kStartBeginText;
464008 flags = kEmptyBeginText|kEmptyBeginLine;
464009 } else if (EndPtr(text)[0] == '\n') {
464010 start = kStartBeginLine;
464011 flags = kEmptyBeginLine;
464012 } else if (Prog::IsWordChar(EndPtr(text)[0] & 0xFF)) {
464013 start = kStartAfterWordChar;
464014 flags = kFlagLastWord;
464015 } else {
464016 start = kStartAfterNonWordChar;
464017 flags = 0;
464018 }
464019 }
464020 if (params->anchored)
464021 start |= kStartAnchored;
464022 StartInfo* info = &start_[start];
464023
464024 // Try once without cache_lock for writing.
464025 // Try again after resetting the cache
464026 // (ResetCache will relock cache_lock for writing).
464027 if (!AnalyzeSearchHelper(params, info, flags)) {
464028 ResetCache(params->cache_lock);
464029 if (!AnalyzeSearchHelper(params, info, flags)) {
464030 params->failed = true;
464031 LOG(DFATAL) << "Failed to analyze start state.";
464032 return false;
464033 }
464034 }
464035
464036 params->start = info->start.load(std::memory_order_acquire);
464037
464038 // Even if we could prefix accel, we cannot do so when anchored and,
464039 // less obviously, we cannot do so when we are going to need flags.
464040 // This trick works only when there is a single byte that leads to a
464041 // different state!
464042 if (prog_->can_prefix_accel() &&
464043 !params->anchored &&
464044 params->start > SpecialStateMax &&
464045 params->start->flag_ >> kFlagNeedShift == 0)
464046 params->can_prefix_accel = true;
464047
464048 return true;
464049}
Definition duckdb.cpp:462650

◆ AnalyzeSearchHelper()

bool duckdb_re2::DFA::AnalyzeSearchHelper ( SearchParams * params,
StartInfo * info,
uint32_t flags )
private
464053 {
464054 // Quick check.
464055 State* start = info->start.load(std::memory_order_acquire);
464056 if (start != NULL)
464057 return true;
464058
464059 MutexLock l(&mutex_);
464060 start = info->start.load(std::memory_order_relaxed);
464061 if (start != NULL)
464062 return true;
464063
464064 q0_->clear();
464065 AddToQueue(q0_,
464066 params->anchored ? prog_->start() : prog_->start_unanchored(),
464067 flags);
464068 start = WorkqToCachedState(q0_, NULL, flags);
464069 if (start == NULL)
464070 return false;
464071
464072 // Synchronize with "quick check" above.
464073 info->start.store(start, std::memory_order_release);
464074 return true;
464075}

◆ InlinedSearchLoop()

template<bool can_prefix_accel, bool want_earliest_match, bool run_forward>
bool duckdb_re2::DFA::InlinedSearchLoop ( SearchParams * params)
inlineprivate
463691 {
463692 State* start = params->start;
463693 const uint8_t* bp = BytePtr(params->text.data()); // start of text
463694 const uint8_t* p = bp; // text scanning point
463695 const uint8_t* ep = BytePtr(params->text.data() +
463696 params->text.size()); // end of text
463697 const uint8_t* resetp = NULL; // p at last cache reset
463698 if (!run_forward) {
463699 using std::swap;
463700 swap(p, ep);
463701 }
463702
463703 const uint8_t* bytemap = prog_->bytemap();
463704 const uint8_t* lastmatch = NULL; // most recent matching position in text
463705 bool matched = false;
463706
463707 State* s = start;
463708
463709 if (s->IsMatch()) {
463710 matched = true;
463711 lastmatch = p;
463712 if (params->matches != NULL && kind_ == Prog::kManyMatch) {
463713 for (int i = s->ninst_ - 1; i >= 0; i--) {
463714 int id = s->inst_[i];
463715 if (id == MatchSep)
463716 break;
463717 params->matches->insert(id);
463718 }
463719 }
463720 if (want_earliest_match) {
463721 params->ep = reinterpret_cast<const char*>(lastmatch);
463722 return true;
463723 }
463724 }
463725
463726 while (p != ep) {
463727
463728 if (can_prefix_accel && s == start) {
463729 // In start state, only way out is to find the prefix,
463730 // so we use prefix accel (e.g. memchr) to skip ahead.
463731 // If not found, we can skip to the end of the string.
463732 p = BytePtr(prog_->PrefixAccel(p, ep - p));
463733 if (p == NULL) {
463734 p = ep;
463735 break;
463736 }
463737 }
463738
463739 int c;
463740 if (run_forward)
463741 c = *p++;
463742 else
463743 c = *--p;
463744
463745 // Note that multiple threads might be consulting
463746 // s->next_[bytemap[c]] simultaneously.
463747 // RunStateOnByte takes care of the appropriate locking,
463748 // including a memory barrier so that the unlocked access
463749 // (sometimes known as "double-checked locking") is safe.
463750 // The alternative would be either one DFA per thread
463751 // or one mutex operation per input byte.
463752 //
463753 // ns == DeadState means the state is known to be dead
463754 // (no more matches are possible).
463755 // ns == NULL means the state has not yet been computed
463756 // (need to call RunStateOnByteUnlocked).
463757 // RunStateOnByte returns ns == NULL if it is out of memory.
463758 // ns == FullMatchState means the rest of the string matches.
463759 //
463760 // Okay to use bytemap[] not ByteMap() here, because
463761 // c is known to be an actual byte and not kByteEndText.
463762
463763 State* ns = s->next_[bytemap[c]].load(std::memory_order_acquire);
463764 if (ns == NULL) {
463765 ns = RunStateOnByteUnlocked(s, c);
463766 if (ns == NULL) {
463767 // After we reset the cache, we hold cache_mutex exclusively,
463768 // so if resetp != NULL, it means we filled the DFA state
463769 // cache with this search alone (without any other threads).
463770 // Benchmarks show that doing a state computation on every
463771 // byte runs at about 0.2 MB/s, while the NFA (nfa.cc) can do the
463772 // same at about 2 MB/s. Unless we're processing an average
463773 // of 10 bytes per state computation, fail so that RE2 can
463774 // fall back to the NFA. However, RE2::Set cannot fall back,
463775 // so we just have to keep on keeping on in that case.
463776 if (dfa_should_bail_when_slow && resetp != NULL &&
463777 static_cast<size_t>(p - resetp) < 10*state_cache_.size() &&
463778 kind_ != Prog::kManyMatch) {
463779 params->failed = true;
463780 return false;
463781 }
463782 resetp = p;
463783
463784 // Prepare to save start and s across the reset.
463785 StateSaver save_start(this, start);
463786 StateSaver save_s(this, s);
463787
463788 // Discard all the States in the cache.
463789 ResetCache(params->cache_lock);
463790
463791 // Restore start and s so we can continue.
463792 if ((start = save_start.Restore()) == NULL ||
463793 (s = save_s.Restore()) == NULL) {
463794 // Restore already did LOG(DFATAL).
463795 params->failed = true;
463796 return false;
463797 }
463798 ns = RunStateOnByteUnlocked(s, c);
463799 if (ns == NULL) {
463800 LOG(DFATAL) << "RunStateOnByteUnlocked failed after ResetCache";
463801 params->failed = true;
463802 return false;
463803 }
463804 }
463805 }
463806 if (ns <= SpecialStateMax) {
463807 if (ns == DeadState) {
463808 params->ep = reinterpret_cast<const char*>(lastmatch);
463809 return matched;
463810 }
463811 // FullMatchState
463812 params->ep = reinterpret_cast<const char*>(ep);
463813 return true;
463814 }
463815
463816 s = ns;
463817 if (s->IsMatch()) {
463818 matched = true;
463819 // The DFA notices the match one byte late,
463820 // so adjust p before using it in the match.
463821 if (run_forward)
463822 lastmatch = p - 1;
463823 else
463824 lastmatch = p + 1;
463825 if (params->matches != NULL && kind_ == Prog::kManyMatch) {
463826 for (int i = s->ninst_ - 1; i >= 0; i--) {
463827 int id = s->inst_[i];
463828 if (id == MatchSep)
463829 break;
463830 params->matches->insert(id);
463831 }
463832 }
463833 if (want_earliest_match) {
463834 params->ep = reinterpret_cast<const char*>(lastmatch);
463835 return true;
463836 }
463837 }
463838 }
463839
463840 // Process one more byte to see if it triggers a match.
463841 // (Remember, matches are delayed one byte.)
463842
463843 int lastbyte;
463844 if (run_forward) {
463845 if (EndPtr(params->text) == EndPtr(params->context))
463846 lastbyte = kByteEndText;
463847 else
463848 lastbyte = EndPtr(params->text)[0] & 0xFF;
463849 } else {
463850 if (BeginPtr(params->text) == BeginPtr(params->context))
463851 lastbyte = kByteEndText;
463852 else
463853 lastbyte = BeginPtr(params->text)[-1] & 0xFF;
463854 }
463855
463856 State* ns = s->next_[ByteMap(lastbyte)].load(std::memory_order_acquire);
463857 if (ns == NULL) {
463858 ns = RunStateOnByteUnlocked(s, lastbyte);
463859 if (ns == NULL) {
463860 StateSaver save_s(this, s);
463861 ResetCache(params->cache_lock);
463862 if ((s = save_s.Restore()) == NULL) {
463863 params->failed = true;
463864 return false;
463865 }
463866 ns = RunStateOnByteUnlocked(s, lastbyte);
463867 if (ns == NULL) {
463868 LOG(DFATAL) << "RunStateOnByteUnlocked failed after Reset";
463869 params->failed = true;
463870 return false;
463871 }
463872 }
463873 }
463874 if (ns <= SpecialStateMax) {
463875 if (ns == DeadState) {
463876 params->ep = reinterpret_cast<const char*>(lastmatch);
463877 return matched;
463878 }
463879 // FullMatchState
463880 params->ep = reinterpret_cast<const char*>(ep);
463881 return true;
463882 }
463883
463884 s = ns;
463885 if (s->IsMatch()) {
463886 matched = true;
463887 lastmatch = p;
463888 if (params->matches != NULL && kind_ == Prog::kManyMatch) {
463889 for (int i = s->ninst_ - 1; i >= 0; i--) {
463890 int id = s->inst_[i];
463891 if (id == MatchSep)
463892 break;
463893 params->matches->insert(id);
463894 }
463895 }
463896 }
463897
463898 params->ep = reinterpret_cast<const char*>(lastmatch);
463899 return matched;
463900}
Definition duckdb.cpp:463562

◆ SearchFFF()

bool duckdb_re2::DFA::SearchFFF ( SearchParams * params)
private
463903 {
463904 return InlinedSearchLoop<false, false, false>(params);
463905}

◆ SearchFFT()

bool duckdb_re2::DFA::SearchFFT ( SearchParams * params)
private
463906 {
463907 return InlinedSearchLoop<false, false, true>(params);
463908}

◆ SearchFTF()

bool duckdb_re2::DFA::SearchFTF ( SearchParams * params)
private
463909 {
463910 return InlinedSearchLoop<false, true, false>(params);
463911}

◆ SearchFTT()

bool duckdb_re2::DFA::SearchFTT ( SearchParams * params)
private
463912 {
463913 return InlinedSearchLoop<false, true, true>(params);
463914}

◆ SearchTFF()

bool duckdb_re2::DFA::SearchTFF ( SearchParams * params)
private
463915 {
463916 return InlinedSearchLoop<true, false, false>(params);
463917}

◆ SearchTFT()

bool duckdb_re2::DFA::SearchTFT ( SearchParams * params)
private
463918 {
463919 return InlinedSearchLoop<true, false, true>(params);
463920}

◆ SearchTTF()

bool duckdb_re2::DFA::SearchTTF ( SearchParams * params)
private
463921 {
463922 return InlinedSearchLoop<true, true, false>(params);
463923}

◆ SearchTTT()

bool duckdb_re2::DFA::SearchTTT ( SearchParams * params)
private
463924 {
463925 return InlinedSearchLoop<true, true, true>(params);
463926}

◆ FastSearchLoop()

bool duckdb_re2::DFA::FastSearchLoop ( SearchParams * params)
private
463930 {
463931 // Because the methods are private, the Searches array
463932 // cannot be declared at top level.
463933 static bool (DFA::*Searches[])(SearchParams*) = {
463934 &DFA::SearchFFF,
463935 &DFA::SearchFFT,
463936 &DFA::SearchFTF,
463937 &DFA::SearchFTT,
463938 &DFA::SearchTFF,
463939 &DFA::SearchTFT,
463940 &DFA::SearchTTF,
463941 &DFA::SearchTTT,
463942 };
463943
463944 int index = 4 * params->can_prefix_accel +
463945 2 * params->want_earliest_match +
463946 1 * params->run_forward;
463947 return (this->*Searches[index])(params);
463948}
index

◆ ByteMap()

int duckdb_re2::DFA::ByteMap ( int c)
inlineprivate
462693 {
462694 if (c == kByteEndText)
462695 return prog_->bytemap_range();
462696 return prog_->bytemap()[c];
462697 }

The documentation for this class was generated from the following file: