Skip to content

Commit

Permalink
Merge pull request #226 from JetBrains/graph-store-reduce-interface
Browse files Browse the repository at this point in the history
XD-1086 some more code removed from interfaces
  • Loading branch information
leostryuk authored Nov 27, 2024
2 parents 35380a6 + 1d96e6d commit bb2ac34
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import jetbrains.exodus.core.dataStructures.hash.HashSet;
import jetbrains.exodus.core.dataStructures.hash.IntHashMap;
import jetbrains.exodus.core.dataStructures.hash.IntHashSet;
import jetbrains.exodus.core.execution.JobProcessor;
import jetbrains.exodus.core.execution.MultiThreadDelegatingJobProcessor;
import jetbrains.exodus.crypto.EncryptedBlobVault;
import jetbrains.exodus.crypto.StreamCipherProvider;
import jetbrains.exodus.entitystore.PersistentStoreTransaction.TransactionType;
Expand Down Expand Up @@ -721,7 +723,13 @@ public ArrayList<long[]> ensureBlobsConsistency(final PersistentStoreTransaction
return result;
}

@Override
/**
* Clears all the data in the {@code PersistentEntityStore}. It is safe to clear {@code PersistentEntityStore}
* with lots of parallel transactions. Make sure all {@linkplain java.io.InputStream} instances got from
* the {@linkplain #getBlobVault() blob vault} are closed.
*
* Don't use this method if the underlying {@linkplain Environment} is shared among different entity stores.
*/
public void clear() {
environment.clear();
allSequences.clear();
Expand All @@ -743,10 +751,16 @@ public String getName() {
}

@NotNull
@Override
public PersistentEntityStoreConfig getConfig() {
return config;
}
/**
* Returns {@linkplain PersistentEntityStoreConfig} instance used during creation of the
* {@code PersistentEntityStore}. If no config was specified and no setting was mutated, then returned config has
* the same settings as {@linkplain PersistentEntityStoreConfig#DEFAULT}.
*
* @return {@linkplain PersistentEntityStoreConfig} instance
*/

@Override
@NotNull
Expand Down Expand Up @@ -794,12 +808,14 @@ public List<PersistentSequence> getAllSequences() {
}
}

@Override

/**
* @return The number of available bytes on the partition where the database is located
*/
public long getUsableSpace() {
return new File(location).getUsableSpace();
}

