hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [09/17] hbase-site git commit: Published site at .
Date Mon, 20 Nov 2017 16:15:29 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/db363ec6/testdevapidocs/src-html/org/apache/hadoop/hbase/regionserver/TestHStore.MyCompactingMemStore.html
----------------------------------------------------------------------
diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/regionserver/TestHStore.MyCompactingMemStore.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/regionserver/TestHStore.MyCompactingMemStore.html
index dfba8d0..bf3143b 100644
--- a/testdevapidocs/src-html/org/apache/hadoop/hbase/regionserver/TestHStore.MyCompactingMemStore.html
+++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/regionserver/TestHStore.MyCompactingMemStore.html
@@ -1473,379 +1473,384 @@
 <span class="sourceLineNo">1465</span>    int flushSize = 500;<a name="line.1465"></a>
 <span class="sourceLineNo">1466</span>    Configuration conf = HBaseConfiguration.create();<a name="line.1466"></a>
 <span class="sourceLineNo">1467</span>    conf.set(HStore.MEMSTORE_CLASS_NAME, MyCompactingMemStoreWithCustomCompactor.class.getName());<a name="line.1467"></a>
-<span class="sourceLineNo">1468</span>    conf.set(HConstants.HREGION_MEMSTORE_FLUSH_SIZE, String.valueOf(flushSize));<a name="line.1468"></a>
-<span class="sourceLineNo">1469</span>    // Set the lower threshold to invoke the "MERGE" policy<a name="line.1469"></a>
-<span class="sourceLineNo">1470</span>    conf.set(MemStoreCompactionStrategy.COMPACTING_MEMSTORE_THRESHOLD_KEY, String.valueOf(0));<a name="line.1470"></a>
-<span class="sourceLineNo">1471</span>    init(name.getMethodName(), conf, ColumnFamilyDescriptorBuilder.newBuilder(family)<a name="line.1471"></a>
-<span class="sourceLineNo">1472</span>        .setInMemoryCompaction(MemoryCompactionPolicy.BASIC).build());<a name="line.1472"></a>
-<span class="sourceLineNo">1473</span>    byte[] value = Bytes.toBytes("thisisavarylargevalue");<a name="line.1473"></a>
-<span class="sourceLineNo">1474</span>    MemStoreSizing memStoreSizing = new MemStoreSizing();<a name="line.1474"></a>
-<span class="sourceLineNo">1475</span>    long ts = EnvironmentEdgeManager.currentTime();<a name="line.1475"></a>
-<span class="sourceLineNo">1476</span>    long seqId = 100;<a name="line.1476"></a>
-<span class="sourceLineNo">1477</span>    // older data whihc shouldn't be "seen" by client<a name="line.1477"></a>
-<span class="sourceLineNo">1478</span>    store.add(createCell(qf1, ts, seqId, value), memStoreSizing);<a name="line.1478"></a>
-<span class="sourceLineNo">1479</span>    store.add(createCell(qf2, ts, seqId, value), memStoreSizing);<a name="line.1479"></a>
-<span class="sourceLineNo">1480</span>    store.add(createCell(qf3, ts, seqId, value), memStoreSizing);<a name="line.1480"></a>
-<span class="sourceLineNo">1481</span>    assertEquals(1, MyCompactingMemStoreWithCustomCompactor.RUNNER_COUNT.get());<a name="line.1481"></a>
-<span class="sourceLineNo">1482</span>    StoreFlushContext storeFlushCtx = store.createFlushContext(id++, FlushLifeCycleTracker.DUMMY);<a name="line.1482"></a>
-<span class="sourceLineNo">1483</span>    storeFlushCtx.prepare();<a name="line.1483"></a>
-<span class="sourceLineNo">1484</span>    // This shouldn't invoke another in-memory flush because the first compactor thread<a name="line.1484"></a>
-<span class="sourceLineNo">1485</span>    // hasn't accomplished the in-memory compaction.<a name="line.1485"></a>
-<span class="sourceLineNo">1486</span>    store.add(createCell(qf1, ts + 1, seqId + 1, value), memStoreSizing);<a name="line.1486"></a>
-<span class="sourceLineNo">1487</span>    store.add(createCell(qf1, ts + 1, seqId + 1, value), memStoreSizing);<a name="line.1487"></a>
+<span class="sourceLineNo">1468</span>    conf.setDouble(CompactingMemStore.IN_MEMORY_FLUSH_THRESHOLD_FACTOR_KEY, 0.25);<a name="line.1468"></a>
+<span class="sourceLineNo">1469</span>    MyCompactingMemStoreWithCustomCompactor.RUNNER_COUNT.set(0);<a name="line.1469"></a>
+<span class="sourceLineNo">1470</span>    conf.set(HConstants.HREGION_MEMSTORE_FLUSH_SIZE, String.valueOf(flushSize));<a name="line.1470"></a>
+<span class="sourceLineNo">1471</span>    // Set the lower threshold to invoke the "MERGE" policy<a name="line.1471"></a>
+<span class="sourceLineNo">1472</span>    conf.set(MemStoreCompactionStrategy.COMPACTING_MEMSTORE_THRESHOLD_KEY, String.valueOf(0));<a name="line.1472"></a>
+<span class="sourceLineNo">1473</span>    init(name.getMethodName(), conf, ColumnFamilyDescriptorBuilder.newBuilder(family)<a name="line.1473"></a>
+<span class="sourceLineNo">1474</span>        .setInMemoryCompaction(MemoryCompactionPolicy.BASIC).build());<a name="line.1474"></a>
+<span class="sourceLineNo">1475</span>    byte[] value = Bytes.toBytes("thisisavarylargevalue");<a name="line.1475"></a>
+<span class="sourceLineNo">1476</span>    MemStoreSizing memStoreSizing = new MemStoreSizing();<a name="line.1476"></a>
+<span class="sourceLineNo">1477</span>    long ts = EnvironmentEdgeManager.currentTime();<a name="line.1477"></a>
+<span class="sourceLineNo">1478</span>    long seqId = 100;<a name="line.1478"></a>
+<span class="sourceLineNo">1479</span>    // older data whihc shouldn't be "seen" by client<a name="line.1479"></a>
+<span class="sourceLineNo">1480</span>    store.add(createCell(qf1, ts, seqId, value), memStoreSizing);<a name="line.1480"></a>
+<span class="sourceLineNo">1481</span>    store.add(createCell(qf2, ts, seqId, value), memStoreSizing);<a name="line.1481"></a>
+<span class="sourceLineNo">1482</span>    store.add(createCell(qf3, ts, seqId, value), memStoreSizing);<a name="line.1482"></a>
+<span class="sourceLineNo">1483</span>    assertEquals(1, MyCompactingMemStoreWithCustomCompactor.RUNNER_COUNT.get());<a name="line.1483"></a>
+<span class="sourceLineNo">1484</span>    StoreFlushContext storeFlushCtx = store.createFlushContext(id++, FlushLifeCycleTracker.DUMMY);<a name="line.1484"></a>
+<span class="sourceLineNo">1485</span>    storeFlushCtx.prepare();<a name="line.1485"></a>
+<span class="sourceLineNo">1486</span>    // This shouldn't invoke another in-memory flush because the first compactor thread<a name="line.1486"></a>
+<span class="sourceLineNo">1487</span>    // hasn't accomplished the in-memory compaction.<a name="line.1487"></a>
 <span class="sourceLineNo">1488</span>    store.add(createCell(qf1, ts + 1, seqId + 1, value), memStoreSizing);<a name="line.1488"></a>
-<span class="sourceLineNo">1489</span>    assertEquals(1, MyCompactingMemStoreWithCustomCompactor.RUNNER_COUNT.get());<a name="line.1489"></a>
-<span class="sourceLineNo">1490</span>    //okay. Let the compaction be completed<a name="line.1490"></a>
-<span class="sourceLineNo">1491</span>    MyMemStoreCompactor.START_COMPACTOR_LATCH.countDown();<a name="line.1491"></a>
-<span class="sourceLineNo">1492</span>    CompactingMemStore mem = (CompactingMemStore) ((HStore)store).memstore;<a name="line.1492"></a>
-<span class="sourceLineNo">1493</span>    while (mem.isMemStoreFlushingInMemory()) {<a name="line.1493"></a>
-<span class="sourceLineNo">1494</span>      TimeUnit.SECONDS.sleep(1);<a name="line.1494"></a>
-<span class="sourceLineNo">1495</span>    }<a name="line.1495"></a>
-<span class="sourceLineNo">1496</span>    // This should invoke another in-memory flush.<a name="line.1496"></a>
-<span class="sourceLineNo">1497</span>    store.add(createCell(qf1, ts + 2, seqId + 2, value), memStoreSizing);<a name="line.1497"></a>
-<span class="sourceLineNo">1498</span>    store.add(createCell(qf1, ts + 2, seqId + 2, value), memStoreSizing);<a name="line.1498"></a>
+<span class="sourceLineNo">1489</span>    store.add(createCell(qf1, ts + 1, seqId + 1, value), memStoreSizing);<a name="line.1489"></a>
+<span class="sourceLineNo">1490</span>    store.add(createCell(qf1, ts + 1, seqId + 1, value), memStoreSizing);<a name="line.1490"></a>
+<span class="sourceLineNo">1491</span>    assertEquals(1, MyCompactingMemStoreWithCustomCompactor.RUNNER_COUNT.get());<a name="line.1491"></a>
+<span class="sourceLineNo">1492</span>    //okay. Let the compaction be completed<a name="line.1492"></a>
+<span class="sourceLineNo">1493</span>    MyMemStoreCompactor.START_COMPACTOR_LATCH.countDown();<a name="line.1493"></a>
+<span class="sourceLineNo">1494</span>    CompactingMemStore mem = (CompactingMemStore) ((HStore)store).memstore;<a name="line.1494"></a>
+<span class="sourceLineNo">1495</span>    while (mem.isMemStoreFlushingInMemory()) {<a name="line.1495"></a>
+<span class="sourceLineNo">1496</span>      TimeUnit.SECONDS.sleep(1);<a name="line.1496"></a>
+<span class="sourceLineNo">1497</span>    }<a name="line.1497"></a>
+<span class="sourceLineNo">1498</span>    // This should invoke another in-memory flush.<a name="line.1498"></a>
 <span class="sourceLineNo">1499</span>    store.add(createCell(qf1, ts + 2, seqId + 2, value), memStoreSizing);<a name="line.1499"></a>
