mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
added option to reverse-sort YaCy tables (internal API change only)
This commit is contained in:
parent
6d3d4c4ea6
commit
3ac31614a3
|
@ -243,7 +243,7 @@ public class Table_YMark_p {
|
|||
final String tagsString = YMarkUtil.cleanTagsString(post.get(YMarkEntry.BOOKMARK.TAGS.key()));
|
||||
mapIterator = sb.tables.bookmarks.getBookmarksByTag(bmk_user, tagsString);
|
||||
} else {
|
||||
mapIterator = sb.tables.orderByPK(sb.tables.iterator(table, matcher), maxcount).iterator();
|
||||
mapIterator = sb.tables.orderByPK(sb.tables.iterator(table, matcher), maxcount, false).iterator();
|
||||
}
|
||||
|
||||
Tables.Row row;
|
||||
|
|
|
@ -160,7 +160,7 @@ public class Tables_p {
|
|||
count = 0;
|
||||
try {
|
||||
final Iterator<Tables.Row> plainIterator = sb.tables.iterator(table, matcher);
|
||||
final Iterator<Tables.Row> mapIterator = sb.tables.orderByPK(plainIterator, maxcount).iterator();
|
||||
final Iterator<Tables.Row> mapIterator = sb.tables.orderByPK(plainIterator, maxcount, false).iterator();
|
||||
Tables.Row row;
|
||||
boolean dark = true;
|
||||
byte[] cell;
|
||||
|
|
|
@ -155,7 +155,7 @@ public class table_p {
|
|||
int count = 0;
|
||||
try {
|
||||
final Iterator<Tables.Row> plainIterator = sb.tables.iterator(table, matcher);
|
||||
final Iterator<Tables.Row> mapIterator = sb.tables.orderByPK(plainIterator, maxcount).iterator();
|
||||
final Iterator<Tables.Row> mapIterator = sb.tables.orderByPK(plainIterator, maxcount, false).iterator();
|
||||
Tables.Row trow;
|
||||
boolean dark = true;
|
||||
String cellName, cellValue;
|
||||
|
|
|
@ -676,12 +676,10 @@ public final class CrawlSwitchboard {
|
|||
try {
|
||||
ret = new MapHeap(file, Word.commonHashLength, NaturalOrder.naturalOrder, 1024 * 64, 500, ' ');
|
||||
} catch (final IOException e ) {
|
||||
ConcurrentLog.logException(e);
|
||||
ConcurrentLog.logException(e);
|
||||
FileUtils.deletedelete(file);
|
||||
try {
|
||||
ret =
|
||||
new MapHeap(file, Word.commonHashLength, NaturalOrder.naturalOrder, 1024 * 64, 500, ' ');
|
||||
ret = new MapHeap(file, Word.commonHashLength, NaturalOrder.naturalOrder, 1024 * 64, 500, ' ');
|
||||
} catch (final IOException e1 ) {
|
||||
ConcurrentLog.logException(e1);
|
||||
ret = null;
|
||||
|
|
|
@ -454,14 +454,14 @@ public class Tables implements Iterable<String> {
|
|||
return new RowIterator(table, wherePattern);
|
||||
}
|
||||
|
||||
public Collection<Row> orderByPK(final Iterator<Row> rowIterator, int maxcount) {
|
||||
public Collection<Row> orderByPK(final Iterator<Row> rowIterator, int maxcount, boolean reverse) {
|
||||
final TreeMap<String, Row> sortTree = new TreeMap<String, Row>();
|
||||
Row row;
|
||||
while ((maxcount < 0 || maxcount-- > 0) && rowIterator.hasNext()) {
|
||||
row = rowIterator.next();
|
||||
sortTree.put(UTF8.String(row.pk), row);
|
||||
}
|
||||
return sortTree.values();
|
||||
return reverse ? sortTree.descendingMap().values() : sortTree.values();
|
||||
}
|
||||
|
||||
public Collection<Row> orderBy(final Iterator<Row> rowIterator, int maxcount, final String sortColumn) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user