use of org.apache.ignite.internal.processors.cache.persistence.wal.reader.FilteredWalIterator in project ignite by apache.
the class WalScanner method findAllRecordsFor.
/**
* Finding all page physical records whose pageId is contained in given collection.
*
* @param groupAndPageIds Search pages.
* @return Final step for execution some action on result.
*/
@NotNull
public WalScanner.ScanTerminateStep findAllRecordsFor(@NotNull Collection<T2<Integer, Long>> groupAndPageIds) {
requireNonNull(groupAndPageIds);
HashSet<T2<Integer, Long>> groupAndPageIds0 = new HashSet<>(groupAndPageIds);
// Collect all (group, partition) partition pairs.
Set<T2<Integer, Integer>> groupAndParts = groupAndPageIds0.stream().map((tup) -> new T2<>(tup.get1(), PageIdUtils.partId(tup.get2()))).collect(Collectors.toSet());
// Build WAL filter. (Checkoint, Page, Partition meta)
Predicate<IgniteBiTuple<WALPointer, WALRecord>> filter = checkpoint().or(pageOwner(groupAndPageIds0)).or(partitionMetaStateUpdate(groupAndParts));
return new ScanTerminateStep(() -> new FilteredWalIterator(walIteratorSupplier.get(), filter));
}
use of org.apache.ignite.internal.processors.cache.persistence.wal.reader.FilteredWalIterator in project ignite by apache.
the class IgniteWalConverter method walIterator.
/**
* Getting WAL iterator.
*
* @param walIter WAL iterator.
* @param pageIds Pages for searching in format grpId:pageId.
* @return WAL iterator.
*/
private static WALIterator walIterator(WALIterator walIter, Collection<T2<Integer, Long>> pageIds) throws IgniteCheckedException {
Predicate<IgniteBiTuple<WALPointer, WALRecord>> filter = null;
if (!pageIds.isEmpty()) {
Set<T2<Integer, Long>> grpAndPageIds0 = new HashSet<>(pageIds);
// Collect all (group, partition) partition pairs.
Set<T2<Integer, Integer>> grpAndParts = grpAndPageIds0.stream().map((tup) -> new T2<>(tup.get1(), PageIdUtils.partId(tup.get2()))).collect(Collectors.toSet());
// Build WAL filter. (Checkoint, Page, Partition meta)
filter = checkpoint().or(pageOwner(grpAndPageIds0)).or(partitionMetaStateUpdate(grpAndParts));
}
return filter != null ? new FilteredWalIterator(walIter, filter) : walIter;
}
use of org.apache.ignite.internal.processors.cache.persistence.wal.reader.FilteredWalIterator in project ignite by apache.
the class IgniteWalConverter method getCurrentWalFilePath.
/**
* Get current wal file path, used in {@code WALIterator}.
*
* @param it WALIterator.
* @return Current wal file path.
*/
private static String getCurrentWalFilePath(WALIterator it) {
String res = null;
try {
WALIterator walIter = it instanceof FilteredWalIterator ? U.field(it, "delegateWalIter") : it;
Integer curIdx = U.field(walIter, "curIdx");
List<FileDescriptor> walFileDescriptors = U.field(walIter, "walFileDescriptors");
if (curIdx != null && walFileDescriptors != null && curIdx < walFileDescriptors.size())
res = walFileDescriptors.get(curIdx).getAbsolutePath();
} catch (Exception e) {
e.printStackTrace();
}
return res;
}
Aggregations