### Question:
SortImpl { public SortMetrics getMetrics() { return metrics; } SortImpl(OperExecContext opContext, SortConfig sortConfig,
                  SpilledRuns spilledRuns, VectorContainer batch); void setSchema(BatchSchema schema); boolean forceSpill(); void addBatch(VectorAccessible incoming); SortMetrics getMetrics(); SortResults startMerge(); void close();  }### Answer:
@Test public void testSpill() throws Exception { OperatorFixtureBuilder builder = OperatorFixture.builder(); builder.configBuilder() .put(ExecConstants.EXTERNAL_SORT_BATCH_LIMIT, 2); try (OperatorFixture fixture = builder.build()) { BatchSchema schema = SortTestUtilities.nonNullSchema(); SortTestFixture sortTest = new SortTestFixture(fixture) { @Override protected void validateSort(SortImpl sort) { assertEquals(1, sort.getMetrics().getSpillCount()); assertEquals(0, sort.getMetrics().getMergeCount()); assertEquals(2, sort.getMetrics().getPeakBatchCount()); } @Override protected void validateFinalStats(SortImpl sort) { assertTrue(sort.getMetrics().getWriteBytes() > 0); } }; sortTest.addInput(fixture.rowSetBuilder(schema) .add(2, "second") .build()); sortTest.addInput(fixture.rowSetBuilder(schema) .add(3, "third") .build()); sortTest.addInput(fixture.rowSetBuilder(schema) .add(1, "first") .build()); sortTest.addOutput(fixture.rowSetBuilder(schema) .add(1, "first") .add(2, "second") .add(3, "third") .build()); sortTest.run(); } }