-<span class="sourceLineNo">1500</span>    assertEquals(2, MyCompactingMemStoreWithCustomCompactor.RUNNER_COUNT.get());<a name="line.1500"></a>
-<span class="sourceLineNo">1501</span>    conf.set(HConstants.HREGION_MEMSTORE_FLUSH_SIZE,<a name="line.1501"></a>
-<span class="sourceLineNo">1502</span>      String.valueOf(TableDescriptorBuilder.DEFAULT_MEMSTORE_FLUSH_SIZE));<a name="line.1502"></a>
-<span class="sourceLineNo">1503</span>    storeFlushCtx.flushCache(Mockito.mock(MonitoredTask.class));<a name="line.1503"></a>
-<span class="sourceLineNo">1504</span>    storeFlushCtx.commit(Mockito.mock(MonitoredTask.class));<a name="line.1504"></a>
-<span class="sourceLineNo">1505</span>  }<a name="line.1505"></a>
-<span class="sourceLineNo">1506</span><a name="line.1506"></a>
-<span class="sourceLineNo">1507</span>  @Test<a name="line.1507"></a>
-<span class="sourceLineNo">1508</span>  public void testAge() throws IOException {<a name="line.1508"></a>
-<span class="sourceLineNo">1509</span>    long currentTime = System.currentTimeMillis();<a name="line.1509"></a>
-<span class="sourceLineNo">1510</span>    ManualEnvironmentEdge edge = new ManualEnvironmentEdge();<a name="line.1510"></a>
-<span class="sourceLineNo">1511</span>    edge.setValue(currentTime);<a name="line.1511"></a>
-<span class="sourceLineNo">1512</span>    EnvironmentEdgeManager.injectEdge(edge);<a name="line.1512"></a>
-<span class="sourceLineNo">1513</span>    Configuration conf = TEST_UTIL.getConfiguration();<a name="line.1513"></a>
-<span class="sourceLineNo">1514</span>    ColumnFamilyDescriptor hcd = ColumnFamilyDescriptorBuilder.of(family);<a name="line.1514"></a>
-<span class="sourceLineNo">1515</span>    initHRegion(name.getMethodName(), conf,<a name="line.1515"></a>
-<span class="sourceLineNo">1516</span>      TableDescriptorBuilder.newBuilder(TableName.valueOf(table)), hcd, null, false);<a name="line.1516"></a>
-<span class="sourceLineNo">1517</span>    HStore store = new HStore(region, hcd, conf) {<a name="line.1517"></a>
-<span class="sourceLineNo">1518</span><a name="line.1518"></a>
-<span class="sourceLineNo">1519</span>      @Override<a name="line.1519"></a>
-<span class="sourceLineNo">1520</span>      protected StoreEngine&lt;?, ?, ?, ?&gt; createStoreEngine(HStore store, Configuration conf,<a name="line.1520"></a>
-<span class="sourceLineNo">1521</span>          CellComparator kvComparator) throws IOException {<a name="line.1521"></a>
-<span class="sourceLineNo">1522</span>        List&lt;HStoreFile&gt; storefiles =<a name="line.1522"></a>
-<span class="sourceLineNo">1523</span>            Arrays.asList(mockStoreFile(currentTime - 10), mockStoreFile(currentTime - 100),<a name="line.1523"></a>
-<span class="sourceLineNo">1524</span>              mockStoreFile(currentTime - 1000), mockStoreFile(currentTime - 10000));<a name="line.1524"></a>
-<span class="sourceLineNo">1525</span>        StoreFileManager sfm = mock(StoreFileManager.class);<a name="line.1525"></a>
-<span class="sourceLineNo">1526</span>        when(sfm.getStorefiles()).thenReturn(storefiles);<a name="line.1526"></a>
-<span class="sourceLineNo">1527</span>        StoreEngine&lt;?, ?, ?, ?&gt; storeEngine = mock(StoreEngine.class);<a name="line.1527"></a>
-<span class="sourceLineNo">1528</span>        when(storeEngine.getStoreFileManager()).thenReturn(sfm);<a name="line.1528"></a>
-<span class="sourceLineNo">1529</span>        return storeEngine;<a name="line.1529"></a>
-<span class="sourceLineNo">1530</span>      }<a name="line.1530"></a>
-<span class="sourceLineNo">1531</span>    };<a name="line.1531"></a>
-<span class="sourceLineNo">1532</span>    assertEquals(10L, store.getMinStoreFileAge().getAsLong());<a name="line.1532"></a>
-<span class="sourceLineNo">1533</span>    assertEquals(10000L, store.getMaxStoreFileAge().getAsLong());<a name="line.1533"></a>
-<span class="sourceLineNo">1534</span>    assertEquals((10 + 100 + 1000 + 10000) / 4.0, store.getAvgStoreFileAge().getAsDouble(), 1E-4);<a name="line.1534"></a>
-<span class="sourceLineNo">1535</span>  }<a name="line.1535"></a>
-<span class="sourceLineNo">1536</span><a name="line.1536"></a>
-<span class="sourceLineNo">1537</span>  private HStoreFile mockStoreFile(long createdTime) {<a name="line.1537"></a>
-<span class="sourceLineNo">1538</span>    StoreFileInfo info = mock(StoreFileInfo.class);<a name="line.1538"></a>
-<span class="sourceLineNo">1539</span>    when(info.getCreatedTimestamp()).thenReturn(createdTime);<a name="line.1539"></a>
-<span class="sourceLineNo">1540</span>    HStoreFile sf = mock(HStoreFile.class);<a name="line.1540"></a>
-<span class="sourceLineNo">1541</span>    when(sf.getReader()).thenReturn(mock(StoreFileReader.class));<a name="line.1541"></a>
-<span class="sourceLineNo">1542</span>    when(sf.isHFile()).thenReturn(true);<a name="line.1542"></a>
-<span class="sourceLineNo">1543</span>    when(sf.getFileInfo()).thenReturn(info);<a name="line.1543"></a>
-<span class="sourceLineNo">1544</span>    return sf;<a name="line.1544"></a>
-<span class="sourceLineNo">1545</span>  }<a name="line.1545"></a>
-<span class="sourceLineNo">1546</span><a name="line.1546"></a>
-<span class="sourceLineNo">1547</span>  private MyStore initMyStore(String methodName, Configuration conf, MyStoreHook hook)<a name="line.1547"></a>
-<span class="sourceLineNo">1548</span>      throws IOException {<a name="line.1548"></a>
-<span class="sourceLineNo">1549</span>    return (MyStore) init(methodName, conf,<a name="line.1549"></a>
-<span class="sourceLineNo">1550</span>      TableDescriptorBuilder.newBuilder(TableName.valueOf(table)),<a name="line.1550"></a>
-<span class="sourceLineNo">1551</span>      ColumnFamilyDescriptorBuilder.newBuilder(family).setMaxVersions(5).build(), hook);<a name="line.1551"></a>
-<span class="sourceLineNo">1552</span>  }<a name="line.1552"></a>
-<span class="sourceLineNo">1553</span><a name="line.1553"></a>
-<span class="sourceLineNo">1554</span>  private class MyStore extends HStore {<a name="line.1554"></a>
-<span class="sourceLineNo">1555</span>    private final MyStoreHook hook;<a name="line.1555"></a>
-<span class="sourceLineNo">1556</span><a name="line.1556"></a>
-<span class="sourceLineNo">1557</span>    MyStore(final HRegion region, final ColumnFamilyDescriptor family, final Configuration<a name="line.1557"></a>
-<span class="sourceLineNo">1558</span>        confParam, MyStoreHook hook, boolean switchToPread) throws IOException {<a name="line.1558"></a>
-<span class="sourceLineNo">1559</span>      super(region, family, confParam);<a name="line.1559"></a>
-<span class="sourceLineNo">1560</span>      this.hook = hook;<a name="line.1560"></a>
-<span class="sourceLineNo">1561</span>    }<a name="line.1561"></a>
-<span class="sourceLineNo">1562</span><a name="line.1562"></a>
-<span class="sourceLineNo">1563</span>    @Override<a name="line.1563"></a>
-<span class="sourceLineNo">1564</span>    public List&lt;KeyValueScanner&gt; getScanners(List&lt;HStoreFile&gt; files, boolean cacheBlocks,<a name="line.1564"></a>
-<span class="sourceLineNo">1565</span>        boolean usePread, boolean isCompaction, ScanQueryMatcher matcher, byte[] startRow,<a name="line.1565"></a>
-<span class="sourceLineNo">1566</span>        boolean includeStartRow, byte[] stopRow, boolean includeStopRow, long readPt,<a name="line.1566"></a>
-<span class="sourceLineNo">1567</span>        boolean includeMemstoreScanner) throws IOException {<a name="line.1567"></a>
-<span class="sourceLineNo">1568</span>      hook.getScanners(this);<a name="line.1568"></a>
-<span class="sourceLineNo">1569</span>      return super.getScanners(files, cacheBlocks, usePread, isCompaction, matcher, startRow, true,<a name="line.1569"></a>
-<span class="sourceLineNo">1570</span>        stopRow, false, readPt, includeMemstoreScanner);<a name="line.1570"></a>
-<span class="sourceLineNo">1571</span>    }<a name="line.1571"></a>
-<span class="sourceLineNo">1572</span><a name="line.1572"></a>
-<span class="sourceLineNo">1573</span>    @Override<a name="line.1573"></a>
-<span class="sourceLineNo">1574</span>    public long getSmallestReadPoint() {<a name="line.1574"></a>
-<span class="sourceLineNo">1575</span>      return hook.getSmallestReadPoint(this);<a name="line.1575"></a>
-<span class="sourceLineNo">1576</span>    }<a name="line.1576"></a>
-<span class="sourceLineNo">1577</span>  }<a name="line.1577"></a>
-<span class="sourceLineNo">1578</span><a name="line.1578"></a>
-<span class="sourceLineNo">1579</span>  private abstract class MyStoreHook {<a name="line.1579"></a>
+<span class="sourceLineNo">1500</span>    store.add(createCell(qf1, ts + 2, seqId + 2, value), memStoreSizing);<a name="line.1500"></a>
+<span class="sourceLineNo">1501</span>    store.add(createCell(qf1, ts + 2, seqId + 2, value), memStoreSizing);<a name="line.1501"></a>
+<span class="sourceLineNo">1502</span>    assertEquals(2, MyCompactingMemStoreWithCustomCompactor.RUNNER_COUNT.get());<a name="line.1502"></a>
+<span class="sourceLineNo">1503</span>    conf.set(HConstants.HREGION_MEMSTORE_FLUSH_SIZE,<a name="line.1503"></a>
+<span class="sourceLineNo">1504</span>      String.valueOf(TableDescriptorBuilder.DEFAULT_MEMSTORE_FLUSH_SIZE));<a name="line.1504"></a>
+<span class="sourceLineNo">1505</span>    storeFlushCtx.flushCache(Mockito.mock(MonitoredTask.class));<a name="line.1505"></a>
+<span class="sourceLineNo">1506</span>    storeFlushCtx.commit(Mockito.mock(MonitoredTask.class));<a name="line.1506"></a>
+<span class="sourceLineNo">1507</span>  }<a name="line.1507"></a>
+<span class="sourceLineNo">1508</span><a name="line.1508"></a>
+<span class="sourceLineNo">1509</span>  @Test<a name="line.1509"></a>
+<span class="sourceLineNo">1510</span>  public void testAge() throws IOException {<a name="line.1510"></a>
+<span class="sourceLineNo">1511</span>    long currentTime = System.currentTimeMillis();<a name="line.1511"></a>
+<span class="sourceLineNo">1512</span>    ManualEnvironmentEdge edge = new ManualEnvironmentEdge();<a name="line.1512"></a>
+<span class="sourceLineNo">1513</span>    edge.setValue(currentTime);<a name="line.1513"></a>
+<span class="sourceLineNo">1514</span>    EnvironmentEdgeManager.injectEdge(edge);<a name="line.1514"></a>
+<span class="sourceLineNo">1515</span>    Configuration conf = TEST_UTIL.getConfiguration();<a name="line.1515"></a>
+<span class="sourceLineNo">1516</span>    ColumnFamilyDescriptor hcd = ColumnFamilyDescriptorBuilder.of(family);<a name="line.1516"></a>
+<span class="sourceLineNo">1517</span>    initHRegion(name.getMethodName(), conf,<a name="line.1517"></a>
+<span class="sourceLineNo">1518</span>      TableDescriptorBuilder.newBuilder(TableName.valueOf(table)), hcd, null, false);<a name="line.1518"></a>
+<span class="sourceLineNo">1519</span>    HStore store = new HStore(region, hcd, conf) {<a name="line.1519"></a>
+<span class="sourceLineNo">1520</span><a name="line.1520"></a>
+<span class="sourceLineNo">1521</span>      @Override<a name="line.1521"></a>
+<span class="sourceLineNo">1522</span>      protected StoreEngine&lt;?, ?, ?, ?&gt; createStoreEngine(HStore store, Configuration conf,<a name="line.1522"></a>
+<span class="sourceLineNo">1523</span>          CellComparator kvComparator) throws IOException {<a name="line.1523"></a>
+<span class="sourceLineNo">1524</span>        List&lt;HStoreFile&gt; storefiles =<a name="line.1524"></a>
+<span class="sourceLineNo">1525</span>            Arrays.asList(mockStoreFile(currentTime - 10), mockStoreFile(currentTime - 100),<a name="line.1525"></a>
+<span class="sourceLineNo">1526</span>              mockStoreFile(currentTime - 1000), mockStoreFile(currentTime - 10000));<a name="line.1526"></a>
+<span class="sourceLineNo">1527</span>        StoreFileManager sfm = mock(StoreFileManager.class);<a name="line.1527"></a>
+<span class="sourceLineNo">1528</span>        when(sfm.getStorefiles()).thenReturn(storefiles);<a name="line.1528"></a>
+<span class="sourceLineNo">1529</span>        StoreEngine&lt;?, ?, ?, ?&gt; storeEngine = mock(StoreEngine.class);<a name="line.1529"></a>
+<span class="sourceLineNo">1530</span>        when(storeEngine.getStoreFileManager()).thenReturn(sfm);<a name="line.1530"></a>
+<span class="sourceLineNo">1531</span>        return storeEngine;<a name="line.1531"></a>
+<span class="sourceLineNo">1532</span>      }<a name="line.1532"></a>
+<span class="sourceLineNo">1533</span>    };<a name="line.1533"></a>
+<span class="sourceLineNo">1534</span>    assertEquals(10L, store.getMinStoreFileAge().getAsLong());<a name="line.1534"></a>
+<span class="sourceLineNo">1535</span>    assertEquals(10000L, store.getMaxStoreFileAge().getAsLong());<a name="line.1535"></a>
+<span class="sourceLineNo">1536</span>    assertEquals((10 + 100 + 1000 + 10000) / 4.0, store.getAvgStoreFileAge().getAsDouble(), 1E-4);<a name="line.1536"></a>
+<span class="sourceLineNo">1537</span>  }<a name="line.1537"></a>
+<span class="sourceLineNo">1538</span><a name="line.1538"></a>
+<span class="sourceLineNo">1539</span>  private HStoreFile mockStoreFile(long createdTime) {<a name="line.1539"></a>
+<span class="sourceLineNo">1540</span>    StoreFileInfo info = mock(StoreFileInfo.class);<a name="line.1540"></a>
+<span class="sourceLineNo">1541</span>    when(info.getCreatedTimestamp()).thenReturn(createdTime);<a name="line.1541"></a>
+<span class="sourceLineNo">1542</span>    HStoreFile sf = mock(HStoreFile.class);<a name="line.1542"></a>
+<span class="sourceLineNo">1543</span>    when(sf.getReader()).thenReturn(mock(StoreFileReader.class));<a name="line.1543"></a>
+<span class="sourceLineNo">1544</span>    when(sf.isHFile()).thenReturn(true);<a name="line.1544"></a>
+<span class="sourceLineNo">1545</span>    when(sf.getFileInfo()).thenReturn(info);<a name="line.1545"></a>
+<span class="sourceLineNo">1546</span>    return sf;<a name="line.1546"></a>
+<span class="sourceLineNo">1547</span>  }<a name="line.1547"></a>
+<span class="sourceLineNo">1548</span><a name="line.1548"></a>
+<span class="sourceLineNo">1549</span>  private MyStore initMyStore(String methodName, Configuration conf, MyStoreHook hook)<a name="line.1549"></a>
+<span class="sourceLineNo">1550</span>      throws IOException {<a name="line.1550"></a>
+<span class="sourceLineNo">1551</span>    return (MyStore) init(methodName, conf,<a name="line.1551"></a>
+<span class="sourceLineNo">1552</span>      TableDescriptorBuilder.newBuilder(TableName.valueOf(table)),<a name="line.1552"></a>
+<span class="sourceLineNo">1553</span>      ColumnFamilyDescriptorBuilder.newBuilder(family).setMaxVersions(5).build(), hook);<a name="line.1553"></a>
+<span class="sourceLineNo">1554</span>  }<a name="line.1554"></a>
+<span class="sourceLineNo">1555</span><a name="line.1555"></a>
+<span class="sourceLineNo">1556</span>  private class MyStore extends HStore {<a name="line.1556"></a>
+<span class="sourceLineNo">1557</span>    private final MyStoreHook hook;<a name="line.1557"></a>
+<span class="sourceLineNo">1558</span><a name="line.1558"></a>
+<span class="sourceLineNo">1559</span>    MyStore(final HRegion region, final ColumnFamilyDescriptor family, final Configuration<a name="line.1559"></a>
+<span class="sourceLineNo">1560</span>        confParam, MyStoreHook hook, boolean switchToPread) throws IOException {<a name="line.1560"></a>
+<span class="sourceLineNo">1561</span>      super(region, family, confParam);<a name="line.1561"></a>
+<span class="sourceLineNo">1562</span>      this.hook = hook;<a name="line.1562"></a>
+<span class="sourceLineNo">1563</span>    }<a name="line.1563"></a>
+<span class="sourceLineNo">1564</span><a name="line.1564"></a>
+<span class="sourceLineNo">1565</span>    @Override<a name="line.1565"></a>
+<span class="sourceLineNo">1566</span>    public List&lt;KeyValueScanner&gt; getScanners(List&lt;HStoreFile&gt; files, boolean cacheBlocks,<a name="line.1566"></a>
+<span class="sourceLineNo">1567</span>        boolean usePread, boolean isCompaction, ScanQueryMatcher matcher, byte[] startRow,<a name="line.1567"></a>
+<span class="sourceLineNo">1568</span>        boolean includeStartRow, byte[] stopRow, boolean includeStopRow, long readPt,<a name="line.1568"></a>
+<span class="sourceLineNo">1569</span>        boolean includeMemstoreScanner) throws IOException {<a name="line.1569"></a>
+<span class="sourceLineNo">1570</span>      hook.getScanners(this);<a name="line.1570"></a>
+<span class="sourceLineNo">1571</span>      return super.getScanners(files, cacheBlocks, usePread, isCompaction, matcher, startRow, true,<a name="line.1571"></a>
+<span class="sourceLineNo">1572</span>        stopRow, false, readPt, includeMemstoreScanner);<a name="line.1572"></a>
+<span class="sourceLineNo">1573</span>    }<a name="line.1573"></a>
+<span class="sourceLineNo">1574</span><a name="line.1574"></a>
+<span class="sourceLineNo">1575</span>    @Override<a name="line.1575"></a>
+<span class="sourceLineNo">1576</span>    public long getSmallestReadPoint() {<a name="line.1576"></a>
+<span class="sourceLineNo">1577</span>      return hook.getSmallestReadPoint(this);<a name="line.1577"></a>
+<span class="sourceLineNo">1578</span>    }<a name="line.1578"></a>
+<span class="sourceLineNo">1579</span>  }<a name="line.1579"></a>
 <span class="sourceLineNo">1580</span><a name="line.1580"></a>
