Objects: remove findAllObjects

This commit is contained in:
2025-03-14 15:03:11 +01:00
parent d483eba20d
commit d37dc944d0
9 changed files with 11 additions and 51 deletions

View File

@@ -37,12 +37,6 @@ public class CurrentTransaction implements Transaction {
transactionManager.current().delete(key);
}
@Nonnull
@Override
public Collection<JObjectKey> findAllObjects() {
return transactionManager.current().findAllObjects();
}
@Override
public CloseableKvIterator<JObjectKey, JData> getIterator(IteratorStart start, JObjectKey key) {
return transactionManager.current().getIterator(start, key);

View File

@@ -11,6 +11,10 @@ public record JObjectKey(String name) implements Serializable, Comparable<JObjec
return new JObjectKey(name);
}
public static JObjectKey first() {
return new JObjectKey("");
}
@Override
public int compareTo(JObjectKey o) {
return name.compareTo(o.name);

View File

@@ -88,22 +88,6 @@ public class LmdbObjectPersistentStore implements ObjectPersistentStore {
if (!_ready) throw new IllegalStateException("Wrong service order!");
}
@Nonnull
@Override
public Collection<JObjectKey> findAllObjects() {
// try (Txn<ByteBuffer> txn = env.txnRead()) {
// try (var cursor = db.openCursor(txn)) {
// var keys = List.of();
// while (cursor.next()) {
// keys.add(JObjectKey.fromBytes(cursor.key()));
// }
// return keys;
// }
// }
return List.of();
}
@Nonnull
@Override
public Optional<ByteString> readObject(JObjectKey name) {

View File

@@ -24,14 +24,6 @@ public class MemoryObjectPersistentStore implements ObjectPersistentStore {
private long _lastCommitId = 0;
private final ReentrantReadWriteLock _lock = new ReentrantReadWriteLock();
@Nonnull
@Override
public Collection<JObjectKey> findAllObjects() {
synchronized (this) {
return _objects.keySet();
}
}
@Nonnull
@Override
public Optional<ByteString> readObject(JObjectKey name) {

View File

@@ -14,9 +14,6 @@ import java.util.function.Consumer;
// Persistent storage of objects
// All changes are written as sequential transactions
public interface ObjectPersistentStore {
@Nonnull
Collection<JObjectKey> findAllObjects();
@Nonnull
Optional<ByteString> readObject(JObjectKey name);

View File

@@ -25,11 +25,6 @@ public class SerializingObjectPersistentStore {
@Inject
ObjectPersistentStore delegateStore;
@Nonnull
Collection<JObjectKey> findAllObjects() {
return delegateStore.findAllObjects();
}
@Nonnull
Optional<JDataVersionedWrapper> readObject(JObjectKey name) {
return delegateStore.readObject(name).map(serializer::deserialize);

View File

@@ -5,8 +5,6 @@ import com.usatiuk.dhfs.objects.JData;
import com.usatiuk.dhfs.objects.JObjectKey;
import com.usatiuk.dhfs.objects.persistence.IteratorStart;
import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.Optional;
// The transaction interface actually used by user code to retrieve objects
@@ -19,9 +17,6 @@ public interface Transaction extends TransactionHandle {
void delete(JObjectKey key);
@Nonnull
Collection<JObjectKey> findAllObjects(); // FIXME: This is crap
default <T extends JData> Optional<T> get(Class<T> type, JObjectKey key) {
return get(type, key, LockingStrategy.OPTIMISTIC);
}

View File

@@ -214,13 +214,6 @@ public class TransactionFactoryImpl implements TransactionFactory {
_newWrites.put(key, new TxRecord.TxObjectRecordDeleted(key));
}
@Nonnull
@Override
public Collection<JObjectKey> findAllObjects() {
// return store.findAllObjects();
return List.of();
}
@Override
public CloseableKvIterator<JObjectKey, JData> getIterator(IteratorStart start, JObjectKey key) {
Log.tracev("Getting tx iterator with start={0}, key={1}", start, key);

View File

@@ -78,7 +78,13 @@ public class SyncHandler {
public void doInitialSync(PeerId peer) {
txm.run(() -> {
for (var cur : curTx.findAllObjects()) invalidationQueueService.pushInvalidationToOne(peer, cur, true);
try (var it = curTx.getIterator(IteratorStart.GE, JObjectKey.first())) {
while (it.hasNext()) {
var key = it.peekNextKey();
invalidationQueueService.pushInvalidationToOne(peer, key, true);
it.skip();
}
}
});
}
}