public EncodedDataConsumer(Consumer<ColumnVectorBatch> consumer, final int colCount, LlapDaemonIOMetrics ioMetrics, QueryFragmentCounters counters) { this.downstreamConsumer = consumer; this.ioMetrics = ioMetrics; this.mxBean = LlapUtil.initThreadMxBean(); cvbPool = new FixedSizedObjectPool<ColumnVectorBatch>(CVB_POOL_SIZE, new Pool.PoolObjectHelper<ColumnVectorBatch>() { @Override public ColumnVectorBatch create() { return new ColumnVectorBatch(colCount); } @Override public void resetBeforeOffer(ColumnVectorBatch t) { // Don't reset anything, we are reusing column vectors. } }); this.counters = counters; }
public static FixedSizedObjectPool<IoTrace> createTracePool(Configuration conf) { final int ioTraceSize = (int)HiveConf.getSizeVar(conf, ConfVars.LLAP_IO_TRACE_SIZE); final boolean isAlwaysDump = HiveConf.getBoolVar(conf, ConfVars.LLAP_IO_TRACE_ALWAYS_DUMP); int ioThreads = HiveConf.getIntVar(conf, ConfVars.LLAP_IO_THREADPOOL_SIZE); return new FixedSizedObjectPool<>(ioThreads, new Pool.PoolObjectHelper<IoTrace>() { @Override public IoTrace create() { return new IoTrace(ioTraceSize, isAlwaysDump); } @Override public void resetBeforeOffer(IoTrace t) { t.reset(); } }); } }
final CountDownLatch cdlIn = new CountDownLatch(TASK_COUNT), cdlOut = new CountDownLatch(1); final FixedSizedObjectPool<Object> pool = new FixedSizedObjectPool<>(size, new OneObjHelper(), true);
@Test public void testFullEmpty() { final int SIZE = 8; HashSet<Object> offered = new HashSet<>(); FixedSizedObjectPool<Object> pool = new FixedSizedObjectPool<>(SIZE, new DummyHelper(), true); Object newObj = pool.take(); for (int i = 0; i < SIZE; ++i) { Object obj = new Object(); offered.add(obj); assertTrue(pool.tryOffer(obj)); } assertFalse(pool.tryOffer(newObj)); for (int i = 0; i < SIZE; ++i) { Object obj = pool.take(); assertTrue(offered.remove(obj)); } assertTrue(offered.isEmpty()); Object newObj2 = pool.take(); assertNotSame(newObj, newObj2); }
public EncodedDataConsumer(Consumer<ColumnVectorBatch> consumer, final int colCount, LlapDaemonIOMetrics ioMetrics) { this.downstreamConsumer = consumer; this.ioMetrics = ioMetrics; cvbPool = new FixedSizedObjectPool<ColumnVectorBatch>(CVB_POOL_SIZE, new Pool.PoolObjectHelper<ColumnVectorBatch>() { @Override public ColumnVectorBatch create() { return new ColumnVectorBatch(colCount); } @Override public void resetBeforeOffer(ColumnVectorBatch t) { // Don't reset anything, we are reusing column vectors. } }); }