### Question:
RealtimeInvertedIndexReader implements InvertedIndexReader<MutableRoaringBitmap> { public RealtimeInvertedIndexReader() { ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock(); _readLock = readWriteLock.readLock(); _writeLock = readWriteLock.writeLock(); } RealtimeInvertedIndexReader(); void add(int dictId, int docId); @Override MutableRoaringBitmap getDocIds(int dictId); @Override void close();  }### Answer:
@Test public void testRealtimeInvertedIndexReader() { RealtimeInvertedIndexReader realtimeInvertedIndexReader = new RealtimeInvertedIndexReader(); MutableRoaringBitmap docIds = realtimeInvertedIndexReader.getDocIds(0); assertNotNull(docIds); assertTrue(docIds.isEmpty()); realtimeInvertedIndexReader.add(0, 0); docIds = realtimeInvertedIndexReader.getDocIds(0); assertNotNull(docIds); assertFalse(docIds.isEmpty()); assertTrue(docIds.contains(0)); assertFalse(docIds.contains(1)); docIds = realtimeInvertedIndexReader.getDocIds(1); assertNotNull(docIds); assertTrue(docIds.isEmpty()); realtimeInvertedIndexReader.add(0, 1); docIds = realtimeInvertedIndexReader.getDocIds(0); assertNotNull(docIds); assertFalse(docIds.isEmpty()); assertTrue(docIds.contains(0)); assertTrue(docIds.contains(1)); docIds = realtimeInvertedIndexReader.getDocIds(1); assertNotNull(docIds); assertTrue(docIds.isEmpty()); docIds = realtimeInvertedIndexReader.getDocIds(2); assertNotNull(docIds); assertTrue(docIds.isEmpty()); realtimeInvertedIndexReader.add(1, 2); docIds = realtimeInvertedIndexReader.getDocIds(0); assertNotNull(docIds); assertFalse(docIds.isEmpty()); assertTrue(docIds.contains(0)); assertTrue(docIds.contains(1)); assertFalse(docIds.contains(2)); docIds = realtimeInvertedIndexReader.getDocIds(1); assertNotNull(docIds); assertFalse(docIds.isEmpty()); assertFalse(docIds.contains(0)); assertFalse(docIds.contains(1)); assertTrue(docIds.contains(2)); docIds = realtimeInvertedIndexReader.getDocIds(2); assertNotNull(docIds); assertTrue(docIds.isEmpty()); realtimeInvertedIndexReader.add(2, 2); docIds = realtimeInvertedIndexReader.getDocIds(0); assertNotNull(docIds); assertFalse(docIds.isEmpty()); assertTrue(docIds.contains(0)); assertTrue(docIds.contains(1)); assertFalse(docIds.contains(2)); docIds = realtimeInvertedIndexReader.getDocIds(1); assertNotNull(docIds); assertFalse(docIds.isEmpty()); assertFalse(docIds.contains(0)); assertFalse(docIds.contains(1)); assertTrue(docIds.contains(2)); docIds = realtimeInvertedIndexReader.getDocIds(2); assertFalse(docIds.isEmpty()); assertFalse(docIds.contains(0)); assertFalse(docIds.contains(1)); assertTrue(docIds.contains(2)); }