@Ignore @Test public void testPerformance() { H2PersistentQueue<String> sut = new H2PersistentQueue<>(this.mvStore, "test"); int numIterations = 10000000; for (int i = 0; i < numIterations; i++) { sut.add("Hello"); } mvStore.commit(); for (int i = 0; i < numIterations; i++) { assertEquals("Hello", sut.poll()); } assertTrue("should be empty", sut.isEmpty()); }
@Override public T poll() { if (head.equals(tail)) { return null; } final long nextTail = tail.getAndIncrement(); final T tail = this.queueMap.get(nextTail); queueMap.remove(nextTail); this.metadataMap.put("tail", nextTail + 1); return tail; }
H2PersistentQueue extends AbstractQueue<T> { @Override public T poll() { if (head.equals(tail)) { return null; } final long nextTail = tail.getAndIncrement(); final T tail = this.queueMap.get(nextTail); queueMap.remove(nextTail); this.metadataMap.put("tail", nextTail + 1); return tail; } }
H2PersistentQueue extends AbstractQueue<T> { @Override public T poll() { if (head.equals(tail)) { return null; } final long nextTail = tail.getAndIncrement(); final T tail = this.queueMap.get(nextTail); queueMap.remove(nextTail); this.metadataMap.put("tail", nextTail + 1); return tail; } H2PersistentQueue(MVStore store, String queueName); }
H2PersistentQueue extends AbstractQueue<T> { @Override public T poll() { if (head.equals(tail)) { return null; } final long nextTail = tail.getAndIncrement(); final T tail = this.queueMap.get(nextTail); queueMap.remove(nextTail); this.metadataMap.put("tail", nextTail + 1); return tail; } H2PersistentQueue(MVStore store, String queueName); @Override Iterator<T> iterator(); @Override int size(); @Override boolean offer(T t); @Override T poll(); @Override T peek(); }
H2PersistentQueue extends AbstractQueue<T> { @Override public T poll() { if (head.equals(tail)) { return null; } final long nextTail = tail.getAndIncrement(); final T tail = this.queueMap.get(nextTail); queueMap.remove(nextTail); this.metadataMap.put("tail", nextTail + 1); return tail; } H2PersistentQueue(MVStore store, String queueName); @Override Iterator<T> iterator(); @Override int size(); @Override boolean offer(T t); @Override T poll(); @Override T peek();  }