Java Code Examples for org.eclipse.collections.impl.list.mutable.FastList#get()
The following examples show how to use
org.eclipse.collections.impl.list.mutable.FastList#get() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FastUnsafeOffHeapDataStorage.java From reladomo with Apache License 2.0 | 6 votes |
private void bucketAllIncomingData(int currentMaxPage, FastList<FastUnsafeOffHeapPageBuffer> buffers, FastUnsafeOffHeapIntList toInsert, FastUnsafeOffHeapIntList toRemove, FastUnsafeOffHeapIntList toUpdate, FastUnsafeOffHeapIntList toNukeAndInsert, SyncLog syncLog) { for (int i = 0; i < buffers.size(); i++) { FastUnsafeOffHeapPageBuffer buffer = buffers.get(i); FastUnsafeOffHeapIntList masterPageIndicies = buffer.getMasterPageIndicies(); for (int bufferPageIndex = 0; bufferPageIndex < masterPageIndicies.size(); bufferPageIndex++) { int page = masterPageIndicies.get(bufferPageIndex); if (page <= currentMaxPage) { for (int pageDataIndex = 0; pageDataIndex < (1 << PAGE_POWER_OF_TWO); pageDataIndex++) { bucketIncomingData(toInsert, toRemove, toUpdate, toNukeAndInsert, buffer, bufferPageIndex, page, pageDataIndex); } } } } syncLog.setToInsertInExistingPages(toInsert.size()); syncLog.setToUpdateExisting(toUpdate.size()); syncLog.setToRemoveExisting(toRemove.size()); syncLog.setToNukeAndInsert(toNukeAndInsert.size()); }
Example 2
Source File: MithraCompositeList.java From reladomo with Apache License 2.0 | 6 votes |
public void add(int index, E element) { int max = 0; FastList<MithraFastList<E>> localLists = this.lists; for (int i = 0; i < localLists.size(); i++) { List<E> list = localLists.get(i); int previousMax = max; max += list.size(); if (index <= max) { list.add(index - previousMax, element); return; } } throw new IndexOutOfBoundsException("No such element " + index + " size: " + this.size()); }
Example 3
Source File: MithraCompositeList.java From reladomo with Apache License 2.0 | 6 votes |
public int indexOf(final Object o) { int offset = 0; FastList<MithraFastList<E>> localLists = this.lists; for (int i = 0; i < localLists.size(); i++) { List list = localLists.get(i); int index = list.indexOf(o); if (index > -1) { return index + offset; } offset += list.size(); } return -1; }
Example 4
Source File: MithraCompositeList.java From reladomo with Apache License 2.0 | 6 votes |
public int lastIndexOf(final Object o) { int offset = this.size(); FastList<MithraFastList<E>> localLists = this.lists; for (int i = localLists.size() - 1; i >= 0; i--) { List list = localLists.get(i); offset -= list.size(); int index = list.lastIndexOf(o); if (index > -1) { return index + offset; } } return -1; }
Example 5
Source File: RelationshipMultiEqualityOperation.java From reladomo with Apache License 2.0 | 6 votes |
private void parallelFilter(final boolean[] applied, MithraCompositeList mithraCompositeList) { final FastList<FastList> lists = mithraCompositeList.getLists(); CpuBoundTask[] tasks = new CpuBoundTask[lists.size()]; for(int i=0;i<lists.size();i++) { final FastList toFilter = lists.get(i); tasks[i] = new CpuBoundTask() { @Override public void execute() { filterResultsInPlace(applied, toFilter); } }; } new FixedCountTaskFactory(tasks).startAndWorkUntilFinished(); }
Example 6
Source File: OrOperation.java From reladomo with Apache License 2.0 | 6 votes |
private List applyAtomicInPlace(FastList result, Operation[] atomic) { int currentFilledIndex = 0; for (int i = 0; i < result.size(); i++) { Object o = result.get(i); if (matches(o, atomic)) { // keep it if (currentFilledIndex != i) { result.set(currentFilledIndex, o); } currentFilledIndex++; } } this.resetTheEnd(result, currentFilledIndex); return result; }
Example 7
Source File: AndOperation.java From reladomo with Apache License 2.0 | 6 votes |
private static List applyAtomicInPlace(FastList result, Operation[] atomic) { int currentFilledIndex = 0; for (int i = 0; i < result.size(); i++) { Object o = result.get(i); Boolean matched = Boolean.TRUE; for (int j = 0; j < atomic.length && matched; j++) { Operation op = atomic[j]; matched = op.matches(o); if (matched == null) return null; } if (matched) { // keep it if (currentFilledIndex != i) { result.set(currentFilledIndex, o); } currentFilledIndex++; } } resetTheEnd(result, currentFilledIndex); return result; }
Example 8
Source File: MultiEqualityOperation.java From reladomo with Apache License 2.0 | 6 votes |
private void parallelFilter(final boolean[] applied, MithraCompositeList mithraCompositeList) { final FastList<FastList> lists = mithraCompositeList.getLists(); CpuBoundTask[] tasks = new CpuBoundTask[lists.size()]; for(int i=0;i<lists.size();i++) { final FastList toFilter = lists.get(i); tasks[i] = new CpuBoundTask() { @Override public void execute() { filterResultsInPlace(applied, toFilter); } }; } new FixedCountTaskFactory(tasks).startAndWorkUntilFinished(); }
Example 9
Source File: TopLevelMergeOptions.java From reladomo with Apache License 2.0 | 5 votes |
private void ensureDependent(AbstractRelatedFinder arf) { DeepRelationshipAttribute parentAttribute = arf.getParentDeepRelationshipAttribute(); RelatedFinder finderInstance = this.getMetaData().getFinderInstance(); if (parentAttribute == null) { if (!finderInstance.getDependentRelationshipFinders().contains(arf)) { throw new MithraBusinessException("Can only navigate to dependent relationships! "+arf.getRelationshipName()+" is not a dependent"); } } FastList<AbstractRelatedFinder> list = FastList.newList(4); list.add(arf); while(parentAttribute != null) { list.add((AbstractRelatedFinder) parentAttribute); parentAttribute = parentAttribute.getParentDeepRelationshipAttribute(); } for(int i=list.size() - 1; i >=0; i--) { AbstractRelatedFinder child = list.get(i); if (!finderInstance.getDependentRelationshipFinders().contains(child)) { throw new MithraBusinessException("Can only navigate to dependent relationships! "+ child.getRelationshipName()+" is not a dependent"); } finderInstance = child; } }
Example 10
Source File: FastUnsafeOffHeapDataStorage.java From reladomo with Apache License 2.0 | 5 votes |
private void copyDataFromBuffers(MasterSyncResult syncResult, FastList<FastUnsafeOffHeapPageBuffer> buffers, IntLongHashMap pageLocationMap, int toCopyDataIndex) { int page = toCopyDataIndex >> PAGE_POWER_OF_TWO; int pageDataIndex = toCopyDataIndex & ((1 << PAGE_POWER_OF_TWO) - 1); long pageFromSyncResult = pageLocationMap.get(page); int pageBufferLocation = syncResult.getPageBufferLocation(pageFromSyncResult); int bufferPageIndex = syncResult.getBufferPageIndex(pageFromSyncResult); FastUnsafeOffHeapPageBuffer buffer = buffers.get(pageBufferLocation); long src = buffer.getPageStartLocation(bufferPageIndex) + pageDataIndex * dataSize; long dest = computeAddress(toCopyDataIndex, 0); assertedCopyMemory(src + 1, dest + 1, dataSize - 1, buffer.getBaseAddress(), buffer.getAllocatedLength(), this.baseAddress, this.totalAllocated); fence++; UNSAFE.putByte(dest, UNSAFE.getByte(src)); // we copy the dataVersion field last }
Example 11
Source File: FastUnsafeOffHeapDataStorage.java From reladomo with Apache License 2.0 | 5 votes |
private void copyBufferPage(MasterSyncResult syncResult, long pageSize, long newBase, FastList<FastUnsafeOffHeapPageBuffer> buffers, int destinationPageIndex, long pageFromSyncResult, long newSize) { int pageBufferLocation = syncResult.getPageBufferLocation(pageFromSyncResult); int bufferPageIndex = syncResult.getBufferPageIndex(pageFromSyncResult); FastUnsafeOffHeapPageBuffer buffer = buffers.get(pageBufferLocation); assertedCopyMemory(buffer.getPageStartLocation(bufferPageIndex), newBase + destinationPageIndex * pageSize, pageSize, buffer.getBaseAddress(), buffer.getAllocatedLength(), newBase, newSize); }
Example 12
Source File: TestPerformance.java From reladomo with Apache License 2.0 | 5 votes |
public void testSubQueryCache() { int max = 30000; FastList<Integer> userIdList = FastList.newList(); int[] userIds = new int[max]; OrderList list = new OrderList(); for(int i=0;i<max;i++) { Order order = new Order(); order.setOrderId(1000+i); order.setUserId(-i); order.setDescription("desc"+i/10); order.setTrackingId("State"+i); list.add(order); userIdList.add(-i); } list.insertAll(); Collections.shuffle(userIdList); for(int i=0;i<userIdList.size();i++) { userIds[i] = userIdList.get(i); } for(int i=0;i<10;i++) { MithraManagerProvider.getMithraManager().clearAllQueryCaches(); Operation superOp = OrderFinder.orderId().greaterThanEquals(1000).and(OrderFinder.userId().lessThan(10)); OrderList superQuery = OrderFinder.findMany(superOp); superQuery.forceResolve(); runSubQueryTest(superOp, userIds); } }
Example 13
Source File: AbstractNonDatedCache.java From reladomo with Apache License 2.0 | 4 votes |
public void updateCache(List newDataList, List updatedDataList, List deletedData) { long start = 0; if (logger.isDebugEnabled()) { start = System.currentTimeMillis(); } Boolean lock = null; try { this.readWriteLock.acquireWriteLock(); lock = Boolean.TRUE; FastList checkToReindexList = new FastList(updatedDataList.size()); for (int i = 0; i < deletedData.size(); i++) { MithraObject object = (MithraObject) primaryKeyIndex.removeUsingUnderlying(deletedData.get(i)); if (object != null) { for (int j = 1; j < this.indices.length; j++) { Index index = this.indices[j]; index.remove(object); } this.markObjectAsDeleted(object); } } for (int i = 0; i < updatedDataList.size(); i++) { Object data = updatedDataList.get(i); MithraObject updatedObject = (MithraObject) primaryKeyIndex.getFromData(data); checkToReindexList.add(updatedObject); } ensureCapacity(primaryKeyIndex.size() + newDataList.size()); updateCacheForNewObjects(newDataList, updatedDataList, checkToReindexList); this.readWriteLock.release(); lock = null; for (int i = 0; i < checkToReindexList.size(); i++) { MithraObject obj = (MithraObject) checkToReindexList.get(i); obj.zReindexAndSetDataIfChanged((MithraDataObject) updatedDataList.get(i), this); } } finally { if (lock != null) { this.readWriteLock.release(); } } if (logger.isDebugEnabled()) { logger.debug("Cache update took "+(System.currentTimeMillis()-start)+" ms"); } }