@Test public void includeExcludeIdQuery() throws IndexingException { addElements(arrayBasedStorageLeaf, 100); StorageIndexQuery indexQuery = mock(StorageIndexQuery.class); List<Long> includeIds = new ArrayList<>(); List<Long> excludeIds = new ArrayList<>(); when(indexQuery.getIncludeIds()).thenReturn(includeIds); when(indexQuery.getExcludeIds()).thenReturn(excludeIds); includeIds.add(50L); List<IStorageDescriptor> result = arrayBasedStorageLeaf.query(indexQuery); assertThat(result, hasSize(1)); excludeIds.add(50L); result = arrayBasedStorageLeaf.query(indexQuery); assertThat(result, is(empty())); when(indexQuery.getIncludeIds()).thenReturn(null); result = arrayBasedStorageLeaf.query(indexQuery); assertThat(result, hasSize(99)); when(indexQuery.getMinId()).thenReturn(100L); result = arrayBasedStorageLeaf.query(indexQuery); assertThat(result, hasSize(1)); }
@Override public List<IStorageDescriptor> query(IIndexQuery query) { if (query instanceof StorageIndexQuery) { return this.queryWithStorageQuery((StorageIndexQuery) query); } else { readLock.lock(); try { List<IStorageDescriptor> returnList = new ArrayList<>(); int index = 0; if (query.getMinId() != 0) { index = Arrays.binarySearch(idArray, 0, size, query.getMinId()); if (index < 0) { index = -index - 1; } } for (; index < size; index++) { if (0 != idArray[index]) { SimpleStorageDescriptor simpleDescriptor = descriptorArray[index]; if (null != simpleDescriptor) { returnList.add(new StorageDescriptor(this.id, simpleDescriptor)); } } } return returnList; } finally { readLock.unlock(); } } }
ArrayBasedStorageLeaf implements IStorageTreeComponent<E> { @Override public List<IStorageDescriptor> query(IIndexQuery query) { if (query instanceof StorageIndexQuery) { return this.queryWithStorageQuery((StorageIndexQuery) query); } else { readLock.lock(); try { List<IStorageDescriptor> returnList = new ArrayList<>(); int index = 0; if (query.getMinId() != 0) { index = Arrays.binarySearch(idArray, 0, size, query.getMinId()); if (index < 0) { index = -index - 1; } } for (; index < size; index++) { if (0 != idArray[index]) { SimpleStorageDescriptor simpleDescriptor = descriptorArray[index]; if (null != simpleDescriptor) { returnList.add(new StorageDescriptor(this.id, simpleDescriptor)); } } } return returnList; } finally { readLock.unlock(); } } } }
ArrayBasedStorageLeaf implements IStorageTreeComponent<E> { @Override public List<IStorageDescriptor> query(IIndexQuery query) { if (query instanceof StorageIndexQuery) { return this.queryWithStorageQuery((StorageIndexQuery) query); } else { readLock.lock(); try { List<IStorageDescriptor> returnList = new ArrayList<>(); int index = 0; if (query.getMinId() != 0) { index = Arrays.binarySearch(idArray, 0, size, query.getMinId()); if (index < 0) { index = -index - 1; } } for (; index < size; index++) { if (0 != idArray[index]) { SimpleStorageDescriptor simpleDescriptor = descriptorArray[index]; if (null != simpleDescriptor) { returnList.add(new StorageDescriptor(this.id, simpleDescriptor)); } } } return returnList; } finally { readLock.unlock(); } } } ArrayBasedStorageLeaf();  ArrayBasedStorageLeaf(int id); }
ArrayBasedStorageLeaf implements IStorageTreeComponent<E> { @Override public List<IStorageDescriptor> query(IIndexQuery query) { if (query instanceof StorageIndexQuery) { return this.queryWithStorageQuery((StorageIndexQuery) query); } else { readLock.lock(); try { List<IStorageDescriptor> returnList = new ArrayList<>(); int index = 0; if (query.getMinId() != 0) { index = Arrays.binarySearch(idArray, 0, size, query.getMinId()); if (index < 0) { index = -index - 1; } } for (; index < size; index++) { if (0 != idArray[index]) { SimpleStorageDescriptor simpleDescriptor = descriptorArray[index]; if (null != simpleDescriptor) { returnList.add(new StorageDescriptor(this.id, simpleDescriptor)); } } } return returnList; } finally { readLock.unlock(); } } } ArrayBasedStorageLeaf();  ArrayBasedStorageLeaf(int id); @Override IStorageDescriptor put(E element); @Override IStorageDescriptor get(E element); @Override List<IStorageDescriptor> query(IIndexQuery query); @Override List<IStorageDescriptor> query(IIndexQuery query, ForkJoinPool forkJoinPool); @Override IStorageDescriptor getAndRemove(E element); @Override void preWriteFinalization(); @Override long getComponentSize(IObjectSizes objectSizes); @Override RecursiveTask<List<IStorageDescriptor>> getTaskForForkJoinQuery(IIndexQuery query); @Override int hashCode(); @SuppressWarnings("unchecked") @Override boolean equals(Object obj); @Override String toString(); }
ArrayBasedStorageLeaf implements IStorageTreeComponent<E> { @Override public List<IStorageDescriptor> query(IIndexQuery query) { if (query instanceof StorageIndexQuery) { return this.queryWithStorageQuery((StorageIndexQuery) query); } else { readLock.lock(); try { List<IStorageDescriptor> returnList = new ArrayList<>(); int index = 0; if (query.getMinId() != 0) { index = Arrays.binarySearch(idArray, 0, size, query.getMinId()); if (index < 0) { index = -index - 1; } } for (; index < size; index++) { if (0 != idArray[index]) { SimpleStorageDescriptor simpleDescriptor = descriptorArray[index]; if (null != simpleDescriptor) { returnList.add(new StorageDescriptor(this.id, simpleDescriptor)); } } } return returnList; } finally { readLock.unlock(); } } } ArrayBasedStorageLeaf();  ArrayBasedStorageLeaf(int id); @Override IStorageDescriptor put(E element); @Override IStorageDescriptor get(E element); @Override List<IStorageDescriptor> query(IIndexQuery query); @Override List<IStorageDescriptor> query(IIndexQuery query, ForkJoinPool forkJoinPool); @Override IStorageDescriptor getAndRemove(E element); @Override void preWriteFinalization(); @Override long getComponentSize(IObjectSizes objectSizes); @Override RecursiveTask<List<IStorageDescriptor>> getTaskForForkJoinQuery(IIndexQuery query); @Override int hashCode(); @SuppressWarnings("unchecked") @Override boolean equals(Object obj); @Override String toString();  }