Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnvg committed Oct 18, 2024
1 parent 9173205 commit 383d02e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,12 @@ public interface LeafIteratorLookup {
private abstract static class SourceBlockLoader implements BlockLoader {
protected final ValueFetcher fetcher;
private final LeafIteratorLookup lookup;
private final StoredFieldsSpec storedFieldsSpec;
private final SourceFieldMapper.Mode sourceMode;

private SourceBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup, StoredFieldsSpec storedFieldsSpec) {
private SourceBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup, SourceFieldMapper.Mode sourceMode) {
this.fetcher = fetcher;
this.lookup = lookup;
this.storedFieldsSpec = storedFieldsSpec;
}

private SourceBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup, SourceFieldMapper.Mode sourceMode) {
this(
fetcher,
lookup,
sourceMode == SourceFieldMapper.Mode.SYNTHETIC ? NEEDS_SOURCE_AND_IGNORED_SOURCE : StoredFieldsSpec.NEEDS_SOURCE
);
}

// Assumes synthetic source only
private SourceBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup, String additionalField) {
this(fetcher, lookup, NEEDS_SOURCE_AND_IGNORED_SOURCE.merge(new StoredFieldsSpec(true, false, Set.of(additionalField))));
this.sourceMode = sourceMode;
}

@Override
Expand All @@ -128,7 +115,7 @@ public final ColumnAtATimeReader columnAtATimeReader(LeafReaderContext context)

@Override
public final StoredFieldsSpec rowStrideStoredFieldSpec() {
return storedFieldsSpec;
return sourceMode == SourceFieldMapper.Mode.SYNTHETIC ? NEEDS_SOURCE_AND_IGNORED_SOURCE : StoredFieldsSpec.NEEDS_SOURCE;
}

@Override
Expand Down Expand Up @@ -208,10 +195,6 @@ public BytesRefsBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup, Sou
super(fetcher, lookup, sourceMode);
}

public BytesRefsBlockLoader(SourceValueFetcher fetcher, LeafIteratorLookup lookup, String originalFieldName) {
super(fetcher, lookup, originalFieldName);
}

@Override
public final Builder builder(BlockFactory factory, int expectedCount) {
return factory.bytesRefs(expectedCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1023,12 +1023,12 @@ protected String delegatingTo() {
*/
return null;
}
SourceValueFetcher fetcher = SourceValueFetcher.toString(blContext.sourcePaths(name()));
var sourceMode = blContext.indexSettings().getIndexMappingSourceMode();
if (sourceMode == SourceFieldMapper.Mode.SYNTHETIC && syntheticSourceDelegate().ignoreAbove() != Integer.MAX_VALUE) {
String originalName = syntheticSourceDelegate().name() + "._original";
return new BlockSourceReader.BytesRefsBlockLoader(fetcher, blockReaderDisiLookup(blContext), originalName);
return new BlockStoredFieldsReader.BytesFromBytesRefsBlockLoader(originalName);
} else {
SourceValueFetcher fetcher = SourceValueFetcher.toString(blContext.sourcePaths(name()));
return new BlockSourceReader.BytesRefsBlockLoader(fetcher, blockReaderDisiLookup(blContext), sourceMode);
}
}
Expand Down

0 comments on commit 383d02e

Please sign in to comment.