ExecutionBlockId ebId = QueryIdFactory.newExecutionBlockId(
QueryIdFactory.newQueryId(System.currentTimeMillis(), 0));
TupleCacheKey cacheKey = new TupleCacheKey(ebId.toString(), "TestTable");
TupleCache tupleCache = TupleCache.getInstance();
assertFalse(tupleCache.isBroadcastCacheReady(cacheKey));
assertTrue(tupleCache.lockBroadcastScan(cacheKey));
assertFalse(tupleCache.lockBroadcastScan(cacheKey));
tupleCache.addBroadcastCache(cacheKey, tupleData);
assertTrue(tupleCache.isBroadcastCacheReady(cacheKey));
Scanner scanner = tupleCache.openCacheScanner(cacheKey, null);
assertNotNull(scanner);
int count = 0;
while (true) {
Tuple tuple = scanner.next();
if (tuple == null) {
break;
}
assertEquals(tupleData.get(count), tuple);
count++;
}
assertEquals(tupleData.size(), count);
tupleCache.removeBroadcastCache(ebId);
assertFalse(tupleCache.isBroadcastCacheReady(cacheKey));
assertTrue(tupleCache.lockBroadcastScan(cacheKey));
tupleCache.removeBroadcastCache(ebId);
}