More helpful descriptions of index queries.
This commit is contained in:
parent
5fb75adaae
commit
1e4157017d
@ -16,4 +16,10 @@ public class EmptyEntrySource implements EntrySource {
|
||||
public boolean hasMore() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String indexName() {
|
||||
return "Empty";
|
||||
}
|
||||
}
|
||||
|
@ -7,4 +7,6 @@ public interface EntrySource {
|
||||
void read(LongQueryBuffer buffer);
|
||||
|
||||
boolean hasMore();
|
||||
|
||||
String indexName();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import nu.marginalia.array.buffer.LongQueryBuffer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class IndexQuery {
|
||||
private final List<EntrySource> sources;
|
||||
@ -66,14 +67,10 @@ public class IndexQuery {
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Sources:\n");
|
||||
for (var source : sources) {
|
||||
sb.append(source).append('\n');
|
||||
}
|
||||
sb.append("Includes:\n");
|
||||
for (var include : inclusionFilter) {
|
||||
sb.append("\t").append(include.describe()).append("\n");
|
||||
}
|
||||
|
||||
sb.append(sources.stream().map(EntrySource::indexName).collect(Collectors.joining(", ", "[", "]")));
|
||||
sb.append(" -> ");
|
||||
sb.append(inclusionFilter.stream().map(QueryFilterStepIf::describe).collect(Collectors.joining(", ", "[", "]")));
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -14,14 +14,17 @@ public class ReverseIndexFullEntrySource implements EntrySource {
|
||||
int endOffset;
|
||||
|
||||
final int entrySize;
|
||||
private final int wordId;
|
||||
private final ReverseIndexEntrySourceBehavior behavior;
|
||||
|
||||
public ReverseIndexFullEntrySource(BTreeReader reader,
|
||||
int entrySize,
|
||||
ReverseIndexEntrySourceBehavior behavior) {
|
||||
ReverseIndexEntrySourceBehavior behavior,
|
||||
int wordId) {
|
||||
this.reader = reader;
|
||||
this.behavior = behavior;
|
||||
this.entrySize = entrySize;
|
||||
this.wordId = wordId;
|
||||
|
||||
pos = 0;
|
||||
endOffset = pos + entrySize * reader.numEntries();
|
||||
@ -65,4 +68,9 @@ public class ReverseIndexFullEntrySource implements EntrySource {
|
||||
return pos < endOffset;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String indexName() {
|
||||
return "Priority:" + wordId;
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class ReverseIndexFullReader {
|
||||
|
||||
if (offset < 0) return new EmptyEntrySource();
|
||||
|
||||
return new ReverseIndexFullEntrySource(createReaderNew(offset), ReverseIndexFullParameters.ENTRY_SIZE, behavior);
|
||||
return new ReverseIndexFullEntrySource(createReaderNew(offset), ReverseIndexFullParameters.ENTRY_SIZE, behavior, wordId);
|
||||
}
|
||||
|
||||
public QueryFilterStepIf also(int wordId) {
|
||||
@ -73,7 +73,7 @@ public class ReverseIndexFullReader {
|
||||
|
||||
if (offset < 0) return new QueryFilterNoPass();
|
||||
|
||||
return new ReverseIndexRetainFilter(createReaderNew(offset));
|
||||
return new ReverseIndexRetainFilter(createReaderNew(offset), "full", wordId);
|
||||
}
|
||||
|
||||
public QueryFilterStepIf not(int wordId) {
|
||||
|
@ -14,10 +14,12 @@ public class ReverseIndexPriorityEntrySource implements EntrySource {
|
||||
int endOffset;
|
||||
|
||||
private final ReverseIndexEntrySourceBehavior behavior;
|
||||
private final int wordId;
|
||||
|
||||
public ReverseIndexPriorityEntrySource(BTreeReader reader, ReverseIndexEntrySourceBehavior behavior) {
|
||||
public ReverseIndexPriorityEntrySource(BTreeReader reader, ReverseIndexEntrySourceBehavior behavior, int wordId) {
|
||||
this.reader = reader;
|
||||
this.behavior = behavior;
|
||||
this.wordId = wordId;
|
||||
|
||||
pos = 0;
|
||||
endOffset = pos + reader.numEntries();
|
||||
@ -49,4 +51,8 @@ public class ReverseIndexPriorityEntrySource implements EntrySource {
|
||||
return pos < endOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String indexName() {
|
||||
return "Priority:" + wordId;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class ReverseIndexPriorityReader {
|
||||
|
||||
if (offset < 0) return new EmptyEntrySource();
|
||||
|
||||
return new ReverseIndexPriorityEntrySource(createReaderNew(offset), ReverseIndexEntrySourceBehavior.DO_PREFER);
|
||||
return new ReverseIndexPriorityEntrySource(createReaderNew(offset), ReverseIndexEntrySourceBehavior.DO_PREFER, wordId);
|
||||
}
|
||||
|
||||
private BTreeReader createReaderNew(long offset) {
|
||||
@ -60,7 +60,7 @@ public class ReverseIndexPriorityReader {
|
||||
|
||||
if (offset < 0) return new QueryFilterNoPass();
|
||||
|
||||
return new ReverseIndexRetainFilter(createReaderNew(offset));
|
||||
return new ReverseIndexRetainFilter(createReaderNew(offset), "priority", wordId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import nu.marginalia.array.buffer.LongQueryBuffer;
|
||||
import nu.marginalia.btree.BTreeReader;
|
||||
import nu.marginalia.index.query.filter.QueryFilterStepIf;
|
||||
|
||||
public record ReverseIndexRetainFilter(BTreeReader range) implements QueryFilterStepIf {
|
||||
public record ReverseIndexRetainFilter(BTreeReader range, String name, int wordId) implements QueryFilterStepIf {
|
||||
|
||||
@Override
|
||||
public void apply(LongQueryBuffer buffer) {
|
||||
@ -23,6 +23,6 @@ public record ReverseIndexRetainFilter(BTreeReader range) implements QueryFilter
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "ReverseIndexRetainFilter";
|
||||
return "Retain:" + name + "/" + wordId;
|
||||
}
|
||||
}
|
||||
|
@ -33,12 +33,12 @@ public class SearchIndexReader {
|
||||
|
||||
public IndexQueryBuilder findPriorityWord(int wordId) {
|
||||
return new SearchIndexQueryBuilder(reverseIndexFullReader, reverseIndexPriorityReader, new IndexQuery(
|
||||
List.of(reverseIndexPriorityReader.priorityDocuments(wordId))));
|
||||
List.of(reverseIndexPriorityReader.priorityDocuments(wordId))), wordId);
|
||||
}
|
||||
|
||||
public IndexQueryBuilder findFullWord(int wordId, ReverseIndexEntrySourceBehavior behavior) {
|
||||
return new SearchIndexQueryBuilder(reverseIndexFullReader, reverseIndexPriorityReader, new IndexQuery(
|
||||
List.of(reverseIndexFullReader.documents(wordId, behavior))));
|
||||
List.of(reverseIndexFullReader.documents(wordId, behavior))), wordId);
|
||||
}
|
||||
|
||||
QueryFilterStepIf filterForParams(IndexQueryParams params) {
|
||||
|
Loading…
Reference in New Issue
Block a user