a common index structure for FIB, PIT, StrategyChoice, and Measurements More...
#include <name-tree.hpp>
Public Types | |
using | const_iterator = Iterator |
Public Member Functions | |
NameTree (size_t nBuckets=1024) | |
size_t | size () const |
size_t | getNBuckets () const |
template<typename EntryT > | |
Entry * | getEntry (const EntryT &tableEntry) const |
Entry & | lookup (const Name &name, size_t prefixLen) |
find or insert an entry by name More... | |
Entry & | lookup (const Name &name) |
equivalent to lookup(name, name.size()) More... | |
Entry & | lookup (const fib::Entry &fibEntry) |
equivalent to lookup(fibEntry.getPrefix()) More... | |
Entry & | lookup (const pit::Entry &pitEntry) |
equivalent to lookup(pitEntry.getName(), std::min(pitEntry.getName().size(), getMaxDepth())) More... | |
Entry & | lookup (const measurements::Entry &measurementsEntry) |
equivalent to lookup(measurementsEntry.getName()) More... | |
Entry & | lookup (const strategy_choice::Entry &strategyChoiceEntry) |
equivalent to lookup(strategyChoiceEntry.getPrefix()) More... | |
size_t | eraseIfEmpty (Entry *entry, bool canEraseAncestors=true) |
delete the entry if it is empty More... | |
Entry * | findExactMatch (const Name &name, size_t prefixLen=std::numeric_limits< size_t >::max()) const |
exact match lookup More... | |
Entry * | findLongestPrefixMatch (const Name &name, const EntrySelector &entrySelector=AnyEntry()) const |
longest prefix matching More... | |
Entry * | findLongestPrefixMatch (const Entry &entry, const EntrySelector &entrySelector=AnyEntry()) const |
equivalent to findLongestPrefixMatch(entry.getName(), entrySelector) More... | |
template<typename EntryT > | |
Entry * | findLongestPrefixMatch (const EntryT &tableEntry, const EntrySelector &entrySelector=AnyEntry()) const |
equivalent to findLongestPrefixMatch(getEntry(tableEntry)->getName(), entrySelector) More... | |
Entry * | findLongestPrefixMatch (const pit::Entry &pitEntry, const EntrySelector &entrySelector=AnyEntry()) const |
equivalent to findLongestPrefixMatch(pitEntry.getName(), entrySelector) More... | |
Range | findAllMatches (const Name &name, const EntrySelector &entrySelector=AnyEntry()) const |
all-prefixes match lookup More... | |
Range | fullEnumerate (const EntrySelector &entrySelector=AnyEntry()) const |
enumerate all entries More... | |
Range | partialEnumerate (const Name &prefix, const EntrySubTreeSelector &entrySubTreeSelector=AnyEntrySubTree()) const |
enumerate all entries under a prefix More... | |
const_iterator | begin () const |
const_iterator | end () const |
Static Public Member Functions | |
static constexpr size_t | getMaxDepth () |
maximum depth of the name tree More... | |
Friends | |
class | EnumerationImpl |
a common index structure for FIB, PIT, StrategyChoice, and Measurements
Definition at line 38 of file name-tree.hpp.
Definition at line 220 of file name-tree.hpp.
|
explicit |
Definition at line 38 of file name-tree.cpp.
|
inlinestatic |
maximum depth of the name tree
Calling NameTree::lookup
with a name with many components would cause the creation of many NameTree entries, which could take very long time. This constant limits the maximum number of name components in the name of a NameTree entry. Thus, it limits the number of NameTree entries created from a long name, bounding the processing complexity.
Definition at line 53 of file name-tree.hpp.
References nfd::FIB_MAX_DEPTH.
Referenced by nfd::name_tree::Entry::Entry(), findExactMatch(), nfd::measurements::Measurements::findLongestPrefixMatch(), findLongestPrefixMatch(), nfd::measurements::Measurements::getMaxDepth(), nfd::strategy_choice::StrategyChoice::insert(), lookup(), and nfd::strategy_choice::operator<<().
|
inline |
Definition at line 61 of file name-tree.hpp.
References nfd::name_tree::Hashtable::size().
|
inline |
Definition at line 69 of file name-tree.hpp.
References nfd::name_tree::Hashtable::getNBuckets().
|
inline |
Definition at line 79 of file name-tree.hpp.
References nfd::name_tree::Entry::get().
Referenced by nfd::fib::Fib::erase(), nfd::measurements::Measurements::extendLifetime(), findLongestPrefixMatch(), nfd::measurements::Measurements::getParent(), and lookup().
find or insert an entry by name
This method seeks a name tree entry of name name.getPrefix(prefixLen)
. If the entry does not exist, it is created along with all ancestors. Existing iterators are unaffected during this operation.
prefixLen
must not exceed name.size()
. prefixLen
must not exceed getMaxDepth()
. Definition at line 44 of file name-tree.cpp.
References nfd::name_tree::computeHashes(), nfd::name_tree::Node::entry, getMaxDepth(), nfd::name_tree::Hashtable::insert(), NFD_LOG_TRACE, and nfd::name_tree::Entry::setParent().
Referenced by nfd::measurements::Measurements::get(), nfd::fib::Fib::insert(), nfd::strategy_choice::StrategyChoice::insert(), lookup(), and nfd::strategy_choice::StrategyChoice::setDefaultStrategy().
equivalent to lookup(name, name.size())
Definition at line 100 of file name-tree.hpp.
References lookup().
Entry & nfd::name_tree::NameTree::lookup | ( | const fib::Entry & | fibEntry | ) |
equivalent to lookup(fibEntry.getPrefix())
fibEntry | a FIB entry attached to this name tree, or Fib::s_emptyEntry |
lookup(const Name&)
in common cases. Definition at line 67 of file name-tree.cpp.
References ndn::Name::empty(), getEntry(), nfd::fib::Entry::getPrefix(), lookup(), and NFD_LOG_TRACE.
Entry & nfd::name_tree::NameTree::lookup | ( | const pit::Entry & | pitEntry | ) |
equivalent to lookup(pitEntry.getName(), std::min(pitEntry.getName().size(), getMaxDepth()))
pitEntry | a PIT entry attached to this name tree |
lookup(const Name&)
in common cases. Definition at line 82 of file name-tree.cpp.
References getEntry(), getMaxDepth(), nfd::pit::Entry::getName(), nfd::name_tree::Entry::getPitEntries(), lookup(), and NFD_LOG_TRACE.
Entry & nfd::name_tree::NameTree::lookup | ( | const measurements::Entry & | measurementsEntry | ) |
equivalent to lookup(measurementsEntry.getName())
measurementsEntry | a Measurements entry attached to this name tree |
lookup(const Name&)
in common cases. Definition at line 101 of file name-tree.cpp.
References getEntry(), nfd::measurements::Entry::getName(), and NFD_LOG_TRACE.
Entry & nfd::name_tree::NameTree::lookup | ( | const strategy_choice::Entry & | strategyChoiceEntry | ) |
equivalent to lookup(strategyChoiceEntry.getPrefix())
strategyChoiceEntry | a StrategyChoice entry attached to this name tree |
lookup(const Name&)
in common cases. Definition at line 112 of file name-tree.cpp.
References getEntry(), nfd::strategy_choice::Entry::getPrefix(), and NFD_LOG_TRACE.
size_t nfd::name_tree::NameTree::eraseIfEmpty | ( | Entry * | entry, |
bool | canEraseAncestors = true |
||
) |
delete the entry if it is empty
entry | a valid entry |
canEraseAncestors | whether ancestors should be deleted if they become empty |
canEraseAncestors
is true, ancestors of the entry are also deleted if they become empty. Definition at line 123 of file name-tree.cpp.
References nfd::name_tree::Hashtable::erase(), nfd::name_tree::Entry::getName(), nfd::name_tree::getNode(), nfd::name_tree::Entry::getParent(), nfd::name_tree::Entry::isEmpty(), NFD_LOG_TRACE, and nfd::name_tree::Entry::unsetParent().
Referenced by nfd::strategy_choice::StrategyChoice::erase().
Entry * nfd::name_tree::NameTree::findExactMatch | ( | const Name & | name, |
size_t | prefixLen = std::numeric_limits<size_t>::max() |
||
) | const |
exact match lookup
name.getPrefix(prefixLen)
, or nullptr if it does not exist Definition at line 150 of file name-tree.cpp.
References nfd::name_tree::Node::entry, nfd::name_tree::Hashtable::find(), and getMaxDepth().
Referenced by nfd::fib::Fib::erase(), nfd::strategy_choice::StrategyChoice::erase(), nfd::fib::Fib::findExactMatch(), nfd::measurements::Measurements::findExactMatch(), findLongestPrefixMatch(), nfd::strategy_choice::StrategyChoice::get(), and partialEnumerate().
Entry * nfd::name_tree::NameTree::findLongestPrefixMatch | ( | const Name & | name, |
const EntrySelector & | entrySelector = AnyEntry() |
||
) | const |
longest prefix matching
name
and passes entrySelector
, where no other entry with a longer name satisfies those requirements; or nullptr if no entry satisfying those requirements exists Definition at line 162 of file name-tree.cpp.
References nfd::name_tree::computeHashes(), nfd::name_tree::Node::entry, nfd::name_tree::Hashtable::find(), and getMaxDepth().
Referenced by findAllMatches(), nfd::strategy_choice::StrategyChoice::findEffectiveStrategyImpl(), and findLongestPrefixMatch().
Entry * nfd::name_tree::NameTree::findLongestPrefixMatch | ( | const Entry & | entry, |
const EntrySelector & | entrySelector = AnyEntry() |
||
) | const |
equivalent to findLongestPrefixMatch(entry.getName(), entrySelector)
findLongestPrefixMatch(const Name&, const EntrySelector&)
in common cases. Definition at line 178 of file name-tree.cpp.
References nfd::name_tree::Entry::getParent().
|
inline |
equivalent to findLongestPrefixMatch(getEntry(tableEntry)->getName(), entrySelector)
EntryT | fib::Entry or measurements::Entry or strategy_choice::Entry |
findLongestPrefixMatch(const Name&, const EntrySelector&)
in common cases. tableEntry
is not attached to this name tree. Definition at line 179 of file name-tree.hpp.
References findLongestPrefixMatch(), and getEntry().
Entry * nfd::name_tree::NameTree::findLongestPrefixMatch | ( | const pit::Entry & | pitEntry, |
const EntrySelector & | entrySelector = AnyEntry() |
||
) | const |
equivalent to findLongestPrefixMatch(pitEntry.getName(), entrySelector)
findLongestPrefixMatch(const Name&, const EntrySelector&)
in common cases. pitEntry
is not attached to this name tree. Definition at line 191 of file name-tree.cpp.
References findExactMatch(), findLongestPrefixMatch(), getEntry(), getMaxDepth(), nfd::name_tree::Entry::getName(), nfd::pit::Entry::getName(), and ndn::Name::size().
boost::iterator_range< NameTree::const_iterator > nfd::name_tree::NameTree::findAllMatches | ( | const Name & | name, |
const EntrySelector & | entrySelector = AnyEntry() |
||
) | const |
all-prefixes match lookup
name
, and matches entrySelector
.Example:
name
is inserted during the enumeration, it may or may not be visited. If a name tree entry whose name is a prefix of name
is deleted during the enumeration, undefined behavior may occur. Definition at line 213 of file name-tree.cpp.
References end(), and findLongestPrefixMatch().
Referenced by nfd::pit::Pit::findAllDataMatches().
boost::iterator_range< NameTree::const_iterator > nfd::name_tree::NameTree::fullEnumerate | ( | const EntrySelector & | entrySelector = AnyEntry() | ) | const |
enumerate all entries
entrySelector
Example:
Definition at line 226 of file name-tree.cpp.
References end().
Referenced by nfd::pit::Pit::begin(), and begin().
boost::iterator_range< NameTree::const_iterator > nfd::name_tree::NameTree::partialEnumerate | ( | const Name & | prefix, |
const EntrySubTreeSelector & | entrySubTreeSelector = AnyEntrySubTree() |
||
) | const |
enumerate all entries under a prefix
prefix
, and matches entrySubTreeSelector
.Example:
prefix
is inserted or deleted during the enumeration, it may cause the enumeration to skip entries or visit some entries twice. Definition at line 232 of file name-tree.cpp.
References end(), and findExactMatch().
|
inline |
Definition at line 264 of file name-tree.hpp.
References fullEnumerate().
|
inline |
Definition at line 273 of file name-tree.hpp.
Referenced by findAllMatches(), fullEnumerate(), and partialEnumerate().
|
friend |
Definition at line 281 of file name-tree.hpp.