-<span class="sourceLineNo">1581</span>    void getScanners(MyStore store) throws IOException {<a name="line.1581"></a>
-<span class="sourceLineNo">1582</span>    }<a name="line.1582"></a>
-<span class="sourceLineNo">1583</span><a name="line.1583"></a>
-<span class="sourceLineNo">1584</span>    long getSmallestReadPoint(HStore store) {<a name="line.1584"></a>
-<span class="sourceLineNo">1585</span>      return store.getHRegion().getSmallestReadPoint();<a name="line.1585"></a>
-<span class="sourceLineNo">1586</span>    }<a name="line.1586"></a>
-<span class="sourceLineNo">1587</span>  }<a name="line.1587"></a>
-<span class="sourceLineNo">1588</span><a name="line.1588"></a>
-<span class="sourceLineNo">1589</span>  @Test<a name="line.1589"></a>
-<span class="sourceLineNo">1590</span>  public void testSwitchingPreadtoStreamParallelyWithCompactionDischarger() throws Exception {<a name="line.1590"></a>
-<span class="sourceLineNo">1591</span>    Configuration conf = HBaseConfiguration.create();<a name="line.1591"></a>
-<span class="sourceLineNo">1592</span>    conf.set("hbase.hstore.engine.class", DummyStoreEngine.class.getName());<a name="line.1592"></a>
-<span class="sourceLineNo">1593</span>    conf.setLong(StoreScanner.STORESCANNER_PREAD_MAX_BYTES, 0);<a name="line.1593"></a>
-<span class="sourceLineNo">1594</span>    // Set the lower threshold to invoke the "MERGE" policy<a name="line.1594"></a>
-<span class="sourceLineNo">1595</span>    MyStore store = initMyStore(name.getMethodName(), conf, new MyStoreHook() {});<a name="line.1595"></a>
-<span class="sourceLineNo">1596</span>    MemStoreSizing memStoreSizing = new MemStoreSizing();<a name="line.1596"></a>
-<span class="sourceLineNo">1597</span>    long ts = System.currentTimeMillis();<a name="line.1597"></a>
-<span class="sourceLineNo">1598</span>    long seqID = 1l;<a name="line.1598"></a>
-<span class="sourceLineNo">1599</span>    // Add some data to the region and do some flushes<a name="line.1599"></a>
-<span class="sourceLineNo">1600</span>    for (int i = 1; i &lt; 10; i++) {<a name="line.1600"></a>
-<span class="sourceLineNo">1601</span>      store.add(createCell(Bytes.toBytes("row" + i), qf1, ts, seqID++, Bytes.toBytes("")),<a name="line.1601"></a>
-<span class="sourceLineNo">1602</span>        memStoreSizing);<a name="line.1602"></a>
-<span class="sourceLineNo">1603</span>    }<a name="line.1603"></a>
-<span class="sourceLineNo">1604</span>    // flush them<a name="line.1604"></a>
-<span class="sourceLineNo">1605</span>    flushStore(store, seqID);<a name="line.1605"></a>
-<span class="sourceLineNo">1606</span>    for (int i = 11; i &lt; 20; i++) {<a name="line.1606"></a>
-<span class="sourceLineNo">1607</span>      store.add(createCell(Bytes.toBytes("row" + i), qf1, ts, seqID++, Bytes.toBytes("")),<a name="line.1607"></a>
-<span class="sourceLineNo">1608</span>        memStoreSizing);<a name="line.1608"></a>
-<span class="sourceLineNo">1609</span>    }<a name="line.1609"></a>
-<span class="sourceLineNo">1610</span>    // flush them<a name="line.1610"></a>
-<span class="sourceLineNo">1611</span>    flushStore(store, seqID);<a name="line.1611"></a>
-<span class="sourceLineNo">1612</span>    for (int i = 21; i &lt; 30; i++) {<a name="line.1612"></a>
-<span class="sourceLineNo">1613</span>      store.add(createCell(Bytes.toBytes("row" + i), qf1, ts, seqID++, Bytes.toBytes("")),<a name="line.1613"></a>
-<span class="sourceLineNo">1614</span>        memStoreSizing);<a name="line.1614"></a>
-<span class="sourceLineNo">1615</span>    }<a name="line.1615"></a>
-<span class="sourceLineNo">1616</span>    // flush them<a name="line.1616"></a>
-<span class="sourceLineNo">1617</span>    flushStore(store, seqID);<a name="line.1617"></a>
-<span class="sourceLineNo">1618</span><a name="line.1618"></a>
-<span class="sourceLineNo">1619</span>    assertEquals(3, store.getStorefilesCount());<a name="line.1619"></a>
-<span class="sourceLineNo">1620</span>    Scan scan = new Scan();<a name="line.1620"></a>
-<span class="sourceLineNo">1621</span>    scan.addFamily(family);<a name="line.1621"></a>
-<span class="sourceLineNo">1622</span>    Collection&lt;HStoreFile&gt; storefiles2 = store.getStorefiles();<a name="line.1622"></a>
-<span class="sourceLineNo">1623</span>    ArrayList&lt;HStoreFile&gt; actualStorefiles = Lists.newArrayList(storefiles2);<a name="line.1623"></a>
-<span class="sourceLineNo">1624</span>    StoreScanner storeScanner =<a name="line.1624"></a>
-<span class="sourceLineNo">1625</span>        (StoreScanner) store.getScanner(scan, scan.getFamilyMap().get(family), Long.MAX_VALUE);<a name="line.1625"></a>
-<span class="sourceLineNo">1626</span>    // get the current heap<a name="line.1626"></a>
-<span class="sourceLineNo">1627</span>    KeyValueHeap heap = storeScanner.heap;<a name="line.1627"></a>
-<span class="sourceLineNo">1628</span>    // create more store files<a name="line.1628"></a>
-<span class="sourceLineNo">1629</span>    for (int i = 31; i &lt; 40; i++) {<a name="line.1629"></a>
-<span class="sourceLineNo">1630</span>      store.add(createCell(Bytes.toBytes("row" + i), qf1, ts, seqID++, Bytes.toBytes("")),<a name="line.1630"></a>
-<span class="sourceLineNo">1631</span>        memStoreSizing);<a name="line.1631"></a>
-<span class="sourceLineNo">1632</span>    }<a name="line.1632"></a>
-<span class="sourceLineNo">1633</span>    // flush them<a name="line.1633"></a>
-<span class="sourceLineNo">1634</span>    flushStore(store, seqID);<a name="line.1634"></a>
-<span class="sourceLineNo">1635</span><a name="line.1635"></a>
-<span class="sourceLineNo">1636</span>    for (int i = 41; i &lt; 50; i++) {<a name="line.1636"></a>
-<span class="sourceLineNo">1637</span>      store.add(createCell(Bytes.toBytes("row" + i), qf1, ts, seqID++, Bytes.toBytes("")),<a name="line.1637"></a>
-<span class="sourceLineNo">1638</span>        memStoreSizing);<a name="line.1638"></a>
-<span class="sourceLineNo">1639</span>    }<a name="line.1639"></a>
-<span class="sourceLineNo">1640</span>    // flush them<a name="line.1640"></a>
-<span class="sourceLineNo">1641</span>    flushStore(store, seqID);<a name="line.1641"></a>
-<span class="sourceLineNo">1642</span>    storefiles2 = store.getStorefiles();<a name="line.1642"></a>
-<span class="sourceLineNo">1643</span>    ArrayList&lt;HStoreFile&gt; actualStorefiles1 = Lists.newArrayList(storefiles2);<a name="line.1643"></a>
-<span class="sourceLineNo">1644</span>    actualStorefiles1.removeAll(actualStorefiles);<a name="line.1644"></a>
-<span class="sourceLineNo">1645</span>    // Do compaction<a name="line.1645"></a>
-<span class="sourceLineNo">1646</span>    MyThread thread = new MyThread(storeScanner);<a name="line.1646"></a>
-<span class="sourceLineNo">1647</span>    thread.start();<a name="line.1647"></a>
-<span class="sourceLineNo">1648</span>    store.replaceStoreFiles(actualStorefiles, actualStorefiles1);<a name="line.1648"></a>
-<span class="sourceLineNo">1649</span>    thread.join();<a name="line.1649"></a>
-<span class="sourceLineNo">1650</span>    KeyValueHeap heap2 = thread.getHeap();<a name="line.1650"></a>
-<span class="sourceLineNo">1651</span>    assertFalse(heap.equals(heap2));<a name="line.1651"></a>
-<span class="sourceLineNo">1652</span>  }<a name="line.1652"></a>
-<span class="sourceLineNo">1653</span><a name="line.1653"></a>
-<span class="sourceLineNo">1654</span>  private static class MyThread extends Thread {<a name="line.1654"></a>
-<span class="sourceLineNo">1655</span>    private StoreScanner scanner;<a name="line.1655"></a>
-<span class="sourceLineNo">1656</span>    private KeyValueHeap heap;<a name="line.1656"></a>
-<span class="sourceLineNo">1657</span><a name="line.1657"></a>
-<span class="sourceLineNo">1658</span>    public MyThread(StoreScanner scanner) {<a name="line.1658"></a>
-<span class="sourceLineNo">1659</span>      this.scanner = scanner;<a name="line.1659"></a>
-<span class="sourceLineNo">1660</span>    }<a name="line.1660"></a>
-<span class="sourceLineNo">1661</span><a name="line.1661"></a>
-<span class="sourceLineNo">1662</span>    public KeyValueHeap getHeap() {<a name="line.1662"></a>
-<span class="sourceLineNo">1663</span>      return this.heap;<a name="line.1663"></a>
-<span class="sourceLineNo">1664</span>    }<a name="line.1664"></a>
-<span class="sourceLineNo">1665</span><a name="line.1665"></a>
-<span class="sourceLineNo">1666</span>    public void run() {<a name="line.1666"></a>
-<span class="sourceLineNo">1667</span>      scanner.trySwitchToStreamRead();<a name="line.1667"></a>
-<span class="sourceLineNo">1668</span>      heap = scanner.heap;<a name="line.1668"></a>
-<span class="sourceLineNo">1669</span>    }<a name="line.1669"></a>
-<span class="sourceLineNo">1670</span>  }<a name="line.1670"></a>
-<span class="sourceLineNo">1671</span><a name="line.1671"></a>
-<span class="sourceLineNo">1672</span>  private static class MyMemStoreCompactor extends MemStoreCompactor {<a name="line.1672"></a>
-<span class="sourceLineNo">1673</span>    private static final AtomicInteger RUNNER_COUNT = new AtomicInteger(0);<a name="line.1673"></a>
-<span class="sourceLineNo">1674</span>    private static final CountDownLatch START_COMPACTOR_LATCH = new CountDownLatch(1);<a name="line.1674"></a>
-<span class="sourceLineNo">1675</span>    public MyMemStoreCompactor(CompactingMemStore compactingMemStore, MemoryCompactionPolicy<a name="line.1675"></a>
-<span class="sourceLineNo">1676</span>        compactionPolicy) throws IllegalArgumentIOException {<a name="line.1676"></a>
-<span class="sourceLineNo">1677</span>      super(compactingMemStore, compactionPolicy);<a name="line.1677"></a>
-<span class="sourceLineNo">1678</span>    }<a name="line.1678"></a>
-<span class="sourceLineNo">1679</span><a name="line.1679"></a>
-<span class="sourceLineNo">1680</span>    @Override<a name="line.1680"></a>
-<span class="sourceLineNo">1681</span>    public boolean start() throws IOException {<a name="line.1681"></a>
-<span class="sourceLineNo">1682</span>      boolean isFirst = RUNNER_COUNT.getAndIncrement() == 0;<a name="line.1682"></a>
-<span class="sourceLineNo">1683</span>      boolean rval = super.start();<a name="line.1683"></a>
-<span class="sourceLineNo">1684</span>      if (isFirst) {<a name="line.1684"></a>
-<span class="sourceLineNo">1685</span>        try {<a name="line.1685"></a>
-<span class="sourceLineNo">1686</span>          START_COMPACTOR_LATCH.await();<a name="line.1686"></a>
-<span class="sourceLineNo">1687</span>        } catch (InterruptedException ex) {<a name="line.1687"></a>
-<span class="sourceLineNo">1688</span>          throw new RuntimeException(ex);<a name="line.1688"></a>
-<span class="sourceLineNo">1689</span>        }<a name="line.1689"></a>
-<span class="sourceLineNo">1690</span>      }<a name="line.1690"></a>
-<span class="sourceLineNo">1691</span>      return rval;<a name="line.1691"></a>
-<span class="sourceLineNo">1692</span>    }<a name="line.1692"></a>
-<span class="sourceLineNo">1693</span>  }<a name="line.1693"></a>
-<span class="sourceLineNo">1694</span><a name="line.1694"></a>
-<span class="sourceLineNo">1695</span>  public static class MyCompactingMemStoreWithCustomCompactor extends CompactingMemStore {<a name="line.1695"></a>
-<span class="sourceLineNo">1696</span>    private static final AtomicInteger RUNNER_COUNT = new AtomicInteger(0);<a name="line.1696"></a>
-<span class="sourceLineNo">1697</span>    public MyCompactingMemStoreWithCustomCompactor(Configuration conf, CellComparatorImpl c,<a name="line.1697"></a>
-<span class="sourceLineNo">1698</span>        HStore store, RegionServicesForStores regionServices,<a name="line.1698"></a>
-<span class="sourceLineNo">1699</span>        MemoryCompactionPolicy compactionPolicy) throws IOException {<a name="line.1699"></a>
-<span class="sourceLineNo">1700</span>      super(conf, c, store, regionServices, compactionPolicy);<a name="line.1700"></a>
-<span class="sourceLineNo">1701</span>    }<a name="line.1701"></a>
-<span class="sourceLineNo">1702</span><a name="line.1702"></a>
-<span class="sourceLineNo">1703</span>    @Override<a name="line.1703"></a>
-<span class="sourceLineNo">1704</span>    protected MemStoreCompactor createMemStoreCompactor(MemoryCompactionPolicy compactionPolicy)<a name="line.1704"></a>
-<span class="sourceLineNo">1705</span>        throws IllegalArgumentIOException {<a name="line.1705"></a>
-<span class="sourceLineNo">1706</span>      return new MyMemStoreCompactor(this, compactionPolicy);<a name="line.1706"></a>
-<span class="sourceLineNo">1707</span>    }<a name="line.1707"></a>
-<span class="sourceLineNo">1708</span><a name="line.1708"></a>
-<span class="sourceLineNo">1709</span>    @Override<a name="line.1709"></a>
-<span class="sourceLineNo">1710</span>    protected boolean shouldFlushInMemory() {<a name="line.1710"></a>
-<span class="sourceLineNo">1711</span>      boolean rval = super.shouldFlushInMemory();<a name="line.1711"></a>
-<span class="sourceLineNo">1712</span>      if (rval) {<a name="line.1712"></a>
-<span class="sourceLineNo">1713</span>        RUNNER_COUNT.incrementAndGet();<a name="line.1713"></a>
-<span class="sourceLineNo">1714</span>      }<a name="line.1714"></a>
-<span class="sourceLineNo">1715</span>      return rval;<a name="line.1715"></a>
-<span class="sourceLineNo">1716</span>    }<a name="line.1716"></a>
-<span class="sourceLineNo">1717</span>  }<a name="line.1717"></a>
-<span class="sourceLineNo">1718</span><a name="line.1718"></a>
-<span class="sourceLineNo">1719</span>  public static class MyCompactingMemStore extends CompactingMemStore {<a name="line.1719"></a>
-<span class="sourceLineNo">1720</span>    private static final AtomicBoolean START_TEST = new AtomicBoolean(false);<a name="line.1720"></a>
-<span class="sourceLineNo">1721</span>    private final CountDownLatch getScannerLatch = new CountDownLatch(1);<a name="line.1721"></a>
-<span class="sourceLineNo">1722</span>    private final CountDownLatch snapshotLatch = new CountDownLatch(1);<a name="line.1722"></a>
-<span class="sourceLineNo">1723</span>    public MyCompactingMemStore(Configuration conf, CellComparatorImpl c,<a name="line.1723"></a>
-<span class="sourceLineNo">1724</span>        HStore store, RegionServicesForStores regionServices,<a name="line.1724"></a>
-<span class="sourceLineNo">1725</span>        MemoryCompactionPolicy compactionPolicy) throws IOException {<a name="line.1725"></a>
-<span class="sourceLineNo">1726</span>      super(conf, c, store, regionServices, compactionPolicy);<a name="line.1726"></a>
-<span class="sourceLineNo">1727</span>    }<a name="line.1727"></a>
-<span class="sourceLineNo">1728</span><a name="line.1728"></a>
-<span class="sourceLineNo">1729</span>    @Override<a name="line.1729"></a>
-<span class="sourceLineNo">1730</span>    protected List&lt;KeyValueScanner&gt; createList(int capacity) {<a name="line.1730"></a>
-<span class="sourceLineNo">1731</span>      if (START_TEST.get()) {<a name="line.1731"></a>
-<span class="sourceLineNo">1732</span>        try {<a name="line.1732"></a>
-<span class="sourceLineNo">1733</span>          getScannerLatch.countDown();<a name="line.1733"></a>
-<span class="sourceLineNo">1734</span>          snapshotLatch.await();<a name="line.1734"></a>
-<span class="sourceLineNo">1735</span>        } catch (InterruptedException e) {<a name="line.1735"></a>
-<span class="sourceLineNo">1736</span>          throw new RuntimeException(e);<a name="line.1736"></a>
-<span class="sourceLineNo">1737</span>        }<a name="line.1737"></a>
-<span class="sourceLineNo">1738</span>      }<a name="line.1738"></a>
-<span class="sourceLineNo">1739</span>      return new ArrayList&lt;&gt;(capacity);<a name="line.1739"></a>
-<span class="sourceLineNo">1740</span>    }<a name="line.1740"></a>
-<span class="sourceLineNo">1741</span>    @Override<a name="line.1741"></a>
-<span class="sourceLineNo">1742</span>    protected void pushActiveToPipeline(MutableSegment active) {<a name="line.1742"></a>
-<span class="sourceLineNo">1743</span>      if (START_TEST.get()) {<a name="line.1743"></a>
-<span class="sourceLineNo">1744</span>        try {<a name="line.1744"></a>
-<span class="sourceLineNo">1745</span>          getScannerLatch.await();<a name="line.1745"></a>
-<span class="sourceLineNo">1746</span>        } catch (InterruptedException e) {<a name="line.1746"></a>
-<span class="sourceLineNo">1747</span>          throw new RuntimeException(e);<a name="line.1747"></a>
-<span class="sourceLineNo">1748</span>        }<a name="line.1748"></a>
-<span class="sourceLineNo">1749</span>      }<a name="line.1749"></a>
-<span class="sourceLineNo">1750</span><a name="line.1750"></a>
-<span class="sourceLineNo">1751</span>      super.pushActiveToPipeline(active);<a name="line.1751"></a>
-<span class="sourceLineNo">1752</span>      if (START_TEST.get()) {<a name="line.1752"></a>
-<span class="sourceLineNo">1753</span>        snapshotLatch.countDown();<a name="line.1753"></a>
+<span class="sourceLineNo">1581</span>  private abstract class MyStoreHook {<a name="line.1581"></a>
+<span class="sourceLineNo">1582</span><a name="line.1582"></a>
+<span class="sourceLineNo">1583</span>    void getScanners(MyStore store) throws IOException {<a name="line.1583"></a>
+<span class="sourceLineNo">1584</span>    }<a name="line.1584"></a>
+<span class="sourceLineNo">1585</span><a name="line.1585"></a>
+<span class="sourceLineNo">1586</span>    long getSmallestReadPoint(HStore store) {<a name="line.1586"></a>
+<span class="sourceLineNo">1587</span>      return store.getHRegion().getSmallestReadPoint();<a name="line.1587"></a>
+<span class="sourceLineNo">1588</span>    }<a name="line.1588"></a>
+<span class="sourceLineNo">1589</span>  }<a name="line.1589"></a>
+<span class="sourceLineNo">1590</span><a name="line.1590"></a>
+<span class="sourceLineNo">1591</span>  @Test<a name="line.1591"></a>
+<span class="sourceLineNo">1592</span>  public void testSwitchingPreadtoStreamParallelyWithCompactionDischarger() throws Exception {<a name="line.1592"></a>
+<span class="sourceLineNo">1593</span>    Configuration conf = HBaseConfiguration.create();<a name="line.1593"></a>
+<span class="sourceLineNo">1594</span>    conf.set("hbase.hstore.engine.class", DummyStoreEngine.class.getName());<a name="line.1594"></a>
+<span class="sourceLineNo">1595</span>    conf.setLong(StoreScanner.STORESCANNER_PREAD_MAX_BYTES, 0);<a name="line.1595"></a>
+<span class="sourceLineNo">1596</span>    // Set the lower threshold to invoke the "MERGE" policy<a name="line.1596"></a>
+<span class="sourceLineNo">1597</span>    MyStore store = initMyStore(name.getMethodName(), conf, new MyStoreHook() {});<a name="line.1597"></a>
+<span class="sourceLineNo">1598</span>    MemStoreSizing memStoreSizing = new MemStoreSizing();<a name="line.1598"></a>
+<span class="sourceLineNo">1599</span>    long ts = System.currentTimeMillis();<a name="line.1599"></a>
+<span class="sourceLineNo">1600</span>    long seqID = 1l;<a name="line.1600"></a>
+<span class="sourceLineNo">1601</span>    // Add some data to the region and do some flushes<a name="line.1601"></a>
+<span class="sourceLineNo">1602</span>    for (int i = 1; i &lt; 10; i++) {<a name="line.1602"></a>
+<span class="sourceLineNo">1603</span>      store.add(createCell(Bytes.toBytes("row" + i), qf1, ts, seqID++, Bytes.toBytes("")),<a name="line.1603"></a>
+<span class="sourceLineNo">1604</span>        memStoreSizing);<a name="line.1604"></a>
+<span class="sourceLineNo">1605</span>    }<a name="line.1605"></a>
+<span class="sourceLineNo">1606</span>    // flush them<a name="line.1606"></a>
+<span class="sourceLineNo">1607</span>    flushStore(store, seqID);<a name="line.1607"></a>
+<span class="sourceLineNo">1608</span>    for (int i = 11; i &lt; 20; i++) {<a name="line.1608"></a>
+<span class="sourceLineNo">1609</span>      store.add(createCell(Bytes.toBytes("row" + i), qf1, ts, seqID++, Bytes.toBytes("")),<a name="line.1609"></a>
+<span class="sourceLineNo">1610</span>        memStoreSizing);<a name="line.1610"></a>
+<span class="sourceLineNo">1611</span>    }<a name="line.1611"></a>
+<span class="sourceLineNo">1612</span>    // flush them<a name="line.1612"></a>
+<span class="sourceLineNo">1613</span>    flushStore(store, seqID);<a name="line.1613"></a>
+<span class="sourceLineNo">1614</span>    for (int i = 21; i &lt; 30; i++) {<a name="line.1614"></a>
+<span class="sourceLineNo">1615</span>      store.add(createCell(Bytes.toBytes("row" + i), qf1, ts, seqID++, Bytes.toBytes("")),<a name="line.1615"></a>
+<span class="sourceLineNo">1616</span>        memStoreSizing);<a name="line.1616"></a>
+<span class="sourceLineNo">1617</span>    }<a name="line.1617"></a>
+<span class="sourceLineNo">1618</span>    // flush them<a name="line.1618"></a>
+<span class="sourceLineNo">1619</span>    flushStore(store, seqID);<a name="line.1619"></a>
+<span class="sourceLineNo">1620</span><a name="line.1620"></a>
+<span class="sourceLineNo">1621</span>    assertEquals(3, store.getStorefilesCount());<a name="line.1621"></a>
+<span class="sourceLineNo">1622</span>    Scan scan = new Scan();<a name="line.1622"></a>
+<span class="sourceLineNo">1623</span>    scan.addFamily(family);<a name="line.1623"></a>
+<span class="sourceLineNo">1624</span>    Collection&lt;HStoreFile&gt; storefiles2 = store.getStorefiles();<a name="line.1624"></a>
+<span class="sourceLineNo">1625</span>    ArrayList&lt;HStoreFile&gt; actualStorefiles = Lists.newArrayList(storefiles2);<a name="line.1625"></a>
+<span class="sourceLineNo">1626</span>    StoreScanner storeScanner =<a name="line.1626"></a>
+<span class="sourceLineNo">1627</span>        (StoreScanner) store.getScanner(scan, scan.getFamilyMap().get(family), Long.MAX_VALUE);<a name="line.1627"></a>
+<span class="sourceLineNo">1628</span>    // get the current heap<a name="line.1628"></a>
+<span class="sourceLineNo">1629</span>    KeyValueHeap heap = storeScanner.heap;<a name="line.1629"></a>
+<span class="sourceLineNo">1630</span>    // create more store files<a name="line.1630"></a>
+<span class="sourceLineNo">1631</span>    for (int i = 31; i &lt; 40; i++) {<a name="line.1631"></a>
+<span class="sourceLineNo">1632</span>      store.add(createCell(Bytes.toBytes("row" + i), qf1, ts, seqID++, Bytes.toBytes("")),<a name="line.1632"></a>
+<span class="sourceLineNo">1633</span>        memStoreSizing);<a name="line.1633"></a>
+<span class="sourceLineNo">1634</span>    }<a name="line.1634"></a>
+<span class="sourceLineNo">1635</span>    // flush them<a name="line.1635"></a>
+<span class="sourceLineNo">1636</span>    flushStore(store, seqID);<a name="line.1636"></a>
+<span class="sourceLineNo">1637</span><a name="line.1637"></a>
+<span class="sourceLineNo">1638</span>    for (int i = 41; i &lt; 50; i++) {<a name="line.1638"></a>
+<span class="sourceLineNo">1639</span>      store.add(createCell(Bytes.toBytes("row" + i), qf1, ts, seqID++, Bytes.toBytes("")),<a name="line.1639"></a>
+<span class="sourceLineNo">1640</span>        memStoreSizing);<a name="line.1640"></a>
+<span class="sourceLineNo">1641</span>    }<a name="line.1641"></a>
+<span class="sourceLineNo">1642</span>    // flush them<a name="line.1642"></a>
+<span class="sourceLineNo">1643</span>    flushStore(store, seqID);<a name="line.1643"></a>
+<span class="sourceLineNo">1644</span>    storefiles2 = store.getStorefiles();<a name="line.1644"></a>
+<span class="sourceLineNo">1645</span>    ArrayList&lt;HStoreFile&gt; actualStorefiles1 = Lists.newArrayList(storefiles2);<a name="line.1645"></a>
+<span class="sourceLineNo">1646</span>    actualStorefiles1.removeAll(actualStorefiles);<a name="line.1646"></a>
+<span class="sourceLineNo">1647</span>    // Do compaction<a name="line.1647"></a>
+<span class="sourceLineNo">1648</span>    MyThread thread = new MyThread(storeScanner);<a name="line.1648"></a>
+<span class="sourceLineNo">1649</span>    thread.start();<a name="line.1649"></a>
+<span class="sourceLineNo">1650</span>    store.replaceStoreFiles(actualStorefiles, actualStorefiles1);<a name="line.1650"></a>
+<span class="sourceLineNo">1651</span>    thread.join();<a name="line.1651"></a>
+<span class="sourceLineNo">1652</span>    KeyValueHeap heap2 = thread.getHeap();<a name="line.1652"></a>
+<span class="sourceLineNo">1653</span>    assertFalse(heap.equals(heap2));<a name="line.1653"></a>
+<span class="sourceLineNo">1654</span>  }<a name="line.1654"></a>
+<span class="sourceLineNo">1655</span><a name="line.1655"></a>
+<span class="sourceLineNo">1656</span>  private static class MyThread extends Thread {<a name="line.1656"></a>
+<span class="sourceLineNo">1657</span>    private StoreScanner scanner;<a name="line.1657"></a>
+<span class="sourceLineNo">1658</span>    private KeyValueHeap heap;<a name="line.1658"></a>
+<span class="sourceLineNo">1659</span><a name="line.1659"></a>
+<span class="sourceLineNo">1660</span>    public MyThread(StoreScanner scanner) {<a name="line.1660"></a>
+<span class="sourceLineNo">1661</span>      this.scanner = scanner;<a name="line.1661"></a>
+<span class="sourceLineNo">1662</span>    }<a name="line.1662"></a>
+<span class="sourceLineNo">1663</span><a name="line.1663"></a>
+<span class="sourceLineNo">1664</span>    public KeyValueHeap getHeap() {<a name="line.1664"></a>
+<span class="sourceLineNo">1665</span>      return this.heap;<a name="line.1665"></a>
+<span class="sourceLineNo">1666</span>    }<a name="line.1666"></a>
+<span class="sourceLineNo">1667</span><a name="line.1667"></a>
+<span class="sourceLineNo">1668</span>    public void run() {<a name="line.1668"></a>
+<span class="sourceLineNo">1669</span>      scanner.trySwitchToStreamRead();<a name="line.1669"></a>
+<span class="sourceLineNo">1670</span>      heap = scanner.heap;<a name="line.1670"></a>
+<span class="sourceLineNo">1671</span>    }<a name="line.1671"></a>
+<span class="sourceLineNo">1672</span>  }<a name="line.1672"></a>
+<span class="sourceLineNo">1673</span><a name="line.1673"></a>
+<span class="sourceLineNo">1674</span>  private static class MyMemStoreCompactor extends MemStoreCompactor {<a name="line.1674"></a>
+<span class="sourceLineNo">1675</span>    private static final AtomicInteger RUNNER_COUNT = new AtomicInteger(0);<a name="line.1675"></a>
+<span class="sourceLineNo">1676</span>    private static final CountDownLatch START_COMPACTOR_LATCH = new CountDownLatch(1);<a name="line.1676"></a>
+<span class="sourceLineNo">1677</span>    public MyMemStoreCompactor(CompactingMemStore compactingMemStore, MemoryCompactionPolicy<a name="line.1677"></a>
+<span class="sourceLineNo">1678</span>        compactionPolicy) throws IllegalArgumentIOException {<a name="line.1678"></a>
+<span class="sourceLineNo">1679</span>      super(compactingMemStore, compactionPolicy);<a name="line.1679"></a>
+<span class="sourceLineNo">1680</span>    }<a name="line.1680"></a>
+<span class="sourceLineNo">1681</span><a name="line.1681"></a>
+<span class="sourceLineNo">1682</span>    @Override<a name="line.1682"></a>
+<span class="sourceLineNo">1683</span>    public boolean start() throws IOException {<a name="line.1683"></a>
+<span class="sourceLineNo">1684</span>      boolean isFirst = RUNNER_COUNT.getAndIncrement() == 0;<a name="line.1684"></a>
+<span class="sourceLineNo">1685</span>      boolean rval = super.start();<a name="line.1685"></a>
+<span class="sourceLineNo">1686</span>      if (isFirst) {<a name="line.1686"></a>
+<span class="sourceLineNo">1687</span>        try {<a name="line.1687"></a>
+<span class="sourceLineNo">1688</span>          START_COMPACTOR_LATCH.await();<a name="line.1688"></a>
+<span class="sourceLineNo">1689</span>        } catch (InterruptedException ex) {<a name="line.1689"></a>
+<span class="sourceLineNo">1690</span>          throw new RuntimeException(ex);<a name="line.1690"></a>
+<span class="sourceLineNo">1691</span>        }<a name="line.1691"></a>
+<span class="sourceLineNo">1692</span>      }<a name="line.1692"></a>
+<span class="sourceLineNo">1693</span>      return rval;<a name="line.1693"></a>
+<span class="sourceLineNo">1694</span>    }<a name="line.1694"></a>
+<span class="sourceLineNo">1695</span>  }<a name="line.1695"></a>
+<span class="sourceLineNo">1696</span><a name="line.1696"></a>
+<span class="sourceLineNo">1697</span>  public static class MyCompactingMemStoreWithCustomCompactor extends CompactingMemStore {<a name="line.1697"></a>
+<span class="sourceLineNo">1698</span>    private static final AtomicInteger RUNNER_COUNT = new AtomicInteger(0);<a name="line.1698"></a>
+<span class="sourceLineNo">1699</span>    public MyCompactingMemStoreWithCustomCompactor(Configuration conf, CellComparatorImpl c,<a name="line.1699"></a>
+<span class="sourceLineNo">1700</span>        HStore store, RegionServicesForStores regionServices,<a name="line.1700"></a>
+<span class="sourceLineNo">1701</span>        MemoryCompactionPolicy compactionPolicy) throws IOException {<a name="line.1701"></a>
+<span class="sourceLineNo">1702</span>      super(conf, c, store, regionServices, compactionPolicy);<a name="line.1702"></a>
+<span class="sourceLineNo">1703</span>    }<a name="line.1703"></a>
+<span class="sourceLineNo">1704</span><a name="line.1704"></a>
+<span class="sourceLineNo">1705</span>    @Override<a name="line.1705"></a>
+<span class="sourceLineNo">1706</span>    protected MemStoreCompactor createMemStoreCompactor(MemoryCompactionPolicy compactionPolicy)<a name="line.1706"></a>
+<span class="sourceLineNo">1707</span>        throws IllegalArgumentIOException {<a name="line.1707"></a>
+<span class="sourceLineNo">1708</span>      return new MyMemStoreCompactor(this, compactionPolicy);<a name="line.1708"></a>
+<span class="sourceLineNo">1709</span>    }<a name="line.1709"></a>
+<span class="sourceLineNo">1710</span><a name="line.1710"></a>
+<span class="sourceLineNo">1711</span>    @Override<a name="line.1711"></a>
+<span class="sourceLineNo">1712</span>    protected boolean shouldFlushInMemory() {<a name="line.1712"></a>
+<span class="sourceLineNo">1713</span>      boolean rval = super.shouldFlushInMemory();<a name="line.1713"></a>
+<span class="sourceLineNo">1714</span>      if (rval) {<a name="line.1714"></a>
+<span class="sourceLineNo">1715</span>        RUNNER_COUNT.incrementAndGet();<a name="line.1715"></a>
+<span class="sourceLineNo">1716</span>        if (LOG.isDebugEnabled()) {<a name="line.1716"></a>
+<span class="sourceLineNo">1717</span>          LOG.debug("runner count: " + RUNNER_COUNT.get());<a name="line.1717"></a>
+<span class="sourceLineNo">1718</span>        }<a name="line.1718"></a>
+<span class="sourceLineNo">1719</span>      }<a name="line.1719"></a>
+<span class="sourceLineNo">1720</span>      return rval;<a name="line.1720"></a>
+<span class="sourceLineNo">1721</span>    }<a name="line.1721"></a>
+<span class="sourceLineNo">1722</span>  }<a name="line.1722"></a>
+<span class="sourceLineNo">1723</span><a name="line.1723"></a>
+<span class="sourceLineNo">1724</span>  public static class MyCompactingMemStore extends CompactingMemStore {<a name="line.1724"></a>
+<span class="sourceLineNo">1725</span>    private static final AtomicBoolean START_TEST = new AtomicBoolean(false);<a name="line.1725"></a>
+<span class="sourceLineNo">1726</span>    private final CountDownLatch getScannerLatch = new CountDownLatch(1);<a name="line.1726"></a>
+<span class="sourceLineNo">1727</span>    private final CountDownLatch snapshotLatch = new CountDownLatch(1);<a name="line.1727"></a>
+<span class="sourceLineNo">1728</span>    public MyCompactingMemStore(Configuration conf, CellComparatorImpl c,<a name="line.1728"></a>
+<span class="sourceLineNo">1729</span>        HStore store, RegionServicesForStores regionServices,<a name="line.1729"></a>
+<span class="sourceLineNo">1730</span>        MemoryCompactionPolicy compactionPolicy) throws IOException {<a name="line.1730"></a>
+<span class="sourceLineNo">1731</span>      super(conf, c, store, regionServices, compactionPolicy);<a name="line.1731"></a>
+<span class="sourceLineNo">1732</span>    }<a name="line.1732"></a>
+<span class="sourceLineNo">1733</span><a name="line.1733"></a>
+<span class="sourceLineNo">1734</span>    @Override<a name="line.1734"></a>
+<span class="sourceLineNo">1735</span>    protected List&lt;KeyValueScanner&gt; createList(int capacity) {<a name="line.1735"></a>
+<span class="sourceLineNo">1736</span>      if (START_TEST.get()) {<a name="line.1736"></a>
+<span class="sourceLineNo">1737</span>        try {<a name="line.1737"></a>
+<span class="sourceLineNo">1738</span>          getScannerLatch.countDown();<a name="line.1738"></a>
+<span class="sourceLineNo">1739</span>          snapshotLatch.await();<a name="line.1739"></a>
+<span class="sourceLineNo">1740</span>        } catch (InterruptedException e) {<a name="line.1740"></a>
+<span class="sourceLineNo">1741</span>          throw new RuntimeException(e);<a name="line.1741"></a>
+<span class="sourceLineNo">1742</span>        }<a name="line.1742"></a>
+<span class="sourceLineNo">1743</span>      }<a name="line.1743"></a>
+<span class="sourceLineNo">1744</span>      return new ArrayList&lt;&gt;(capacity);<a name="line.1744"></a>
+<span class="sourceLineNo">1745</span>    }<a name="line.1745"></a>
+<span class="sourceLineNo">1746</span>    @Override<a name="line.1746"></a>
+<span class="sourceLineNo">1747</span>    protected void pushActiveToPipeline(MutableSegment active) {<a name="line.1747"></a>
+<span class="sourceLineNo">1748</span>      if (START_TEST.get()) {<a name="line.1748"></a>
+<span class="sourceLineNo">1749</span>        try {<a name="line.1749"></a>
+<span class="sourceLineNo">1750</span>          getScannerLatch.await();<a name="line.1750"></a>
+<span class="sourceLineNo">1751</span>        } catch (InterruptedException e) {<a name="line.1751"></a>
+<span class="sourceLineNo">1752</span>          throw new RuntimeException(e);<a name="line.1752"></a>
+<span class="sourceLineNo">1753</span>        }<a name="line.1753"></a>
 <span class="sourceLineNo">1754</span>      }<a name="line.1754"></a>
-<span class="sourceLineNo">1755</span>    }<a name="line.1755"></a>
-<span class="sourceLineNo">1756</span>  }<a name="line.1756"></a>
-<span class="sourceLineNo">1757</span><a name="line.1757"></a>
-<span class="sourceLineNo">1758</span>  interface MyListHook {<a name="line.1758"></a>
-<span class="sourceLineNo">1759</span>    void hook(int currentSize);<a name="line.1759"></a>
-<span class="sourceLineNo">1760</span>  }<a name="line.1760"></a>
-<span class="sourceLineNo">1761</span><a name="line.1761"></a>
-<span class="sourceLineNo">1762</span>  private static class MyList&lt;T&gt; implements List&lt;T&gt; {<a name="line.1762"></a>
-<span class="sourceLineNo">1763</span>    private final List&lt;T&gt; delegatee = new ArrayList&lt;&gt;();<a name="line.1763"></a>
-<span class="sourceLineNo">1764</span>    private final MyListHook hookAtAdd;<a name="line.1764"></a>
-<span class="sourceLineNo">1765</span>    MyList(final MyListHook hookAtAdd) {<a name="line.1765"></a>
-<span class="sourceLineNo">1766</span>      this.hookAtAdd = hookAtAdd;<a name="line.1766"></a>
-<span class="sourceLineNo">1767</span>    }<a name="line.1767"></a>
-<span class="sourceLineNo">1768</span>    @Override<a name="line.1768"></a>
-<span class="sourceLineNo">1769</span>    public int size() {return delegatee.size();}<a name="line.1769"></a>
-<span class="sourceLineNo">1770</span><a name="line.1770"></a>
-<span class="sourceLineNo">1771</span>    @Override<a name="line.1771"></a>
-<span class="sourceLineNo">1772</span>    public boolean isEmpty() {return delegatee.isEmpty();}<a name="line.1772"></a>
-<span class="sourceLineNo">1773</span><a name="line.1773"></a>
-<span class="sourceLineNo">1774</span>    @Override<a name="line.1774"></a>
-<span class="sourceLineNo">1775</span>    public boolean contains(Object o) {return delegatee.contains(o);}<a name="line.1775"></a>
-<span class="sourceLineNo">1776</span><a name="line.1776"></a>
-<span class="sourceLineNo">1777</span>    @Override<a name="line.1777"></a>
-<span class="sourceLineNo">1778</span>    public Iterator&lt;T&gt; iterator() {return delegatee.iterator();}<a name="line.1778"></a>
-<span class="sourceLineNo">1779</span><a name="line.1779"></a>
-<span class="sourceLineNo">1780</span>    @Override<a name="line.1780"></a>
-<span class="sourceLineNo">1781</span>    public Object[] toArray() {return delegatee.toArray();}<a name="line.1781"></a>
-<span class="sourceLineNo">1782</span><a name="line.1782"></a>
-<span class="sourceLineNo">1783</span>    @Override<a name="line.1783"></a>
-<span class="sourceLineNo">1784</span>    public &lt;R&gt; R[] toArray(R[] a) {return delegatee.toArray(a);}<a name="line.1784"></a>
-<span class="sourceLineNo">1785</span><a name="line.1785"></a>
-<span class="sourceLineNo">1786</span>    @Override<a name="line.1786"></a>
-<span class="sourceLineNo">1787</span>    public boolean add(T e) {<a name="line.1787"></a>
-<span class="sourceLineNo">1788</span>      hookAtAdd.hook(size());<a name="line.1788"></a>
-<span class="sourceLineNo">1789</span>      return delegatee.add(e);<a name="line.1789"></a>
-<span class="sourceLineNo">1790</span>    }<a name="line.1790"></a>
-<span class="sourceLineNo">1791</span><a name="line.1791"></a>
-<span class="sourceLineNo">1792</span>    @Override<a name="line.1792"></a>
-<span class="sourceLineNo">1793</span>    public boolean remove(Object o) {return delegatee.remove(o);}<a name="line.1793"></a>
-<span class="sourceLineNo">1794</span><a name="line.1794"></a>
-<span class="sourceLineNo">1795</span>    @Override<a name="line.1795"></a>
-<span class="sourceLineNo">1796</span>    public boolean containsAll(Collection&lt;?&gt; c) {return delegatee.containsAll(c);}<a name="line.1796"></a>
-<span class="sourceLineNo">1797</span><a name="line.1797"></a>
-<span class="sourceLineNo">1798</span>    @Override<a name="line.1798"></a>
-<span class="sourceLineNo">1799</span>    public boolean addAll(Collection&lt;? extends T&gt; c) {return delegatee.addAll(c);}<a name="line.1799"></a>
-<span class="sourceLineNo">1800</span><a name="line.1800"></a>
-<span class="sourceLineNo">1801</span>    @Override<a name="line.1801"></a>
-<span class="sourceLineNo">1802</span>    public boolean addAll(int index, Collection&lt;? extends T&gt; c) {return delegatee.addAll(index, c);}<a name="line.1802"></a>
-<span class="sourceLineNo">1803</span><a name="line.1803"></a>
-<span class="sourceLineNo">1804</span>    @Override<a name="line.1804"></a>
-<span class="sourceLineNo">1805</span>    public boolean removeAll(Collection&lt;?&gt; c) {return delegatee.removeAll(c);}<a name="line.1805"></a>
-<span class="sourceLineNo">1806</span><a name="line.1806"></a>
-<span class="sourceLineNo">1807</span>    @Override<a name="line.1807"></a>
-<span class="sourceLineNo">1808</span>    public boolean retainAll(Collection&lt;?&gt; c) {return delegatee.retainAll(c);}<a name="line.1808"></a>
-<span class="sourceLineNo">1809</span><a name="line.1809"></a>
-<span class="sourceLineNo">1810</span>    @Override<a name="line.1810"></a>
-<span class="sourceLineNo">1811</span>    public void clear() {delegatee.clear();}<a name="line.1811"></a>
-<span class="sourceLineNo">1812</span><a name="line.1812"></a>
-<span class="sourceLineNo">1813</span>    @Override<a name="line.1813"></a>
-<span class="sourceLineNo">1814</span>    public T get(int index) {return delegatee.get(index);}<a name="line.1814"></a>
-<span class="sourceLineNo">1815</span><a name="line.1815"></a>
-<span class="sourceLineNo">1816</span>    @Override<a name="line.1816"></a>
-<span class="sourceLineNo">1817</span>    public T set(int index, T element) {return delegatee.set(index, element);}<a name="line.1817"></a>
-<span class="sourceLineNo">1818</span><a name="line.1818"></a>
-<span class="sourceLineNo">1819</span>    @Override<a name="line.1819"></a>
-<span class="sourceLineNo">1820</span>    public void add(int index, T element) {delegatee.add(index, element);}<a name="line.1820"></a>
-<span class="sourceLineNo">1821</span><a name="line.1821"></a>
-<span class="sourceLineNo">1822</span>    @Override<a name="line.1822"></a>
-<span class="sourceLineNo">1823</span>    public T remove(int index) {return delegatee.remove(index);}<a name="line.1823"></a>
-<span class="sourceLineNo">1824</span><a name="line.1824"></a>
-<span class="sourceLineNo">1825</span>    @Override<a name="line.1825"></a>
-<span class="sourceLineNo">1826</span>    public int indexOf(Object o) {return delegatee.indexOf(o);}<a name="line.1826"></a>
-<span class="sourceLineNo">1827</span><a name="line.1827"></a>
-<span class="sourceLineNo">1828</span>    @Override<a name="line.1828"></a>
-<span class="sourceLineNo">1829</span>    public int lastIndexOf(Object o) {return delegatee.lastIndexOf(o);}<a name="line.1829"></a>
-<span class="sourceLineNo">1830</span><a name="line.1830"></a>
-<span class="sourceLineNo">1831</span>    @Override<a name="line.1831"></a>
-<span class="sourceLineNo">1832</span>    public ListIterator&lt;T&gt; listIterator() {return delegatee.listIterator();}<a name="line.1832"></a>
-<span class="sourceLineNo">1833</span><a name="line.1833"></a>
-<span class="sourceLineNo">1834</span>    @Override<a name="line.1834"></a>
-<span class="sourceLineNo">1835</span>    public ListIterator&lt;T&gt; listIterator(int index) {return delegatee.listIterator(index);}<a name="line.1835"></a>
-<span class="sourceLineNo">1836</span><a name="line.1836"></a>
-<span class="sourceLineNo">1837</span>    @Override<a name="line.1837"></a>
-<span class="sourceLineNo">1838</span>    public List&lt;T&gt; subList(int fromIndex, int toIndex) {return delegatee.subList(fromIndex, toIndex);}<a name="line.1838"></a>
-<span class="sourceLineNo">1839</span>  }<a name="line.1839"></a>
-<span class="sourceLineNo">1840</span>}<a name="line.1840"></a>
+<span class="sourceLineNo">1755</span><a name="line.1755"></a>
+<span class="sourceLineNo">1756</span>      super.pushActiveToPipeline(active);<a name="line.1756"></a>
+<span class="sourceLineNo">1757</span>      if (START_TEST.get()) {<a name="line.1757"></a>
+<span class="sourceLineNo">1758</span>        snapshotLatch.countDown();<a name="line.1758"></a>
+<span class="sourceLineNo">1759</span>      }<a name="line.1759"></a>
+<span class="sourceLineNo">1760</span>    }<a name="line.1760"></a>
+<span class="sourceLineNo">1761</span>  }<a name="line.1761"></a>
+<span class="sourceLineNo">1762</span><a name="line.1762"></a>
+<span class="sourceLineNo">1763</span>  interface MyListHook {<a name="line.1763"></a>
+<span class="sourceLineNo">1764</span>    void hook(int currentSize);<a name="line.1764"></a>
+<span class="sourceLineNo">1765</span>  }<a name="line.1765"></a>
+<span class="sourceLineNo">1766</span><a name="line.1766"></a>
+<span class="sourceLineNo">1767</span>  private static class MyList&lt;T&gt; implements List&lt;T&gt; {<a name="line.1767"></a>
+<span class="sourceLineNo">1768</span>    private final List&lt;T&gt; delegatee = new ArrayList&lt;&gt;();<a name="line.1768"></a>
+<span class="sourceLineNo">1769</span>    private final MyListHook hookAtAdd;<a name="line.1769"></a>
+<span class="sourceLineNo">1770</span>    MyList(final MyListHook hookAtAdd) {<a name="line.1770"></a>
+<span class="sourceLineNo">1771</span>      this.hookAtAdd = hookAtAdd;<a name="line.1771"></a>
+<span class="sourceLineNo">1772</span>    }<a name="line.1772"></a>
+<span class="sourceLineNo">1773</span>    @Override<a name="line.1773"></a>
+<span class="sourceLineNo">1774</span>    public int size() {return delegatee.size();}<a name="line.1774"></a>
+<span class="sourceLineNo">1775</span><a name="line.1775"></a>
+<span class="sourceLineNo">1776</span>    @Override<a name="line.1776"></a>
+<span class="sourceLineNo">1777</span>    public boolean isEmpty() {return delegatee.isEmpty();}<a name="line.1777"></a>
+<span class="sourceLineNo">1778</span><a name="line.1778"></a>
+<span class="sourceLineNo">1779</span>    @Override<a name="line.1779"></a>
+<span class="sourceLineNo">1780</span>    public boolean contains(Object o) {return delegatee.contains(o);}<a name="line.1780"></a>
+<span class="sourceLineNo">1781</span><a name="line.1781"></a>
+<span class="sourceLineNo">1782</span>    @Override<a name="line.1782"></a>
+<span class="sourceLineNo">1783</span>    public Iterator&lt;T&gt; iterator() {return delegatee.iterator();}<a name="line.1783"></a>
+<span class="sourceLineNo">1784</span><a name="line.1784"></a>
+<span class="sourceLineNo">1785</span>    @Override<a name="line.1785"></a>
+<span class="sourceLineNo">1786</span>    public Object[] toArray() {return delegatee.toArray();}<a name="line.1786"></a>
+<span class="sourceLineNo">1787</span><a name="line.1787"></a>
+<span class="sourceLineNo">1788</span>    @Override<a name="line.1788"></a>
+<span class="sourceLineNo">1789</span>    public &lt;R&gt; R[] toArray(R[] a) {return delegatee.toArray(a);}<a name="line.1789"></a>
+<span class="sourceLineNo">1790</span><a name="line.1790"></a>
+<span class="sourceLineNo">1791</span>    @Override<a name="line.1791"></a>
+<span class="sourceLineNo">1792</span>    public boolean add(T e) {<a name="line.1792"></a>
+<span class="sourceLineNo">1793</span>      hookAtAdd.hook(size());<a name="line.1793"></a>
+<span class="sourceLineNo">1794</span>      return delegatee.add(e);<a name="line.1794"></a>
+<span class="sourceLineNo">1795</span>    }<a name="line.1795"></a>
+<span class="sourceLineNo">1796</span><a name="line.1796"></a>
+<span class="sourceLineNo">1797</span>    @Override<a name="line.1797"></a>
+<span class="sourceLineNo">1798</span>    public boolean remove(Object o) {return delegatee.remove(o);}<a name="line.1798"></a>
+<span class="sourceLineNo">1799</span><a name="line.1799"></a>
+<span class="sourceLineNo">1800</span>    @Override<a name="line.1800"></a>
+<span class="sourceLineNo">1801</span>    public boolean containsAll(Collection&lt;?&gt; c) {return delegatee.containsAll(c);}<a name="line.1801"></a>
+<span class="sourceLineNo">1802</span><a name="line.1802"></a>
+<span class="sourceLineNo">1803</span>    @Override<a name="line.1803"></a>
+<span class="sourceLineNo">1804</span>    public boolean addAll(Collection&lt;? extends T&gt; c) {return delegatee.addAll(c);}<a name="line.1804"></a>
+<span class="sourceLineNo">1805</span><a name="line.1805"></a>
+<span class="sourceLineNo">1806</span>    @Override<a name="line.1806"></a>
+<span class="sourceLineNo">1807</span>    public boolean addAll(int index, Collection&lt;? extends T&gt; c) {return delegatee.addAll(index, c);}<a name="line.1807"></a>
+<span class="sourceLineNo">1808</span><a name="line.1808"></a>
+<span class="sourceLineNo">1809</span>    @Override<a name="line.1809"></a>
+<span class="sourceLineNo">1810</span>    public boolean removeAll(Collection&lt;?&gt; c) {return delegatee.removeAll(c);}<a name="line.1810"></a>
+<span class="sourceLineNo">1811</span><a name="line.1811"></a>
+<span class="sourceLineNo">1812</span>    @Override<a name="line.1812"></a>
+<span class="sourceLineNo">1813</span>    public boolean retainAll(Collection&lt;?&gt; c) {return delegatee.retainAll(c);}<a name="line.1813"></a>
+<span class="sourceLineNo">1814</span><a name="line.1814"></a>
+<span class="sourceLineNo">1815</span>    @Override<a name="line.1815"></a>
+<span class="sourceLineNo">1816</span>    public void clear() {delegatee.clear();}<a name="line.1816"></a>
+<span class="sourceLineNo">1817</span><a name="line.1817"></a>
+<span class="sourceLineNo">1818</span>    @Override<a name="line.1818"></a>
+<span class="sourceLineNo">1819</span>    public T get(int index) {return delegatee.get(index);}<a name="line.1819"></a>
+<span class="sourceLineNo">1820</span><a name="line.1820"></a>
+<span class="sourceLineNo">1821</span>    @Override<a name="line.1821"></a>
+<span class="sourceLineNo">1822</span>    public T set(int index, T element) {return delegatee.set(index, element);}<a name="line.1822"></a>
+<span class="sourceLineNo">1823</span><a name="line.1823"></a>
+<span class="sourceLineNo">1824</span>    @Override<a name="line.1824"></a>
+<span class="sourceLineNo">1825</span>    public void add(int index, T element) {delegatee.add(index, element);}<a name="line.1825"></a>
+<span class="sourceLineNo">1826</span><a name="line.1826"></a>
+<span class="sourceLineNo">1827</span>    @Override<a name="line.1827"></a>
+<span class="sourceLineNo">1828</span>    public T remove(int index) {return delegatee.remove(index);}<a name="line.1828"></a>
+<span class="sourceLineNo">1829</span><a name="line.1829"></a>
+<span class="sourceLineNo">1830</span>    @Override<a name="line.1830"></a>
+<span class="sourceLineNo">1831</span>    public int indexOf(Object o) {return delegatee.indexOf(o);}<a name="line.1831"></a>
+<span class="sourceLineNo">1832</span><a name="line.1832"></a>
+<span class="sourceLineNo">1833</span>    @Override<a name="line.1833"></a>
+<span class="sourceLineNo">1834</span>    public int lastIndexOf(Object o) {return delegatee.lastIndexOf(o);}<a name="line.1834"></a>
+<span class="sourceLineNo">1835</span><a name="line.1835"></a>
+<span class="sourceLineNo">1836</span>    @Override<a name="line.1836"></a>
+<span class="sourceLineNo">1837</span>    public ListIterator&lt;T&gt; listIterator() {return delegatee.listIterator();}<a name="line.1837"></a>
+<span class="sourceLineNo">1838</span><a name="line.1838"></a>
+<span class="sourceLineNo">1839</span>    @Override<a name="line.1839"></a>
+<span class="sourceLineNo">1840</span>    public ListIterator&lt;T&gt; listIterator(int index) {return delegatee.listIterator(index);}<a name="line.1840"></a>
+<span class="sourceLineNo">1841</span><a name="line.1841"></a>
+<span class="sourceLineNo">1842</span>    @Override<a name="line.1842"></a>
+<span class="sourceLineNo">1843</span>    public List&lt;T&gt; subList(int fromIndex, int toIndex) {return delegatee.subList(fromIndex, toIndex);}<a name="line.1843"></a>
+<span class="sourceLineNo">1844</span>  }<a name="line.1844"></a>
+<span class="sourceLineNo">1845</span>}<a name="line.1845"></a>
 
 
 


Mime
View raw message