Class L1PriorityQueue<E extends IDIndexedAccessible>
- java.lang.Object
-
- org.apache.iotdb.db.mpp.execution.schedule.queue.IndexedBlockingQueue<E>
-
- org.apache.iotdb.db.mpp.execution.schedule.queue.L1PriorityQueue<E>
-
public class L1PriorityQueue<E extends IDIndexedAccessible> extends IndexedBlockingQueue<E>
An efficient subclass ofIndexedBlockingQueuewith 1-level priority groups.The time complexity of operations are:
remove(IDIndexedAccessible)()}: O(logN).IndexedBlockingQueue.push(IDIndexedAccessible): O(logN).IndexedBlockingQueue.poll(): O(logN).IndexedBlockingQueue.get(ID)}: O(1).
-
-
Constructor Summary
Constructors Constructor Description L1PriorityQueue(int maxCapacity, java.util.Comparator<E> comparator, E queryHolder)Init the queue with max capacity and specified comparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidclearAllElements()Clear all elements in this queue.protected booleancontains(E element)Check whether an element with the same ID exists.protected Eget(E element)Return the element with the same id of the input, null if it doesn't exist.protected booleanisEmpty()Whether the queue is empty.protected EpollFirst()Get and remove the first element.protected voidpushToQueue(E element)Push the element into the queue.protected Eremove(E element)Remove and return the element by its ID.
-
-
-
Constructor Detail
-
L1PriorityQueue
public L1PriorityQueue(int maxCapacity, java.util.Comparator<E> comparator, E queryHolder)Init the queue with max capacity and specified comparator.- Parameters:
maxCapacity- the max capacity of the queue.comparator- the comparator for comparing the elements.queryHolder- the query holder instance.- Throws:
java.lang.IllegalArgumentException- if maxCapacity <= 0.- See Also:
IndexedBlockingQueue
-
-
Method Detail
-
isEmpty
protected boolean isEmpty()
Description copied from class:IndexedBlockingQueueWhether the queue is empty.This implementation needn't be thread-safe.
- Specified by:
isEmptyin classIndexedBlockingQueue<E extends IDIndexedAccessible>- Returns:
- true if the queue is empty, otherwise false.
-
pollFirst
protected E pollFirst()
Description copied from class:IndexedBlockingQueueGet and remove the first element.This implementation needn't be thread-safe.
- Specified by:
pollFirstin classIndexedBlockingQueue<E extends IDIndexedAccessible>- Returns:
- The first element.
-
pushToQueue
protected void pushToQueue(E element)
Description copied from class:IndexedBlockingQueuePush the element into the queue.This implementation needn't be thread-safe.
- Specified by:
pushToQueuein classIndexedBlockingQueue<E extends IDIndexedAccessible>- Parameters:
element- the element to be pushed.
-
remove
protected E remove(E element)
Description copied from class:IndexedBlockingQueueRemove and return the element by its ID. It returns null if it doesn't exist.This implementation needn't be thread-safe.
- Specified by:
removein classIndexedBlockingQueue<E extends IDIndexedAccessible>- Parameters:
element- the element to be removed.- Returns:
- the removed element.
-
contains
protected boolean contains(E element)
Description copied from class:IndexedBlockingQueueCheck whether an element with the same ID exists.This implementation needn't be thread-safe.
- Specified by:
containsin classIndexedBlockingQueue<E extends IDIndexedAccessible>- Parameters:
element- the element to be checked.- Returns:
- true if an element with the same ID exists, otherwise false.
-
get
protected E get(E element)
Description copied from class:IndexedBlockingQueueReturn the element with the same id of the input, null if it doesn't exist.This implementation needn't be thread-safe.
- Specified by:
getin classIndexedBlockingQueue<E extends IDIndexedAccessible>- Parameters:
element- the element to be queried.- Returns:
- the element with the same id in the queue. Null if it doesn't exist.
-
clearAllElements
protected void clearAllElements()
Description copied from class:IndexedBlockingQueueClear all elements in this queue.This implementation needn't be thread-safe.
- Specified by:
clearAllElementsin classIndexedBlockingQueue<E extends IDIndexedAccessible>
-
-