You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Version.javapublicLookupResultget(LookupKeykey)
{
LookupResultlookupResult = level0.get(key, readStats);
if (lookupResult == null) {
for (Levellevel : levels) {
lookupResult = level.get(key, readStats);
...
}
}
...
returnlookupResult;
}
// Level0.javapublicLookupResultget(LookupKeykey, ReadStatsreadStats)
{
...
List<FileMetaData> fileMetaDataList = newArrayList<>(files.size());
for (FileMetaDatafileMetaData : files) {
if (...) {
fileMetaDataList.add(fileMetaData);
}
}
Collections.sort(fileMetaDataList, NEWEST_FIRST);
...
}
// Level.javapublicLookupResultget(LookupKeykey, ReadStatsreadStats)
{
...
List<FileMetaData> fileMetaDataList = newArrayList<>(files.size());
if (levelNumber == 0) { // Do we really need to judge this condition ?for (FileMetaDatafileMetaData : files) {
if (...) {
fileMetaDataList.add(fileMetaData);
}
}
}
else {
// Binary search to find earliest index whose largest key >= ikey.
}
...
}
In the above function, level0.get() and level.get() are called respectively. However, In the implementation of the former, calls the sort function Collections.sort(fileMetaDataList, NEWEST_FIRST); to make the newer files in front of the list while the other call doesn't. So do we need this sort function call or not? And why get function in Level.java should consider the situation of level0?
The text was updated successfully, but these errors were encountered:
Level 0 files are not compacted, so you have to process them in temporal order to ensure that old (deleted or over written) values are not returned. Later levels are compacted, so you don't need this.
I understand that. I mean, does the get method in Level.java need to check the first if-statement (levelnumber = = 0), I think it has been processed by the get method in Level0.java, which also means that the get method in Level.java doesn't need the sort as you said.
In other words, can we just delete the code fragment below in Level.java because this situation has been considered in Level0.java:
if (levelNumber == 0) { // Do we really need to judge this condition ?for (FileMetaDatafileMetaData : files) {
if (...) {
fileMetaDataList.add(fileMetaData);
}
}
}
hecenjie
changed the title
The necessity of sort function in get(LookupKey key, ReadStats readStats)
Unnecessary to check levelnumber = = 0 in Level.java
Feb 25, 2020
In the above function,
level0.get()
andlevel.get()
are called respectively. However, In the implementation of the former, calls the sort functionCollections.sort(fileMetaDataList, NEWEST_FIRST);
to make the newer files in front of the list while the other call doesn't. So do we need this sort function call or not? And why get function inLevel.java
should consider the situation of level0?The text was updated successfully, but these errors were encountered: