@Test public void getNextRecord100000Records30Sample() throws Exception { int expected = 0; float ratio = (float) (30.0 / 100000.0); samplingBitSet.set(99); samplingBitSet.set(999); samplingBitSet.set(9999); recordsLimit = 100000; when(mockContext.getStatsSampleRatio()).thenReturn(ratio); readSamplingBridge = new ReadSamplingBridge(mockContext, mockAccessorFactory, mockResolverFactory); for (int i = 0; i < 30; i++) { result = readSamplingBridge.getNext(); assertNotNull(result); int residue = i % 3; int div = i / 3; if (residue == 0) { expected = 99 + (div * 10000); } else if (residue == 1) { expected = 999 + (div * 10000); } else { expected = 9999 + (div * 10000); } assertEquals("" + expected, result.toString()); } result = readSamplingBridge.getNext(); assertNull(result); }
@Override public Writable getNext() throws Exception { Writable output = super.getNext(); while (!sampleBitSet.get(curIndex)) { if (output == null) { break; } incIndex(); output = super.getNext(); } incIndex(); return output; }
ReadSamplingBridge extends ReadBridge { @Override public Writable getNext() throws Exception { Writable output = super.getNext(); while (!sampleBitSet.get(curIndex)) { if (output == null) { break; } incIndex(); output = super.getNext(); } incIndex(); return output; } }
ReadSamplingBridge extends ReadBridge { @Override public Writable getNext() throws Exception { Writable output = super.getNext(); while (!sampleBitSet.get(curIndex)) { if (output == null) { break; } incIndex(); output = super.getNext(); } incIndex(); return output; } ReadSamplingBridge(RequestContext context);   ReadSamplingBridge(RequestContext context, AccessorFactory accessorFactory, ResolverFactory resolverFactory); }
ReadSamplingBridge extends ReadBridge { @Override public Writable getNext() throws Exception { Writable output = super.getNext(); while (!sampleBitSet.get(curIndex)) { if (output == null) { break; } incIndex(); output = super.getNext(); } incIndex(); return output; } ReadSamplingBridge(RequestContext context);   ReadSamplingBridge(RequestContext context, AccessorFactory accessorFactory, ResolverFactory resolverFactory); @Override Writable getNext(); }
ReadSamplingBridge extends ReadBridge { @Override public Writable getNext() throws Exception { Writable output = super.getNext(); while (!sampleBitSet.get(curIndex)) { if (output == null) { break; } incIndex(); output = super.getNext(); } incIndex(); return output; } ReadSamplingBridge(RequestContext context);   ReadSamplingBridge(RequestContext context, AccessorFactory accessorFactory, ResolverFactory resolverFactory); @Override Writable getNext();  }