@Override
@NotNull
public BlobVault getBlobVault() {
return blobVault;
Expand Down Expand Up @@ -2365,20 +2381,37 @@ public Iterable<Pair<Long, Long>> getBlobFileLengths(@NotNull final PersistentSt
return new BlobFileLengthsIterable(txn, fromHandle);
}

@Override
/**
* {@linkplain MultiThreadDelegatingJobProcessor Job processor} used by the {@code PersistentEntityStore} for
* background caching activities. Allows to indirectly estimate load of the {@code PersistentEntityStore}. E.g.,
* if it has numerous {@linkplain JobProcessor#pendingJobs() pending caching jobs} (say, thousands) then most
* likely caching doesn't work well and the {@code PersistentEntityStore} looks overloaded.
*
* @return job processor used for background caching activities
*/
@NotNull
public EntityStoreSharedAsyncProcessor getAsyncProcessor() {
return iterableCache.getProcessor();
}

@Override
/**
* {@linkplain MultiThreadDelegatingJobProcessor Job processor} used by the {@code PersistentEntityStore} for
* background counts (inconsistent) caching activities. Allows to indirectly estimate load of the {@code PersistentEntityStore}. E.g.,
* if it has numerous {@linkplain JobProcessor#pendingJobs() pending caching jobs} (say, thousands) then most
* likely caching doesn't work well and the {@code PersistentEntityStore} looks overloaded.
*
* @return job processor used for background caching activities
*/
@NotNull
public EntityStoreSharedAsyncProcessor getCountsAsyncProcessor() {
return iterableCache.getCountsProcessor();
}

/**
* @return statistics of this {@code PersistentEntityStore} instance
* @see PersistentEntityStoreConfig#GATHER_STATISTICS
*/
@NotNull
@Override
public Statistics getStatistics() {
return statistics;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ public final CachedInstanceIterable getOrCreateCachedInstance(@NotNull StoreTran
}
if (cached == null || cached.getHandle().isExpired()) {
cached = createCachedInstance(txn);
if (canBeReordered() && !store.getConfig().isReorderingDisabled() && !cached.isSortedById()) {
if (canBeReordered() && !((PersistentEntityStoreImpl) store).getConfig().isReorderingDisabled() && !cached.isSortedById()) {
cached = cached.orderById();
}
if (canBeCached) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@ import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal
import com.orientechnologies.orient.core.db.ODatabaseSession
import jetbrains.exodus.backup.BackupStrategy
import jetbrains.exodus.bindings.ComparableBinding
import jetbrains.exodus.core.execution.MultiThreadDelegatingJobProcessor
import jetbrains.exodus.entitystore.*
import jetbrains.exodus.management.Statistics
import java.io.File

class OPersistentEntityStore(
private val databaseProvider: ODatabaseProvider,
private val name: String,
private val schemaBuddy: OSchemaBuddy = OSchemaBuddyImpl(databaseProvider)
) : PersistentEntityStore, OEntityStore {

private val config = PersistentEntityStoreConfig()
private val dummyJobProcessor = object : MultiThreadDelegatingJobProcessor("dummy", 1) {}
private val dummyStatistics = object : Statistics<Enum<*>>(arrayOf()) {}
private val currentTransaction = ThreadLocal<OStoreTransaction>()

override fun close() {
Expand Down Expand Up @@ -112,10 +106,6 @@ class OPersistentEntityStore(
return object : BackupStrategy() {}
}

override fun clear() {
throw IllegalStateException("Should not ever be called")
}

override fun executeInTransaction(executable: StoreTransactionalExecutable) {
computeInTransaction { tx ->
executable.execute(tx)
Expand Down Expand Up @@ -147,8 +137,6 @@ class OPersistentEntityStore(
override fun <T : Any?> computeInReadonlyTransaction(computable: StoreTransactionalComputable<T>) =
computeInTransaction(computable)

override fun getBlobVault() = DummyBlobVault(config)

override fun registerCustomPropertyType(
txn: StoreTransaction,
clazz: Class<out Comparable<Any?>>,
Expand Down Expand Up @@ -177,22 +165,11 @@ class OPersistentEntityStore(
currentTx.renameOClass(oldEntityTypeName, newEntityTypeName)
}

override fun getUsableSpace(): Long {
return File(location).usableSpace
}

override fun getConfig(): PersistentEntityStoreConfig = config

override fun getAsyncProcessor() = dummyJobProcessor

override fun getStatistics() = dummyStatistics

override fun getAndCheckCurrentTransaction(): StoreTransaction {
return requireActiveTransaction()
}

override fun getCountsAsyncProcessor() = dummyJobProcessor

override fun requireActiveTransaction(): OStoreTransaction {
val tx = currentTransaction.get()
check(tx != null) { "No active transactions on the current thread" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@
*/
public interface PersistentEntityStore extends EntityStore, Backupable {

/**
* Clears all the data in the {@code PersistentEntityStore}. It is safe to clear {@code PersistentEntityStore}
* with lots of parallel transactions. Make sure all {@linkplain java.io.InputStream} instances got from
* the {@linkplain #getBlobVault() blob vault} are closed.
*
* Don't use this method if the underlying {@linkplain Environment} is shared among different entity stores.
*/
void clear();

/**
* Executes specified executable in a new {@linkplain StoreTransaction transaction}. If transaction cannot be
* flushed after {@linkplain StoreTransactionalExecutable#execute(StoreTransaction)} is called, the executable
Expand Down Expand Up @@ -110,12 +101,6 @@ public interface PersistentEntityStore extends EntityStore, Backupable {
*/
<T> T computeInReadonlyTransaction(@NotNull StoreTransactionalComputable<T> computable);

/**
* @return {@linkplain BlobVault} which is used for managing blobs
*/
@NotNull
BlobVault getBlobVault();

/**
* Registers custom property type extending {@linkplain Comparable}. Values of specified {@code clazz} can be
* passed then to {@linkplain Entity#setProperty(String, Comparable)}. {@code ComparableBinding} describes the
Expand Down Expand Up @@ -170,50 +155,6 @@ void registerCustomPropertyType(@NotNull final StoreTransaction txn,
*/
void renameEntityType(@NotNull String oldEntityTypeName, @NotNull String newEntityTypeName);

/**
* @return The number of available bytes on the partition where the database is located
*/
long getUsableSpace();

/**
* Returns {@linkplain PersistentEntityStoreConfig} instance used during creation of the
* {@code PersistentEntityStore}. If no config was specified and no setting was mutated, then returned config has
* the same settings as {@linkplain PersistentEntityStoreConfig#DEFAULT}.
*
* @return {@linkplain PersistentEntityStoreConfig} instance
*/
@NotNull
PersistentEntityStoreConfig getConfig();

/**
* {@linkplain MultiThreadDelegatingJobProcessor Job processor} used by the {@code PersistentEntityStore} for
* background caching activities. Allows to indirectly estimate load of the {@code PersistentEntityStore}. E.g.,
* if it has numerous {@linkplain JobProcessor#pendingJobs() pending caching jobs} (say, thousands) then most
* likely caching doesn't work well and the {@code PersistentEntityStore} looks overloaded.
*
* @return job processor used for background caching activities
*/
@NotNull
MultiThreadDelegatingJobProcessor getAsyncProcessor();

/**
* {@linkplain MultiThreadDelegatingJobProcessor Job processor} used by the {@code PersistentEntityStore} for
* background counts (inconsistent) caching activities. Allows to indirectly estimate load of the {@code PersistentEntityStore}. E.g.,
* if it has numerous {@linkplain JobProcessor#pendingJobs() pending caching jobs} (say, thousands) then most
* likely caching doesn't work well and the {@code PersistentEntityStore} looks overloaded.
*
* @return job processor used for background caching activities
*/
@NotNull
MultiThreadDelegatingJobProcessor getCountsAsyncProcessor();

/**
* @return statistics of this {@code PersistentEntityStore} instance
* @see PersistentEntityStoreConfig#GATHER_STATISTICS
*/
@NotNull
Statistics getStatistics();

@NotNull
StoreTransaction getAndCheckCurrentTransaction();
}

0 comments on commit bb2ac34

Please sign in to comment.