rpuch commented on code in PR #1226: URL: https://github.com/apache/ignite-3/pull/1226#discussion_r1003274602
########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/raft/snapshot/PartitionAccessImpl.java: ########## @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.table.distributed.raft.snapshot; + +import java.util.ArrayList; +import java.util.List; +import org.apache.ignite.internal.storage.MvPartitionStorage; +import org.apache.ignite.internal.storage.ReadResult; +import org.apache.ignite.internal.storage.RowId; +import org.apache.ignite.internal.util.Cursor; +import org.jetbrains.annotations.Nullable; + +/** + * {@link PartitionAccess} that adapts an {@link MvPartitionStorage}. + */ +public class PartitionAccessImpl implements PartitionAccess { + private final PartitionKey partitionKey; + private final MvPartitionStorage partitionStorage; + + public PartitionAccessImpl(PartitionKey partitionKey, MvPartitionStorage partitionStorage) { + this.partitionKey = partitionKey; + this.partitionStorage = partitionStorage; + } + + @Override + public PartitionKey key() { + return partitionKey; + } + + @Override + public long persistedIndex() { + return partitionStorage.persistedIndex(); + } + + @Override + public @Nullable RowId closestRowId(RowId lowerBound) { + return partitionStorage.closestRowId(lowerBound); + } + + @Override + public List<ReadResult> rowVersions(RowId rowId) { Review Comment: I need to read all the contents of the cursor, so I do that as soon as possible. I can do it here or I can do it there. But for mocking/faking purposes, a method returning a `List` is a bit more convenient (it's easier to construct an instance of a list than an instance of a mock). Also, as the notion of a `List` (it's usually a detached thing) is simpler than the notion of a `Cursor` (it's attached to some source of data), I prefer the simplest of them in the API of this interface. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
