Task #1187
closedNameTree
100%
Description
Develop the NameTree.
NameTree provides a unified data structure for FIB, PIT, and Measurements.
Each NameTree Entry contains:
- a Name
- zero or one
fib::Entry
- zero or more
pit::Entry
- zero or one
measurements::Entry
The NameTree should provide methods to:
- exact match: given a Name, return the NameTree entry with that Name, or determine that such entry does not exist
- longest prefix match: given a query Name, return the NameTree entry whose Name is a prefix of the query Name; the entry returned should have the longest Name among candidate entries
- insert: given a Name, return the NameTree entry with that Name; insert a new entry if such entry does not exist
- delete: given a Name or a NameTree entry, delete that entry if it exists
- full enumerate: iterate over all NameTree entries
- partial enumerate: given a query Name, iterate over NameTree entries under this Name prefix
- get parent: given a NameTree entry, return a NameTree entry whose Name equals this entry's Name minus the last component; insert a new entry if such entry does not exist
- get ancestor: given a NameTree entry, return an existing NameTree entry whose Name is a prefix of this entry's Name minus the last component; the entry returned should have the longest Name among candidate entries
- count: return the total number of NameTree entries
The design should have reasonable performance.
The physical data structure of NameTree is not specified. It's up to the assignee.
Updated by Junxiao Shi almost 11 years ago
- Estimated time changed from 12.00 h to 24.00 h
Updated by Junxiao Shi almost 11 years ago
- Description updated (diff)
- Status changed from New to In Progress
Updated by Junxiao Shi almost 11 years ago
20140214 conference call discussed four physical structures:
- Name Prefix hash table (used in ccnd)
- byte-based Patricia trie
- NameComponent-based trie (used in ndnSIM)
- binary Patricia trie
Name Prefix hash table demo code contains a hand-written hashtable, and an equivalent of ccnd nameprefix_seek
function.
I identify the following problems with this demo code:
- The data structure is mixing hashtable node and entry.
NamePrefixEntry::m_next
is used to resolve hash collision; such field should not be mixed with the business logic (pointers to FIB/PIT/Measurements entries).
A mature hashtable library such as boost::unordered_map could be used.
If a hand-written hashtable is desired, those fields should be placed intoprivate:
section (and makeNameTree
a friend), so that they are not visible from outside. - Longest prefix match, full/partial enumerate methods are missing.
- The hash key should be TLV-encoded Name, not URI.
When code is committed to the main repository, it need also follow CodeStyle, avoid using namespace
, be placed into namespace nfd
, and has unit testing.
Updated by Haowei Yuan almost 11 years ago
Updated code at github repo
- lpm, full/partial enumeration functions added
- converted from std::string to Name
- todo: try hash table from boost
Updated by Alex Afanasyev almost 11 years ago
I would suggest you to submit code into NFD gerrit (you already have permission to submit patchsets: git push gerrit HEAD:refs/for/master
). If you want, you can have your own branch to which you submit code and after it is done we will merge to master (or you can directly submit to be merged into master).
Updated by Haowei Yuan almost 11 years ago
Got it. I will push the code to gerrit when the unit testing code is done.
Alex Afanasyev wrote:
I would suggest you to submit code into NFD gerrit (you already have permission to submit patchsets:
git push gerrit HEAD:refs/for/master
). If you want, you can have your own branch to which you submit code and after it is done we will merge to master (or you can directly submit to be merged into master).
Updated by Haowei Yuan almost 11 years ago
- % Done changed from 0 to 80
I have a few questions about the APITs:
What's the return value for full/partial enumerate()? Should it be a Name Tree Entry vector?
What's the difference between getParent() and getAncestor(). It seems that getAncestor() should return all the entries by following the parent pointer in the form of a Name Tree Entry vector, is this the case? The current description is not very clear to me.
I cloned the source code from github NFD, to push the code to gerrit, shall I just do git push gerrit HEAD:refs/for/master, or I should clone from gerrit first, and then do git push?
Updated by Junxiao Shi almost 11 years ago
Return type for full/partial enumerate is conceptually an iterable.
The exact C++ interface and type needs to be co-designed with FIB and management.
It's also okay to use Visitor pattern.
Suppose NameTree has entries /A and /A/B/C, getParent(/A/B/C)
inserts /A/B and returns it, getAncestor(/A/B/C)
returns /A.
If all intermediate levels are guaranteed to exist, there's no difference between these two operations.
It's best to clone the repository from Gerrit, although you can also push from a repository cloned from GitHub.
Before you push a patchset, please make sure code conforms to CodeStyle, unit tests are included and working.
Updated by Haowei Yuan almost 11 years ago
My current plan is to store all the Name Entries in a C++ std::vector, and the return value would be the pointer to that vector. And currently, all the Name Tree Entry will be inserted to the vector (no matter whether it contains only a FIB, only a PIT, or both). What do you think?
- We might find that it is better to have fullEnumerateFIB() or fullEnumeratePIT() be helpful in the future, and we should be able to add them if needed.
Currenlty, seek() function has to be called before any lookup, which guarantees all the intermedia nodes are in the Name Tree. So there is no difference between getParent() and getAncestor(). And currently, getAncestor() is not implemented.
OK, I will clone the repository from Gerrit. I have tried to follow the code style, and I will review the code again before push it. But I guess there will probably be places that need to be revised or improved. Hope the feedback or codereview process could help on that. : )
Updated by Haowei Yuan almost 11 years ago
- Status changed from In Progress to Feedback
I just pushed the Name Tree code to the gerrit repo. I think there will be some changes that need to be made later as we implement the PIT/FIB/Measurement table, but it is better to get the code out first. Any feedback/comment is welcome.
Updated by Junxiao Shi almost 11 years ago
- Status changed from Feedback to Closed
- % Done changed from 80 to 100
Basic feature is working.
Additional optimization will be written as another task.