├── .github ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── gradle_21.yml ├── .gitignore ├── LICENSE.txt ├── README.md ├── benchmarks ├── LICENSE.txt ├── build.gradle.kts ├── readme.md └── src │ └── jmh │ ├── java │ └── jetbrains │ │ └── exodus │ │ └── benchmark │ │ ├── TokyoCabinetBenchmark.java │ │ ├── crypto │ │ └── JMHStreamCipherBenchmarks.java │ │ ├── dataStructures │ │ ├── JMHConcurrentObjectCacheBenchmark.java │ │ ├── JMHHashMapBenchmark.java │ │ ├── JMHJavaUtilHashMapBenchmark.java │ │ ├── JMHObjectCacheBenchmark.java │ │ ├── JMHSmallHashMapBenchmark.java │ │ └── persistent │ │ │ ├── JMHPersistentLongSetBenchmark.java │ │ │ ├── JMHPersistentLongSetFillBenchmark.java │ │ │ └── JMHPersistentLongSetIterationBenchmark.java │ │ ├── env │ │ ├── JMHEnvBenchmarkBase.java │ │ └── tokyo │ │ │ ├── JMHEnvTokyoCabinetBenchmarkBase.java │ │ │ ├── JMHEnvTokyoCabinetReadBenchmark.java │ │ │ ├── JMHEnvTokyoCabinetWriteBenchmark.java │ │ │ ├── JMHEnvWithPrefixingTokyoCabinetReadBenchmark.java │ │ │ └── JMHEnvWithPrefixingTokyoCabinetWriteBenchmark.java │ │ ├── query │ │ └── InMemorySortBenchmark.java │ │ └── util │ │ ├── JMHStringBindingTest.java │ │ ├── JMHStringInternerBenchmark.java │ │ └── JMHStringInternerMacroBenchmark.java │ └── kotlin │ └── jetbrains │ └── exodus │ └── benchmark │ └── query │ └── InMemorySortBenchmarkBase.kt ├── build.gradle.kts ├── compress ├── LICENSE.txt ├── build.gradle.kts └── src │ ├── main │ └── java │ │ └── jetbrains │ │ └── exodus │ │ └── util │ │ └── CompressBackupUtil.java │ └── test │ └── java │ └── jetbrains │ └── exodus │ └── util │ └── CompressBackupUtilTest.java ├── crypto ├── LICENSE.txt ├── build.gradle.kts ├── readme.md └── src │ ├── main │ ├── kotlin │ │ └── jetbrains │ │ │ └── exodus │ │ │ └── crypto │ │ │ ├── InitializationVektor.kt │ │ │ ├── convert │ │ │ ├── ArchiveBackupableFactory.kt │ │ │ ├── ArchiveEncryptListenerFactory.kt │ │ │ ├── DirectoryEncryptListenerFactory.kt │ │ │ ├── EncryptListener.kt │ │ │ ├── Protocol.kt │ │ │ ├── ScytaleEngine.kt │ │ │ └── Util.kt │ │ │ └── streamciphers │ │ │ ├── ChaChaStreamCipherProvider.kt │ │ │ ├── JBChaChaStreamCipherProvider.kt │ │ │ ├── KeyAwareStreamCipherProvider.kt │ │ │ └── Salsa20StreamCipherProvider.kt │ └── resources │ │ └── META-INF │ │ └── services │ │ └── jetbrains.exodus.crypto.StreamCipherProvider │ └── test │ └── kotlin │ └── jetbrains │ └── exodus │ └── crypto │ ├── ChaChaEqualityTest.kt │ ├── ChaChaStreamCipherTest.kt │ ├── Salsa20StreamCipherTest.kt │ └── convert │ └── AsyncEncryptionTest.kt ├── entity-store ├── LICENSE.txt ├── build.gradle.kts ├── readme.md └── src │ ├── main │ ├── java │ │ └── jetbrains │ │ │ └── exodus │ │ │ └── entitystore │ │ │ ├── EmptyId.java │ │ │ ├── EntityIterableHandle.java │ │ │ ├── EntityIterableType.java │ │ │ ├── EntityStoreSharedAsyncProcessor.java │ │ │ ├── Explainer.java │ │ │ ├── FileSystemBlobVault.java │ │ │ ├── FileSystemBlobVaultOld.java │ │ │ ├── FlushLog.java │ │ │ ├── InsertConstraintException.java │ │ │ ├── OpenTablesCache.java │ │ │ ├── PersistentEntity.java │ │ │ ├── PersistentEntityId.java │ │ │ ├── PersistentEntityStoreBackupStrategy.java │ │ │ ├── PersistentEntityStoreImpl.java │ │ │ ├── PersistentEntityStoreStatistics.java │ │ │ ├── PersistentEntityStores.java │ │ │ ├── PersistentSequence.java │ │ │ ├── PersistentSequenceBlobHandleGenerator.java │ │ │ ├── PersistentSequentialDictionary.java │ │ │ ├── PersistentStoreTransaction.java │ │ │ ├── PersistentStoreTransactionSnapshot.java │ │ │ ├── PhantomLinkException.java │ │ │ ├── ReadOnlyPersistentEntity.java │ │ │ ├── ReadonlyPersistentStoreTransaction.java │ │ │ ├── Settings.java │ │ │ ├── StoreNamingRules.java │ │ │ ├── TmpBlobHandle.java │ │ │ ├── TxnProvider.java │ │ │ ├── UnexpectedBlobVaultVersionException.java │ │ │ ├── UniqueKeyIndexException.java │ │ │ ├── Updatable.java │ │ │ ├── iterate │ │ │ ├── CachedInstanceIterable.java │ │ │ ├── ConstantEntityIterableHandle.java │ │ │ ├── DistinctIterable.java │ │ │ ├── EntitiesWithBlobIterable.java │ │ │ ├── EntitiesWithLinkIterable.java │ │ │ ├── EntitiesWithLinkSortedIterable.java │ │ │ ├── EntitiesWithPropertyIterable.java │ │ │ ├── EntityAddedOrDeletedHandleChecker.java │ │ │ ├── EntityFromLinkSetIterable.java │ │ │ ├── EntityFromLinkSetIteratorBase.java │ │ │ ├── EntityFromLinksIterable.java │ │ │ ├── EntityIdArrayCachedInstanceIterableFactory.java │ │ │ ├── EntityIdArrayWithSetIterableWrapper.java │ │ │ ├── EntityIdArrayWithSetIteratorWrapper.java │ │ │ ├── EntityIterableBase.java │ │ │ ├── EntityIterableDecoratorBase.java │ │ │ ├── EntityIterableHandleBase.java │ │ │ ├── EntityIterableHandleDecorator.java │ │ │ ├── EntityIterableInstantiator.java │ │ │ ├── EntityIteratorBase.java │ │ │ ├── EntityIteratorFixingDecorator.java │ │ │ ├── EntityIteratorWithPropId.java │ │ │ ├── EntityLinksIterableBase.java │ │ │ ├── EntityReverseIterable.java │ │ │ ├── EntityTypeFilteredIterator.java │ │ │ ├── ExcludeNullIterableDecorator.java │ │ │ ├── FilterEntityTypeIterable.java │ │ │ ├── HandleChecker.java │ │ │ ├── IdFilter.java │ │ │ ├── LinkChangedHandleChecker.java │ │ │ ├── MergeSortedIterable.java │ │ │ ├── MergeSortedIterableWithValueGetter.java │ │ │ ├── NonDisposableEntityIterator.java │ │ │ ├── PropertiesIterable.java │ │ │ ├── PropertyChangedHandleChecker.java │ │ │ ├── PropertyRangeIterable.java │ │ │ ├── PropertyValueIterator.java │ │ │ ├── SingleEntityIterable.java │ │ │ ├── SingleKeyCursorCounter.java │ │ │ ├── SingleKeyCursorIsEmptyChecker.java │ │ │ ├── SkipEntityIterable.java │ │ │ ├── SortIndirectIterable.java │ │ │ ├── SortIterable.java │ │ │ ├── SortResultIterable.java │ │ │ ├── SourceMappingIterator.java │ │ │ ├── TakeEntityIterable.java │ │ │ ├── TxnGetterStrategy.java │ │ │ ├── UpdatableCachedInstanceIterable.java │ │ │ ├── UpdatableEntityIdSortedSetCachedInstanceIterable.java │ │ │ ├── binop │ │ │ │ ├── AddNullDecoratorIterable.java │ │ │ │ ├── BinaryOperatorEntityIterable.java │ │ │ │ └── ConcatenationIterable.java │ │ │ └── cached │ │ │ │ ├── EmptyCachedInstanceIterable.java │ │ │ │ ├── MultiTypeSortedEntityIdArrayCachedInstanceIterable.java │ │ │ │ ├── MultiTypeUnsortedEntityIdArrayCachedInstanceIterable.java │ │ │ │ ├── SingleTypeSortedEntityIdArrayCachedInstanceIterable.java │ │ │ │ ├── SingleTypeSortedSetEntityIdCachedInstanceIterable.java │ │ │ │ ├── SingleTypeUnsortedEntityIdArrayCachedInstanceIterable.java │ │ │ │ └── iterator │ │ │ │ ├── EntityIdArrayIteratorMultiTypeIdPacked.java │ │ │ │ ├── EntityIdArrayIteratorMultiTypeIdUnpacked.java │ │ │ │ ├── EntityIdArrayIteratorNullTypeId.java │ │ │ │ ├── OrderedEntityIdCollectionIterator.java │ │ │ │ ├── ReverseEntityIdArrayIteratorMultiTypeIdPacked.java │ │ │ │ ├── ReverseEntityIdArrayIteratorMultiTypeIdUnpacked.java │ │ │ │ ├── ReverseEntityIdArrayIteratorNullTypeId.java │ │ │ │ └── ReverseOrderedEntityIdCollectionIterator.java │ │ │ ├── management │ │ │ ├── EntityStoreConfig.java │ │ │ ├── EntityStoreConfigMBean.java │ │ │ ├── EntityStoreStatistics.java │ │ │ └── EntityStoreStatisticsMBean.java │ │ │ ├── tables │ │ │ ├── BitmapTable.java │ │ │ ├── BlobsTable.java │ │ │ ├── EntityIdBinding.java │ │ │ ├── LinkValue.java │ │ │ ├── LinksTable.java │ │ │ ├── PropertiesTable.java │ │ │ ├── PropertyKey.java │ │ │ ├── PropertyTypes.java │ │ │ ├── PropertyValue.java │ │ │ ├── SingleColumnTable.java │ │ │ ├── Table.java │ │ │ └── TwoColumnTable.java │ │ │ └── util │ │ │ ├── BackupUtil.java │ │ │ ├── ImmutableSingleTypeEntityIdBitSet.java │ │ │ ├── ImmutableSingleTypeEntityIdCollection.java │ │ │ ├── IntArrayListSpinAllocator.java │ │ │ ├── LongArrayListSpinAllocator.java │ │ │ ├── MultiTypeEntityIdSet.java │ │ │ └── SingleTypeEntityIdSet.java │ └── kotlin │ │ └── jetbrains │ │ └── exodus │ │ ├── crypto │ │ └── EncryptedBlobVault.kt │ │ └── entitystore │ │ ├── CachedBlobLengths.kt │ │ ├── DummyBlobVault.kt │ │ ├── EntityIdCache.kt │ │ ├── EntityIterableCache.kt │ │ ├── EntityIterableCacheAdapter.kt │ │ ├── EntityIterableCacheAdapterMutable.kt │ │ ├── EntityIterableCacheReverseIndex.kt │ │ ├── EntityIterableCacheStatistics.kt │ │ ├── PersistentEntityStoreRefactorings.kt │ │ ├── PersistentEntityStoreSettingsListener.kt │ │ ├── iterate │ │ ├── EntitiesOfTypeIterable.kt │ │ ├── EntitiesOfTypeRangeIterable.kt │ │ ├── EntitiesWithCertainLinkIterable.kt │ │ ├── EntityToLinksIterable.kt │ │ ├── FieldIndexIterator.kt │ │ ├── FilterEntitiesWithCertainLinkIterable.kt │ │ ├── FilterLinksIterable.kt │ │ ├── PropertyContainsValueEntityIterable.kt │ │ ├── PropertyRangeOrValueIterableBase.kt │ │ ├── PropertyValueIterable.kt │ │ ├── SelectDistinctIterable.kt │ │ ├── SelectManyIterable.kt │ │ ├── UpdatablePropertiesCachedInstanceIterable.kt │ │ ├── binop │ │ │ ├── IntersectionIterable.kt │ │ │ ├── MinusIterable.kt │ │ │ ├── SortedIterator.kt │ │ │ └── UnionIterable.kt │ │ └── util │ │ │ └── LongArrayIterator.kt │ │ ├── tables │ │ └── FieldIndex.kt │ │ └── util │ │ ├── EmptyEntityIdSet.kt │ │ ├── EntityIdSetFactory.kt │ │ └── ImmutableEmptyEntityIdSet.kt │ └── test │ ├── java │ └── jetbrains │ │ └── exodus │ │ ├── entitystore │ │ ├── AbortTest.java │ │ ├── BinaryOperatorsTests.java │ │ ├── ConflictTest.java │ │ ├── EntityFromLinkSetTests.java │ │ ├── EntityIterableHandleTests.java │ │ ├── EntitySnapshotTests.java │ │ ├── EntityStoreTestBase.java │ │ ├── FailoverForkLongTests.java │ │ ├── FailoverForkTests.java │ │ ├── PersistentEntityStoreRefactoringsTests.java │ │ ├── PropertyCustomTypePersistenceTest.java │ │ ├── PropertyCustomTypeTests.java │ │ ├── ReplayTest.java │ │ ├── SmallLogStressTests.java │ │ ├── StoreArtifacts.java │ │ ├── StoreArtifactsPolicy.java │ │ ├── StoreTransactionTests.java │ │ ├── StressTests.java │ │ ├── TestBase.java │ │ ├── TestReplayTest.java │ │ ├── TestTransactionReplayPersistentEntityStoreImpl.java │ │ ├── custom │ │ │ ├── ComparablePair.java │ │ │ └── ComparablePairBinding.java │ │ ├── iterate │ │ │ ├── CornerCaseTests.java │ │ │ ├── EntityIdArrayCachedInstanceIterableTests.java │ │ │ ├── EntityIterableHandleMergeIdsTest.java │ │ │ ├── EntityLinksTests.java │ │ │ ├── FindTests.java │ │ │ └── HumanReadablePresentationTests.java │ │ └── processRunners │ │ │ ├── LongProcessRunner.java │ │ │ └── ProcessRunner.java │ │ └── util │ │ ├── ForkSupportIO.java │ │ ├── ForkSupportIOTest.java │ │ ├── ForkedLogic.java │ │ ├── ForkedProcessRunner.java │ │ ├── IStreamer.java │ │ ├── ProcessKiller.java │ │ ├── Streamer.java │ │ └── WindowsProcessKiller.java │ ├── kotlin │ └── jetbrains │ │ └── exodus │ │ ├── entitystore │ │ ├── BackupTests.kt │ │ ├── BlobVaultTests.kt │ │ ├── EntityBlobTests.kt │ │ ├── EntityIdSetTest.kt │ │ ├── EntityIterableCacheAdapterTest.kt │ │ ├── EntityIterableCacheReverseIndexTest.kt │ │ ├── EntityIterableCacheTest.kt │ │ ├── EntityIterableHandleIdentityTest.kt │ │ ├── EntityStoreCreationTests.kt │ │ ├── EntityTests.kt │ │ ├── IssueTrackerTestCase.kt │ │ ├── PrimitiveIterableTests.kt │ │ ├── SortIndirectIterableTest.kt │ │ ├── TestData.kt │ │ ├── TestOrdering.kt │ │ └── iterate │ │ │ ├── EntityIterableTests.kt │ │ │ ├── SortTests.kt │ │ │ └── StickyObjectTest.kt │ │ └── testutil │ │ ├── TestRandomUtils.kt │ │ └── TimeProfiler.kt │ └── resources │ ├── pskill.exe │ └── testXD_362.data ├── environment-crash-tests ├── build.gradle.kts └── src │ └── test │ └── java │ └── jetbrains │ └── exodus │ └── env │ └── CrashTest.java ├── environment ├── LICENSE.txt ├── build.gradle.kts ├── readme.md └── src │ ├── main │ ├── java │ │ └── jetbrains │ │ │ └── exodus │ │ │ ├── backup │ │ │ └── FileDescriptorInputStream.java │ │ │ ├── env │ │ │ ├── ContextualEnvironmentImpl.java │ │ │ ├── ContextualStoreImpl.java │ │ │ ├── ContextualTemporaryEmptyStore.java │ │ │ ├── CursorImpl.java │ │ │ ├── DatabaseRoot.java │ │ │ ├── EnvironmentBackupStrategyImpl.java │ │ │ ├── EnvironmentImpl.java │ │ │ ├── EnvironmentStatistics.java │ │ │ ├── MetaTree.java │ │ │ ├── MetaTreeImpl.java │ │ │ ├── MetaTreePrototype.java │ │ │ ├── ReadWriteTransaction.java │ │ │ ├── ReadonlyTransaction.java │ │ │ ├── ReentrantTransactionDispatcher.java │ │ │ ├── StoreGetCache.java │ │ │ ├── StoreImpl.java │ │ │ ├── TemporaryEmptyStore.java │ │ │ ├── TransactionAcquireTimeoutException.java │ │ │ ├── TransactionBase.java │ │ │ ├── TransactionFinishedException.java │ │ │ └── TransactionSet.java │ │ │ ├── io │ │ │ ├── AbstractDataWriter.java │ │ │ ├── AsyncFileDataReaderWriterProvider.java │ │ │ ├── AsyncFileDataWriter.java │ │ │ ├── SharedMappedByteBuffer.java │ │ │ ├── SharedMappedFilesCache.java │ │ │ └── SharedOpenFilesCache.java │ │ │ ├── log │ │ │ ├── ArrayByteIterableWithAddress.java │ │ │ ├── BackupMetadata.java │ │ │ ├── BlockByteIterator.java │ │ │ ├── BlockDataIterator.java │ │ │ ├── BlockNotFoundException.java │ │ │ ├── BufferedDataWriter.java │ │ │ ├── ByteIterableWithAddress.java │ │ │ ├── ByteIteratorWithAddress.java │ │ │ ├── CacheDataProvider.java │ │ │ ├── CompressedUnsignedLongByteIterable.java │ │ │ ├── DataCorruptionException.java │ │ │ ├── DataIterator.java │ │ │ ├── HashCodeLoggable.java │ │ │ ├── LogAwareFixedLengthByteIterable.java │ │ │ ├── LogConfig.java │ │ │ ├── LogTestConfig.java │ │ │ ├── LogTip.java │ │ │ ├── LogUtil.java │ │ │ ├── Loggable.java │ │ │ ├── LoggableIterator.java │ │ │ ├── MultiPageByteIterableWithAddress.java │ │ │ ├── MultiPageLoggable.java │ │ │ ├── NullLoggable.java │ │ │ ├── RandomAccessLoggable.java │ │ │ ├── ReadBytesListener.java │ │ │ ├── RemoveFileListener.java │ │ │ ├── SingleByteIterable.java │ │ │ ├── SinglePageLoggable.java │ │ │ ├── StartupMetadata.java │ │ │ └── TooBigLoggableException.java │ │ │ └── tree │ │ │ ├── Dumpable.java │ │ │ ├── ExpiredLoggableCollection.java │ │ │ ├── INode.java │ │ │ ├── ITree.java │ │ │ ├── ITreeCursor.java │ │ │ ├── ITreeCursorMutable.java │ │ │ ├── ITreeMutable.java │ │ │ ├── LongIterator.java │ │ │ ├── MutableTreeRoot.java │ │ │ ├── TreeCursor.java │ │ │ ├── TreeCursorMutable.java │ │ │ ├── TreeMetaInfo.java │ │ │ ├── TreeTraverser.java │ │ │ ├── btree │ │ │ ├── AddressIterator.java │ │ │ ├── BTree.java │ │ │ ├── BTreeBalancePolicy.java │ │ │ ├── BTreeBase.java │ │ │ ├── BTreeCursorDup.java │ │ │ ├── BTreeCursorDupMutable.java │ │ │ ├── BTreeDup.java │ │ │ ├── BTreeDupMutable.java │ │ │ ├── BTreeEmpty.java │ │ │ ├── BTreeMetaInfo.java │ │ │ ├── BTreeMutable.java │ │ │ ├── BTreeMutatingTraverser.java │ │ │ ├── BTreeMutatingTraverserDup.java │ │ │ ├── BTreeReclaimTraverser.java │ │ │ ├── BTreeTraverser.java │ │ │ ├── BTreeTraverserDup.java │ │ │ ├── BaseLeafNode.java │ │ │ ├── BaseLeafNodeMutable.java │ │ │ ├── BasePage.java │ │ │ ├── BasePageImmutable.java │ │ │ ├── BasePageMutable.java │ │ │ ├── BottomPage.java │ │ │ ├── BottomPageMutable.java │ │ │ ├── DupLeafNodeMutable.java │ │ │ ├── ILeafNode.java │ │ │ ├── ILeafNodeMutable.java │ │ │ ├── InternalPage.java │ │ │ ├── InternalPageMutable.java │ │ │ ├── LeafNode.java │ │ │ ├── LeafNodeDup.java │ │ │ ├── LeafNodeDupMutable.java │ │ │ ├── LeafNodeKV.java │ │ │ ├── LeafNodeMutable.java │ │ │ └── TreePos.java │ │ │ └── patricia │ │ │ ├── AddressIterator.java │ │ │ ├── ChildReference.java │ │ │ ├── ChildReferenceBase.java │ │ │ ├── ChildReferenceMutable.java │ │ │ ├── ChildReferenceSet.java │ │ │ ├── ChildReferenceTransient.java │ │ │ ├── EscapingByteIterable.java │ │ │ ├── ImmutableNode.java │ │ │ ├── MutableNodeSaveContext.java │ │ │ ├── NodeBase.java │ │ │ ├── PatriciaCursorDecorator.java │ │ │ ├── PatriciaMetaInfo.java │ │ │ ├── PatriciaReclaimActualTraverser.java │ │ │ ├── PatriciaReclaimSourceTraverser.java │ │ │ ├── PatriciaTraverser.java │ │ │ ├── PatriciaTree.java │ │ │ ├── PatriciaTreeBase.java │ │ │ ├── PatriciaTreeDecorator.java │ │ │ ├── PatriciaTreeEmpty.java │ │ │ ├── PatriciaTreeForReclaim.java │ │ │ ├── PatriciaTreeWithDuplicates.java │ │ │ ├── PatriciaTreeWithDuplicatesMutable.java │ │ │ ├── SinglePageImmutableNode.java │ │ │ └── TreeAwareNodeDecorator.java │ ├── kotlin │ │ └── jetbrains │ │ │ └── exodus │ │ │ ├── crypto │ │ │ └── EnvKrypt.kt │ │ │ ├── debug │ │ │ ├── Misc.kt │ │ │ ├── StackTrace.kt │ │ │ └── TxnProfiler.kt │ │ │ ├── env │ │ │ ├── BitmapImpl.kt │ │ │ ├── BitmapIterator.kt │ │ │ ├── ContextualBitmapImpl.kt │ │ │ ├── CopyEnvironment.kt │ │ │ ├── Environments.kt │ │ │ ├── StuckTransactionMonitor.kt │ │ │ ├── Unsafe.kt │ │ │ └── management │ │ │ │ ├── BackupController.kt │ │ │ │ ├── BackupControllerMBean.kt │ │ │ │ ├── DatabaseProfiler.kt │ │ │ │ ├── DatabaseProfilerMBean.kt │ │ │ │ ├── EnvironmentConfig.kt │ │ │ │ ├── EnvironmentConfigMBean.kt │ │ │ │ ├── EnvironmentConfigWithOperations.kt │ │ │ │ ├── EnvironmentStatistics.kt │ │ │ │ └── EnvironmentStatisticsMBean.kt │ │ │ ├── gc │ │ │ ├── BackgroundCleaner.kt │ │ │ ├── BackgroundCleaningJob.kt │ │ │ ├── CleanEntireLogJob.kt │ │ │ ├── ComputeUtilizationFromScratchJob.kt │ │ │ ├── GarbageCollector.kt │ │ │ ├── GcJob.kt │ │ │ ├── PeriodicGc.kt │ │ │ └── UtilizationProfile.kt │ │ │ ├── io │ │ │ ├── FileDataReader.kt │ │ │ ├── LockingManager.kt │ │ │ ├── WatchingFileDataWriter.kt │ │ │ └── inMemory │ │ │ │ ├── Memory.kt │ │ │ │ ├── MemoryDataReader.kt │ │ │ │ ├── MemoryDataReaderWriterProvider.kt │ │ │ │ └── MemoryDataWriter.kt │ │ │ ├── log │ │ │ ├── AbstractBlockListener.kt │ │ │ ├── BlockListener.kt │ │ │ ├── BlockSet.kt │ │ │ ├── Log.kt │ │ │ ├── LogCache.kt │ │ │ ├── LogWarmup.kt │ │ │ ├── SeparateLogCache.kt │ │ │ └── SharedLogCache.kt │ │ │ └── tree │ │ │ └── patricia │ │ │ ├── MultiPageImmutableNode.kt │ │ │ ├── MutableNode.kt │ │ │ ├── MutableRoot.kt │ │ │ ├── NodeChildren.kt │ │ │ └── PatriciaTreeMutable.kt │ └── resources │ │ └── META-INF │ │ └── services │ │ └── jetbrains.exodus.io.DataReaderWriterProvider │ └── test │ ├── java │ └── jetbrains │ │ └── exodus │ │ ├── env │ │ ├── EnvironmentLockTest.java │ │ ├── EnvironmentTest.java │ │ ├── EnvironmentTestInMemory.java │ │ ├── EnvironmentTestsBase.java │ │ ├── RecoveryClassLoaderTest.java │ │ ├── ReentrantTransactionDispatcherTest.java │ │ └── TransactionTest.java │ │ ├── log │ │ ├── LogInMemoryTests.java │ │ ├── LogLockingTests.java │ │ ├── LogTests.java │ │ ├── LogTestsBase.java │ │ ├── LogUtilTests.java │ │ ├── LoggableTests.java │ │ └── TestLoggable.java │ │ └── tree │ │ ├── CursorTestBase.java │ │ ├── StringKVNode.java │ │ ├── TreeAddressIteratorTest.java │ │ ├── TreeBaseTest.java │ │ ├── TreeCursorConcurrentModificationTest.java │ │ ├── TreeCursorDuplicatesTest.java │ │ ├── TreeCursorNoDuplicatesTest.java │ │ ├── TreeDeleteTest.java │ │ ├── TreePutTest.java │ │ ├── btree │ │ ├── BTreeAddressIteratorTest.java │ │ ├── BTreeCursorConcurrentCursorModificationTest.java │ │ ├── BTreeCursorConcurrentModificationTest.java │ │ ├── BTreeCursorDeleteTest.java │ │ ├── BTreeCursorDupConcurrentCursorModificationTest.java │ │ ├── BTreeCursorDupConcurrentModificationTest.java │ │ ├── BTreeCursorDuplicatesTest.java │ │ ├── BTreeCursorNoDuplicatesTest.java │ │ ├── BTreeDeleteCommonTest.java │ │ ├── BTreeDeleteSpecificTest.java │ │ ├── BTreeDuplicatesExpiredAddressesTest.java │ │ ├── BTreeLeafNodeTest.java │ │ ├── BTreeNoDuplicatesExpiredAddressesTest.java │ │ ├── BTreePutCommonTest.java │ │ ├── BTreePutSpecificTest.java │ │ ├── BTreeReclaimSpecialTest.java │ │ ├── BTreeReclaimTest.java │ │ ├── BTreeSimpleTest.java │ │ ├── BTreeSpecificCursorDuplicatesTest.java │ │ ├── BTreeSpecificCursorNoDuplicatesTest.java │ │ ├── BTreeStructureIdTest.java │ │ ├── BTreeStructureTest.java │ │ ├── BTreeTest.java │ │ └── BTreeTestBase.java │ │ └── patricia │ │ ├── PatriciaAddressIteratorTest.java │ │ ├── PatriciaCursorConcurrentCursorModificationTest.java │ │ ├── PatriciaCursorConcurrentModificationTest.java │ │ ├── PatriciaCursorDuplicatesTest.java │ │ ├── PatriciaCursorNoDuplicatesTest.java │ │ ├── PatriciaDeleteCommonTest.java │ │ ├── PatriciaPutCommonTest.java │ │ ├── PatriciaReclaimTest.java │ │ ├── PatriciaTestBase.java │ │ └── PatriciaTreeAddressIteratorTest.java │ └── kotlin │ └── jetbrains │ └── exodus │ ├── crypto │ └── InvalidCipherParametersTest.kt │ ├── env │ ├── BitmapImplTest.kt │ ├── BitmapIteratorTest.kt │ ├── ContextualBitmapImplTest.kt │ ├── EnvironmentConfigTest.kt │ ├── OutOfDiskSpaceInMemoryTest.kt │ ├── OutOfDiskSpaceTest.kt │ ├── StoreTest.kt │ ├── XodusConcurrentCursorTest.kt │ └── management │ │ ├── DatabaseProfilerMBeanTest.kt │ │ ├── EnvironmentConfigMBeanTest.kt │ │ └── EnvironmentStatisticsMBeanTest.kt │ ├── gc │ ├── GarbageCollectorInterleavingTest.kt │ ├── GarbageCollectorInterleavingTestPrefixing.kt │ ├── GarbageCollectorLowCacheTest.kt │ ├── GarbageCollectorLowCacheTestPrefixing.kt │ ├── GarbageCollectorTest.kt │ ├── GarbageCollectorTestInMemory.kt │ ├── GarbageCollectorTestPrefixing.kt │ └── GarbageCollectorTestPrefixingInMemory.kt │ └── io │ └── SharedMappedByteBufferTest.kt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── images ├── key.gpg ├── license └── copyright.ftl ├── lucene-directory-v2 ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── jetbrains │ │ │ └── exodus │ │ │ └── lucene2 │ │ │ ├── DirUtil.java │ │ │ └── XodusDirectory.java │ ├── kotlin │ │ └── jetbrains │ │ │ └── exodus │ │ │ └── lucene2 │ │ │ └── codecs │ │ │ └── Lucene87CodecWithNoFieldCompression.kt │ └── resources │ │ └── META-INF │ │ └── services │ │ └── org.apache.lucene.codecs.Codec │ └── test │ ├── java │ └── jetbrains │ │ └── exodus │ │ └── lucene2 │ │ ├── XodusDirectoryEncryptedTest.java │ │ ├── XodusDirectoryNotEncryptedTest.java │ │ └── XodusThreadFilter.java │ └── kotlin │ └── jetbrains │ └── exodus │ └── lucene2 │ ├── XodusLuceneTests.kt │ └── XodusLuceneTestsBase.kt ├── openAPI ├── LICENSE.txt ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── jetbrains │ │ │ └── exodus │ │ │ ├── AbstractConfig.java │ │ │ ├── ArrayByteIterable.java │ │ │ ├── ByteBufferByteIterable.java │ │ │ ├── ByteIterable.java │ │ │ ├── ByteIterableBase.java │ │ │ ├── ByteIterator.java │ │ │ ├── CompoundByteIterable.java │ │ │ ├── CompoundByteIteratorBase.java │ │ │ ├── ConfigSettingChangeListener.java │ │ │ ├── ConfigurationStrategy.java │ │ │ ├── ExodusException.java │ │ │ ├── FileByteIterable.java │ │ │ ├── FixedLengthByteIterable.java │ │ │ ├── InvalidSettingException.java │ │ │ ├── OutOfDiskSpaceException.java │ │ │ ├── backup │ │ │ ├── BackupBean.java │ │ │ ├── BackupStrategy.java │ │ │ ├── Backupable.java │ │ │ └── VirtualFileDescriptor.java │ │ │ ├── bindings │ │ │ ├── BindingUtils.java │ │ │ ├── BooleanBinding.java │ │ │ ├── ByteBinding.java │ │ │ ├── ComparableBinding.java │ │ │ ├── ComparableSet.java │ │ │ ├── ComparableSetBinding.java │ │ │ ├── ComparableValueType.java │ │ │ ├── CompressedUnsignedLongArrayByteIterable.java │ │ │ ├── DoubleBinding.java │ │ │ ├── FloatBinding.java │ │ │ ├── IntegerBinding.java │ │ │ ├── LongBinding.java │ │ │ ├── ShortBinding.java │ │ │ ├── SignedDoubleBinding.java │ │ │ ├── SignedFloatBinding.java │ │ │ └── StringBinding.java │ │ │ ├── crypto │ │ │ ├── ExodusCryptoException.java │ │ │ ├── InvalidCipherParametersException.java │ │ │ ├── StreamCipher.java │ │ │ ├── StreamCipherInputStream.java │ │ │ ├── StreamCipherOutputStream.java │ │ │ └── StreamCipherProvider.java │ │ │ ├── entitystore │ │ │ ├── BlobHandleGenerator.java │ │ │ ├── BlobVault.java │ │ │ ├── BlobVaultItem.java │ │ │ ├── ComparableGetter.java │ │ │ ├── DiskBasedBlobVault.java │ │ │ ├── Entity.java │ │ │ ├── EntityId.java │ │ │ ├── EntityIterable.java │ │ │ ├── EntityIterator.java │ │ │ ├── EntityRemovedInDatabaseException.java │ │ │ ├── EntityStore.java │ │ │ ├── EntityStoreException.java │ │ │ ├── FileBasedBlobValueItem.java │ │ │ ├── MetaServer.java │ │ │ ├── PersistentEntityStore.java │ │ │ ├── PersistentEntityStoreConfig.java │ │ │ ├── QueryCancellingPolicy.java │ │ │ ├── Selector.java │ │ │ ├── Sequence.java │ │ │ ├── StoreTransaction.java │ │ │ ├── StoreTransactionalComputable.java │ │ │ ├── StoreTransactionalExecutable.java │ │ │ ├── VaultSizeFunctions.java │ │ │ └── iterate │ │ │ │ ├── EntityIdCollection.java │ │ │ │ ├── EntityIdSet.java │ │ │ │ ├── OrderedEntityIdCollection.java │ │ │ │ └── SortedEntityIdSet.java │ │ │ ├── env │ │ │ ├── Bitmap.java │ │ │ ├── ContextualBitmap.java │ │ │ ├── ContextualEnvironment.java │ │ │ ├── ContextualStore.java │ │ │ ├── Cursor.java │ │ │ ├── Environment.java │ │ │ ├── EnvironmentClosedException.java │ │ │ ├── EnvironmentConfig.java │ │ │ ├── ReadonlyTransactionException.java │ │ │ ├── Store.java │ │ │ ├── StoreConfig.java │ │ │ ├── Transaction.java │ │ │ ├── TransactionalComputable.java │ │ │ └── TransactionalExecutable.java │ │ │ ├── io │ │ │ ├── Block.java │ │ │ ├── DataReader.java │ │ │ ├── DataReaderWriterProvider.java │ │ │ ├── DataWriter.java │ │ │ ├── RemoveBlockType.java │ │ │ └── StorageTypeNotAllowedException.java │ │ │ ├── management │ │ │ ├── Statistics.java │ │ │ └── StatisticsItem.java │ │ │ └── util │ │ │ └── LightOutputStream.java │ └── kotlin │ │ └── jetbrains │ │ └── exodus │ │ ├── crypto │ │ └── Krypt.kt │ │ ├── entitystore │ │ ├── BlobStringsCache.kt │ │ ├── EntityStoreEx.kt │ │ └── replication │ │ │ └── PersistentEntityStoreReplicator.kt │ │ ├── env │ │ ├── EnvironmentEx.kt │ │ └── replication │ │ │ └── EnvironmentReplicationDelta.kt │ │ └── log │ │ └── replication │ │ └── LogReplicationDelta.kt │ └── test │ ├── java │ └── jetbrains │ │ └── exodus │ │ └── bindings │ │ └── ComparableSetBindingTest.java │ └── kotlin │ └── jetbrains │ └── exodus │ ├── FileByteIterableTest.kt │ ├── FixedLengthByteIterableTest.kt │ ├── bindings │ ├── CompressingBindingsTest.kt │ ├── DoubleBindingsTest.kt │ ├── FloatBindingsTest.kt │ └── StringBindingsTest.kt │ ├── crypto │ ├── StreamCipherTest.kt │ └── TrivialStreamCipher.kt │ ├── entitystore │ ├── PersistentEntityStoreCacheConfigTest.kt │ └── PersistentEntityStoreConfigTest.kt │ └── env │ └── EnvironmentConfigTest.kt ├── query ├── LICENSE.txt ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── jetbrains │ │ │ └── exodus │ │ │ └── query │ │ │ ├── AddNullStaticTypedEntityIterable.java │ │ │ ├── And.java │ │ │ ├── CommutativeOperator.java │ │ │ ├── ComparableGetterSort.java │ │ │ ├── Concat.java │ │ │ ├── ConversionWildcard.java │ │ │ ├── ExcludeNullStaticTypedEntityIterable.java │ │ │ ├── GenericSort.java │ │ │ ├── GetAll.java │ │ │ ├── GetLinks.java │ │ │ ├── InMemoryMergeSortIterableWithArrayList.java │ │ │ ├── InMemoryMergeSortOnInitIterable.java │ │ │ ├── InMemoryQuickSortIterable.java │ │ │ ├── InMemoryQuickSortOnInitIterable.java │ │ │ ├── InMemoryQuickSortTwoSidesIterable.java │ │ │ ├── InMemoryTimSortIterable.java │ │ │ ├── LinkEqual.java │ │ │ ├── LinkEqualToLinkNotNull.java │ │ │ ├── LinkNotNull.java │ │ │ ├── MergePropertyRanges.java │ │ │ ├── MetaDataAwareUniqueKeyIndicesEngine.java │ │ │ ├── Minus.java │ │ │ ├── NodeBase.java │ │ │ ├── NodeFactory.java │ │ │ ├── OptimizationPlan.java │ │ │ ├── OptimizationRule.java │ │ │ ├── OptimizedTreesCache.java │ │ │ ├── PropertyContains.java │ │ │ ├── PropertyEqual.java │ │ │ ├── PropertyEqualToPropertyNoNull.java │ │ │ ├── PropertyNotNull.java │ │ │ ├── PropertyRange.java │ │ │ ├── PropertyStartsWith.java │ │ │ ├── Root.java │ │ │ ├── Sort.java │ │ │ ├── SortByLinkProperty.java │ │ │ ├── SortByProperty.java │ │ │ ├── Sorts.java │ │ │ ├── StaticTypedEntityIterable.java │ │ │ ├── StaticTypedIterableDecorator.java │ │ │ ├── TreeKeepingEntityIterable.java │ │ │ ├── UnaryNode.java │ │ │ ├── UnaryNot.java │ │ │ ├── UniqueKeyIndicesEngine.java │ │ │ ├── Wildcard.java │ │ │ └── metadata │ │ │ ├── AssociationEndCardinality.java │ │ │ ├── AssociationEndMetaData.java │ │ │ ├── AssociationEndMetaDataImpl.java │ │ │ ├── AssociationEndType.java │ │ │ ├── AssociationMetaData.java │ │ │ ├── AssociationMetaDataImpl.java │ │ │ ├── AssociationType.java │ │ │ ├── EntityMetaData.java │ │ │ ├── EntityMetaDataImpl.java │ │ │ ├── Index.java │ │ │ ├── IndexField.java │ │ │ ├── IndexFieldImpl.java │ │ │ ├── IndexImpl.java │ │ │ ├── MemberMetaData.java │ │ │ ├── MetaBuilder.java │ │ │ ├── ModelMetaData.java │ │ │ ├── ModelMetaDataImpl.java │ │ │ ├── PropertyMetaData.java │ │ │ ├── PropertyMetaDataImpl.java │ │ │ ├── PropertyType.java │ │ │ └── SimplePropertyMetaDataImpl.java │ └── kotlin │ │ └── jetbrains │ │ └── exodus │ │ └── query │ │ ├── BinaryOperator.kt │ │ ├── BoundedPriorityQueue.kt │ │ ├── InMemoryBoundedHeapSortIterable.kt │ │ ├── InMemoryHeapSortIterable.kt │ │ ├── InMemoryHeapSortIterableWithValueGetter.kt │ │ ├── InMemoryKeapSortIterable.kt │ │ ├── InMemoryMergeSortIterable.kt │ │ ├── InMemoryMergeSortIterableWithValueGetter.kt │ │ ├── InMemoryQueueSortIterable.kt │ │ ├── InMemoryQueueSortIterableMixin.kt │ │ ├── IterableDecorator.kt │ │ ├── LinksEqualDecorator.kt │ │ ├── Or.kt │ │ ├── PriorityMap.kt │ │ ├── QueryEngine.kt │ │ ├── SortEngine.kt │ │ └── Utils.kt │ └── test │ ├── java │ └── jetbrains │ │ └── exodus │ │ └── query │ │ ├── QueryTreeTest.java │ │ ├── QueryUtil.java │ │ ├── UniqueKeyIndicesTest.java │ │ └── metadata │ │ └── ModelMetaDataTests.java │ └── kotlin │ └── jetbrains │ └── exodus │ └── query │ └── InMemorySortTest.kt ├── samples ├── LICENSE.txt ├── build.gradle.kts └── src │ └── main │ └── java │ └── jetbrains │ └── exodus │ ├── entitystore │ └── PersistentStoreExample.java │ └── env │ ├── EnvironmentReadWriteExample.java │ └── Users.java ├── settings.gradle.kts ├── tools ├── LICENSE.txt ├── build.gradle.kts └── src │ └── main │ ├── kotlin │ └── jetbrains │ │ └── exodus │ │ ├── Main.kt │ │ ├── crypto │ │ └── Scytale.kt │ │ ├── entityStore │ │ └── ApplyRefactorings.kt │ │ ├── env │ │ ├── CheckSpaceConsumption.kt │ │ └── Reflect.kt │ │ └── parallelbackup │ │ └── ParallelBackup.kt │ └── resources │ └── META-INF │ └── services │ └── jetbrains.exodus.io.DataReaderWriterProvider └── utils ├── LICENSE.txt ├── build.gradle.kts └── src ├── main ├── java │ └── jetbrains │ │ └── exodus │ │ ├── core │ │ ├── crypto │ │ │ └── MessageDigestUtil.java │ │ ├── dataStructures │ │ │ ├── CacheHitRateable.java │ │ │ ├── ConcurrentObjectCache.java │ │ │ ├── ConcurrentStablePriorityQueue.java │ │ │ ├── FakeObjectCache.java │ │ │ ├── IntArrayList.java │ │ │ ├── LongArrayList.java │ │ │ ├── LongIntPair.java │ │ │ ├── LongObjectBifFunction.java │ │ │ ├── LongObjectCache.java │ │ │ ├── NanoSet.java │ │ │ ├── ObjectCache.java │ │ │ ├── ObjectCacheBase.java │ │ │ ├── ObjectCacheDecorator.java │ │ │ ├── Pair.java │ │ │ ├── Priority.java │ │ │ ├── PriorityQueue.java │ │ │ ├── SoftConcurrentLongObjectCache.java │ │ │ ├── SoftConcurrentObjectCache.java │ │ │ ├── SoftLongObjectCache.java │ │ │ ├── SoftLongObjectCacheBase.java │ │ │ ├── SoftObjectCache.java │ │ │ ├── SoftObjectCacheBase.java │ │ │ ├── StablePriorityQueue.java │ │ │ ├── Stack.java │ │ │ ├── Triple.java │ │ │ ├── decorators │ │ │ │ ├── HashMapDecorator.java │ │ │ │ ├── HashSetDecorator.java │ │ │ │ ├── LinkedHashSetDecorator.java │ │ │ │ └── QueueDecorator.java │ │ │ ├── hash │ │ │ │ ├── AbstractHashMap.java │ │ │ │ ├── HashMap.java │ │ │ │ ├── HashSet.java │ │ │ │ ├── HashUtil.java │ │ │ │ ├── IntHashMap.java │ │ │ │ ├── IntHashSet.java │ │ │ │ ├── IntLinkedHashMap.java │ │ │ │ ├── LinkedHashMap.java │ │ │ │ ├── LinkedHashSet.java │ │ │ │ ├── LongHashSet.java │ │ │ │ ├── LongIterator.java │ │ │ │ ├── LongLinkedHashMap.java │ │ │ │ ├── LongLinkedHashSet.java │ │ │ │ ├── LongSet.java │ │ │ │ ├── ObjectProcedure.java │ │ │ │ ├── ObjectProcedureThrows.java │ │ │ │ └── PairProcedure.java │ │ │ └── persistent │ │ │ │ ├── AbstractPersistent23Tree.java │ │ │ │ ├── AbstractPersistentHashSet.java │ │ │ │ ├── EvictListener.java │ │ │ │ ├── Flag.java │ │ │ │ ├── LongComparable.java │ │ │ │ ├── LongMapEntry.java │ │ │ │ ├── Persistent23Tree.java │ │ │ │ ├── Persistent23TreeMap.java │ │ │ │ ├── PersistentBitTreeLongMap.java │ │ │ │ ├── PersistentHashMap.java │ │ │ │ ├── PersistentHashSet.java │ │ │ │ ├── PersistentLinkedHashMap.java │ │ │ │ ├── PersistentLong23TreeMap.java │ │ │ │ ├── PersistentLong23TreeSet.java │ │ │ │ ├── PersistentLongMap.java │ │ │ │ ├── PersistentLongSet.java │ │ │ │ ├── PersistentQueue.java │ │ │ │ ├── PersistentStack.java │ │ │ │ └── RootHolder.java │ │ └── execution │ │ │ ├── DecoratorJob.java │ │ │ ├── DefaultExceptionHandler.java │ │ │ ├── DelegatingJobProcessor.java │ │ │ ├── Job.java │ │ │ ├── JobProcessor.java │ │ │ ├── JobProcessorAdapter.java │ │ │ ├── JobProcessorExceptionHandler.java │ │ │ ├── JobProcessorQueueAdapter.java │ │ │ ├── LatchJob.java │ │ │ ├── MultiThreadDelegatingJobProcessor.java │ │ │ ├── RunnableJob.java │ │ │ ├── ThreadJobProcessor.java │ │ │ ├── ThreadJobProcessorPool.java │ │ │ └── locks │ │ │ ├── CriticalSection.java │ │ │ ├── DebugLatch.java │ │ │ ├── Guard.java │ │ │ ├── Latch.java │ │ │ ├── ReleaseLatch.java │ │ │ └── Semaphore.java │ │ ├── management │ │ └── MBeanBase.java │ │ └── util │ │ ├── ByteArraySizedInputStream.java │ │ ├── ByteArraySpinAllocator.java │ │ ├── ByteUtil.java │ │ ├── DeferredIO.java │ │ ├── HexUtil.java │ │ ├── LightByteArrayOutputStream.java │ │ ├── MathUtil.java │ │ ├── Random.java │ │ ├── SharedRandomAccessFile.java │ │ ├── SpinAllocator.java │ │ ├── StringBuilderSpinAllocator.java │ │ ├── StringHashMap.java │ │ └── UTFUtil.java └── kotlin │ └── jetbrains │ └── exodus │ ├── core │ ├── cache │ │ ├── BasicCache.kt │ │ ├── CaffeineCache.kt │ │ ├── CustomCaffeine.kt │ │ └── persistent │ │ │ ├── CacheEvictionSubject.kt │ │ │ ├── CaffeinePersistentCache.kt │ │ │ ├── CaffeinePersistentCacheConfig.kt │ │ │ ├── PersistentCache.kt │ │ │ ├── PersistentIndex.kt │ │ │ ├── ValueMap.kt │ │ │ └── VersionTracker.kt │ ├── dataStructures │ │ ├── ConcurrentIntObjectCache.kt │ │ ├── ConcurrentLongObjectCache.kt │ │ ├── IntObjectCacheBase.kt │ │ ├── LongObjectCacheBase.kt │ │ ├── NonAdjustableCaches.kt │ │ ├── hash │ │ │ ├── LongHashMap.kt │ │ │ ├── LongLongHashMap.kt │ │ │ └── PackedLongHashSet.kt │ │ └── persistent │ │ │ ├── LongIterators.kt │ │ │ ├── PersistentBitTreeLongSet.kt │ │ │ └── PersistentEx.kt │ └── execution │ │ ├── IterableJob.kt │ │ ├── JobHandler.kt │ │ └── SharedTimer.kt │ ├── kotlin │ └── Kodus.kt │ ├── runtime │ └── OOMGuard.kt │ ├── system │ ├── JVMConstants.kt │ └── OperatingSystem.kt │ └── util │ ├── IOUtil.kt │ ├── IdGenerator.kt │ ├── SafeByteBufferCleaner.kt │ ├── StringInterner.kt │ ├── SystemProperty.kt │ └── UnsafeHolder.kt └── test ├── java └── jetbrains │ └── exodus │ ├── StringInternerTest.java │ ├── TestFor.java │ ├── TestUtil.java │ ├── core │ ├── crypto │ │ └── MessageDigestTest.java │ └── dataStructures │ │ ├── ConcurrentStablePriorityQueueTest.java │ │ ├── LongObjectCacheTest.java │ │ ├── ObjectCacheTest.java │ │ ├── PriorityQueueTest.java │ │ ├── StablePriorityQueueTest.java │ │ ├── hash │ │ ├── HashMapTest.java │ │ ├── HashSetTest.java │ │ ├── IntHashMapTest.java │ │ ├── IntHashSetTest.java │ │ ├── IntLinkedHashMapTest.java │ │ ├── LinkedHashMapTest.java │ │ ├── LinkedHashSetTest.java │ │ ├── LongHashMapTest.java │ │ ├── LongLinkedHashMapTest.java │ │ └── LongLinkedHashSetTest.java │ │ └── persistent │ │ ├── Persistent23TreeMapTest.java │ │ ├── Persistent23TreeTest.java │ │ ├── PersistentBitTreeLongMapTest.java │ │ ├── PersistentHashMapTest.java │ │ ├── PersistentHashSetTest.java │ │ ├── PersistentLinkedHashMapTest.java │ │ ├── PersistentLongMapTest.java │ │ ├── PersistentQueueTest.java │ │ └── PersistentStackTest.java │ └── util │ └── MathTest.java ├── kotlin └── jetbrains │ └── exodus │ ├── core │ ├── cache │ │ └── persistent │ │ │ ├── CaffeinePersistentCacheTest.kt │ │ │ ├── ValueMapTest.kt │ │ │ └── VersionTrackerTest.kt │ ├── dataStructures │ │ ├── hash │ │ │ ├── LongHashSetTest.kt │ │ │ ├── LongSetTest.kt │ │ │ └── PackedLongHashSetTest.kt │ │ └── persistent │ │ │ ├── PersistentBitTreeLongSetTest.kt │ │ │ └── PersistentLong23TreeSetTest.kt │ └── execution │ │ ├── JobProcessorTest.kt │ │ ├── MultiThreadDelegatingJobProcessorTest.kt │ │ └── locks │ │ └── LatchTest.kt │ ├── testutil │ └── ParallelRunUtil.kt │ └── util │ └── IOUtilTest.kt └── resources ├── jna0.jar └── jna1.jar /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### What does this PR do? 2 | 3 | A brief description of the change being made with this pull request. 4 | 5 | ### Motivation 6 | 7 | What inspired you to submit this pull request? 8 | 9 | ### Related issues 10 | 11 | A list of issues either fixed, containing architectural discussions, otherwise relevant 12 | for this Pull Request. 13 | 14 | ### Additional Notes 15 | 16 | Anything else we should know when reviewing? 17 | 18 | ### Checklist 19 | 20 | [] I have added unit tests to the code I am submitting 21 | [] My unit tests cover both failure and success scenarios 22 | [] If applicable, I have discussed my architecture 23 | -------------------------------------------------------------------------------- /.github/workflows/gradle_21.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | # This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time 6 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle 7 | 8 | name: JDK 21 - master 9 | 10 | on: 11 | push: 12 | branches: [ "master", "graph-store"] 13 | pull_request: 14 | branches: [ "master", "graph-store"] 15 | 16 | permissions: 17 | contents: read 18 | 19 | jobs: 20 | build: 21 | 22 | runs-on: ubuntu-latest 23 | 24 | steps: 25 | - uses: actions/checkout@v4 26 | - name: Set up JDKs 21 27 | uses: actions/setup-java@v4 28 | with: 29 | java-version: "21" 30 | distribution: 'temurin' 31 | - name: Cache 32 | uses: actions/cache@v3 33 | with: 34 | path: | 35 | ~/.gradle/caches 36 | ~/.gradle/wrapper 37 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 38 | restore-keys: | 39 | ${{ runner.os }}-gradle- 40 | - name: Build with Gradle 41 | uses: gradle/gradle-build-action@v2 42 | with: 43 | arguments: build 44 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.com 4 | *.class 5 | *.dll 6 | *.o 7 | *.so 8 | *.pyc 9 | 10 | # Per user settings # 11 | ################### 12 | *.iws 13 | *.iml 14 | .idea 15 | .gradle 16 | build 17 | target 18 | maven-cache 19 | out 20 | 21 | # Packages # 22 | ############ 23 | # it's better to unpack these files and commit the raw source 24 | # git has its own built in compression methods 25 | 26 | 27 | # Logs and databases # 28 | ###################### 29 | *.log 30 | *.sql 31 | *.sqlite 32 | 33 | # OS generated files # 34 | ###################### 35 | .DS_Store 36 | ehthumbs.db 37 | Icon? 38 | Thumbs.db 39 | 40 | # Compiled folders # 41 | ###################### 42 | classes/ 43 | classes_gen/ 44 | 45 | # Other folders # 46 | ###################### 47 | *.csproj.*txt 48 | dotNet/*/_ReSharper.*/* 49 | dotNET/CSharpConverter/*/*/classes_gen/* 50 | -------------------------------------------------------------------------------- /benchmarks/build.gradle.kts: -------------------------------------------------------------------------------- 1 | val currentJmhVersion = "1.35" 2 | 3 | buildscript { 4 | dependencies { 5 | classpath("org.apache.commons:commons-lang3:3.5") 6 | } 7 | } 8 | 9 | plugins { 10 | id("me.champeau.jmh") 11 | } 12 | 13 | 14 | dependencies { 15 | val jmh = configurations.getByName("jmh") 16 | jmh(project(":xodus-environment")) 17 | jmh(project(":xodus-entity-store")) 18 | jmh(project(":xodus-query")) 19 | jmh(project(":xodus-crypto")) 20 | jmh(project(":xodus-utils")) 21 | jmh("org.openjdk.jmh:jmh-core:$currentJmhVersion") 22 | jmh("org.openjdk.jmh:jmh-generator-annprocess:$currentJmhVersion") 23 | jmh(libs.junit) 24 | } 25 | 26 | jmh { 27 | excludes.set(listOf("dataStructures|util|query|crypto")) 28 | includes.set(listOf("env.*")) 29 | jmhVersion.set(currentJmhVersion) 30 | jvmArgs.set(listOf("-server", "-Xmx1g", "-Xms1g", "-XX:+HeapDumpOnOutOfMemoryError")) 31 | duplicateClassesStrategy.set(DuplicatesStrategy.WARN) 32 | resultFormat.set("JSON") 33 | } 34 | 35 | val deleteEmptyBenchmarkList = tasks.register("deleteEmptyBenchmarkList") { 36 | delete("$buildDir/jmh-generated-classes/META-INF/BenchmarkList") 37 | } 38 | 39 | 40 | tasks.named("jmhCompileGeneratedClasses") { 41 | finalizedBy(deleteEmptyBenchmarkList) 42 | } 43 | -------------------------------------------------------------------------------- /benchmarks/src/jmh/java/jetbrains/exodus/benchmark/dataStructures/JMHConcurrentObjectCacheBenchmark.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.benchmark.dataStructures; 17 | 18 | import jetbrains.exodus.core.dataStructures.ConcurrentObjectCache; 19 | import jetbrains.exodus.core.dataStructures.ObjectCacheBase; 20 | 21 | public class JMHConcurrentObjectCacheBenchmark extends JMHObjectCacheBenchmark { 22 | 23 | @Override 24 | protected ObjectCacheBase createCache() { 25 | return new ConcurrentObjectCache<>(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /benchmarks/src/jmh/java/jetbrains/exodus/benchmark/dataStructures/JMHJavaUtilHashMapBenchmark.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.benchmark.dataStructures; 17 | 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | 21 | public class JMHJavaUtilHashMapBenchmark extends JMHHashMapBenchmark { 22 | 23 | @Override 24 | protected Map createHashMap() { 25 | return new HashMap<>(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /benchmarks/src/jmh/java/jetbrains/exodus/benchmark/env/tokyo/JMHEnvWithPrefixingTokyoCabinetReadBenchmark.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.benchmark.env.tokyo; 17 | 18 | import jetbrains.exodus.env.StoreConfig; 19 | 20 | public class JMHEnvWithPrefixingTokyoCabinetReadBenchmark extends JMHEnvTokyoCabinetReadBenchmark { 21 | 22 | @Override 23 | protected StoreConfig getStoreConfig() { 24 | return StoreConfig.WITHOUT_DUPLICATES_WITH_PREFIXING; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /benchmarks/src/jmh/java/jetbrains/exodus/benchmark/env/tokyo/JMHEnvWithPrefixingTokyoCabinetWriteBenchmark.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.benchmark.env.tokyo; 17 | 18 | import jetbrains.exodus.env.StoreConfig; 19 | 20 | public class JMHEnvWithPrefixingTokyoCabinetWriteBenchmark extends JMHEnvTokyoCabinetWriteBenchmark { 21 | 22 | @Override 23 | protected StoreConfig getStoreConfig() { 24 | return StoreConfig.WITHOUT_DUPLICATES_WITH_PREFIXING; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /compress/build.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api(project(":xodus-openAPI")) 3 | implementation(project(":xodus-utils")) 4 | implementation(libs.lz4) 5 | } -------------------------------------------------------------------------------- /crypto/build.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation(project(":xodus-environment")) 3 | implementation(project(":xodus-entity-store")) 4 | implementation(project(":xodus-utils")) 5 | api(project(":xodus-openAPI")) 6 | implementation(libs.bouncyCastle) 7 | testImplementation(project(":xodus-utils", "testArtifacts")) 8 | testImplementation(project(":xodus-openAPI", "testArtifacts")) 9 | } -------------------------------------------------------------------------------- /crypto/src/main/kotlin/jetbrains/exodus/crypto/InitializationVektor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.crypto 17 | 18 | const val LONG_BYTES = java.lang.Long.SIZE / java.lang.Byte.SIZE 19 | 20 | /** 21 | * Converts `Long` initialization vector to a `ByteArray` of size 8. 22 | */ 23 | fun Long.toByteArray(): ByteArray { 24 | return toByteArray(LONG_BYTES) 25 | } 26 | 27 | /** 28 | * Converts `Long` initialization vector to a `ByteArray` of specified `size`. 29 | */ 30 | fun Long.toByteArray(size: Int): ByteArray { 31 | val result = ByteArray(size) 32 | var l = this 33 | repeat(size) { 34 | result[it] = (l and 0xff).toByte() 35 | l = l shr java.lang.Byte.SIZE 36 | } 37 | return result 38 | } -------------------------------------------------------------------------------- /crypto/src/main/kotlin/jetbrains/exodus/crypto/convert/EncryptListener.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.crypto.convert 17 | 18 | interface EncryptListener { 19 | fun onFile(header: FileHeader) 20 | fun onFileEnd(header: FileHeader) 21 | fun onData(header: FileHeader, size: Int, data: ByteArray) 22 | } 23 | -------------------------------------------------------------------------------- /crypto/src/main/kotlin/jetbrains/exodus/crypto/convert/Protocol.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.crypto.convert 17 | 18 | interface EncryptMessage 19 | 20 | data class FileHeader( 21 | val path: String, 22 | val name: String, 23 | val size: Long, 24 | val timestamp: Long, 25 | val handle: Long, 26 | val chunkedIV: Boolean, 27 | val canBeEncrypted: Boolean 28 | ) : EncryptMessage 29 | 30 | class FileChunk( 31 | val header: FileHeader, 32 | val size: Int, 33 | val data: ByteArray 34 | ) : EncryptMessage 35 | 36 | object EndChunk : EncryptMessage 37 | -------------------------------------------------------------------------------- /crypto/src/main/resources/META-INF/services/jetbrains.exodus.crypto.StreamCipherProvider: -------------------------------------------------------------------------------- 1 | jetbrains.exodus.crypto.streamciphers.Salsa20StreamCipherProvider 2 | jetbrains.exodus.crypto.streamciphers.ChaChaStreamCipherProvider 3 | jetbrains.exodus.crypto.streamciphers.JBChaChaStreamCipherProvider -------------------------------------------------------------------------------- /crypto/src/test/kotlin/jetbrains/exodus/crypto/ChaChaStreamCipherTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.crypto 17 | 18 | import jetbrains.exodus.crypto.streamciphers.CHACHA_CIPHER_ID 19 | 20 | class ChaChaStreamCipherTest : StreamCipherTest() { 21 | 22 | override fun createCipher(): StreamCipher { 23 | return newCipher(CHACHA_CIPHER_ID) 24 | } 25 | } -------------------------------------------------------------------------------- /crypto/src/test/kotlin/jetbrains/exodus/crypto/Salsa20StreamCipherTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.crypto 17 | 18 | import jetbrains.exodus.crypto.streamciphers.SALSA20_CIPHER_ID 19 | 20 | class Salsa20StreamCipherTest : StreamCipherTest() { 21 | 22 | override fun createCipher(): StreamCipher { 23 | return newCipher(SALSA20_CIPHER_ID) 24 | } 25 | } -------------------------------------------------------------------------------- /entity-store/build.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api(project(":xodus-openAPI")) 3 | 4 | implementation(project(":xodus-utils")) 5 | implementation(project(":xodus-environment")) 6 | implementation(project(":xodus-compress")) 7 | implementation(libs.commons.io) 8 | 9 | testImplementation("io.github.classgraph:classgraph:4.8.90") 10 | testImplementation(project(":xodus-utils", "testArtifacts")) 11 | testImplementation(libs.mockk) 12 | } 13 | 14 | val testArtifacts: Configuration by configurations.creating 15 | 16 | tasks { 17 | val jarTest by creating(Jar::class) { 18 | archiveClassifier.set("test") 19 | from(sourceSets.test.get().output) 20 | } 21 | 22 | artifacts { 23 | add("testArtifacts", jarTest) 24 | } 25 | } -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/InsertConstraintException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | public class InsertConstraintException extends UniqueKeyIndexException { 19 | 20 | public InsertConstraintException(String message) { 21 | super(message); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentSequenceBlobHandleGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | class PersistentSequenceBlobHandleGenerator implements BlobHandleGenerator { 21 | 22 | @NotNull 23 | private final PersistentSequenceGetter sequenceGetter; 24 | 25 | PersistentSequenceBlobHandleGenerator(@NotNull final PersistentSequenceGetter sequenceGetter) { 26 | this.sequenceGetter = sequenceGetter; 27 | } 28 | 29 | @Override 30 | public long nextHandle() { 31 | return sequenceGetter.get().increment(); 32 | } 33 | 34 | interface PersistentSequenceGetter { 35 | 36 | PersistentSequence get(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/PhantomLinkException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | class PhantomLinkException extends EntityRemovedInDatabaseException { 19 | 20 | PhantomLinkException(String entityType) { 21 | super(entityType); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/TmpBlobHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | import java.io.InputStream; 19 | import java.nio.file.Path; 20 | 21 | public class TmpBlobHandle { 22 | public final Path path; 23 | public final InputStream stream; 24 | public final long size; 25 | public final long tmpHandle; 26 | 27 | public TmpBlobHandle(Path path, InputStream stream, long size, long tmpHandle) { 28 | this.path = path; 29 | this.stream = stream; 30 | this.size = size; 31 | this.tmpHandle = tmpHandle; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/TxnProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public interface TxnProvider { 21 | 22 | @NotNull 23 | PersistentStoreTransaction getTransaction(); 24 | } 25 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/UnexpectedBlobVaultVersionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | public class UnexpectedBlobVaultVersionException extends EntityStoreException { 19 | 20 | public UnexpectedBlobVaultVersionException(String message) { 21 | super(message); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/UniqueKeyIndexException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | public abstract class UniqueKeyIndexException extends EntityStoreException { 19 | 20 | protected UniqueKeyIndexException() { 21 | } 22 | 23 | protected UniqueKeyIndexException(String message) { 24 | super(message); 25 | } 26 | 27 | protected UniqueKeyIndexException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | 31 | protected UniqueKeyIndexException(Throwable cause) { 32 | super(cause); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/Updatable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public interface Updatable { 21 | 22 | Updatable beginUpdate(@NotNull PersistentStoreTransaction txn); 23 | 24 | boolean isMutated(); 25 | 26 | void endUpdate(@NotNull PersistentStoreTransaction txn); 27 | } 28 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/EntityAddedOrDeletedHandleChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import jetbrains.exodus.entitystore.EntityId; 19 | 20 | public interface EntityAddedOrDeletedHandleChecker extends HandleChecker { 21 | EntityId getId(); 22 | } 23 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/EntityFromLinkSetIteratorBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | abstract class EntityFromLinkSetIteratorBase extends EntityIteratorBase implements EntityIteratorWithPropId { 21 | 22 | protected EntityFromLinkSetIteratorBase(@NotNull final EntityIterableBase iterable) { 23 | super(iterable); 24 | } 25 | 26 | protected abstract int currentPropId(); 27 | 28 | protected abstract String getLinkName(final int linkId); 29 | 30 | @Override 31 | public String currentLinkName() { 32 | return getLinkName(currentPropId()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/EntityIterableInstantiator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import jetbrains.exodus.entitystore.PersistentEntityStoreImpl; 19 | import jetbrains.exodus.entitystore.PersistentStoreTransaction; 20 | 21 | public interface EntityIterableInstantiator { 22 | 23 | EntityIterableBase instantiate(PersistentStoreTransaction txn, PersistentEntityStoreImpl store, Object[] parameters); 24 | } 25 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/EntityIteratorWithPropId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import jetbrains.exodus.entitystore.EntityIterator; 19 | 20 | public interface EntityIteratorWithPropId extends EntityIterator { 21 | 22 | String currentLinkName(); 23 | } 24 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/EntityLinksIterableBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import jetbrains.exodus.entitystore.EntityId; 19 | import jetbrains.exodus.entitystore.PersistentStoreTransaction; 20 | import org.jetbrains.annotations.NotNull; 21 | import org.jetbrains.annotations.Nullable; 22 | 23 | public abstract class EntityLinksIterableBase extends EntityIterableBase { 24 | 25 | @NotNull 26 | protected final EntityId entityId; 27 | 28 | protected EntityLinksIterableBase(@Nullable final PersistentStoreTransaction txn, 29 | @NotNull final EntityId entityId) { 30 | super(txn); 31 | this.entityId = entityId; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/HandleChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import jetbrains.exodus.entitystore.EntityIterableHandle; 19 | import jetbrains.exodus.entitystore.PersistentStoreTransaction; 20 | import jetbrains.exodus.entitystore.Updatable; 21 | import org.jetbrains.annotations.NotNull; 22 | 23 | public interface HandleChecker { 24 | int getLinkId(); 25 | 26 | int getPropertyId(); 27 | 28 | int getTypeId(); 29 | 30 | int getTypeIdAffectingCreation(); 31 | 32 | @NotNull 33 | PersistentStoreTransaction getTxn(); 34 | 35 | void beginUpdate(@NotNull Updatable instance); 36 | 37 | @Deprecated 38 | Updatable getUpdatableIterable(@NotNull final EntityIterableHandle handle); 39 | } 40 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/LinkChangedHandleChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import jetbrains.exodus.entitystore.EntityId; 19 | 20 | public interface LinkChangedHandleChecker extends HandleChecker { 21 | EntityId getSourceId(); 22 | 23 | EntityId getTargetId(); 24 | 25 | int getLinkId(); 26 | } 27 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/PropertyChangedHandleChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import org.jetbrains.annotations.Nullable; 19 | 20 | public interface PropertyChangedHandleChecker extends HandleChecker { 21 | int getTypeId(); 22 | 23 | int getPropertyId(); 24 | 25 | long getLocalId(); 26 | 27 | @Nullable 28 | Comparable getOldValue(); 29 | 30 | @Nullable 31 | Comparable getNewValue(); 32 | } 33 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/PropertyValueIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import jetbrains.exodus.entitystore.EntityIterator; 19 | import org.jetbrains.annotations.Nullable; 20 | 21 | @SuppressWarnings("rawtypes") 22 | public interface PropertyValueIterator extends EntityIterator { 23 | 24 | @Nullable 25 | Comparable currentValue(); 26 | } 27 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/SingleKeyCursorCounter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import jetbrains.exodus.ByteIterable; 19 | import jetbrains.exodus.env.Cursor; 20 | import org.jetbrains.annotations.NotNull; 21 | 22 | final class SingleKeyCursorCounter { 23 | 24 | private final long count; 25 | 26 | SingleKeyCursorCounter(@NotNull final Cursor cursor, @NotNull final ByteIterable keyEntry) { 27 | try { 28 | final boolean success = cursor.getSearchKey(keyEntry) != null; 29 | count = success ? cursor.count() : 0; 30 | } finally { 31 | cursor.close(); 32 | } 33 | } 34 | 35 | public long getCount() { 36 | return count; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/SingleKeyCursorIsEmptyChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import jetbrains.exodus.ByteIterable; 19 | import jetbrains.exodus.env.Cursor; 20 | import org.jetbrains.annotations.NotNull; 21 | 22 | final class SingleKeyCursorIsEmptyChecker { 23 | 24 | private final boolean isEmpty; 25 | 26 | SingleKeyCursorIsEmptyChecker(@NotNull final Cursor cursor, @NotNull final ByteIterable keyEntry) { 27 | try { 28 | isEmpty = cursor.getSearchKey(keyEntry) == null; 29 | } finally { 30 | cursor.close(); 31 | } 32 | } 33 | 34 | public boolean isEmpty() { 35 | return isEmpty; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/SourceMappingIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import jetbrains.exodus.entitystore.EntityId; 19 | import jetbrains.exodus.entitystore.EntityIterator; 20 | import org.jetbrains.annotations.NotNull; 21 | 22 | public interface SourceMappingIterator extends EntityIterator { 23 | 24 | @NotNull 25 | EntityId getSourceId(); 26 | } 27 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/iterate/TxnGetterStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import jetbrains.exodus.entitystore.PersistentStoreTransaction; 19 | import org.jetbrains.annotations.NotNull; 20 | 21 | public interface TxnGetterStrategy { 22 | 23 | TxnGetterStrategy DEFAULT = iterable -> iterable.getStore().getAndCheckCurrentTransaction(); 24 | 25 | PersistentStoreTransaction getTxn(@NotNull final EntityIterableBase iterable); 26 | } 27 | -------------------------------------------------------------------------------- /entity-store/src/main/java/jetbrains/exodus/entitystore/tables/Table.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.tables; 17 | 18 | import jetbrains.exodus.entitystore.PersistentEntityStoreImpl; 19 | import org.jetbrains.annotations.NonNls; 20 | import org.jetbrains.annotations.NotNull; 21 | 22 | public abstract class Table { 23 | @NonNls 24 | public static final String ALL_IDX = "#all_idx"; 25 | 26 | public static void checkStatus(final boolean success, @NotNull final String message) { 27 | if (!success) { 28 | PersistentEntityStoreImpl.loggerWarn(message + ", operation unsuccessful", new Throwable()); 29 | } 30 | } 31 | 32 | public abstract boolean canBeCached(); 33 | } 34 | -------------------------------------------------------------------------------- /entity-store/src/main/kotlin/jetbrains/exodus/entitystore/iterate/util/LongArrayIterator.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate.util 17 | 18 | import jetbrains.exodus.core.dataStructures.hash.LongIterator 19 | 20 | class LongArrayIterator @JvmOverloads constructor(val array: LongArray, val size: Int = array.size) : LongIterator { 21 | private var index = 0 22 | override fun hasNext() = index < size 23 | override fun next() = nextLong() 24 | override fun nextLong() = array[index++] 25 | 26 | override fun remove() = throw UnsupportedOperationException() 27 | } 28 | -------------------------------------------------------------------------------- /entity-store/src/main/kotlin/jetbrains/exodus/entitystore/util/EntityIdSetFactory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.util 17 | 18 | import jetbrains.exodus.entitystore.iterate.EntityIdSet 19 | 20 | object EntityIdSetFactory { 21 | 22 | private val NOTHING = EmptyEntityIdSet() 23 | private val NOTHING_IMMUTABLE = ImmutableEmptyEntityIdSet() 24 | 25 | @JvmStatic 26 | fun newSet(): EntityIdSet = NOTHING 27 | 28 | @JvmStatic 29 | fun newImmutableSet(): EntityIdSet = NOTHING_IMMUTABLE 30 | } 31 | -------------------------------------------------------------------------------- /entity-store/src/main/kotlin/jetbrains/exodus/entitystore/util/ImmutableEmptyEntityIdSet.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.util 17 | 18 | import jetbrains.exodus.entitystore.EntityId 19 | import jetbrains.exodus.entitystore.iterate.EntityIdSet 20 | 21 | internal class ImmutableEmptyEntityIdSet : EmptyEntityIdSet() { 22 | 23 | override fun add(id: EntityId?): EntityIdSet = this 24 | 25 | override fun add(typeId: Int, localId: Long): EntityIdSet = this 26 | } -------------------------------------------------------------------------------- /entity-store/src/test/java/jetbrains/exodus/entitystore/FailoverForkLongTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | import jetbrains.exodus.entitystore.processRunners.LongProcessRunner; 19 | import jetbrains.exodus.entitystore.processRunners.ProcessRunner; 20 | 21 | @StoreArtifacts 22 | public class FailoverForkLongTests extends FailoverForkTests { 23 | 24 | @Override 25 | protected Class getProcessRunner() { 26 | return LongProcessRunner.class; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /entity-store/src/test/java/jetbrains/exodus/entitystore/StoreArtifactsPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | /** 19 | * Contains available policies for artifact storage annotation. 20 | * 21 | * @see StoreArtifacts 22 | */ 23 | public enum StoreArtifactsPolicy { 24 | ALWAYS, 25 | ON_FAILURE_ONLY; 26 | 27 | 28 | StoreArtifactsPolicy() { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /entity-store/src/test/java/jetbrains/exodus/util/ForkedLogic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.util; 17 | 18 | public abstract class ForkedLogic { 19 | 20 | protected Streamer getStreamer() { 21 | return ForkedProcessRunner.streamer; 22 | } 23 | 24 | public abstract void forked(String[] args) throws Exception; 25 | 26 | protected void close() { 27 | ForkedProcessRunner.close(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /entity-store/src/test/java/jetbrains/exodus/util/IStreamer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.util; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | import org.jetbrains.annotations.Nullable; 20 | 21 | import java.io.IOException; 22 | 23 | public interface IStreamer { 24 | @Nullable 25 | String readString(); 26 | 27 | void writeString(@NotNull String data) throws IOException; 28 | 29 | void close() throws IOException; 30 | } 31 | -------------------------------------------------------------------------------- /entity-store/src/test/java/jetbrains/exodus/util/ProcessKiller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.util; 17 | 18 | import java.io.IOException; 19 | 20 | public interface ProcessKiller { 21 | 22 | boolean suitableForOS(String osName); 23 | 24 | void killProcess(int id) throws IOException; 25 | } 26 | -------------------------------------------------------------------------------- /entity-store/src/test/resources/pskill.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/xodus/7b728d185aa648da1414f6ceb2c876c4399e6311/entity-store/src/test/resources/pskill.exe -------------------------------------------------------------------------------- /entity-store/src/test/resources/testXD_362.data: -------------------------------------------------------------------------------- 1 | Some test file data -------------------------------------------------------------------------------- /environment-crash-tests/build.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencies { 2 | testImplementation(project(":xodus-utils", "testArtifacts")) 3 | testImplementation(project(":xodus-utils")) 4 | testImplementation(project(":xodus-environment")) 5 | } 6 | 7 | tasks.test { 8 | testLogging.showStandardStreams = true 9 | } -------------------------------------------------------------------------------- /environment/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 2 | 3 | dependencies { 4 | implementation(project(":xodus-compress")) 5 | implementation(project(":xodus-utils")) 6 | api(project(":xodus-openAPI")) 7 | implementation(libs.jetbrains.annotations) 8 | testImplementation(project(":xodus-utils", "testArtifacts")) 9 | } 10 | 11 | val testArtifacts: Configuration by configurations.creating 12 | 13 | tasks { 14 | val jarTest by creating(Jar::class) { 15 | archiveClassifier.set("test") 16 | from(sourceSets.test.get().output) 17 | } 18 | 19 | artifacts { 20 | add("testArtifacts", jarTest) 21 | } 22 | 23 | named("compileKotlin", KotlinCompile::class) { 24 | kotlinOptions { 25 | allWarningsAsErrors = true 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/env/MetaTree.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.env; 17 | 18 | public interface MetaTree extends MetaTreePrototype { 19 | } 20 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/env/MetaTreePrototype.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.env; 17 | 18 | public interface MetaTreePrototype { 19 | long treeAddress(); 20 | long rootAddress(); 21 | } 22 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/env/TransactionAcquireTimeoutException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.env; 17 | 18 | import jetbrains.exodus.ExodusException; 19 | 20 | public class TransactionAcquireTimeoutException extends ExodusException { 21 | 22 | TransactionAcquireTimeoutException(final int millis) { 23 | super("Failed to acquire transaction within " + millis + " milliseconds"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/env/TransactionFinishedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.env; 17 | 18 | import jetbrains.exodus.ExodusException; 19 | import jetbrains.exodus.debug.StackTrace; 20 | import org.jetbrains.annotations.Nullable; 21 | 22 | public class TransactionFinishedException extends ExodusException { 23 | 24 | @Nullable 25 | private final StackTrace trace; 26 | 27 | TransactionFinishedException() { 28 | this(null); 29 | } 30 | 31 | TransactionFinishedException(@Nullable StackTrace trace) { 32 | super("Transaction is already finished"); 33 | this.trace = trace; 34 | } 35 | 36 | @Nullable 37 | public StackTrace getTrace() { 38 | return trace; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/log/BlockByteIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.log; 17 | 18 | public interface BlockByteIterator { 19 | 20 | int nextBytes(byte[] array, int off, int len); 21 | } -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/log/ByteIteratorWithAddress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.log; 17 | 18 | import jetbrains.exodus.ByteIterator; 19 | 20 | public interface ByteIteratorWithAddress extends ByteIterator { 21 | 22 | long getAddress(); 23 | 24 | int getOffset(); 25 | 26 | int available(); 27 | 28 | default boolean availableInCurrentPage(final int bytes) { 29 | return false; 30 | } 31 | 32 | default byte[] getCurrentPage() { 33 | throw new UnsupportedOperationException(); 34 | } 35 | 36 | default int getCompressedUnsignedInt() { 37 | return CompressedUnsignedLongByteIterable.getInt(this); 38 | } 39 | 40 | default long getCompressedUnsignedLong() { 41 | return CompressedUnsignedLongByteIterable.getLong(this); 42 | } 43 | } -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/log/CacheDataProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.log; 17 | 18 | public interface CacheDataProvider { 19 | int getIdentity(); 20 | 21 | byte[] readPage(long pageAddress, long fileAddress); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/log/LogTestConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.log; 17 | 18 | public class LogTestConfig { 19 | 20 | private long maxHighAddress; 21 | 22 | /** 23 | * If maxHighAddress is set to a non-negative value, no loggable with address GE to it will be written. 24 | */ 25 | public long getMaxHighAddress() { 26 | return maxHighAddress; 27 | } 28 | 29 | public void setMaxHighAddress(final long maxHighAddress) { 30 | this.maxHighAddress = maxHighAddress; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/log/RandomAccessLoggable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.log; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public interface RandomAccessLoggable extends Loggable { 21 | 22 | @NotNull 23 | @Override 24 | ByteIterableWithAddress getData(); 25 | } 26 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/log/ReadBytesListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.log; 17 | 18 | public interface ReadBytesListener { 19 | 20 | void bytesRead(final byte[] bytes, final int count); 21 | } 22 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/log/RemoveFileListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.log; 17 | 18 | public interface RemoveFileListener { 19 | 20 | void beforeRemoveFile(long fileAddress); 21 | 22 | void afterRemoveFile(long fileAddress); 23 | } 24 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/log/SingleByteIterable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.log; 17 | 18 | import jetbrains.exodus.ArrayByteIterable; 19 | import jetbrains.exodus.ByteIterable; 20 | 21 | public class SingleByteIterable { 22 | 23 | private static final ByteIterable[] ITERABLES; 24 | 25 | private SingleByteIterable() { 26 | } 27 | 28 | static { 29 | ITERABLES = new ByteIterable[256]; 30 | for (int i = 0; i < ITERABLES.length; i++) { 31 | ITERABLES[i] = new ArrayByteIterable(new byte[]{(byte) i}); 32 | } 33 | } 34 | 35 | public static ByteIterable getIterable(final byte b) { 36 | return ITERABLES[b & 0xff]; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/log/TooBigLoggableException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.log; 17 | 18 | import jetbrains.exodus.ExodusException; 19 | 20 | public class TooBigLoggableException extends ExodusException { 21 | 22 | private static final String DEFAULT_MESSAGE = "Can't write a loggable which size is greater than file size."; 23 | 24 | public TooBigLoggableException() { 25 | this(DEFAULT_MESSAGE); 26 | } 27 | 28 | public TooBigLoggableException(final String message) { 29 | super(message); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/tree/Dumpable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree; 17 | 18 | import org.jetbrains.annotations.Nullable; 19 | 20 | import java.io.PrintStream; 21 | 22 | public interface Dumpable { 23 | /** 24 | * Dump node to stream 25 | * 26 | * @param out stream to write to 27 | * @param level indentation 28 | * @param renderer renderer for nodes 29 | */ 30 | void dump(PrintStream out, int level, @Nullable ToString renderer); 31 | 32 | /** 33 | * To String renderer for INode implementers 34 | */ 35 | interface ToString { 36 | 37 | String toString(INode ln); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/tree/ITreeCursorMutable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree; 17 | 18 | public interface ITreeCursorMutable extends ITreeCursor { 19 | void treeChanged(); 20 | } 21 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/tree/LongIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree; 17 | 18 | /* 19 | * Iterates over longs 20 | */ 21 | public interface LongIterator { 22 | 23 | LongIterator EMPTY = new LongIterator() { 24 | @Override 25 | public boolean hasNext() { 26 | return false; 27 | } 28 | 29 | @Override 30 | public long next() { 31 | return -1L; 32 | } 33 | }; 34 | 35 | boolean hasNext(); 36 | 37 | long next(); 38 | } 39 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/tree/MutableTreeRoot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree; 17 | 18 | /** 19 | * Marker interface for nodes suitable for TreeCursorMutable reset 20 | */ 21 | public interface MutableTreeRoot extends Dumpable { 22 | } 23 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/tree/btree/BaseLeafNodeMutable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.btree; 17 | 18 | abstract class BaseLeafNodeMutable extends BaseLeafNode implements ILeafNodeMutable { 19 | @Override 20 | public boolean isMutable() { 21 | return true; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/tree/btree/ILeafNodeMutable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.btree; 17 | 18 | import jetbrains.exodus.ByteIterable; 19 | import jetbrains.exodus.tree.ITree; 20 | 21 | interface ILeafNodeMutable extends ILeafNode { 22 | 23 | long save(ITree tree); 24 | 25 | boolean delete(ByteIterable value); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/tree/btree/TreePos.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.btree; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | /** 21 | * Position in btree 22 | */ 23 | class TreePos { 24 | 25 | @NotNull 26 | final BasePage node; 27 | final int pos; 28 | 29 | TreePos(@NotNull final BasePage node, final int pos) { 30 | this.node = node; 31 | this.pos = pos; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/tree/patricia/ChildReferenceBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.patricia; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | abstract class ChildReferenceBase { 21 | 22 | byte firstByte; 23 | 24 | ChildReferenceBase(final byte firstByte) { 25 | this.firstByte = firstByte; 26 | } 27 | 28 | abstract boolean isMutable(); 29 | 30 | abstract NodeBase getNode(@NotNull final PatriciaTreeBase tree); 31 | } 32 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/tree/patricia/ImmutableNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.patricia; 17 | 18 | import jetbrains.exodus.log.RandomAccessLoggable; 19 | import jetbrains.exodus.tree.INode; 20 | 21 | public interface ImmutableNode extends INode { 22 | RandomAccessLoggable getLoggable(); 23 | 24 | long getAddress(); 25 | 26 | NodeBase asNodeBase(); 27 | } 28 | -------------------------------------------------------------------------------- /environment/src/main/java/jetbrains/exodus/tree/patricia/PatriciaTreeForReclaim.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.patricia; 17 | 18 | import jetbrains.exodus.log.Log; 19 | import org.jetbrains.annotations.NotNull; 20 | 21 | public class PatriciaTreeForReclaim extends PatriciaTree { 22 | private long backRef; 23 | 24 | public PatriciaTreeForReclaim(@NotNull final Log log, final long rootAddress, final int structureId) { 25 | super(log, rootAddress, structureId); 26 | } 27 | 28 | @Override 29 | void rememberBackRef(final long backReference) { 30 | backRef = backReference; 31 | } 32 | 33 | long getBackRef() { 34 | return backRef; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /environment/src/main/kotlin/jetbrains/exodus/debug/Misc.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.debug 17 | 18 | import java.io.ByteArrayOutputStream 19 | import java.io.PrintStream 20 | 21 | internal fun dumpToString(dump: (PrintStream) -> Unit): String { 22 | val out = ByteArrayOutputStream() 23 | val utf8Name = Charsets.UTF_8.name() 24 | PrintStream(out, false, utf8Name).use { ps -> dump(ps) } 25 | return out.toString(utf8Name) 26 | } -------------------------------------------------------------------------------- /environment/src/main/kotlin/jetbrains/exodus/env/Unsafe.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.env 17 | 18 | import kotlin.concurrent.withLock 19 | 20 | fun EnvironmentImpl.executeInCommitLock(action: () -> T): T { 21 | return synchronized(commitLock) { 22 | action() 23 | } 24 | } 25 | 26 | fun EnvironmentImpl.executeInMetaWriteLock(action: () -> T): T { 27 | return metaWriteLock.withLock { 28 | action() 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /environment/src/main/kotlin/jetbrains/exodus/env/management/BackupControllerMBean.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.env.management 17 | 18 | const val BACKUP_CONTROLLER_NAME_PREFIX = "jetbrains.exodus.env: type=BackupController" 19 | 20 | interface BackupControllerMBean { 21 | fun prepareBackup() 22 | fun finishBackup() 23 | 24 | val backupInProgress: Boolean 25 | } 26 | -------------------------------------------------------------------------------- /environment/src/main/kotlin/jetbrains/exodus/env/management/DatabaseProfilerMBean.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.env.management 17 | 18 | const val PROFILER_OBJECT_NAME_PREFIX = "jetbrains.exodus.env: type=DatabaseProfiler" 19 | 20 | interface DatabaseProfilerMBean { 21 | fun reset() 22 | fun dump() 23 | } -------------------------------------------------------------------------------- /environment/src/main/kotlin/jetbrains/exodus/env/management/EnvironmentConfigWithOperations.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.env.management 17 | 18 | import jetbrains.exodus.env.EnvironmentImpl 19 | 20 | class EnvironmentConfigWithOperations(env: EnvironmentImpl) : EnvironmentConfig(env) { 21 | 22 | override fun close() { 23 | env.close() 24 | super.close() 25 | } 26 | 27 | fun clean() { 28 | env.clear() 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /environment/src/main/kotlin/jetbrains/exodus/gc/PeriodicGc.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.gc 17 | 18 | import jetbrains.exodus.core.execution.SharedTimer 19 | import java.lang.ref.WeakReference 20 | 21 | class PeriodicGc(gc: GarbageCollector) : SharedTimer.ExpirablePeriodicTask { 22 | 23 | private val gcRef = WeakReference(gc) 24 | private val gc: GarbageCollector? get() = gcRef.get() 25 | 26 | override val isExpired: Boolean get() = gc == null 27 | 28 | override fun run() { 29 | gc?.let { gc -> 30 | val env = gc.environment 31 | val period = env.environmentConfig.gcRunEvery 32 | if (period > 0 && gc.lastInvocationTime + (period.toLong() * 1000L) < System.currentTimeMillis()) { 33 | env.gc() 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /environment/src/main/kotlin/jetbrains/exodus/io/inMemory/MemoryDataReaderWriterProvider.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.io.inMemory 17 | 18 | import jetbrains.exodus.core.dataStructures.Pair 19 | import jetbrains.exodus.io.DataReader 20 | import jetbrains.exodus.io.DataReaderWriterProvider 21 | import jetbrains.exodus.io.DataWriter 22 | 23 | class MemoryDataReaderWriterProvider : DataReaderWriterProvider() { 24 | 25 | override fun newReaderWriter(location: String): Pair = 26 | Memory().run { Pair(MemoryDataReader(this), MemoryDataWriter(this)) } 27 | 28 | override fun isInMemory() = true 29 | } -------------------------------------------------------------------------------- /environment/src/main/kotlin/jetbrains/exodus/log/AbstractBlockListener.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.log 17 | 18 | import jetbrains.exodus.io.Block 19 | 20 | abstract class AbstractBlockListener() : BlockListener { 21 | 22 | override fun blockCreated(block: Block) { 23 | } 24 | 25 | override fun beforeBlockDeleted(block: Block) { 26 | } 27 | 28 | override fun afterBlockDeleted(address: Long) { 29 | } 30 | 31 | override fun blockModified(block: Block) { 32 | } 33 | } -------------------------------------------------------------------------------- /environment/src/main/kotlin/jetbrains/exodus/log/BlockListener.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.log 17 | 18 | import jetbrains.exodus.io.Block 19 | 20 | interface BlockListener { 21 | 22 | fun blockCreated(block: Block) 23 | 24 | fun beforeBlockDeleted(block: Block) 25 | fun afterBlockDeleted(address: Long) 26 | 27 | fun blockModified(block: Block) 28 | } 29 | -------------------------------------------------------------------------------- /environment/src/main/kotlin/jetbrains/exodus/tree/patricia/MutableRoot.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.patricia 17 | 18 | import jetbrains.exodus.tree.MutableTreeRoot 19 | 20 | internal open class MutableRoot : MutableNode, MutableTreeRoot { 21 | 22 | val sourceAddress: Long 23 | 24 | constructor(origin: ImmutableNode) : super(origin.asNodeBase()) { 25 | sourceAddress = origin.address 26 | } 27 | 28 | constructor(node: MutableNode, sourceAddress: Long) : super(node.keySequence, node.value, node.children) { 29 | this.sourceAddress = sourceAddress 30 | } 31 | 32 | override val isRoot: Boolean get() = true 33 | } 34 | -------------------------------------------------------------------------------- /environment/src/main/kotlin/jetbrains/exodus/tree/patricia/NodeChildren.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.patricia 17 | 18 | import jetbrains.exodus.ByteIterable 19 | 20 | internal interface NodeChildren : Iterable { 21 | override fun iterator(): NodeChildrenIterator 22 | } 23 | 24 | internal interface NodeChildrenIterator : MutableIterator { 25 | fun hasPrev(): Boolean 26 | fun prev(): ChildReference? 27 | val isMutable: Boolean 28 | fun nextInPlace() 29 | fun prevInPlace() 30 | val node: ChildReference? 31 | val parentNode: NodeBase? 32 | val index: Int 33 | val key: ByteIterable? 34 | } -------------------------------------------------------------------------------- /environment/src/main/resources/META-INF/services/jetbrains.exodus.io.DataReaderWriterProvider: -------------------------------------------------------------------------------- 1 | jetbrains.exodus.io.AsyncFileDataReaderWriterProvider 2 | jetbrains.exodus.io.inMemory.MemoryDataReaderWriterProvider -------------------------------------------------------------------------------- /environment/src/test/java/jetbrains/exodus/log/LogInMemoryTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.log; 17 | 18 | import jetbrains.exodus.core.dataStructures.Pair; 19 | import jetbrains.exodus.io.DataReader; 20 | import jetbrains.exodus.io.DataWriter; 21 | import jetbrains.exodus.io.inMemory.Memory; 22 | import jetbrains.exodus.io.inMemory.MemoryDataReader; 23 | import jetbrains.exodus.io.inMemory.MemoryDataWriter; 24 | 25 | public class LogInMemoryTests extends LogTests { 26 | 27 | @Override 28 | protected Pair createLogRW() { 29 | final Memory memory = new Memory(); 30 | return new Pair<>(new MemoryDataReader(memory), new MemoryDataWriter(memory)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /environment/src/test/java/jetbrains/exodus/tree/TreeAddressIteratorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree; 17 | 18 | import org.junit.Assert; 19 | import org.junit.Test; 20 | 21 | public abstract class TreeAddressIteratorTest extends TreeBaseTest { 22 | 23 | protected abstract ITree createEmpty(); 24 | 25 | @Test 26 | public void testEmpty() { 27 | Assert.assertFalse(createEmpty().addressIterator().hasNext()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /environment/src/test/java/jetbrains/exodus/tree/btree/BTreeAddressIteratorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.btree; 17 | 18 | import jetbrains.exodus.tree.ITree; 19 | import jetbrains.exodus.tree.ITreeMutable; 20 | import jetbrains.exodus.tree.TreeAddressIteratorTest; 21 | 22 | public class BTreeAddressIteratorTest extends TreeAddressIteratorTest { 23 | 24 | @Override 25 | protected ITree createEmpty() { 26 | return new BTreeEmpty(log, false, 0); 27 | } 28 | 29 | @Override 30 | protected ITreeMutable createMutableTree(final boolean hasDuplicates, final int structureId) { 31 | return null; 32 | } 33 | 34 | @Override 35 | protected ITree openTree(long address, boolean hasDuplicates) { 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /environment/src/test/java/jetbrains/exodus/tree/btree/BTreeCursorConcurrentCursorModificationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.btree; 17 | 18 | import jetbrains.exodus.ByteIterable; 19 | import jetbrains.exodus.tree.TreeBaseTest; 20 | import org.jetbrains.annotations.NotNull; 21 | 22 | public class BTreeCursorConcurrentCursorModificationTest extends BTreeCursorConcurrentModificationTest { 23 | @Override 24 | protected void deleteImpl(@NotNull ByteIterable key) { 25 | TreeBaseTest.doDeleteViaCursor(this, key); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /environment/src/test/java/jetbrains/exodus/tree/btree/BTreeCursorConcurrentModificationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.btree; 17 | 18 | import jetbrains.exodus.tree.ITree; 19 | import jetbrains.exodus.tree.ITreeMutable; 20 | import jetbrains.exodus.tree.TreeCursorConcurrentModificationTest; 21 | 22 | public class BTreeCursorConcurrentModificationTest extends TreeCursorConcurrentModificationTest { 23 | 24 | @Override 25 | protected ITreeMutable createMutableTree(final boolean hasDuplicates, final int structureId) { 26 | return BTreeTestBase.doCreateMutableTree(hasDuplicates, structureId); 27 | } 28 | 29 | @Override 30 | protected ITree openTree(long address, boolean hasDuplicates) { 31 | return BTreeTestBase.doOpenTree(address, hasDuplicates); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /environment/src/test/java/jetbrains/exodus/tree/btree/BTreeCursorDuplicatesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.btree; 17 | 18 | import jetbrains.exodus.tree.ITree; 19 | import jetbrains.exodus.tree.ITreeMutable; 20 | import jetbrains.exodus.tree.TreeCursorDuplicatesTest; 21 | 22 | public class BTreeCursorDuplicatesTest extends TreeCursorDuplicatesTest { 23 | 24 | @Override 25 | protected ITreeMutable createMutableTree(final boolean hasDuplicates, final int structureId) { 26 | return BTreeTestBase.doCreateMutableTree(hasDuplicates, structureId); 27 | } 28 | 29 | @Override 30 | protected ITree openTree(long address, boolean hasDuplicates) { 31 | return BTreeTestBase.doOpenTree(address, hasDuplicates); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /environment/src/test/java/jetbrains/exodus/tree/btree/BTreePutCommonTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.btree; 17 | 18 | import jetbrains.exodus.tree.ITree; 19 | import jetbrains.exodus.tree.ITreeMutable; 20 | import jetbrains.exodus.tree.TreePutTest; 21 | 22 | public class BTreePutCommonTest extends TreePutTest { 23 | 24 | @Override 25 | protected ITreeMutable createMutableTree(final boolean hasDuplicates, final int structureId) { 26 | return new BTreeEmpty(log, hasDuplicates, structureId).getMutableCopy(); 27 | } 28 | 29 | @Override 30 | protected ITree openTree(long address, boolean hasDuplicates) { 31 | return new BTree(log, address, hasDuplicates, 1); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /environment/src/test/java/jetbrains/exodus/tree/patricia/PatriciaAddressIteratorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.patricia; 17 | 18 | import org.junit.Test; 19 | 20 | public class PatriciaAddressIteratorTest extends PatriciaTestBase { 21 | 22 | @Test 23 | public void testSimple() { 24 | tm = createMutableTree(false, 1); 25 | for (char c = 'a'; c < 'k'; c++) { 26 | getTreeMutable().put(kv("xx" + c, "")); 27 | } 28 | 29 | for (char c = 'a'; c < 'k'; c++) { 30 | getTreeMutable().put(kv("xy" + c, "")); 31 | } 32 | 33 | t = new PatriciaTree(log, saveTree(), 1); 34 | checkAddressSet(getTree(), 23); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /environment/src/test/java/jetbrains/exodus/tree/patricia/PatriciaCursorConcurrentCursorModificationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.patricia; 17 | 18 | import jetbrains.exodus.ByteIterable; 19 | import jetbrains.exodus.tree.TreeBaseTest; 20 | import org.jetbrains.annotations.NotNull; 21 | 22 | public class PatriciaCursorConcurrentCursorModificationTest extends PatriciaCursorConcurrentModificationTest { 23 | @Override 24 | protected void deleteImpl(@NotNull ByteIterable key) { 25 | TreeBaseTest.doDeleteViaCursor(this, key); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /environment/src/test/java/jetbrains/exodus/tree/patricia/PatriciaCursorDuplicatesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.patricia; 17 | 18 | import jetbrains.exodus.tree.ITree; 19 | import jetbrains.exodus.tree.ITreeMutable; 20 | import jetbrains.exodus.tree.TreeCursorDuplicatesTest; 21 | 22 | public class PatriciaCursorDuplicatesTest extends TreeCursorDuplicatesTest { 23 | @Override 24 | protected ITreeMutable createMutableTree(final boolean hasDuplicates, final int structureId) { 25 | return PatriciaTestBase.doCreateMutableTree(hasDuplicates, structureId); 26 | } 27 | 28 | @Override 29 | protected ITree openTree(long address, boolean hasDuplicates) { 30 | return PatriciaTestBase.doOpenTree(address, hasDuplicates); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /environment/src/test/java/jetbrains/exodus/tree/patricia/PatriciaCursorNoDuplicatesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.patricia; 17 | 18 | import jetbrains.exodus.tree.ITree; 19 | import jetbrains.exodus.tree.ITreeMutable; 20 | import jetbrains.exodus.tree.TreeCursorNoDuplicatesTest; 21 | 22 | public class PatriciaCursorNoDuplicatesTest extends TreeCursorNoDuplicatesTest { 23 | 24 | @Override 25 | protected ITreeMutable createMutableTree(final boolean hasDuplicates, final int structureId) { 26 | return PatriciaTestBase.doCreateMutableTree(hasDuplicates, structureId); 27 | } 28 | 29 | @Override 30 | protected ITree openTree(long address, boolean hasDuplicates) { 31 | return PatriciaTestBase.doOpenTree(address, hasDuplicates); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /environment/src/test/java/jetbrains/exodus/tree/patricia/PatriciaDeleteCommonTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.patricia; 17 | 18 | import jetbrains.exodus.tree.ITree; 19 | import jetbrains.exodus.tree.ITreeMutable; 20 | import jetbrains.exodus.tree.TreeDeleteTest; 21 | 22 | public class PatriciaDeleteCommonTest extends TreeDeleteTest { 23 | 24 | @Override 25 | protected ITreeMutable createMutableTree(final boolean hasDuplicates, final int structureId) { 26 | return PatriciaTestBase.doCreateMutableTree(hasDuplicates, structureId); 27 | } 28 | 29 | @Override 30 | protected ITree openTree(long address, boolean hasDuplicates) { 31 | return PatriciaTestBase.doOpenTree(address, hasDuplicates); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /environment/src/test/java/jetbrains/exodus/tree/patricia/PatriciaPutCommonTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.patricia; 17 | 18 | import jetbrains.exodus.tree.ITree; 19 | import jetbrains.exodus.tree.ITreeMutable; 20 | import jetbrains.exodus.tree.TreePutTest; 21 | 22 | public class PatriciaPutCommonTest extends TreePutTest { 23 | 24 | @Override 25 | protected ITreeMutable createMutableTree(final boolean hasDuplicates, final int structureId) { 26 | return PatriciaTestBase.doCreateMutableTree(hasDuplicates, structureId); 27 | } 28 | 29 | @Override 30 | protected ITree openTree(long address, boolean hasDuplicates) { 31 | return PatriciaTestBase.doOpenTree(address, hasDuplicates); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /environment/src/test/java/jetbrains/exodus/tree/patricia/PatriciaTreeAddressIteratorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.tree.patricia; 17 | 18 | import jetbrains.exodus.tree.ITree; 19 | import jetbrains.exodus.tree.ITreeMutable; 20 | import jetbrains.exodus.tree.TreeAddressIteratorTest; 21 | 22 | public class PatriciaTreeAddressIteratorTest extends TreeAddressIteratorTest { 23 | 24 | @Override 25 | protected ITree createEmpty() { 26 | return new PatriciaTreeEmpty(log, 0, false); 27 | } 28 | 29 | @Override 30 | protected ITreeMutable createMutableTree(final boolean hasDuplicates, final int structureId) { 31 | return null; 32 | } 33 | 34 | @Override 35 | protected ITree openTree(long address, boolean hasDuplicates) { 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /environment/src/test/kotlin/jetbrains/exodus/env/EnvironmentConfigTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.env 17 | 18 | import org.junit.Assert 19 | import org.junit.Test 20 | 21 | class EnvironmentConfigTest { 22 | 23 | @Test 24 | fun `storeGetCache default value`() { 25 | System.setProperty(EnvironmentConfig.ENV_STOREGET_CACHE_SIZE, "0") 26 | Assert.assertNotSame( 27 | EnvironmentConfig.DEFAULT.getSetting(EnvironmentConfig.ENV_STOREGET_CACHE_SIZE), 28 | EnvironmentConfig().getSetting(EnvironmentConfig.ENV_STOREGET_CACHE_SIZE)) 29 | } 30 | } -------------------------------------------------------------------------------- /environment/src/test/kotlin/jetbrains/exodus/env/OutOfDiskSpaceInMemoryTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.env 17 | 18 | import jetbrains.exodus.core.dataStructures.Pair 19 | import jetbrains.exodus.io.DataReader 20 | import jetbrains.exodus.io.DataWriter 21 | import jetbrains.exodus.io.inMemory.Memory 22 | import jetbrains.exodus.io.inMemory.MemoryDataReader 23 | import jetbrains.exodus.io.inMemory.MemoryDataWriter 24 | 25 | class OutOfDiskSpaceInMemoryTest : OutOfDiskSpaceTest() { 26 | 27 | override fun createRW(): Pair { 28 | val memory = Memory() 29 | return Pair(MemoryDataReader(memory), MemoryDataWriter(memory)) 30 | } 31 | 32 | override fun deleteRW() { 33 | reader = null 34 | writer = null 35 | } 36 | } -------------------------------------------------------------------------------- /environment/src/test/kotlin/jetbrains/exodus/gc/GarbageCollectorInterleavingTestPrefixing.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.gc 17 | 18 | import jetbrains.exodus.env.StoreConfig 19 | 20 | class GarbageCollectorInterleavingTestPrefixing : GarbageCollectorInterleavingTest() { 21 | 22 | override val storeConfig: StoreConfig 23 | get() = StoreConfig.WITHOUT_DUPLICATES_WITH_PREFIXING 24 | 25 | override val recordsNumber: Int 26 | get() = 47 27 | } 28 | -------------------------------------------------------------------------------- /environment/src/test/kotlin/jetbrains/exodus/gc/GarbageCollectorLowCacheTestPrefixing.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.gc 17 | 18 | import jetbrains.exodus.env.StoreConfig 19 | 20 | class GarbageCollectorLowCacheTestPrefixing : GarbageCollectorLowCacheTest() { 21 | 22 | override val config: StoreConfig 23 | get() = StoreConfig.WITHOUT_DUPLICATES_WITH_PREFIXING 24 | } 25 | -------------------------------------------------------------------------------- /environment/src/test/kotlin/jetbrains/exodus/gc/GarbageCollectorTestPrefixing.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.gc 17 | 18 | import jetbrains.exodus.env.StoreConfig 19 | 20 | class GarbageCollectorTestPrefixing : GarbageCollectorTest() { 21 | 22 | override fun getStoreConfig(hasDuplicates: Boolean) = 23 | if (hasDuplicates) 24 | StoreConfig.WITH_DUPLICATES_WITH_PREFIXING 25 | else 26 | StoreConfig.WITHOUT_DUPLICATES_WITH_PREFIXING 27 | } 28 | -------------------------------------------------------------------------------- /environment/src/test/kotlin/jetbrains/exodus/gc/GarbageCollectorTestPrefixingInMemory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.gc 17 | 18 | import jetbrains.exodus.env.StoreConfig 19 | 20 | class GarbageCollectorTestPrefixingInMemory : GarbageCollectorTestInMemory() { 21 | 22 | override fun getStoreConfig(hasDuplicates: Boolean) = 23 | if (hasDuplicates) 24 | StoreConfig.WITH_DUPLICATES_WITH_PREFIXING 25 | else 26 | StoreConfig.WITHOUT_DUPLICATES_WITH_PREFIXING 27 | } 28 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # enables gradle daemon - dedicated build process, which significantly speeds up subsequent builds 2 | org.gradle.daemon=true 3 | # allows gradle to configure and build using all cores available 4 | org.gradle.parallel=true 5 | # gradle will use a maximum of the given number of workers 6 | #org.gradle.workers.max=1 7 | # give enough memory for gradle daemon 8 | org.gradle.jvmargs=-Xmx1024m -XX:+HeapDumpOnOutOfMemoryError 9 | # skips configuration phase for modules, which are not involved in requested tasks 10 | org.gradle.configureondemand=true 11 | 12 | systemProp.org.gradle.unsafe.kotlin.assignment=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/xodus/7b728d185aa648da1414f6ceb2c876c4399e6311/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /images: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /key.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/xodus/7b728d185aa648da1414f6ceb2c876c4399e6311/key.gpg -------------------------------------------------------------------------------- /license/copyright.ftl: -------------------------------------------------------------------------------- 1 | Copyright ${inceptionYear} - ${year} ${owner} 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | https://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /lucene-directory-v2/build.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation(project(":xodus-environment")) 3 | api(project(":xodus-openAPI")) 4 | implementation(project(":xodus-utils")) 5 | implementation(libs.jetbrains.annotations) 6 | 7 | implementation(libs.lucene.core) 8 | implementation(libs.lucene.analyzers.common) 9 | implementation(libs.lucene.queries) 10 | implementation(libs.lucene.queryparser) 11 | 12 | //noinspection DependencyNotationArgument 13 | //testImplementation project(':xodus-environment').sourceSets.test.output 14 | //noinspection DependencyNotationArgume 15 | testImplementation(project(":xodus-utils", "testArtifacts")) 16 | testImplementation(libs.lucene.test.framework) 17 | testImplementation(project(":xodus-environment", "testArtifacts")) 18 | } -------------------------------------------------------------------------------- /lucene-directory-v2/src/main/resources/META-INF/services/org.apache.lucene.codecs.Codec: -------------------------------------------------------------------------------- 1 | jetbrains.exodus.lucene2.codecs.Lucene87CodecWithNoFieldCompression -------------------------------------------------------------------------------- /lucene-directory-v2/src/test/java/jetbrains/exodus/lucene2/XodusThreadFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.lucene2; 17 | 18 | import com.carrotsearch.randomizedtesting.ThreadFilter; 19 | 20 | public class XodusThreadFilter implements ThreadFilter { 21 | @Override 22 | public boolean reject(Thread t) { 23 | return t.isDaemon(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /openAPI/build.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation(libs.jetbrains.annotations) 3 | implementation(project(":xodus-utils")) 4 | testImplementation(project(":xodus-utils", "testArtifacts")) 5 | } 6 | 7 | val testArtifacts by configurations.creating 8 | 9 | tasks { 10 | val jarTest by creating(Jar::class) { 11 | archiveClassifier.set("test") 12 | from(sourceSets.test.get().output) 13 | } 14 | artifacts { 15 | add("testArtifacts", jarTest) 16 | } 17 | } -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/ConfigurationStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus; 17 | 18 | /** 19 | * Defines a way how {@link AbstractConfig} should be initially set. E.g., {@link #IGNORE} creates 20 | * default config, {@link #SYSTEM_PROPERTY} creates config filled up with values of system properties. 21 | */ 22 | public interface ConfigurationStrategy { 23 | 24 | ConfigurationStrategy IGNORE = key -> null; 25 | 26 | ConfigurationStrategy SYSTEM_PROPERTY = System::getProperty; 27 | 28 | String getProperty(String key); 29 | } 30 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/InvalidSettingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus; 17 | 18 | /** 19 | * An exception thrown on setting an invalid configuration value. 20 | */ 21 | public class InvalidSettingException extends ExodusException { 22 | 23 | public InvalidSettingException(String message) { 24 | super(message); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/OutOfDiskSpaceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus; 17 | 18 | /** 19 | * An a exception thrown on commit or flush of a transaction or during opening existing database if no space left on device. 20 | */ 21 | public class OutOfDiskSpaceException extends ExodusException { 22 | 23 | private static final String DEFAULT_MESSAGE = "No space left on device to complete current transaction"; 24 | 25 | public OutOfDiskSpaceException(Throwable cause) { 26 | super(DEFAULT_MESSAGE, cause); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/backup/Backupable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.backup; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | /** 21 | * Something that can be backed up. {@link jetbrains.exodus.env.Environment}, 22 | * {@link jetbrains.exodus.entitystore.PersistentEntityStore} and {@link jetbrains.exodus.entitystore.BlobVault} are 23 | * {@code Backupable}. 24 | * 25 | * @see jetbrains.exodus.env.Environment 26 | * @see jetbrains.exodus.entitystore.PersistentEntityStore 27 | * @see jetbrains.exodus.entitystore.BlobVault 28 | */ 29 | public interface Backupable { 30 | 31 | @NotNull 32 | BackupStrategy getBackupStrategy(); 33 | } 34 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/crypto/ExodusCryptoException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.crypto; 17 | 18 | import jetbrains.exodus.ExodusException; 19 | 20 | /** 21 | * Base class for exceptions thrown by implementations of {@code jetbrains.exodus.crypto} API. 22 | */ 23 | public class ExodusCryptoException extends ExodusException { 24 | 25 | public ExodusCryptoException() { 26 | } 27 | 28 | public ExodusCryptoException(String message) { 29 | super(message); 30 | } 31 | 32 | public ExodusCryptoException(String message, Throwable cause) { 33 | super(message, cause); 34 | } 35 | 36 | public ExodusCryptoException(Throwable cause) { 37 | super(cause); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/crypto/InvalidCipherParametersException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.crypto; 17 | 18 | public class InvalidCipherParametersException extends ExodusCryptoException { 19 | 20 | public InvalidCipherParametersException() { 21 | super("Database is ciphered with different/unknown cipher parameters"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/entitystore/BlobVaultItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public interface BlobVaultItem { 21 | 22 | long getHandle(); 23 | 24 | @NotNull 25 | String getLocation(); 26 | 27 | boolean exists(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/entitystore/ComparableGetter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | /** 19 | * {@code Selector} is a generic interface for property getter functions for Entity. 20 | */ 21 | public interface ComparableGetter extends Selector { 22 | 23 | /** 24 | * Returns value for given object 25 | * 26 | * @return value 27 | */ 28 | @Override 29 | Comparable select(final Entity key); 30 | } 31 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/entitystore/EntityStoreException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | import jetbrains.exodus.ExodusException; 19 | 20 | /** 21 | * Any EntityStore exception is {@code EntityStoreException}. 22 | * 23 | * @see EntityRemovedInDatabaseException 24 | */ 25 | public class EntityStoreException extends ExodusException { 26 | 27 | public EntityStoreException() { 28 | } 29 | 30 | public EntityStoreException(String message) { 31 | super(message); 32 | } 33 | 34 | public EntityStoreException(String message, Throwable cause) { 35 | super(message, cause); 36 | } 37 | 38 | public EntityStoreException(Throwable cause) { 39 | super(cause); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/entitystore/MetaServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | import jetbrains.exodus.env.Environment; 19 | 20 | public interface MetaServer { 21 | 22 | void start(Environment environment); 23 | 24 | void stop(Environment environment); 25 | } 26 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/entitystore/Selector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | /** 19 | * {@code Selector} is a generic interface for property getter functions. 20 | */ 21 | public interface Selector { 22 | 23 | 24 | /** 25 | * Returns value for given object 26 | * 27 | * @return value 28 | */ 29 | Comparable select(final T key); 30 | } 31 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/entitystore/VaultSizeFunctions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore; 17 | 18 | import jetbrains.exodus.env.Transaction; 19 | import org.jetbrains.annotations.NotNull; 20 | 21 | public interface VaultSizeFunctions { 22 | 23 | long getBlobVaultSize(); 24 | 25 | long getBlobSize(final long blobHandle, @NotNull final Transaction txn); 26 | } 27 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/entitystore/iterate/EntityIdCollection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import jetbrains.exodus.entitystore.EntityId; 19 | 20 | public interface EntityIdCollection extends Iterable { 21 | 22 | int count(); 23 | } 24 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/entitystore/iterate/OrderedEntityIdCollection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import jetbrains.exodus.entitystore.EntityId; 19 | 20 | import java.util.Iterator; 21 | 22 | public interface OrderedEntityIdCollection extends EntityIdCollection { 23 | EntityId getFirst(); 24 | 25 | EntityId getLast(); 26 | 27 | Iterator reverseIterator(); 28 | } 29 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/entitystore/iterate/SortedEntityIdSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore.iterate; 17 | 18 | import jetbrains.exodus.entitystore.EntityId; 19 | import org.jetbrains.annotations.NotNull; 20 | 21 | public interface SortedEntityIdSet extends EntityIdSet, OrderedEntityIdCollection { 22 | 23 | int indexOf(@NotNull EntityId entityId); 24 | } 25 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/env/EnvironmentClosedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.env; 17 | 18 | import jetbrains.exodus.ExodusException; 19 | 20 | /** 21 | * Is thrown on attempt to close already closed {@linkplain Environment}. 22 | * 23 | * @see Environment#close() 24 | */ 25 | public class EnvironmentClosedException extends ExodusException { 26 | 27 | private static final String DEFAULT_MESSAGE = "Environment is already closed"; 28 | 29 | public EnvironmentClosedException() { 30 | super(DEFAULT_MESSAGE); 31 | } 32 | 33 | public EnvironmentClosedException(Throwable cause) { 34 | super(DEFAULT_MESSAGE, cause); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /openAPI/src/main/java/jetbrains/exodus/io/StorageTypeNotAllowedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.io; 17 | 18 | import jetbrains.exodus.ExodusException; 19 | 20 | /** 21 | * Exception thrown if a database is being opened on a storage of not allowed type: 22 | * removable device, on a remote file system, or on a RAM disk. 23 | */ 24 | public class StorageTypeNotAllowedException extends ExodusException { 25 | 26 | public StorageTypeNotAllowedException(String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /openAPI/src/main/kotlin/jetbrains/exodus/entitystore/EntityStoreEx.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore 17 | 18 | /** 19 | * Global and extension functions for different public classes in the `jetbrains.exodus.entitystore` package 20 | */ 21 | 22 | fun newPersistentEntityStoreConfig(configurator: PersistentEntityStoreConfig.() -> Unit): PersistentEntityStoreConfig { 23 | return PersistentEntityStoreConfig().apply { 24 | configurator() 25 | } 26 | } -------------------------------------------------------------------------------- /openAPI/src/main/kotlin/jetbrains/exodus/env/replication/EnvironmentReplicationDelta.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.env.replication 17 | 18 | import jetbrains.exodus.log.replication.LogReplicationDelta 19 | 20 | interface EnvironmentReplicationDelta : LogReplicationDelta { 21 | val id: Long 22 | val metaTreeAddress: Long 23 | val rootAddress: Long 24 | val encrypted: Boolean 25 | } 26 | -------------------------------------------------------------------------------- /openAPI/src/main/kotlin/jetbrains/exodus/log/replication/LogReplicationDelta.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.log.replication 17 | 18 | interface LogReplicationDelta { 19 | val startAddress: Long 20 | val highAddress: Long 21 | val fileLengthBound: Long 22 | val files: LongArray 23 | } 24 | -------------------------------------------------------------------------------- /openAPI/src/test/kotlin/jetbrains/exodus/FixedLengthByteIterableTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus 17 | 18 | import org.junit.Assert 19 | import org.junit.Test 20 | 21 | class FixedLengthByteIterableTest { 22 | 23 | @Test 24 | fun test() { 25 | val it = FixedLengthByteIterable(ArrayByteIterable( 26 | byteArrayOf(1.toByte(), 2.toByte(), 3.toByte()) 27 | ), 0, 1) 28 | var itr = it.iterator() 29 | Assert.assertTrue(itr.hasNext()) 30 | Assert.assertEquals(1.toByte().toLong(), itr.next().toLong()) 31 | Assert.assertFalse(itr.hasNext()) 32 | itr = it.iterator() 33 | itr.skip(1) 34 | Assert.assertFalse(itr.hasNext()) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /openAPI/src/test/kotlin/jetbrains/exodus/crypto/TrivialStreamCipher.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.crypto 17 | 18 | import kotlin.experimental.xor 19 | 20 | class TrivialStreamCipher : StreamCipher { 21 | 22 | private lateinit var key: ByteArray 23 | private var iv: Int = 0 24 | 25 | override fun init(key: ByteArray, iv: Long) { 26 | this.key = key 27 | this.iv = iv.toInt() xor (iv shr 32).toInt() 28 | } 29 | 30 | override fun crypt(b: Byte): Byte { 31 | return b xor key[(iv++ and 0x7fffffff).rem(key.size)] 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /openAPI/src/test/kotlin/jetbrains/exodus/entitystore/PersistentEntityStoreConfigTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.entitystore 17 | 18 | import jetbrains.exodus.ExodusException 19 | import jetbrains.exodus.TestFor 20 | import org.junit.Test 21 | 22 | class PersistentEntityStoreConfigTest { 23 | 24 | @Test(expected = ExodusException::class) 25 | @TestFor(issue = "XD-704") 26 | fun mutateDefaultConfig() { 27 | PersistentEntityStoreConfig.DEFAULT.isCachingDisabled = false 28 | } 29 | 30 | @Test(expected = ExodusException::class) 31 | @TestFor(issue = "XD-704") 32 | fun makeDefaultConfigMutable() { 33 | PersistentEntityStoreConfig.DEFAULT.isMutable = true 34 | } 35 | } -------------------------------------------------------------------------------- /query/build.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation(project(":xodus-entity-store")) 3 | implementation(project(":xodus-utils")) 4 | api(project(":xodus-openAPI")) 5 | implementation("com.github.penemue:keap:0.3.0") 6 | 7 | testImplementation(project(":xodus-utils", "testArtifacts")) 8 | testImplementation(project(":xodus-entity-store", "testArtifacts")) 9 | } -------------------------------------------------------------------------------- /query/src/main/java/jetbrains/exodus/query/CommutativeOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query; 17 | 18 | 19 | import org.jetbrains.annotations.NotNull; 20 | 21 | public abstract class CommutativeOperator extends BinaryOperator { 22 | CommutativeOperator(@NotNull final NodeBase left, @NotNull final NodeBase right) { 23 | super(left, right); 24 | } 25 | 26 | public void flipChildren() { 27 | NodeBase _left = getLeft(); 28 | setLeft(getRight()); 29 | setRight(_left); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /query/src/main/java/jetbrains/exodus/query/NodeFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query; 17 | 18 | 19 | public class NodeFactory { 20 | private NodeFactory() { 21 | } 22 | 23 | public static NodeBase all() { 24 | return new GetAll(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /query/src/main/java/jetbrains/exodus/query/OptimizationRule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query; 17 | 18 | 19 | class OptimizationRule { 20 | private final NodeBase source; 21 | private final NodeBase dest; 22 | 23 | OptimizationRule(NodeBase s, NodeBase d) { 24 | source = s; 25 | dest = d; 26 | } 27 | 28 | NodeBase getSource() { 29 | return source; 30 | } 31 | 32 | NodeBase getDest() { 33 | return dest; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /query/src/main/java/jetbrains/exodus/query/metadata/AssociationEndCardinality.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query.metadata; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public enum AssociationEndCardinality { 21 | 22 | _0_1("0..1"), 23 | _1("1"), 24 | _0_n("0..n"), 25 | _1_n("1..n"); 26 | 27 | private final String name; 28 | 29 | AssociationEndCardinality(String name) { 30 | this.name = name; 31 | } 32 | 33 | @NotNull 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public boolean isMultiple() { 39 | return this == _0_n || this == _1_n; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /query/src/main/java/jetbrains/exodus/query/metadata/AssociationEndMetaData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query.metadata; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public interface AssociationEndMetaData extends MemberMetaData { 21 | 22 | @NotNull 23 | EntityMetaData getOppositeEntityMetaData(); 24 | 25 | boolean getCascadeDelete(); 26 | 27 | boolean getClearOnDelete(); 28 | 29 | boolean getTargetCascadeDelete(); 30 | 31 | boolean getTargetClearOnDelete(); 32 | 33 | @NotNull 34 | AssociationEndCardinality getCardinality(); 35 | 36 | @NotNull 37 | AssociationMetaData getAssociationMetaData(); 38 | 39 | @NotNull 40 | AssociationEndType getAssociationEndType(); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /query/src/main/java/jetbrains/exodus/query/metadata/AssociationEndType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query.metadata; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public enum AssociationEndType { 21 | 22 | UndirectedAssociationEnd("UndirectedAssociationEnd"), 23 | DirectedAssociationEnd("DirectedAssociationEnd"), 24 | ParentEnd("ParentEnd"), 25 | ChildEnd("ChildEnd"); 26 | 27 | private final String name; 28 | 29 | AssociationEndType(String name) { 30 | this.name = name; 31 | } 32 | 33 | @NotNull 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /query/src/main/java/jetbrains/exodus/query/metadata/AssociationMetaData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query.metadata; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public interface AssociationMetaData { 21 | 22 | @NotNull 23 | AssociationType getType(); 24 | 25 | @NotNull 26 | AssociationEndMetaData getOppositeEnd(@NotNull AssociationEndMetaData end); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /query/src/main/java/jetbrains/exodus/query/metadata/AssociationType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query.metadata; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public enum AssociationType { 21 | 22 | Directed("Directed"), 23 | Undirected("Undirected"), 24 | Aggregation("Aggregation"); 25 | 26 | private final String name; 27 | 28 | AssociationType(String name) { 29 | this.name = name; 30 | } 31 | 32 | @NotNull 33 | public String getName() { 34 | return name; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /query/src/main/java/jetbrains/exodus/query/metadata/Index.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query.metadata; 17 | 18 | import org.jetbrains.annotations.Nullable; 19 | 20 | import java.util.List; 21 | import java.util.concurrent.Callable; 22 | 23 | public interface Index { 24 | 25 | String getOwnerEntityType(); 26 | 27 | List getFields(); 28 | 29 | @Nullable 30 | Callable getErrorMessageBuilder(); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /query/src/main/java/jetbrains/exodus/query/metadata/IndexField.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query.metadata; 17 | 18 | public interface IndexField { 19 | 20 | /** 21 | * True for property, false for link 22 | * 23 | * @return value flag 24 | */ 25 | boolean isProperty(); 26 | 27 | String getName(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /query/src/main/java/jetbrains/exodus/query/metadata/IndexFieldImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query.metadata; 17 | 18 | public class IndexFieldImpl implements IndexField { 19 | 20 | private boolean property; 21 | private String name; 22 | 23 | @Override 24 | public boolean isProperty() { 25 | return property; 26 | } 27 | 28 | public void setProperty(boolean property) { 29 | this.property = property; 30 | } 31 | 32 | @Override 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return name; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /query/src/main/java/jetbrains/exodus/query/metadata/MemberMetaData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query.metadata; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public interface MemberMetaData { 21 | 22 | @NotNull 23 | String getName(); 24 | } 25 | -------------------------------------------------------------------------------- /query/src/main/java/jetbrains/exodus/query/metadata/PropertyMetaData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query.metadata; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public interface PropertyMetaData extends MemberMetaData { 21 | 22 | @NotNull 23 | PropertyType getType(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /query/src/main/java/jetbrains/exodus/query/metadata/PropertyType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query.metadata; 17 | 18 | public enum PropertyType { 19 | 20 | PRIMITIVE, 21 | TEXT, 22 | BLOB 23 | } 24 | -------------------------------------------------------------------------------- /query/src/main/kotlin/jetbrains/exodus/query/InMemoryBoundedHeapSortIterable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query 17 | 18 | import jetbrains.exodus.entitystore.Entity 19 | import java.util.* 20 | 21 | class InMemoryBoundedHeapSortIterable(val capacity: Int, source: Iterable, comparator: Comparator) : InMemoryQueueSortIterable(source, comparator) { 22 | 23 | override fun createQueue(unsorted: Collection): Queue { 24 | val result = BoundedPriorityQueue(capacity, comparator) 25 | unsorted.forEach { result.offer(it) } 26 | return result 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /query/src/main/kotlin/jetbrains/exodus/query/InMemoryHeapSortIterable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query 17 | 18 | import jetbrains.exodus.entitystore.Entity 19 | import java.util.* 20 | 21 | class InMemoryHeapSortIterable(source: Iterable, comparator: Comparator) : InMemoryQueueSortIterable(source, comparator) { 22 | 23 | override fun createQueue(unsorted: Collection): Queue { 24 | val result = PriorityQueue(unsorted.size, comparator) 25 | unsorted.forEach { result.offer(it) } 26 | return result 27 | } 28 | } -------------------------------------------------------------------------------- /query/src/main/kotlin/jetbrains/exodus/query/InMemoryKeapSortIterable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query 17 | 18 | import com.github.penemue.keap.keapify 19 | import jetbrains.exodus.entitystore.Entity 20 | import java.util.* 21 | 22 | class InMemoryKeapSortIterable(source: Iterable, comparator: Comparator) : InMemoryQueueSortIterable(source, comparator) { 23 | 24 | override fun createQueue(unsorted: Collection): Queue { 25 | return unsorted.keapify(comparator) 26 | } 27 | } -------------------------------------------------------------------------------- /query/src/main/kotlin/jetbrains/exodus/query/InMemoryQueueSortIterable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.query 17 | 18 | import jetbrains.exodus.entitystore.Entity 19 | 20 | abstract class InMemoryQueueSortIterable(source: Iterable, comparator: Comparator) 21 | : SortEngine.InMemorySortIterable(source, comparator), InMemoryQueueSortIterableMixin { 22 | 23 | override val source: Iterable 24 | get() = super.src 25 | } 26 | -------------------------------------------------------------------------------- /samples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation(project(":xodus-entity-store")) 3 | implementation(project(":xodus-crypto")) 4 | implementation(project(":xodus-environment")) 5 | implementation("org.slf4j:slf4j-jdk14:2.0.7") 6 | } 7 | 8 | tasks { 9 | jar { 10 | enabled = false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tools/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.github.johnrengelman.shadow") 3 | } 4 | 5 | dependencies { 6 | implementation(project(":xodus-crypto")) 7 | implementation(project(":xodus-environment")) 8 | implementation(project(":xodus-entity-store")) 9 | implementation(project(":xodus-compress")) 10 | api(project(":xodus-openAPI")) 11 | implementation(project(":xodus-utils")) 12 | implementation("org.slf4j:slf4j-jdk14:2.0.7") 13 | } 14 | 15 | val testArtifacts: Configuration by configurations.creating 16 | 17 | tasks { 18 | shadowJar { 19 | mustRunAfter(jar) 20 | archiveFileName.set(jar.get().archiveFileName) 21 | manifest { 22 | attributes["Main-Class"] = "jetbrains.exodus.MainKt" 23 | } 24 | } 25 | 26 | 27 | jar { 28 | finalizedBy(shadowJar) 29 | } 30 | 31 | val jarTest by creating(Jar::class) { 32 | archiveClassifier.set("test") 33 | from(sourceSets.test.get().output) 34 | } 35 | 36 | artifacts { 37 | add("default", shadowJar) 38 | add("testArtifacts", jarTest) 39 | } 40 | } -------------------------------------------------------------------------------- /tools/src/main/resources/META-INF/services/jetbrains.exodus.io.DataReaderWriterProvider: -------------------------------------------------------------------------------- 1 | jetbrains.exodus.io.AsyncFileDataReaderWriterProvider 2 | jetbrains.exodus.io.inMemory.MemoryDataReaderWriterProvider -------------------------------------------------------------------------------- /utils/build.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation(libs.jetbrains.annotations) 3 | implementation(libs.slf4j.api) 4 | implementation(libs.caffeine.cache) 5 | } 6 | 7 | val testArtifacts by configurations.creating 8 | 9 | configurations { 10 | testArtifacts.extendsFrom(testRuntimeOnly.get()) 11 | } 12 | 13 | tasks { 14 | val jarTest by creating(Jar::class) { 15 | archiveClassifier.set("test") 16 | from(sourceSets.test.get().output) 17 | } 18 | artifacts { 19 | add("testArtifacts", jarTest) 20 | } 21 | } -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/dataStructures/LongIntPair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures; 17 | 18 | public class LongIntPair { 19 | public final long first; 20 | public final int second; 21 | 22 | public LongIntPair(long first, int second) { 23 | this.first = first; 24 | this.second = second; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/dataStructures/LongObjectBifFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures; 17 | 18 | @FunctionalInterface 19 | public interface LongObjectBifFunction { 20 | U apply(long first, T second); 21 | } 22 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/dataStructures/SoftConcurrentObjectCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures; 17 | 18 | import jetbrains.exodus.core.execution.SharedTimer; 19 | 20 | public class SoftConcurrentObjectCache extends SoftObjectCacheBase { 21 | 22 | public SoftConcurrentObjectCache(final int cacheSize) { 23 | super(cacheSize); 24 | } 25 | 26 | @Override 27 | protected ObjectCacheBase newChunk(final int chunkSize) { 28 | return new ConcurrentObjectCache(chunkSize) { 29 | @Override 30 | protected SharedTimer.ExpirablePeriodicTask getCacheAdjuster() { 31 | return null; 32 | } 33 | }; 34 | } 35 | } -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/dataStructures/SoftLongObjectCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures; 17 | 18 | import jetbrains.exodus.core.execution.SharedTimer; 19 | import org.jetbrains.annotations.NotNull; 20 | 21 | public class SoftLongObjectCache extends SoftLongObjectCacheBase { 22 | 23 | public SoftLongObjectCache(final int cacheSize) { 24 | super(cacheSize); 25 | } 26 | 27 | @NotNull 28 | @Override 29 | protected LongObjectCache newChunk(final int chunkSize) { 30 | return new LongObjectCache(chunkSize) { 31 | @Override 32 | protected SharedTimer.ExpirablePeriodicTask getCacheAdjuster() { 33 | return null; 34 | } 35 | }; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/dataStructures/SoftObjectCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures; 17 | 18 | import jetbrains.exodus.core.execution.SharedTimer; 19 | 20 | public class SoftObjectCache extends SoftObjectCacheBase { 21 | 22 | public SoftObjectCache(final int cacheSize) { 23 | super(cacheSize); 24 | } 25 | 26 | @Override 27 | protected ObjectCacheBase newChunk(final int chunkSize) { 28 | return new ObjectCache(chunkSize) { 29 | @Override 30 | protected SharedTimer.ExpirablePeriodicTask getCacheAdjuster() { 31 | return null; 32 | } 33 | }; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/dataStructures/hash/ObjectProcedure.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures.hash; 17 | 18 | public interface ObjectProcedure { 19 | 20 | boolean execute(T object); 21 | } 22 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/dataStructures/hash/ObjectProcedureThrows.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures.hash; 17 | 18 | public interface ObjectProcedureThrows { 19 | 20 | boolean execute(T object) throws E; 21 | } 22 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/dataStructures/hash/PairProcedure.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures.hash; 17 | 18 | public interface PairProcedure { 19 | 20 | boolean execute(K key, V value); 21 | } 22 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/dataStructures/persistent/EvictListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures.persistent; 17 | 18 | public interface EvictListener { 19 | 20 | void onEvict(K key, V value); 21 | } 22 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/dataStructures/persistent/Flag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures.persistent; 17 | 18 | interface Flag { 19 | 20 | boolean flag(); 21 | } 22 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/dataStructures/persistent/LongComparable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures.persistent; 17 | 18 | public interface LongComparable> extends Comparable { 19 | 20 | long getWeight(); 21 | } 22 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/dataStructures/persistent/RootHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures.persistent; 17 | 18 | interface RootHolder { 19 | 20 | Object getRoot(); 21 | } 22 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/execution/DefaultExceptionHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.execution; 17 | 18 | 19 | import org.slf4j.Logger; 20 | import org.slf4j.LoggerFactory; 21 | 22 | public class DefaultExceptionHandler implements JobProcessorExceptionHandler { 23 | 24 | private static final Logger logger = LoggerFactory.getLogger(JobProcessorExceptionHandler.class); 25 | 26 | @Override 27 | public void handle(JobProcessor processor, Job job, Throwable t) { 28 | logger.error(t.getMessage(), t); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/execution/JobProcessorExceptionHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.execution; 17 | 18 | public interface JobProcessorExceptionHandler { 19 | 20 | void handle(final JobProcessor processor, final Job job, final Throwable t); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/execution/LatchJob.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.execution; 17 | 18 | import jetbrains.exodus.core.execution.locks.Latch; 19 | 20 | public abstract class LatchJob extends Job { 21 | 22 | private final Latch latch; 23 | 24 | protected LatchJob() { 25 | latch = Latch.create(); 26 | } 27 | 28 | public void release() { 29 | latch.release(); 30 | } 31 | 32 | public boolean tryAcquire() { 33 | return latch.tryAcquire(); 34 | } 35 | 36 | public void acquire() throws InterruptedException { 37 | latch.acquire(); 38 | } 39 | 40 | public boolean acquire(long timeout) throws InterruptedException { 41 | return latch.acquire(timeout); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/execution/locks/CriticalSection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.execution.locks; 17 | 18 | import java.util.concurrent.locks.ReentrantLock; 19 | 20 | public final class CriticalSection extends ReentrantLock implements Guard { 21 | 22 | public CriticalSection() { 23 | this(false); 24 | } 25 | 26 | public CriticalSection(final boolean fair) { 27 | super(fair); 28 | } 29 | 30 | public CriticalSection enter() { 31 | lock(); 32 | return this; 33 | } 34 | 35 | @Override 36 | public void close() { 37 | unlock(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/execution/locks/Guard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.execution.locks; 17 | 18 | public interface Guard extends AutoCloseable { 19 | Guard EMPTY = () -> { 20 | 21 | }; 22 | 23 | @Override 24 | void close(); 25 | } 26 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/core/execution/locks/Latch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.execution.locks; 17 | 18 | public abstract class Latch { 19 | 20 | private static final boolean isDebugEnabled = Boolean.getBoolean("jetbrains.exodus.core.execution.debugLatchEnabled"); 21 | 22 | public abstract void acquire() throws InterruptedException; 23 | 24 | public abstract boolean acquire(long timeout) throws InterruptedException; 25 | 26 | public abstract boolean tryAcquire(); 27 | 28 | public abstract void release(); 29 | 30 | public abstract String getOwnerName(); 31 | 32 | public static Latch create() { 33 | return isDebugEnabled ? new DebugLatch() : new ReleaseLatch(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/util/ByteArraySpinAllocator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.util; 17 | 18 | public class ByteArraySpinAllocator extends SpinAllocator { 19 | 20 | public ByteArraySpinAllocator(final int readBufferSize) { 21 | super(() -> new byte[readBufferSize], null); 22 | } 23 | 24 | public ByteArraySpinAllocator(final int readBufferSize, final int maxAllocations) { 25 | super(() -> new byte[readBufferSize], null, maxAllocations); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /utils/src/main/java/jetbrains/exodus/util/StringHashMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.util; 17 | 18 | import jetbrains.exodus.core.dataStructures.hash.HashMap; 19 | 20 | public class StringHashMap extends HashMap { 21 | private static final int DEFAULT_CAPACITY = 9; 22 | private static final float DEFAULT_LOAD_FACTOR = 3; 23 | 24 | public StringHashMap() { 25 | super(DEFAULT_CAPACITY, 0, DEFAULT_LOAD_FACTOR, DEFAULT_TABLE_SIZE, DEFAULT_MASK); 26 | } 27 | 28 | public StringHashMap(int capacity, float loadFactor) { 29 | super(capacity, loadFactor); 30 | } 31 | 32 | @Override 33 | public T put(final String key, final T value) { 34 | return super.put(StringInterner.intern(key), value); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /utils/src/main/kotlin/jetbrains/exodus/runtime/OOMGuard.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.runtime 17 | 18 | import java.lang.ref.Reference 19 | import java.lang.ref.SoftReference 20 | import java.lang.ref.WeakReference 21 | 22 | class OOMGuard(private val extraBytes: Int = 0, 23 | private val softRef: Boolean = true /* use either SoftReference, or WeakReference*/) { 24 | 25 | private var ref: Reference = newReference() 26 | 27 | fun isItCloseToOOM() = ref.get() == null 28 | 29 | fun reset() { 30 | ref = newReference() 31 | } 32 | 33 | private fun newReference() = 34 | (if (extraBytes == 0) Any() else ByteArray(extraBytes)).let { 35 | if (softRef) SoftReference(it) else WeakReference(it) 36 | } 37 | } -------------------------------------------------------------------------------- /utils/src/main/kotlin/jetbrains/exodus/util/IdGenerator.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.util 17 | 18 | import java.lang.Integer.MAX_VALUE 19 | import java.util.concurrent.atomic.AtomicInteger 20 | 21 | const val prime = 800076929 // 800076929 is a prime 22 | 23 | class IdGenerator { 24 | 25 | private val id = AtomicInteger((Math.random() * MAX_VALUE).toInt()) 26 | 27 | fun nextId(): Int { 28 | while (true) { 29 | val currentId = id.get() 30 | var nextId = (currentId + prime) and 0x7fffffff 31 | if (nextId == 0) nextId = prime 32 | if (id.compareAndSet(currentId, nextId)) { 33 | return nextId 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /utils/src/main/kotlin/jetbrains/exodus/util/SystemProperty.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.util 17 | 18 | import java.lang.Boolean.getBoolean 19 | 20 | /** 21 | * Executes an action if specified system property with defaultValue is equal to specified value. 22 | */ 23 | fun doIfPropertyIsEqualTo(prop: String, value: String?, defaultValue: String? = null, action: () -> Unit) { 24 | if (System.getProperty(prop, defaultValue) == value) { 25 | action() 26 | } 27 | } 28 | 29 | /** 30 | * Executes an action if specified system property is equal to `true`. 31 | */ 32 | fun doIfTrue(prop: String, action: () -> Unit) { 33 | if (getBoolean(prop)) { 34 | action() 35 | } 36 | } -------------------------------------------------------------------------------- /utils/src/main/kotlin/jetbrains/exodus/util/UnsafeHolder.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.util 17 | 18 | import java.security.AccessController 19 | import java.security.PrivilegedExceptionAction 20 | 21 | object UnsafeHolder { 22 | 23 | val unsafeClass: Class<*> = doPrivileged { Class.forName("sun.misc.Unsafe") } 24 | val theUnsafe: Any = doPrivileged { 25 | unsafeClass.getDeclaredField("theUnsafe").apply { isAccessible = true }[null] 26 | } 27 | 28 | fun doPrivileged(f: () -> T): T { 29 | return AccessController.doPrivileged(PrivilegedExceptionAction { 30 | f() 31 | }) 32 | } 33 | } -------------------------------------------------------------------------------- /utils/src/test/java/jetbrains/exodus/core/dataStructures/ConcurrentStablePriorityQueueTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures; 17 | 18 | @SuppressWarnings("rawtypes") 19 | public class ConcurrentStablePriorityQueueTest extends PriorityQueueTest { 20 | 21 | @Override 22 | protected PriorityQueue createQueue() { 23 | return new ConcurrentStablePriorityQueue(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /utils/src/test/java/jetbrains/exodus/core/dataStructures/StablePriorityQueueTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures; 17 | 18 | @SuppressWarnings("rawtypes") 19 | public class StablePriorityQueueTest extends PriorityQueueTest { 20 | 21 | @Override 22 | protected PriorityQueue createQueue() { 23 | return new StablePriorityQueue(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /utils/src/test/java/jetbrains/exodus/core/dataStructures/persistent/PersistentBitTreeLongMapTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures.persistent; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public class PersistentBitTreeLongMapTest extends PersistentLongMapTest { 21 | 22 | @NotNull 23 | @Override 24 | protected PersistentLongMap createMap() { 25 | return new PersistentBitTreeLongMap<>(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /utils/src/test/java/jetbrains/exodus/util/MathTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.util; 17 | 18 | import org.junit.Assert; 19 | import org.junit.Test; 20 | 21 | public class MathTest { 22 | 23 | @Test 24 | public void testLog() { 25 | int power = 1; 26 | int expected = 0; 27 | for (int i = 0; i < 10000; i++) { 28 | Assert.assertEquals(expected, MathUtil.integerLogarithm(i)); 29 | if (i == power) { 30 | power <<= 1; 31 | expected++; 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /utils/src/test/kotlin/jetbrains/exodus/core/dataStructures/hash/LongHashSetTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures.hash 17 | 18 | class LongHashSetTest : LongSetTest() { 19 | 20 | override fun newSet() = LongHashSet() 21 | } -------------------------------------------------------------------------------- /utils/src/test/kotlin/jetbrains/exodus/core/dataStructures/hash/PackedLongHashSetTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures.hash 17 | 18 | class PackedLongHashSetTest : LongSetTest() { 19 | 20 | override fun newSet() = PackedLongHashSet() 21 | } -------------------------------------------------------------------------------- /utils/src/test/kotlin/jetbrains/exodus/core/dataStructures/persistent/PersistentLong23TreeSetTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.core.dataStructures.persistent 17 | 18 | class PersistentLong23TreeSetTest : PersistentBitTreeLongSetTest() { 19 | 20 | override fun createSet(): PersistentLongSet { 21 | return PersistentLong23TreeSet() 22 | } 23 | } -------------------------------------------------------------------------------- /utils/src/test/kotlin/jetbrains/exodus/testutil/ParallelRunUtil.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.testutil 17 | 18 | import java.util.concurrent.Executors 19 | import java.util.concurrent.TimeUnit 20 | 21 | fun runInParallel(concurrencyLevel: Int, taskCount: Int = 1, action: (Int) -> Unit) { 22 | val executor = Executors.newFixedThreadPool(concurrencyLevel) 23 | repeat(taskCount) { i -> 24 | executor.submit { 25 | action(i) 26 | } 27 | } 28 | executor.shutdown() 29 | executor.awaitTermination(1, TimeUnit.MINUTES) 30 | } -------------------------------------------------------------------------------- /utils/src/test/kotlin/jetbrains/exodus/util/IOUtilTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright ${inceptionYear} - ${year} ${owner} 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package jetbrains.exodus.util 17 | 18 | import org.junit.Assert 19 | import org.junit.Test 20 | 21 | class IOUtilTest { 22 | 23 | @Test 24 | fun `is removable file`() { 25 | createTempFile().let { tmpFile -> 26 | try { 27 | Assert.assertFalse(IOUtil.isRemovableFile(tmpFile)) 28 | } finally { 29 | IOUtil.deleteFile(tmpFile) 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /utils/src/test/resources/jna0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/xodus/7b728d185aa648da1414f6ceb2c876c4399e6311/utils/src/test/resources/jna0.jar -------------------------------------------------------------------------------- /utils/src/test/resources/jna1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JetBrains/xodus/7b728d185aa648da1414f6ceb2c876c4399e6311/utils/src/test/resources/jna1.jar --------------------------------------------------------------------------------