Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
nik9000 committed Nov 28, 2023
1 parent 0b076b4 commit 064c269
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@
import static org.elasticsearch.test.MapMatcher.assertMap;
import static org.elasticsearch.test.MapMatcher.matchesMap;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.sameInstance;

/**
* Tests for {@link ValuesSourceReaderOperator}. Turns off {@link HandleLimitFS}
Expand Down Expand Up @@ -1222,4 +1224,41 @@ private TextFieldMapper.TextFieldType textFieldWithDelegate(String name, Keyword
false
);
}

public void testNullsShared() {
DriverContext driverContext = driverContext();
int[] pages = new int[] { 0 };
try (
Driver d = new Driver(
driverContext,
simpleInput(driverContext.blockFactory(), 10),
List.of(
new ValuesSourceReaderOperator.Factory(
List.of(
new ValuesSourceReaderOperator.FieldInfo("null1", List.of(BlockLoader.CONSTANT_NULLS)),
new ValuesSourceReaderOperator.FieldInfo("null2", List.of(BlockLoader.CONSTANT_NULLS))
),
List.of(new ValuesSourceReaderOperator.ShardContext(reader, () -> SourceLoader.FROM_STORED_SOURCE)),
0
).get(driverContext)
),
new PageConsumerOperator(page -> {
try {
assertThat(page.getBlockCount(), equalTo(3));
assertThat(page.getBlock(1).areAllValuesNull(), equalTo(true));
assertThat(page.getBlock(2).areAllValuesNull(), equalTo(true));
assertThat(page.getBlock(1), sameInstance(page.getBlock(2)));
pages[0]++;
} finally {
page.releaseBlocks();
}
}),
() -> {}
)
) {
runDriver(d);
}
assertThat(pages[0], greaterThan(0));
assertDriverContext(driverContext);
}
}

0 comments on commit 064c269

Please sign in to comment.