Merge lp:~pbeaman/akiban-persistit/eclipse-canonical-format into lp:akiban-persistit
- eclipse-canonical-format
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Nathan Williams |
Approved revision: | 360 |
Merged at revision: | 357 |
Proposed branch: | lp:~pbeaman/akiban-persistit/eclipse-canonical-format |
Merge into: | lp:akiban-persistit |
Diff against target: |
38278 lines (+6531/-5813) 313 files modified
doc/ReleaseNotes.rst (+20/-0) pom.xml (+37/-1) src/etc/eclipse-cleanup-config.xml (+56/-0) src/etc/eclipse-format-config.xml (+291/-0) src/main/java/com/persistit/Accumulator.java (+10/-9) src/main/java/com/persistit/AccumulatorState.java (+4/-5) src/main/java/com/persistit/AlertMonitor.java (+27/-27) src/main/java/com/persistit/AntiValue.java (+15/-15) src/main/java/com/persistit/BackupTask.java (+14/-13) src/main/java/com/persistit/Buffer.java (+427/-421) src/main/java/com/persistit/BufferPool.java (+110/-99) src/main/java/com/persistit/BufferPoolMXBeanImpl.java (+6/-5) src/main/java/com/persistit/CLI.java (+66/-62) src/main/java/com/persistit/CheckpointManager.java (+26/-27) src/main/java/com/persistit/ClassIndex.java (+38/-36) src/main/java/com/persistit/ClassInfo.java (+10/-9) src/main/java/com/persistit/CleanupManager.java (+27/-26) src/main/java/com/persistit/Configuration.java (+97/-89) src/main/java/com/persistit/DefaultCoderManager.java (+46/-44) src/main/java/com/persistit/DefaultObjectCoder.java (+40/-39) src/main/java/com/persistit/DefaultValueCoder.java (+114/-113) src/main/java/com/persistit/Exchange.java (+177/-170) src/main/java/com/persistit/FastIndex.java (+43/-43) src/main/java/com/persistit/GetVersion.java (+10/-7) src/main/java/com/persistit/IOMeter.java (+35/-31) src/main/java/com/persistit/IOTaskRunnable.java (+11/-11) src/main/java/com/persistit/IntegrityCheck.java (+115/-106) src/main/java/com/persistit/JournalManager.java (+103/-98) src/main/java/com/persistit/JournalRecord.java (+6/-7) src/main/java/com/persistit/JournalTool.java (+47/-47) src/main/java/com/persistit/Key.java (+155/-149) src/main/java/com/persistit/KeyFilter.java (+109/-105) src/main/java/com/persistit/KeyHistogram.java (+10/-8) src/main/java/com/persistit/KeyParser.java (+35/-35) src/main/java/com/persistit/KeyState.java (+21/-21) src/main/java/com/persistit/LongRecordHelper.java (+11/-11) src/main/java/com/persistit/MVV.java (+24/-22) src/main/java/com/persistit/Management.java (+53/-44) src/main/java/com/persistit/ManagementImpl.java (+129/-126) src/main/java/com/persistit/MediatedFileChannel.java (+53/-52) src/main/java/com/persistit/Persistit.java (+113/-112) src/main/java/com/persistit/PersistitMap.java (+93/-85) src/main/java/com/persistit/RecoveryManager.java (+81/-63) src/main/java/com/persistit/SessionId.java (+1/-1) src/main/java/com/persistit/SharedResource.java (+18/-18) src/main/java/com/persistit/StatisticsTask.java (+17/-13) src/main/java/com/persistit/StreamLoader.java (+56/-55) src/main/java/com/persistit/StreamSaver.java (+32/-30) src/main/java/com/persistit/Task.java (+27/-26) src/main/java/com/persistit/TaskCheck.java (+14/-13) src/main/java/com/persistit/TimestampAllocator.java (+2/-2) src/main/java/com/persistit/Transaction.java (+21/-21) src/main/java/com/persistit/TransactionIndex.java (+32/-30) src/main/java/com/persistit/TransactionIndexBucket.java (+6/-6) src/main/java/com/persistit/TransactionPlayer.java (+17/-17) src/main/java/com/persistit/TransactionPlayerSupport.java (+0/-1) src/main/java/com/persistit/TransactionRunnable.java (+3/-3) src/main/java/com/persistit/TransactionStatus.java (+20/-17) src/main/java/com/persistit/Tree.java (+13/-13) src/main/java/com/persistit/TreeSelector.java (+6/-6) src/main/java/com/persistit/TreeState.java (+3/-3) src/main/java/com/persistit/TreeStatistics.java (+6/-6) src/main/java/com/persistit/Value.java (+433/-371) src/main/java/com/persistit/ValueHelper.java (+31/-28) src/main/java/com/persistit/ValueState.java (+8/-8) src/main/java/com/persistit/Volume.java (+8/-7) src/main/java/com/persistit/VolumeHandleLookup.java (+0/-2) src/main/java/com/persistit/VolumeHeader.java (+12/-12) src/main/java/com/persistit/VolumeSpecification.java (+15/-16) src/main/java/com/persistit/VolumeStatistics.java (+8/-8) src/main/java/com/persistit/VolumeStorage.java (+1/-3) src/main/java/com/persistit/VolumeStorageT2.java (+40/-17) src/main/java/com/persistit/VolumeStorageV2.java (+56/-28) src/main/java/com/persistit/VolumeStructure.java (+49/-49) src/main/java/com/persistit/encoding/CollectionValueCoder.java (+20/-19) src/main/java/com/persistit/encoding/EnumValueCoder.java (+4/-4) src/main/java/com/persistit/encoding/KeyDisplayer.java (+4/-4) src/main/java/com/persistit/encoding/KeyRenderer.java (+7/-7) src/main/java/com/persistit/encoding/ObjectCache.java (+19/-19) src/main/java/com/persistit/encoding/SerialValueCoder.java (+9/-9) src/main/java/com/persistit/exception/AppendableIOException.java (+1/-1) src/main/java/com/persistit/exception/BufferSizeUnavailableException.java (+1/-1) src/main/java/com/persistit/exception/ConversionException.java (+3/-3) src/main/java/com/persistit/exception/CorruptImportStreamException.java (+1/-1) src/main/java/com/persistit/exception/CorruptJournalException.java (+1/-1) src/main/java/com/persistit/exception/CorruptValueException.java (+1/-1) src/main/java/com/persistit/exception/CorruptVolumeException.java (+1/-1) src/main/java/com/persistit/exception/InUseException.java (+1/-1) src/main/java/com/persistit/exception/InvalidKeyException.java (+1/-1) src/main/java/com/persistit/exception/InvalidPageAddressException.java (+1/-1) src/main/java/com/persistit/exception/InvalidPageStructureException.java (+1/-1) src/main/java/com/persistit/exception/InvalidPageTypeException.java (+1/-1) src/main/java/com/persistit/exception/InvalidVolumeSpecificationException.java (+1/-1) src/main/java/com/persistit/exception/MalformedValueException.java (+1/-1) src/main/java/com/persistit/exception/MissingKeySegmentException.java (+1/-1) src/main/java/com/persistit/exception/MissingThreadException.java (+1/-1) src/main/java/com/persistit/exception/MissingVolumeException.java (+1/-1) src/main/java/com/persistit/exception/PersistitClosedException.java (+1/-1) src/main/java/com/persistit/exception/PersistitException.java (+3/-3) src/main/java/com/persistit/exception/PersistitIOException.java (+4/-4) src/main/java/com/persistit/exception/PersistitInterruptedException.java (+1/-2) src/main/java/com/persistit/exception/PropertiesNotFoundException.java (+1/-2) src/main/java/com/persistit/exception/ReadOnlyVolumeException.java (+1/-1) src/main/java/com/persistit/exception/RebalanceException.java (+1/-2) src/main/java/com/persistit/exception/RecoveryMissingVolumesException.java (+1/-1) src/main/java/com/persistit/exception/RollbackException.java (+2/-2) src/main/java/com/persistit/exception/TaskEndedException.java (+1/-2) src/main/java/com/persistit/exception/TestException.java (+1/-1) src/main/java/com/persistit/exception/TimeoutException.java (+1/-2) src/main/java/com/persistit/exception/TransactionFailedException.java (+2/-2) src/main/java/com/persistit/exception/TreeAlreadyExistsException.java (+1/-1) src/main/java/com/persistit/exception/TreeNotFoundException.java (+1/-1) src/main/java/com/persistit/exception/TruncateVolumeException.java (+1/-1) src/main/java/com/persistit/exception/VolumeAlreadyExistsException.java (+1/-1) src/main/java/com/persistit/exception/VolumeClosedException.java (+1/-2) src/main/java/com/persistit/exception/VolumeFullException.java (+1/-2) src/main/java/com/persistit/exception/VolumeNotFoundException.java (+1/-2) src/main/java/com/persistit/exception/WrongVolumeException.java (+1/-2) src/main/java/com/persistit/logging/ApacheCommonsLogAdapter.java (+4/-4) src/main/java/com/persistit/logging/DefaultPersistitLogger.java (+8/-5) src/main/java/com/persistit/logging/JDK14LoggingAdapter.java (+3/-4) src/main/java/com/persistit/logging/Log4JAdapter.java (+4/-5) src/main/java/com/persistit/logging/LogBase.java (+3/-4) src/main/java/com/persistit/logging/PersistitLevel.java (+0/-1) src/main/java/com/persistit/logging/PersistitLogMessage.java (+15/-12) src/main/java/com/persistit/logging/Slf4jAdapter.java (+3/-3) src/main/java/com/persistit/mxbeans/CleanupManagerMXBean.java (+2/-2) src/main/java/com/persistit/mxbeans/Description.java (+3/-1) src/main/java/com/persistit/mxbeans/IOMeterMXBean.java (+0/-2) src/main/java/com/persistit/mxbeans/JournalManagerMXBean.java (+2/-2) src/main/java/com/persistit/mxbeans/MXBeanWrapper.java (+30/-29) src/main/java/com/persistit/mxbeans/ManagementMXBean.java (+14/-10) src/main/java/com/persistit/mxbeans/PName.java (+3/-4) src/main/java/com/persistit/mxbeans/TransactionIndexMXBean.java (+0/-1) src/main/java/com/persistit/policy/JoinPolicy.java (+9/-10) src/main/java/com/persistit/policy/SplitPolicy.java (+25/-18) src/main/java/com/persistit/ref/AbstractReference.java (+2/-2) src/main/java/com/persistit/ref/AbstractWeakReference.java (+2/-2) src/main/java/com/persistit/ui/AbstractInspector.java (+1/-1) src/main/java/com/persistit/ui/AdminPanel.java (+1/-1) src/main/java/com/persistit/ui/AdminUI.java (+199/-179) src/main/java/com/persistit/ui/AdminUIBufferPanel.java (+24/-24) src/main/java/com/persistit/ui/AdminUISummaryPanel.java (+23/-22) src/main/java/com/persistit/ui/AdminUITaskPanel.java (+39/-39) src/main/java/com/persistit/ui/AdminUITreePanel.java (+38/-37) src/main/java/com/persistit/ui/InnerJarClassLoader.java (+14/-14) src/main/java/com/persistit/ui/InspectorDisplayablePanel.java (+3/-3) src/main/java/com/persistit/ui/InspectorHexPanel.java (+4/-4) src/main/java/com/persistit/ui/InspectorObjectPanel.java (+18/-17) src/main/java/com/persistit/ui/InspectorPanel.java (+27/-27) src/main/java/com/persistit/ui/ManagementListModel.java (+5/-5) src/main/java/com/persistit/ui/ManagementSlidingTableModel.java (+20/-19) src/main/java/com/persistit/ui/ManagementTableModel.java (+37/-36) src/main/java/com/persistit/ui/PersistitTableModel.java (+54/-54) src/main/java/com/persistit/ui/PoolDisplayPanel.java (+28/-28) src/main/java/com/persistit/ui/TaskSetupPanel.java (+48/-47) src/main/java/com/persistit/ui/TreeAndVolumeSelector.java (+57/-58) src/main/java/com/persistit/ui/VTComboBoxModel.java (+12/-13) src/main/java/com/persistit/ui/ValueInspectorTreeNode.java (+43/-42) src/main/java/com/persistit/ui/renderers/TaskStatusStateRenderer.java (+2/-2) src/main/java/com/persistit/util/ArgParser.java (+31/-32) src/main/java/com/persistit/util/Debug.java (+21/-19) src/main/java/com/persistit/util/InternalHashSet.java (+8/-8) src/main/java/com/persistit/util/SequencerConstants.java (+35/-35) src/main/java/com/persistit/util/ThreadSequencer.java (+22/-22) src/main/java/com/persistit/util/Util.java (+98/-99) src/test/java/com/persistit/AccumulatorMemoryTest.java (+6/-6) src/test/java/com/persistit/AccumulatorRecoveryTest.java (+46/-42) src/test/java/com/persistit/AccumulatorTest.java (+67/-68) src/test/java/com/persistit/AlertMonitorTest.java (+13/-10) src/test/java/com/persistit/BackupTaskTest.java (+8/-6) src/test/java/com/persistit/BufferMaxPack.java (+2/-2) src/test/java/com/persistit/BufferPoolTest.java (+16/-16) src/test/java/com/persistit/BufferTest.java (+14/-12) src/test/java/com/persistit/BufferTest2.java (+39/-38) src/test/java/com/persistit/Bug1003578Test.java (+5/-5) src/test/java/com/persistit/Bug1017957Test.java (+13/-12) src/test/java/com/persistit/Bug1018526Test.java (+8/-7) src/test/java/com/persistit/Bug706132Test.java (+2/-3) src/test/java/com/persistit/Bug708592Test.java (+0/-2) src/test/java/com/persistit/Bug739533Test.java (+1/-2) src/test/java/com/persistit/Bug777918Test.java (+5/-6) src/test/java/com/persistit/Bug790709Test.java (+2/-4) src/test/java/com/persistit/Bug870352Test.java (+1/-3) src/test/java/com/persistit/Bug877656Test.java (+4/-7) src/test/java/com/persistit/Bug882219Test.java (+5/-6) src/test/java/com/persistit/Bug885477Test.java (+0/-3) src/test/java/com/persistit/Bug889850Test.java (+0/-2) src/test/java/com/persistit/Bug911849Test.java (+6/-9) src/test/java/com/persistit/Bug912514Test.java (+6/-6) src/test/java/com/persistit/Bug915594Test.java (+2/-5) src/test/java/com/persistit/Bug918909Test.java (+0/-4) src/test/java/com/persistit/Bug920754Test.java (+0/-4) src/test/java/com/persistit/Bug923790Test.java (+5/-6) src/test/java/com/persistit/Bug927701Test.java (+3/-3) src/test/java/com/persistit/Bug937877Test.java (+4/-5) src/test/java/com/persistit/Bug942669Test.java (+6/-6) src/test/java/com/persistit/Bug947182Test.java (+10/-12) src/test/java/com/persistit/Bug974589Test.java (+2/-2) src/test/java/com/persistit/Bug980292Test.java (+1/-4) src/test/java/com/persistit/Bug989202Test.java (+3/-3) src/test/java/com/persistit/Bug992801Test.java (+0/-4) src/test/java/com/persistit/Bug996241Test.java (+14/-19) src/test/java/com/persistit/ClassIndexTest.java (+29/-27) src/test/java/com/persistit/CleanupManagerTest.java (+3/-3) src/test/java/com/persistit/CommandLineTest.java (+4/-4) src/test/java/com/persistit/ConfigurationTest.java (+21/-20) src/test/java/com/persistit/ConfirmEmptyVolume.java (+1/-1) src/test/java/com/persistit/ConfirmIntegrity.java (+0/-1) src/test/java/com/persistit/CorruptVolumeTest.java (+3/-3) src/test/java/com/persistit/DumpTaskTest.java (+8/-7) src/test/java/com/persistit/ErrorInjectingFileChannel.java (+40/-39) src/test/java/com/persistit/FastIndexTest.java (+19/-19) src/test/java/com/persistit/FatalErrorExceptionTest.java (+3/-3) src/test/java/com/persistit/IOFailureTest.java (+16/-13) src/test/java/com/persistit/IOMeterChargeBenchmark.java (+4/-4) src/test/java/com/persistit/InsertSequenceTest.java (+7/-6) src/test/java/com/persistit/IntegrityCheckTest.java (+28/-26) src/test/java/com/persistit/JournalManagerTest.java (+87/-84) src/test/java/com/persistit/KeyHistogramTest.java (+1/-1) src/test/java/com/persistit/MVCCBasicTest.java (+48/-48) src/test/java/com/persistit/MVCCConcurrentTest.java (+8/-9) src/test/java/com/persistit/MVCCPruneBufferTest.java (+31/-29) src/test/java/com/persistit/MVCCPruneTest.java (+14/-14) src/test/java/com/persistit/MVCCTestBase.java (+40/-36) src/test/java/com/persistit/MVVTest.java (+53/-43) src/test/java/com/persistit/MediatedFileChannelTest.java (+7/-6) src/test/java/com/persistit/MockSerializableObject.java (+1/-1) src/test/java/com/persistit/RecoveryTest.java (+62/-61) src/test/java/com/persistit/ScriptedKeyFilterTest.java (+8/-8) src/test/java/com/persistit/SplitPolicyTest.java (+18/-18) src/test/java/com/persistit/StressRunner.java (+14/-13) src/test/java/com/persistit/TestShim.java (+6/-5) src/test/java/com/persistit/TransactionIndexConcurrencyTest.java (+18/-17) src/test/java/com/persistit/TransactionIndexTest.java (+21/-18) src/test/java/com/persistit/TransactionLifetimeTest.java (+12/-9) src/test/java/com/persistit/TransactionTest2.java (+13/-11) src/test/java/com/persistit/TreeLifetimeTest.java (+16/-16) src/test/java/com/persistit/TreeTest2.java (+4/-4) src/test/java/com/persistit/ValueTest7.java (+6/-7) src/test/java/com/persistit/VolumeTest.java (+32/-32) src/test/java/com/persistit/WarmupTest.java (+23/-22) src/test/java/com/persistit/stress/AbstractStressTest.java (+3/-2) src/test/java/com/persistit/stress/AbstractSuite.java (+19/-19) src/test/java/com/persistit/stress/InsertUUIDs.java (+2/-1) src/test/java/com/persistit/stress/IntentionalFailure.java (+5/-4) src/test/java/com/persistit/stress/Mixture1.java (+2/-1) src/test/java/com/persistit/stress/Mixture2.java (+2/-1) src/test/java/com/persistit/stress/Mixture3.java (+2/-1) src/test/java/com/persistit/stress/MixtureTxn1.java (+1/-1) src/test/java/com/persistit/stress/MixtureTxn2.java (+2/-1) src/test/java/com/persistit/stress/PersistitMap1.java (+2/-1) src/test/java/com/persistit/stress/Recovery1.java (+2/-1) src/test/java/com/persistit/stress/Recovery2.java (+2/-1) src/test/java/com/persistit/stress/Recovery2_StdIn.java (+2/-1) src/test/java/com/persistit/stress/StartStop.java (+7/-5) src/test/java/com/persistit/stress/Stress10Suite.java (+2/-1) src/test/java/com/persistit/stress/Stress12txnSuite.java (+2/-1) src/test/java/com/persistit/stress/Stress4Suite.java (+2/-1) src/test/java/com/persistit/stress/Stress8txnSuite.java (+2/-1) src/test/java/com/persistit/stress/TestResult.java (+1/-1) src/test/java/com/persistit/stress/unit/CommitBench.java (+14/-13) src/test/java/com/persistit/stress/unit/MD5Sum.java (+2/-5) src/test/java/com/persistit/stress/unit/PersistitMapStress1.java (+9/-11) src/test/java/com/persistit/stress/unit/PersistitMapStress2.java (+11/-12) src/test/java/com/persistit/stress/unit/Stress1.java (+3/-4) src/test/java/com/persistit/stress/unit/Stress10.java (+3/-7) src/test/java/com/persistit/stress/unit/Stress11.java (+3/-7) src/test/java/com/persistit/stress/unit/Stress12txn.java (+2/-3) src/test/java/com/persistit/stress/unit/Stress1txn.java (+3/-4) src/test/java/com/persistit/stress/unit/Stress2.java (+5/-6) src/test/java/com/persistit/stress/unit/Stress2txn.java (+5/-7) src/test/java/com/persistit/stress/unit/Stress3.java (+3/-5) src/test/java/com/persistit/stress/unit/Stress3txn.java (+3/-5) src/test/java/com/persistit/stress/unit/Stress4Base.java (+1/-1) src/test/java/com/persistit/stress/unit/Stress4a.java (+1/-1) src/test/java/com/persistit/stress/unit/Stress4b.java (+1/-1) src/test/java/com/persistit/stress/unit/Stress5.java (+1/-2) src/test/java/com/persistit/stress/unit/Stress6.java (+5/-7) src/test/java/com/persistit/stress/unit/Stress7.java (+7/-11) src/test/java/com/persistit/stress/unit/Stress8txn.java (+2/-6) src/test/java/com/persistit/stress/unit/Stress9.java (+5/-6) src/test/java/com/persistit/stress/unit/StressBase.java (+1/-2) src/test/java/com/persistit/stress/unit/StressInsert.java (+3/-4) src/test/java/com/persistit/stress/unit/StressRecovery.java (+20/-21) src/test/java/com/persistit/stress/unit/StressRecoveryTxn1.java (+2/-2) src/test/java/com/persistit/stress/unit/StressUUID.java (+1/-1) src/test/java/com/persistit/stress/unit/TestSamePageOptimization.java (+6/-6) src/test/java/com/persistit/unit/BufferPoolMemConfigurationTest.java (+6/-6) src/test/java/com/persistit/unit/ConcurrentUtil.java (+28/-24) src/test/java/com/persistit/unit/ExchangeTest.java (+36/-35) src/test/java/com/persistit/unit/FileLockTest.java (+1/-1) src/test/java/com/persistit/unit/JoinTest1.java (+3/-2) src/test/java/com/persistit/unit/KeyCoderTest1.java (+41/-40) src/test/java/com/persistit/unit/KeyFilterTest2.java (+11/-11) src/test/java/com/persistit/unit/KeyTest1.java (+23/-22) src/test/java/com/persistit/unit/Log4JLoggerTest.java (+1/-1) src/test/java/com/persistit/unit/LongRecordTest1.java (+1/-1) src/test/java/com/persistit/unit/LotsaSmallKeys.java (+1/-1) src/test/java/com/persistit/unit/PersistitMapTest.java (+3/-1) src/test/java/com/persistit/unit/PersistitUnitTestCase.java (+9/-9) src/test/java/com/persistit/unit/SimpleTest1.java (+5/-4) src/test/java/com/persistit/unit/TemporaryVolumeTest1.java (+11/-10) src/test/java/com/persistit/unit/ThreadSequencerTest.java (+7/-5) src/test/java/com/persistit/unit/TransactionTest1.java (+6/-6) src/test/java/com/persistit/unit/TransactionTest3.java (+2/-1) src/test/java/com/persistit/unit/TreeSelectorTest.java (+8/-8) src/test/java/com/persistit/unit/ValueCoderTest1.java (+1/-1) src/test/java/com/persistit/unit/ValueTest1.java (+33/-22) src/test/java/com/persistit/unit/ValueTest2.java (+1/-1) src/test/java/com/persistit/unit/ValueTest3.java (+16/-0) src/test/java/com/persistit/unit/ValueTest4.java (+16/-0) src/test/java/com/persistit/unit/ValueTest5.java (+5/-5) |
To merge this branch: | bzr merge lp:~pbeaman/akiban-persistit/eclipse-canonical-format |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nathan Williams | Approve | ||
Review via email: mp+119756@code.launchpad.net |
Commit message
Description of the change
This branch contains no substantive changes. It is the result of applying a the Source / Cleanup... refactoring in Eclipse Juno to the entire project. There are a couple of goals:
1. Create a canonical form with correctly organized imports, all @Override annotations, etc. in place for code clarity and regularity. Because of my preference, all variables that can be marked final are so-marked.
2. Make diffs easier: new versions after this will also stay in canonical format, or at least it will be easy to make them so.
Part of the motivation for this is simple aesthetic. The code is easier to read and understand in this form than it was before. Part of this is personal preference: as the developer who changes the code the most right now, I prefer to apply code reformatting frequently while typing, and keeping the code in this form is most convenient for me.
The potential issues with this are:
(a) Versions added after this one will also need to be in canonical form to avoid voluminous spurious diffs.
(b) It will be more difficult to diff old versions against new versions. However, the code has not undergone extensive changes in the recent past so we have a bit of a buffer here. This seems like a good time to do this.
(c) The format is defined by an Eclipse-specific file, eclipse-format.xml generated by exporting the Cleanup configuration wizard's settings. Developers using other tools such as IntelliJ who want to have the same ability to automatically format code will need a way to set up refactoring in those other tools.
- 356. By Peter Beaman
-
Merge from trunk
- 357. By Peter Beaman
-
Move eclipse-format.xml
Peter Beaman (pbeaman) wrote : | # |
Thanks for noticing the conflicts. I guess there was a merge into trunk I forgot to take. All set now.
I'm happy to move the eclipse-format.xml file. Good idea.
Yes, let's make formatting automatic. But not in this proposal.
Yuval Shavit (yshavit) wrote : | # |
If I may interject (since this could set precedence for akiban-server):
If the formatting is not automatic/enforced, then a merge like this does seem somewhat Sisyphean; it's much easier to just have a policy of "don't autoformat areas of a file you're not otherwise touching." And if the formatting is going to be automatic/enforced, then the automated policy is probably going to be different from the exact formatting here -- in which case best to just hold off until that automated one is ready.
I don't have much say in akiban-persistit, so my comments shouldn't be taken as blocking this merge. But if nothing else, I want to be able to point to this comment should the precedence ever reach akiban-server. ;-)
Nathan Williams (nwilliams) wrote : | # |
I'm going to have to agree with Yuval here.
I'm the other one likely to be making changes and if it isn't automated, I'll most likely wind up inconsistent with yours.
If the plugin doesn't actually work as described, and there isn't a(nother) easy solution, I'll retract my request.
- 358. By Peter Beaman
-
Enable maven-eclipse-
format- plugin - 359. By Peter Beaman
-
Exclipse eclipse format files from license header check
Peter Beaman (pbeaman) wrote : | # |
Easier than I thought. Turns out the plugin doesn't like parsing our license header so I had to take it out and add and exclude the the pom. But running mvn compile runs the formatter, corrects a file I artificially modified, and gets the same format.
Nathan Williams (nwilliams) wrote : | # |
Great! Thanks for finishing out the automation Peter.
I won't pretend I looked at the entire diff, but I'll trust Eclipse enough to send it on through.
Leaving big-Approve off for now, as discussed.
- 360. By Peter Beaman
-
Merge from release-notes-3.16
Preview Diff
1 | === modified file 'doc/ReleaseNotes.rst' | |||
2 | --- doc/ReleaseNotes.rst 2012-08-06 14:43:42 +0000 | |||
3 | +++ doc/ReleaseNotes.rst 2012-08-24 18:20:24 +0000 | |||
4 | @@ -44,6 +44,26 @@ | |||
5 | 44 | | | 44 | | |
6 | 45 | | | 45 | | |
7 | 46 | 46 | ||
8 | 47 | |||
9 | 48 | ************************************ | ||
10 | 49 | 3.1.6 | ||
11 | 50 | ************************************ | ||
12 | 51 | |||
13 | 52 | Release Date | ||
14 | 53 | ============ | ||
15 | 54 | August 24, 2012 | ||
16 | 55 | |||
17 | 56 | Overview | ||
18 | 57 | ======== | ||
19 | 58 | This version of Persistit fixes one bug. | ||
20 | 59 | |||
21 | 60 | Fixed Issues | ||
22 | 61 | ============ | ||
23 | 62 | |||
24 | 63 | https://bugs.launchpad.net/akiban-persistit/+bug/1036422 | ||
25 | 64 | |||
26 | 65 | With CommitPolicy HARD we observed a CPU-soaking loop in the commit logic. | ||
27 | 66 | |||
28 | 47 | ************************************ | 67 | ************************************ |
29 | 48 | 3.1.5 | 68 | 3.1.5 |
30 | 49 | ************************************ | 69 | ************************************ |
31 | 50 | 70 | ||
32 | === modified file 'pom.xml' | |||
33 | --- pom.xml 2012-08-07 21:11:28 +0000 | |||
34 | +++ pom.xml 2012-08-24 18:20:24 +0000 | |||
35 | @@ -82,6 +82,14 @@ | |||
36 | 82 | </dependency> | 82 | </dependency> |
37 | 83 | </dependencies> | 83 | </dependencies> |
38 | 84 | 84 | ||
39 | 85 | <pluginRepositories> | ||
40 | 86 | <pluginRepository> | ||
41 | 87 | <id>maven-java-formatter-plugin</id> | ||
42 | 88 | <name>Maven2 Java Formatter Plugin repository</name> | ||
43 | 89 | <url>https://raw.github.com/benalexau/maven-java-formatter-plugin/master/releases/</url> | ||
44 | 90 | </pluginRepository> | ||
45 | 91 | </pluginRepositories> | ||
46 | 92 | |||
47 | 85 | <build> | 93 | <build> |
48 | 86 | <finalName>${project.artifactId}-${project.version}${BZR_REVISION}</finalName> | 94 | <finalName>${project.artifactId}-${project.version}${BZR_REVISION}</finalName> |
49 | 87 | <resources> | 95 | <resources> |
50 | @@ -256,6 +264,7 @@ | |||
51 | 256 | <exclude>.project</exclude> | 264 | <exclude>.project</exclude> |
52 | 257 | <exclude>.classpath</exclude> | 265 | <exclude>.classpath</exclude> |
53 | 258 | <exclude>.bzrignore</exclude> | 266 | <exclude>.bzrignore</exclude> |
54 | 267 | <exclude>src/etc/eclipse*.xml</exclude> | ||
55 | 259 | <!-- Other --> | 268 | <!-- Other --> |
56 | 260 | <exclude>LICENSE.txt</exclude> | 269 | <exclude>LICENSE.txt</exclude> |
57 | 261 | </excludes> | 270 | </excludes> |
58 | @@ -273,6 +282,21 @@ | |||
59 | 273 | <artifactId>maven-eclipse-plugin</artifactId> | 282 | <artifactId>maven-eclipse-plugin</artifactId> |
60 | 274 | <version>2.6</version> | 283 | <version>2.6</version> |
61 | 275 | </plugin> | 284 | </plugin> |
62 | 285 | <plugin> | ||
63 | 286 | <groupId>com.googlecode.maven-java-formatter-plugin</groupId> | ||
64 | 287 | <artifactId>maven-java-formatter-plugin</artifactId> | ||
65 | 288 | <version>0.4.0.e371sr1</version> | ||
66 | 289 | <configuration> | ||
67 | 290 | <configFile>${project.basedir}/src/etc/eclipse-format-config.xml</configFile> | ||
68 | 291 | </configuration> | ||
69 | 292 | <executions> | ||
70 | 293 | <execution> | ||
71 | 294 | <goals> | ||
72 | 295 | <goal>format</goal> | ||
73 | 296 | </goals> | ||
74 | 297 | </execution> | ||
75 | 298 | </executions> | ||
76 | 299 | </plugin> | ||
77 | 276 | </plugins> | 300 | </plugins> |
78 | 277 | <pluginManagement> | 301 | <pluginManagement> |
79 | 278 | <plugins> | 302 | <plugins> |
80 | @@ -324,6 +348,19 @@ | |||
81 | 324 | <ignore /> | 348 | <ignore /> |
82 | 325 | </action> | 349 | </action> |
83 | 326 | </pluginExecution> | 350 | </pluginExecution> |
84 | 351 | <pluginExecution> | ||
85 | 352 | <pluginExecutionFilter> | ||
86 | 353 | <groupId>com.googlecode.maven-java-formatter-plugin</groupId> | ||
87 | 354 | <artifactId>maven-java-formatter-plugin</artifactId> | ||
88 | 355 | <versionRange>[0.4.0.e371sr1,)</versionRange> | ||
89 | 356 | <goals> | ||
90 | 357 | <goal>format</goal> | ||
91 | 358 | </goals> | ||
92 | 359 | </pluginExecutionFilter> | ||
93 | 360 | <action> | ||
94 | 361 | <ignore></ignore> | ||
95 | 362 | </action> | ||
96 | 363 | </pluginExecution> | ||
97 | 327 | </pluginExecutions> | 364 | </pluginExecutions> |
98 | 328 | </lifecycleMappingMetadata> | 365 | </lifecycleMappingMetadata> |
99 | 329 | </configuration> | 366 | </configuration> |
100 | @@ -331,7 +368,6 @@ | |||
101 | 331 | </plugins> | 368 | </plugins> |
102 | 332 | </pluginManagement> | 369 | </pluginManagement> |
103 | 333 | </build> | 370 | </build> |
104 | 334 | |||
105 | 335 | <reporting> | 371 | <reporting> |
106 | 336 | <plugins> | 372 | <plugins> |
107 | 337 | <plugin> | 373 | <plugin> |
108 | 338 | 374 | ||
109 | === added file 'src/etc/eclipse-cleanup-config.xml' | |||
110 | --- src/etc/eclipse-cleanup-config.xml 1970-01-01 00:00:00 +0000 | |||
111 | +++ src/etc/eclipse-cleanup-config.xml 2012-08-24 18:20:24 +0000 | |||
112 | @@ -0,0 +1,56 @@ | |||
113 | 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
114 | 2 | <profiles version="2"> | ||
115 | 3 | <profile kind="CleanUpProfile" name="Akiban-Persistit" version="2"> | ||
116 | 4 | <setting id="cleanup.format_source_code" value="true"/> | ||
117 | 5 | <setting id="cleanup.add_missing_annotations" value="true"/> | ||
118 | 6 | <setting id="cleanup.use_this_for_non_static_method_access_only_if_necessary" value="true"/> | ||
119 | 7 | <setting id="cleanup.remove_unused_private_types" value="true"/> | ||
120 | 8 | <setting id="cleanup.qualify_static_member_accesses_through_instances_with_declaring_class" value="true"/> | ||
121 | 9 | <setting id="cleanup.qualify_static_method_accesses_with_declaring_class" value="false"/> | ||
122 | 10 | <setting id="cleanup.add_generated_serial_version_id" value="false"/> | ||
123 | 11 | <setting id="cleanup.make_variable_declarations_final" value="true"/> | ||
124 | 12 | <setting id="cleanup.add_missing_methods" value="false"/> | ||
125 | 13 | <setting id="cleanup.always_use_this_for_non_static_field_access" value="false"/> | ||
126 | 14 | <setting id="cleanup.remove_trailing_whitespaces_ignore_empty" value="false"/> | ||
127 | 15 | <setting id="cleanup.correct_indentation" value="true"/> | ||
128 | 16 | <setting id="cleanup.never_use_parentheses_in_expressions" value="true"/> | ||
129 | 17 | <setting id="cleanup.add_serial_version_id" value="false"/> | ||
130 | 18 | <setting id="cleanup.remove_unused_private_methods" value="true"/> | ||
131 | 19 | <setting id="cleanup.use_this_for_non_static_field_access" value="false"/> | ||
132 | 20 | <setting id="cleanup.use_blocks_only_for_return_and_throw" value="false"/> | ||
133 | 21 | <setting id="cleanup.remove_unused_private_members" value="false"/> | ||
134 | 22 | <setting id="cleanup.add_missing_override_annotations_interface_methods" value="true"/> | ||
135 | 23 | <setting id="cleanup.remove_trailing_whitespaces_all" value="true"/> | ||
136 | 24 | <setting id="cleanup.make_type_abstract_if_missing_method" value="false"/> | ||
137 | 25 | <setting id="cleanup.always_use_this_for_non_static_method_access" value="false"/> | ||
138 | 26 | <setting id="cleanup.remove_unnecessary_nls_tags" value="true"/> | ||
139 | 27 | <setting id="cleanup.format_source_code_changes_only" value="false"/> | ||
140 | 28 | <setting id="cleanup.qualify_static_field_accesses_with_declaring_class" value="false"/> | ||
141 | 29 | <setting id="cleanup.add_missing_nls_tags" value="false"/> | ||
142 | 30 | <setting id="cleanup.use_this_for_non_static_field_access_only_if_necessary" value="true"/> | ||
143 | 31 | <setting id="cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class" value="false"/> | ||
144 | 32 | <setting id="cleanup.remove_unnecessary_casts" value="true"/> | ||
145 | 33 | <setting id="cleanup.qualify_static_member_accesses_with_declaring_class" value="true"/> | ||
146 | 34 | <setting id="cleanup.use_parentheses_in_expressions" value="false"/> | ||
147 | 35 | <setting id="cleanup.remove_unused_private_fields" value="true"/> | ||
148 | 36 | <setting id="cleanup.make_parameters_final" value="true"/> | ||
149 | 37 | <setting id="cleanup.remove_trailing_whitespaces" value="true"/> | ||
150 | 38 | <setting id="cleanup.remove_unused_imports" value="true"/> | ||
151 | 39 | <setting id="cleanup.organize_imports" value="true"/> | ||
152 | 40 | <setting id="cleanup.sort_members" value="false"/> | ||
153 | 41 | <setting id="cleanup.remove_private_constructors" value="true"/> | ||
154 | 42 | <setting id="cleanup.convert_to_enhanced_for_loop" value="false"/> | ||
155 | 43 | <setting id="cleanup.always_use_blocks" value="true"/> | ||
156 | 44 | <setting id="cleanup.never_use_blocks" value="false"/> | ||
157 | 45 | <setting id="cleanup.always_use_parentheses_in_expressions" value="false"/> | ||
158 | 46 | <setting id="cleanup.use_this_for_non_static_method_access" value="false"/> | ||
159 | 47 | <setting id="cleanup.remove_unused_local_variables" value="false"/> | ||
160 | 48 | <setting id="cleanup.make_private_fields_final" value="true"/> | ||
161 | 49 | <setting id="cleanup.add_missing_deprecated_annotations" value="true"/> | ||
162 | 50 | <setting id="cleanup.add_default_serial_version_id" value="true"/> | ||
163 | 51 | <setting id="cleanup.sort_members_all" value="false"/> | ||
164 | 52 | <setting id="cleanup.use_blocks" value="false"/> | ||
165 | 53 | <setting id="cleanup.add_missing_override_annotations" value="true"/> | ||
166 | 54 | <setting id="cleanup.make_local_variable_final" value="true"/> | ||
167 | 55 | </profile> | ||
168 | 56 | </profiles> | ||
169 | 0 | 57 | ||
170 | === added file 'src/etc/eclipse-format-config.xml' | |||
171 | --- src/etc/eclipse-format-config.xml 1970-01-01 00:00:00 +0000 | |||
172 | +++ src/etc/eclipse-format-config.xml 2012-08-24 18:20:24 +0000 | |||
173 | @@ -0,0 +1,291 @@ | |||
174 | 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
175 | 2 | <profiles version="12"> | ||
176 | 3 | <profile kind="CodeFormatterProfile" name="Akiban-code-format" version="12"> | ||
177 | 4 | <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/> | ||
178 | 5 | <setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/> | ||
179 | 6 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/> | ||
180 | 7 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/> | ||
181 | 8 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/> | ||
182 | 9 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/> | ||
183 | 10 | <setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/> | ||
184 | 11 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/> | ||
185 | 12 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/> | ||
186 | 13 | <setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/> | ||
187 | 14 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/> | ||
188 | 15 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/> | ||
189 | 16 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/> | ||
190 | 17 | <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/> | ||
191 | 18 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/> | ||
192 | 19 | <setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/> | ||
193 | 20 | <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/> | ||
194 | 21 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/> | ||
195 | 22 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/> | ||
196 | 23 | <setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/> | ||
197 | 24 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/> | ||
198 | 25 | <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/> | ||
199 | 26 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/> | ||
200 | 27 | <setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/> | ||
201 | 28 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/> | ||
202 | 29 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/> | ||
203 | 30 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/> | ||
204 | 31 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/> | ||
205 | 32 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/> | ||
206 | 33 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/> | ||
207 | 34 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/> | ||
208 | 35 | <setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/> | ||
209 | 36 | <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/> | ||
210 | 37 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/> | ||
211 | 38 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/> | ||
212 | 39 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/> | ||
213 | 40 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/> | ||
214 | 41 | <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/> | ||
215 | 42 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/> | ||
216 | 43 | <setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/> | ||
217 | 44 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/> | ||
218 | 45 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/> | ||
219 | 46 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/> | ||
220 | 47 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/> | ||
221 | 48 | <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/> | ||
222 | 49 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/> | ||
223 | 50 | <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/> | ||
224 | 51 | <setting id="org.eclipse.jdt.core.compiler.source" value="1.7"/> | ||
225 | 52 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/> | ||
226 | 53 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/> | ||
227 | 54 | <setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/> | ||
228 | 55 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/> | ||
229 | 56 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/> | ||
230 | 57 | <setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/> | ||
231 | 58 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/> | ||
232 | 59 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/> | ||
233 | 60 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/> | ||
234 | 61 | <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/> | ||
235 | 62 | <setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/> | ||
236 | 63 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/> | ||
237 | 64 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/> | ||
238 | 65 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/> | ||
239 | 66 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/> | ||
240 | 67 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/> | ||
241 | 68 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/> | ||
242 | 69 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/> | ||
243 | 70 | <setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/> | ||
244 | 71 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/> | ||
245 | 72 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/> | ||
246 | 73 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/> | ||
247 | 74 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/> | ||
248 | 75 | <setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/> | ||
249 | 76 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/> | ||
250 | 77 | <setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/> | ||
251 | 78 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/> | ||
252 | 79 | <setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/> | ||
253 | 80 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/> | ||
254 | 81 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/> | ||
255 | 82 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/> | ||
256 | 83 | <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/> | ||
257 | 84 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/> | ||
258 | 85 | <setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/> | ||
259 | 86 | <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/> | ||
260 | 87 | <setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/> | ||
261 | 88 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/> | ||
262 | 89 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/> | ||
263 | 90 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/> | ||
264 | 91 | <setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/> | ||
265 | 92 | <setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/> | ||
266 | 93 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/> | ||
267 | 94 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/> | ||
268 | 95 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/> | ||
269 | 96 | <setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/> | ||
270 | 97 | <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/> | ||
271 | 98 | <setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/> | ||
272 | 99 | <setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/> | ||
273 | 100 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/> | ||
274 | 101 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/> | ||
275 | 102 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/> | ||
276 | 103 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/> | ||
277 | 104 | <setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/> | ||
278 | 105 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/> | ||
279 | 106 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/> | ||
280 | 107 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/> | ||
281 | 108 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/> | ||
282 | 109 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/> | ||
283 | 110 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/> | ||
284 | 111 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/> | ||
285 | 112 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/> | ||
286 | 113 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/> | ||
287 | 114 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/> | ||
288 | 115 | <setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/> | ||
289 | 116 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/> | ||
290 | 117 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/> | ||
291 | 118 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/> | ||
292 | 119 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/> | ||
293 | 120 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/> | ||
294 | 121 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/> | ||
295 | 122 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/> | ||
296 | 123 | <setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/> | ||
297 | 124 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/> | ||
298 | 125 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/> | ||
299 | 126 | <setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/> | ||
300 | 127 | <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/> | ||
301 | 128 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/> | ||
302 | 129 | <setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/> | ||
303 | 130 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/> | ||
304 | 131 | <setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/> | ||
305 | 132 | <setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/> | ||
306 | 133 | <setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/> | ||
307 | 134 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/> | ||
308 | 135 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/> | ||
309 | 136 | <setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/> | ||
310 | 137 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/> | ||
311 | 138 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/> | ||
312 | 139 | <setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/> | ||
313 | 140 | <setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/> | ||
314 | 141 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/> | ||
315 | 142 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/> | ||
316 | 143 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/> | ||
317 | 144 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/> | ||
318 | 145 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/> | ||
319 | 146 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/> | ||
320 | 147 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/> | ||
321 | 148 | <setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/> | ||
322 | 149 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/> | ||
323 | 150 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/> | ||
324 | 151 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/> | ||
325 | 152 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/> | ||
326 | 153 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/> | ||
327 | 154 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/> | ||
328 | 155 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/> | ||
329 | 156 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/> | ||
330 | 157 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/> | ||
331 | 158 | <setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/> | ||
332 | 159 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/> | ||
333 | 160 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/> | ||
334 | 161 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/> | ||
335 | 162 | <setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/> | ||
336 | 163 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/> | ||
337 | 164 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/> | ||
338 | 165 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/> | ||
339 | 166 | <setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/> | ||
340 | 167 | <setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/> | ||
341 | 168 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/> | ||
342 | 169 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/> | ||
343 | 170 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/> | ||
344 | 171 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/> | ||
345 | 172 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/> | ||
346 | 173 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/> | ||
347 | 174 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/> | ||
348 | 175 | <setting id="org.eclipse.jdt.core.compiler.compliance" value="1.7"/> | ||
349 | 176 | <setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/> | ||
350 | 177 | <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/> | ||
351 | 178 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/> | ||
352 | 179 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/> | ||
353 | 180 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/> | ||
354 | 181 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/> | ||
355 | 182 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/> | ||
356 | 183 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/> | ||
357 | 184 | <setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/> | ||
358 | 185 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/> | ||
359 | 186 | <setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/> | ||
360 | 187 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/> | ||
361 | 188 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/> | ||
362 | 189 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/> | ||
363 | 190 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/> | ||
364 | 191 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/> | ||
365 | 192 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/> | ||
366 | 193 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/> | ||
367 | 194 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/> | ||
368 | 195 | <setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/> | ||
369 | 196 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/> | ||
370 | 197 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/> | ||
371 | 198 | <setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/> | ||
372 | 199 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/> | ||
373 | 200 | <setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/> | ||
374 | 201 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/> | ||
375 | 202 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/> | ||
376 | 203 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/> | ||
377 | 204 | <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/> | ||
378 | 205 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/> | ||
379 | 206 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/> | ||
380 | 207 | <setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/> | ||
381 | 208 | <setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/> | ||
382 | 209 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/> | ||
383 | 210 | <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/> | ||
384 | 211 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/> | ||
385 | 212 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/> | ||
386 | 213 | <setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/> | ||
387 | 214 | <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/> | ||
388 | 215 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/> | ||
389 | 216 | <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/> | ||
390 | 217 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/> | ||
391 | 218 | <setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/> | ||
392 | 219 | <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/> | ||
393 | 220 | <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/> | ||
394 | 221 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/> | ||
395 | 222 | <setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/> | ||
396 | 223 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/> | ||
397 | 224 | <setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/> | ||
398 | 225 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/> | ||
399 | 226 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/> | ||
400 | 227 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/> | ||
401 | 228 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/> | ||
402 | 229 | <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/> | ||
403 | 230 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/> | ||
404 | 231 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/> | ||
405 | 232 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/> | ||
406 | 233 | <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/> | ||
407 | 234 | <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/> | ||
408 | 235 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/> | ||
409 | 236 | <setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/> | ||
410 | 237 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/> | ||
411 | 238 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/> | ||
412 | 239 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/> | ||
413 | 240 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/> | ||
414 | 241 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/> | ||
415 | 242 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> | ||
416 | 243 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/> | ||
417 | 244 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/> | ||
418 | 245 | <setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/> | ||
419 | 246 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/> | ||
420 | 247 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/> | ||
421 | 248 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/> | ||
422 | 249 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/> | ||
423 | 250 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/> | ||
424 | 251 | <setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.7"/> | ||
425 | 252 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/> | ||
426 | 253 | <setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/> | ||
427 | 254 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/> | ||
428 | 255 | <setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/> | ||
429 | 256 | <setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/> | ||
430 | 257 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/> | ||
431 | 258 | <setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/> | ||
432 | 259 | <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/> | ||
433 | 260 | <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/> | ||
434 | 261 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/> | ||
435 | 262 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/> | ||
436 | 263 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/> | ||
437 | 264 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/> | ||
438 | 265 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/> | ||
439 | 266 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/> | ||
440 | 267 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/> | ||
441 | 268 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/> | ||
442 | 269 | <setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/> | ||
443 | 270 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/> | ||
444 | 271 | <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/> | ||
445 | 272 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/> | ||
446 | 273 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/> | ||
447 | 274 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/> | ||
448 | 275 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> | ||
449 | 276 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/> | ||
450 | 277 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/> | ||
451 | 278 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/> | ||
452 | 279 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/> | ||
453 | 280 | <setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/> | ||
454 | 281 | <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/> | ||
455 | 282 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/> | ||
456 | 283 | <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/> | ||
457 | 284 | <setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/> | ||
458 | 285 | <setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/> | ||
459 | 286 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/> | ||
460 | 287 | <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/> | ||
461 | 288 | <setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/> | ||
462 | 289 | <setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/> | ||
463 | 290 | </profile> | ||
464 | 291 | </profiles> | ||
465 | 0 | 292 | ||
466 | === modified file 'src/main/java/com/persistit/Accumulator.java' | |||
467 | --- src/main/java/com/persistit/Accumulator.java 2012-08-02 04:45:28 +0000 | |||
468 | +++ src/main/java/com/persistit/Accumulator.java 2012-08-24 18:20:24 +0000 | |||
469 | @@ -97,10 +97,10 @@ | |||
470 | 97 | final static Comparator<Accumulator> SORT_COMPARATOR = new Comparator<Accumulator>() { | 97 | final static Comparator<Accumulator> SORT_COMPARATOR = new Comparator<Accumulator>() { |
471 | 98 | 98 | ||
472 | 99 | @Override | 99 | @Override |
474 | 100 | public int compare(Accumulator a, Accumulator b) { | 100 | public int compare(final Accumulator a, final Accumulator b) { |
475 | 101 | final String treeNameA = a.getTree() == null ? "" : a.getTree().getName(); | 101 | final String treeNameA = a.getTree() == null ? "" : a.getTree().getName(); |
476 | 102 | final String treeNameB = b.getTree() == null ? "" : b.getTree().getName(); | 102 | final String treeNameB = b.getTree() == null ? "" : b.getTree().getName(); |
478 | 103 | int compare = treeNameA.compareTo(treeNameB); | 103 | final int compare = treeNameA.compareTo(treeNameB); |
479 | 104 | if (compare != 0) { | 104 | if (compare != 0) { |
480 | 105 | return compare; | 105 | return compare; |
481 | 106 | } else { | 106 | } else { |
482 | @@ -144,7 +144,7 @@ | |||
483 | 144 | * longer present in live TransactionStatus objects. This array has one | 144 | * longer present in live TransactionStatus objects. This array has one |
484 | 145 | * element per TransactionIndexBucket. | 145 | * element per TransactionIndexBucket. |
485 | 146 | */ | 146 | */ |
487 | 147 | private long[] _bucketValues; | 147 | private final long[] _bucketValues; |
488 | 148 | 148 | ||
489 | 149 | /* | 149 | /* |
490 | 150 | * Object held on the accumulators list in {@link Persistit}. An | 150 | * Object held on the accumulators list in {@link Persistit}. An |
491 | @@ -374,7 +374,7 @@ | |||
492 | 374 | } | 374 | } |
493 | 375 | 375 | ||
494 | 376 | Accumulator takeCheckpointRef() { | 376 | Accumulator takeCheckpointRef() { |
496 | 377 | Accumulator result = _checkpointRef; | 377 | final Accumulator result = _checkpointRef; |
497 | 378 | _checkpointRef = null; | 378 | _checkpointRef = null; |
498 | 379 | return result; | 379 | return result; |
499 | 380 | } | 380 | } |
500 | @@ -551,7 +551,7 @@ | |||
501 | 551 | long getSnapshotValue(final long timestamp, final int step) throws PersistitInterruptedException { | 551 | long getSnapshotValue(final long timestamp, final int step) throws PersistitInterruptedException { |
502 | 552 | try { | 552 | try { |
503 | 553 | return _transactionIndex.getAccumulatorSnapshot(this, timestamp, step, _baseValue); | 553 | return _transactionIndex.getAccumulatorSnapshot(this, timestamp, step, _baseValue); |
505 | 554 | } catch (InterruptedException ie) { | 554 | } catch (final InterruptedException ie) { |
506 | 555 | throw new PersistitInterruptedException(ie); | 555 | throw new PersistitInterruptedException(ie); |
507 | 556 | } | 556 | } |
508 | 557 | } | 557 | } |
509 | @@ -588,6 +588,7 @@ | |||
510 | 588 | /** | 588 | /** |
511 | 589 | * Update the Accumulator by contributing a value. The contribution is | 589 | * Update the Accumulator by contributing a value. The contribution is |
512 | 590 | * immediately accumulated into the live value, and it is also posted with a | 590 | * immediately accumulated into the live value, and it is also posted with a |
513 | 591 | * | ||
514 | 591 | * @{link {@link Delta} instance to the supplied {@link Transaction}. | 592 | * @{link {@link Delta} instance to the supplied {@link Transaction}. |
515 | 592 | * | 593 | * |
516 | 593 | * @param value | 594 | * @param value |
517 | @@ -636,8 +637,8 @@ | |||
518 | 636 | * values for this <code>Accumulator</code>. | 637 | * values for this <code>Accumulator</code>. |
519 | 637 | */ | 638 | */ |
520 | 638 | public String toString() { | 639 | public String toString() { |
523 | 639 | return String.format("Accumulator(tree=%s index=%d type=%s base=%,d live=%,d)", _tree == null ? "null" : _tree | 640 | return String.format("Accumulator(tree=%s index=%d type=%s base=%,d live=%,d)", |
524 | 640 | .getName(), _index, getType(), _baseValue, _liveValue.get()); | 641 | _tree == null ? "null" : _tree.getName(), _index, getType(), _baseValue, _liveValue.get()); |
525 | 641 | } | 642 | } |
526 | 642 | 643 | ||
527 | 643 | void store(final Value value) { | 644 | void store(final Value value) { |
528 | @@ -649,8 +650,8 @@ | |||
529 | 649 | 650 | ||
530 | 650 | static AccumulatorState getAccumulatorState(final Tree tree, final int index) throws PersistitException { | 651 | static AccumulatorState getAccumulatorState(final Tree tree, final int index) throws PersistitException { |
531 | 651 | final Exchange exchange = tree.getVolume().getStructure().directoryExchange(); | 652 | final Exchange exchange = tree.getVolume().getStructure().directoryExchange(); |
534 | 652 | exchange.clear().append(VolumeStructure.DIRECTORY_TREE_NAME).append(VolumeStructure.TREE_ACCUMULATOR).append( | 653 | exchange.clear().append(VolumeStructure.DIRECTORY_TREE_NAME).append(VolumeStructure.TREE_ACCUMULATOR) |
535 | 653 | tree.getName()).append(index).fetch(); | 654 | .append(tree.getName()).append(index).fetch(); |
536 | 654 | if (exchange.getValue().isDefined()) { | 655 | if (exchange.getValue().isDefined()) { |
537 | 655 | return (AccumulatorState) exchange.getValue().get(); | 656 | return (AccumulatorState) exchange.getValue().get(); |
538 | 656 | } else { | 657 | } else { |
539 | 657 | 658 | ||
540 | === modified file 'src/main/java/com/persistit/AccumulatorState.java' | |||
541 | --- src/main/java/com/persistit/AccumulatorState.java 2012-08-02 04:45:28 +0000 | |||
542 | +++ src/main/java/com/persistit/AccumulatorState.java 2012-08-24 18:20:24 +0000 | |||
543 | @@ -15,7 +15,6 @@ | |||
544 | 15 | 15 | ||
545 | 16 | package com.persistit; | 16 | package com.persistit; |
546 | 17 | 17 | ||
547 | 18 | |||
548 | 19 | /** | 18 | /** |
549 | 20 | * State of an accumulator recovered from a checkpoint. | 19 | * State of an accumulator recovered from a checkpoint. |
550 | 21 | * | 20 | * |
551 | @@ -48,19 +47,19 @@ | |||
552 | 48 | public String toString() { | 47 | public String toString() { |
553 | 49 | return String.format("Accumulator(tree=%s index=%d type=%s value=%,d)", _treeName, _index, _type, _value); | 48 | return String.format("Accumulator(tree=%s index=%d type=%s value=%,d)", _treeName, _index, _type, _value); |
554 | 50 | } | 49 | } |
556 | 51 | 50 | ||
557 | 52 | public String getTreeName() { | 51 | public String getTreeName() { |
558 | 53 | return _treeName; | 52 | return _treeName; |
559 | 54 | } | 53 | } |
561 | 55 | 54 | ||
562 | 56 | public int getIndex() { | 55 | public int getIndex() { |
563 | 57 | return _index; | 56 | return _index; |
564 | 58 | } | 57 | } |
566 | 59 | 58 | ||
567 | 60 | public Accumulator.Type getType() { | 59 | public Accumulator.Type getType() { |
568 | 61 | return _type; | 60 | return _type; |
569 | 62 | } | 61 | } |
571 | 63 | 62 | ||
572 | 64 | public long getValue() { | 63 | public long getValue() { |
573 | 65 | return _value; | 64 | return _value; |
574 | 66 | } | 65 | } |
575 | 67 | 66 | ||
576 | === modified file 'src/main/java/com/persistit/AlertMonitor.java' | |||
577 | --- src/main/java/com/persistit/AlertMonitor.java 2012-08-02 04:45:28 +0000 | |||
578 | +++ src/main/java/com/persistit/AlertMonitor.java 2012-08-24 18:20:24 +0000 | |||
579 | @@ -113,7 +113,7 @@ | |||
580 | 113 | */ | 113 | */ |
581 | 114 | public class History { | 114 | public class History { |
582 | 115 | private AlertLevel _level = AlertLevel.NORMAL; | 115 | private AlertLevel _level = AlertLevel.NORMAL; |
584 | 116 | private List<Event> _eventList = new ArrayList<Event>(); | 116 | private final List<Event> _eventList = new ArrayList<Event>(); |
585 | 117 | private volatile long _firstEventTime = Long.MAX_VALUE; | 117 | private volatile long _firstEventTime = Long.MAX_VALUE; |
586 | 118 | private volatile long _lastWarnLogTime = Long.MIN_VALUE; | 118 | private volatile long _lastWarnLogTime = Long.MIN_VALUE; |
587 | 119 | private volatile long _lastErrorLogTime = Long.MIN_VALUE; | 119 | private volatile long _lastErrorLogTime = Long.MIN_VALUE; |
588 | @@ -142,7 +142,7 @@ | |||
589 | 142 | public String getDetailedHistory() { | 142 | public String getDetailedHistory() { |
590 | 143 | final StringBuilder sb = new StringBuilder(); | 143 | final StringBuilder sb = new StringBuilder(); |
591 | 144 | synchronized (AlertMonitor.this) { | 144 | synchronized (AlertMonitor.this) { |
593 | 145 | int size = _eventList.size(); | 145 | final int size = _eventList.size(); |
594 | 146 | if (_count > 0) { | 146 | if (_count > 0) { |
595 | 147 | sb.append(String.format(EVENT_FORMAT, 1, format(_firstEvent))); | 147 | sb.append(String.format(EVENT_FORMAT, 1, format(_firstEvent))); |
596 | 148 | for (int index = _count > size ? 0 : 1; index < size; index++) { | 148 | for (int index = _count > size ? 0 : 1; index < size; index++) { |
597 | @@ -250,7 +250,7 @@ | |||
598 | 250 | * does nothing unless the interval has elapsed. | 250 | * does nothing unless the interval has elapsed. |
599 | 251 | */ | 251 | */ |
600 | 252 | public void poll(final long now, final boolean force) { | 252 | public void poll(final long now, final boolean force) { |
602 | 253 | int count = getCount(); | 253 | final int count = getCount(); |
603 | 254 | if (count > _reportedCount) { | 254 | if (count > _reportedCount) { |
604 | 255 | switch (_level) { | 255 | switch (_level) { |
605 | 256 | case ERROR: | 256 | case ERROR: |
606 | @@ -316,7 +316,7 @@ | |||
607 | 316 | * event was posted. | 316 | * event was posted. |
608 | 317 | */ | 317 | */ |
609 | 318 | public static class Event { | 318 | public static class Event { |
611 | 319 | private AlertLevel _level; | 319 | private final AlertLevel _level; |
612 | 320 | private final LogItem _logItem; | 320 | private final LogItem _logItem; |
613 | 321 | private final Object[] _args; | 321 | private final Object[] _args; |
614 | 322 | private final long _time; | 322 | private final long _time; |
615 | @@ -332,7 +332,7 @@ | |||
616 | 332 | * @param args | 332 | * @param args |
617 | 333 | * arguments specific to the <code>LogItem</code> | 333 | * arguments specific to the <code>LogItem</code> |
618 | 334 | */ | 334 | */ |
620 | 335 | public Event(AlertLevel level, LogItem logItem, Object... args) { | 335 | public Event(final AlertLevel level, final LogItem logItem, final Object... args) { |
621 | 336 | this(level, System.currentTimeMillis(), logItem, args); | 336 | this(level, System.currentTimeMillis(), logItem, args); |
622 | 337 | } | 337 | } |
623 | 338 | 338 | ||
624 | @@ -349,7 +349,7 @@ | |||
625 | 349 | * @param args | 349 | * @param args |
626 | 350 | * arguments specific to the <code>LogItem</code> | 350 | * arguments specific to the <code>LogItem</code> |
627 | 351 | */ | 351 | */ |
629 | 352 | public Event(AlertLevel level, long time, LogItem logItem, Object... args) { | 352 | public Event(final AlertLevel level, final long time, final LogItem logItem, final Object... args) { |
630 | 353 | _level = level; | 353 | _level = level; |
631 | 354 | _logItem = logItem; | 354 | _logItem = logItem; |
632 | 355 | _args = args; | 355 | _args = args; |
633 | @@ -492,7 +492,7 @@ | |||
634 | 492 | private volatile long _errorLogTimeInterval = DEFAULT_ERROR_INTERVAL; | 492 | private volatile long _errorLogTimeInterval = DEFAULT_ERROR_INTERVAL; |
635 | 493 | private volatile int _historyLength = DEFAULT_HISTORY_LENGTH; | 493 | private volatile int _historyLength = DEFAULT_HISTORY_LENGTH; |
636 | 494 | 494 | ||
638 | 495 | private AtomicLong _notificationSequence = new AtomicLong(); | 495 | private final AtomicLong _notificationSequence = new AtomicLong(); |
639 | 496 | private volatile ObjectName _objectName; | 496 | private volatile ObjectName _objectName; |
640 | 497 | 497 | ||
641 | 498 | /** | 498 | /** |
642 | @@ -533,7 +533,7 @@ | |||
643 | 533 | * A String describing the nature of the event. A separate | 533 | * A String describing the nature of the event. A separate |
644 | 534 | * event-history is maintained for each unique category. | 534 | * event-history is maintained for each unique category. |
645 | 535 | */ | 535 | */ |
647 | 536 | public synchronized final void post(Event event, final String category) { | 536 | public synchronized final void post(final Event event, final String category) { |
648 | 537 | History history = _historyMap.get(category); | 537 | History history = _historyMap.get(category); |
649 | 538 | if (history == null) { | 538 | if (history == null) { |
650 | 539 | history = new History(); | 539 | history = new History(); |
651 | @@ -570,7 +570,7 @@ | |||
652 | 570 | * the interval in milliseconds | 570 | * the interval in milliseconds |
653 | 571 | */ | 571 | */ |
654 | 572 | @Override | 572 | @Override |
656 | 573 | public void setWarnLogTimeInterval(long warnLogTimeInterval) { | 573 | public void setWarnLogTimeInterval(final long warnLogTimeInterval) { |
657 | 574 | Util.rangeCheck(warnLogTimeInterval, MINIMUM_WARN_INTERVAL, MAXIMUM_WARN_INTERVAL); | 574 | Util.rangeCheck(warnLogTimeInterval, MINIMUM_WARN_INTERVAL, MAXIMUM_WARN_INTERVAL); |
658 | 575 | _warnLogTimeInterval = warnLogTimeInterval; | 575 | _warnLogTimeInterval = warnLogTimeInterval; |
659 | 576 | } | 576 | } |
660 | @@ -592,7 +592,7 @@ | |||
661 | 592 | * the interval in milliseconds | 592 | * the interval in milliseconds |
662 | 593 | */ | 593 | */ |
663 | 594 | @Override | 594 | @Override |
665 | 595 | public void setErrorLogTimeInterval(long errorLogTimeInterval) { | 595 | public void setErrorLogTimeInterval(final long errorLogTimeInterval) { |
666 | 596 | Util.rangeCheck(errorLogTimeInterval, MINIMUM_ERROR_INTERVAL, MAXIMUM_ERROR_INTERVAL); | 596 | Util.rangeCheck(errorLogTimeInterval, MINIMUM_ERROR_INTERVAL, MAXIMUM_ERROR_INTERVAL); |
667 | 597 | _errorLogTimeInterval = errorLogTimeInterval; | 597 | _errorLogTimeInterval = errorLogTimeInterval; |
668 | 598 | } | 598 | } |
669 | @@ -613,7 +613,7 @@ | |||
670 | 613 | * @return the <code>History</code> for that category or <code>null</code> | 613 | * @return the <code>History</code> for that category or <code>null</code> |
671 | 614 | * if the specified category has no <code>History</code>. | 614 | * if the specified category has no <code>History</code>. |
672 | 615 | */ | 615 | */ |
674 | 616 | public synchronized History getHistory(String name) { | 616 | public synchronized History getHistory(final String name) { |
675 | 617 | return _historyMap.get(name); | 617 | return _historyMap.get(name); |
676 | 618 | } | 618 | } |
677 | 619 | 619 | ||
678 | @@ -637,7 +637,7 @@ | |||
679 | 637 | * the historyLength to set | 637 | * the historyLength to set |
680 | 638 | */ | 638 | */ |
681 | 639 | @Override | 639 | @Override |
683 | 640 | public synchronized void setHistoryLength(int historyLength) { | 640 | public synchronized void setHistoryLength(final int historyLength) { |
684 | 641 | Util.rangeCheck(historyLength, MINIMUM_HISTORY_LENGTH, MAXIMUM_HISTORY_LENGTH); | 641 | Util.rangeCheck(historyLength, MINIMUM_HISTORY_LENGTH, MAXIMUM_HISTORY_LENGTH); |
685 | 642 | _historyLength = historyLength; | 642 | _historyLength = historyLength; |
686 | 643 | for (final History history : _historyMap.values()) { | 643 | for (final History history : _historyMap.values()) { |
687 | @@ -652,7 +652,7 @@ | |||
688 | 652 | * @return List of AlertRecord elements. | 652 | * @return List of AlertRecord elements. |
689 | 653 | */ | 653 | */ |
690 | 654 | public synchronized AlertRecord[] getAlertRecordArray() { | 654 | public synchronized AlertRecord[] getAlertRecordArray() { |
692 | 655 | List<AlertRecord> list = new ArrayList<AlertRecord>(); | 655 | final List<AlertRecord> list = new ArrayList<AlertRecord>(); |
693 | 656 | for (final Map.Entry<String, History> entry : _historyMap.entrySet()) { | 656 | for (final Map.Entry<String, History> entry : _historyMap.entrySet()) { |
694 | 657 | for (final Event event : entry.getValue().getEventList()) { | 657 | for (final Event event : entry.getValue().getEventList()) { |
695 | 658 | list.add(new AlertRecord(entry.getKey(), event)); | 658 | list.add(new AlertRecord(entry.getKey(), event)); |
696 | @@ -681,7 +681,7 @@ | |||
697 | 681 | */ | 681 | */ |
698 | 682 | @Override | 682 | @Override |
699 | 683 | public synchronized String toString() { | 683 | public synchronized String toString() { |
701 | 684 | StringBuilder sb = new StringBuilder(); | 684 | final StringBuilder sb = new StringBuilder(); |
702 | 685 | for (final Map.Entry<String, History> entry : _historyMap.entrySet()) { | 685 | for (final Map.Entry<String, History> entry : _historyMap.entrySet()) { |
703 | 686 | sb.append(String.format("%12s: %s\n", entry.getKey(), entry.getValue())); | 686 | sb.append(String.format("%12s: %s\n", entry.getKey(), entry.getValue())); |
704 | 687 | } | 687 | } |
705 | @@ -705,8 +705,8 @@ | |||
706 | 705 | */ | 705 | */ |
707 | 706 | @Override | 706 | @Override |
708 | 707 | public synchronized String getDetailedHistory(final String select) { | 707 | public synchronized String getDetailedHistory(final String select) { |
711 | 708 | Pattern pattern = Util.pattern(select, true); | 708 | final Pattern pattern = Util.pattern(select, true); |
712 | 709 | StringBuilder sb = new StringBuilder(); | 709 | final StringBuilder sb = new StringBuilder(); |
713 | 710 | for (final Map.Entry<String, History> entry : _historyMap.entrySet()) { | 710 | for (final Map.Entry<String, History> entry : _historyMap.entrySet()) { |
714 | 711 | if (pattern.matcher(entry.getKey()).matches()) { | 711 | if (pattern.matcher(entry.getKey()).matches()) { |
715 | 712 | sb.append(String.format("%s:\n", entry.getKey())); | 712 | sb.append(String.format("%s:\n", entry.getKey())); |
716 | @@ -737,10 +737,10 @@ | |||
717 | 737 | */ | 737 | */ |
718 | 738 | @Override | 738 | @Override |
719 | 739 | public MBeanNotificationInfo[] getNotificationInfo() { | 739 | public MBeanNotificationInfo[] getNotificationInfo() { |
724 | 740 | String[] types = new String[] { NOTIFICATION_TYPE }; | 740 | final String[] types = new String[] { NOTIFICATION_TYPE }; |
725 | 741 | String name = Notification.class.getName(); | 741 | final String name = Notification.class.getName(); |
726 | 742 | String description = "Alert raised by Akiban PersistIT"; | 742 | final String description = "Alert raised by Akiban PersistIT"; |
727 | 743 | MBeanNotificationInfo info = new MBeanNotificationInfo(types, name, description); | 743 | final MBeanNotificationInfo info = new MBeanNotificationInfo(types, name, description); |
728 | 744 | return new MBeanNotificationInfo[] { info }; | 744 | return new MBeanNotificationInfo[] { info }; |
729 | 745 | } | 745 | } |
730 | 746 | 746 | ||
731 | @@ -751,7 +751,7 @@ | |||
732 | 751 | * | 751 | * |
733 | 752 | * @param history | 752 | * @param history |
734 | 753 | */ | 753 | */ |
736 | 754 | private void log(History history) { | 754 | private void log(final History history) { |
737 | 755 | final Event event = history.getLastEvent(); | 755 | final Event event = history.getLastEvent(); |
738 | 756 | if (event != null && event.getLogItem().isEnabled()) { | 756 | if (event != null && event.getLogItem().isEnabled()) { |
739 | 757 | if (history.getCount() == 1) { | 757 | if (history.getCount() == 1) { |
740 | @@ -767,13 +767,13 @@ | |||
741 | 767 | * | 767 | * |
742 | 768 | * @param history | 768 | * @param history |
743 | 769 | */ | 769 | */ |
745 | 770 | private void sendNotification(History history) { | 770 | private void sendNotification(final History history) { |
746 | 771 | final Event event = history.getLastEvent(); | 771 | final Event event = history.getLastEvent(); |
747 | 772 | if (event != null && event.getLogItem().isEnabled()) { | 772 | if (event != null && event.getLogItem().isEnabled()) { |
752 | 773 | final String description = LogBase.recurring(event.getLogItem().logMessage(event.getArgs()), history | 773 | final String description = LogBase.recurring(event.getLogItem().logMessage(event.getArgs()), |
753 | 774 | .getCount(), history.getDuration()); | 774 | history.getCount(), history.getDuration()); |
754 | 775 | Notification notification = new Notification(NOTIFICATION_TYPE, getClass().getName(), _notificationSequence | 775 | final Notification notification = new Notification(NOTIFICATION_TYPE, getClass().getName(), |
755 | 776 | .incrementAndGet(), description); | 776 | _notificationSequence.incrementAndGet(), description); |
756 | 777 | sendNotification(notification); | 777 | sendNotification(notification); |
757 | 778 | } | 778 | } |
758 | 779 | } | 779 | } |
759 | @@ -796,7 +796,7 @@ | |||
760 | 796 | * @param event | 796 | * @param event |
761 | 797 | * @return | 797 | * @return |
762 | 798 | */ | 798 | */ |
764 | 799 | private String format(Event event) { | 799 | private String format(final Event event) { |
765 | 800 | return event == null ? "null" : event.toString(); | 800 | return event == null ? "null" : event.toString(); |
766 | 801 | } | 801 | } |
767 | 802 | 802 | ||
768 | 803 | 803 | ||
769 | === modified file 'src/main/java/com/persistit/AntiValue.java' | |||
770 | --- src/main/java/com/persistit/AntiValue.java 2012-08-02 04:45:28 +0000 | |||
771 | +++ src/main/java/com/persistit/AntiValue.java 2012-08-24 18:20:24 +0000 | |||
772 | @@ -15,10 +15,10 @@ | |||
773 | 15 | 15 | ||
774 | 16 | package com.persistit; | 16 | package com.persistit; |
775 | 17 | 17 | ||
776 | 18 | import java.util.Arrays; | ||
777 | 19 | |||
778 | 18 | import com.persistit.exception.InvalidKeyException; | 20 | import com.persistit.exception.InvalidKeyException; |
779 | 19 | 21 | ||
780 | 20 | import java.util.Arrays; | ||
781 | 21 | |||
782 | 22 | /** | 22 | /** |
783 | 23 | * Represents the end of a key range to be removed. Used in Transactions. | 23 | * Represents the end of a key range to be removed. Used in Transactions. |
784 | 24 | * | 24 | * |
785 | @@ -26,29 +26,29 @@ | |||
786 | 26 | * @version 1.1 | 26 | * @version 1.1 |
787 | 27 | */ | 27 | */ |
788 | 28 | class AntiValue { | 28 | class AntiValue { |
791 | 29 | private int _elisionCount; | 29 | private final int _elisionCount; |
792 | 30 | private byte[] _bytes; | 30 | private final byte[] _bytes; |
793 | 31 | 31 | ||
795 | 32 | AntiValue(int ec, byte[] bytes) { | 32 | AntiValue(final int ec, final byte[] bytes) { |
796 | 33 | _elisionCount = ec; | 33 | _elisionCount = ec; |
797 | 34 | _bytes = bytes; | 34 | _bytes = bytes; |
798 | 35 | } | 35 | } |
799 | 36 | 36 | ||
804 | 37 | static void putAntiValue(Value value, Key key1, Key key2) { | 37 | static void putAntiValue(final Value value, final Key key1, final Key key2) { |
805 | 38 | int elisionCount = key1.firstUniqueByteIndex(key2); | 38 | final int elisionCount = key1.firstUniqueByteIndex(key2); |
806 | 39 | int size = key2.getEncodedSize() - elisionCount; | 39 | final int size = key2.getEncodedSize() - elisionCount; |
807 | 40 | byte[] bytes = new byte[size]; | 40 | final byte[] bytes = new byte[size]; |
808 | 41 | System.arraycopy(key2.getEncodedBytes(), elisionCount, bytes, 0, size); | 41 | System.arraycopy(key2.getEncodedBytes(), elisionCount, bytes, 0, size); |
809 | 42 | value.putAntiValue((short) elisionCount, bytes); | 42 | value.putAntiValue((short) elisionCount, bytes); |
810 | 43 | } | 43 | } |
811 | 44 | 44 | ||
816 | 45 | static void fixUpKeys(Exchange exchange, int elisionCount, byte[] bytes, int offset, int length) | 45 | static void fixUpKeys(final Exchange exchange, final int elisionCount, final byte[] bytes, final int offset, |
817 | 46 | throws InvalidKeyException { | 46 | final int length) throws InvalidKeyException { |
818 | 47 | Key spareKey1 = exchange.getAuxiliaryKey1(); | 47 | final Key spareKey1 = exchange.getAuxiliaryKey1(); |
819 | 48 | Key spareKey2 = exchange.getAuxiliaryKey2(); | 48 | final Key spareKey2 = exchange.getAuxiliaryKey2(); |
820 | 49 | spareKey1.copyTo(spareKey2); | 49 | spareKey1.copyTo(spareKey2); |
823 | 50 | byte[] baseBytes = spareKey2.getEncodedBytes(); | 50 | final byte[] baseBytes = spareKey2.getEncodedBytes(); |
824 | 51 | int baseSize = spareKey2.getEncodedSize(); | 51 | final int baseSize = spareKey2.getEncodedSize(); |
825 | 52 | if (baseSize < elisionCount || elisionCount + length > Key.MAX_KEY_LENGTH) { | 52 | if (baseSize < elisionCount || elisionCount + length > Key.MAX_KEY_LENGTH) { |
826 | 53 | throw new InvalidKeyException("Key encoding in transaction is invalid"); | 53 | throw new InvalidKeyException("Key encoding in transaction is invalid"); |
827 | 54 | } | 54 | } |
828 | 55 | 55 | ||
829 | === modified file 'src/main/java/com/persistit/BackupTask.java' | |||
830 | --- src/main/java/com/persistit/BackupTask.java 2012-08-02 04:45:28 +0000 | |||
831 | +++ src/main/java/com/persistit/BackupTask.java 2012-08-24 18:20:24 +0000 | |||
832 | @@ -76,12 +76,13 @@ | |||
833 | 76 | private volatile String _backupStatus; | 76 | private volatile String _backupStatus; |
834 | 77 | 77 | ||
835 | 78 | @Cmd("backup") | 78 | @Cmd("backup") |
842 | 79 | static Task setupTask(@Arg("file|string|Archive file path") String file, | 79 | static Task setupTask(@Arg("file|string|Archive file path") final String file, |
843 | 80 | @Arg("_flag|a|Start appendOnly mode") boolean start, @Arg("_flag|e|End appendOnly mode") boolean end, | 80 | @Arg("_flag|a|Start appendOnly mode") final boolean start, |
844 | 81 | @Arg("_flag|c|Request checkpoint before backup") boolean checkpoint, | 81 | @Arg("_flag|e|End appendOnly mode") final boolean end, |
845 | 82 | @Arg("_flag|z|Compress output to ZIP format") boolean compressed, | 82 | @Arg("_flag|c|Request checkpoint before backup") final boolean checkpoint, |
846 | 83 | @Arg("_flag|f|Emit a list of files that need to be copied") boolean showFiles, | 83 | @Arg("_flag|z|Compress output to ZIP format") final boolean compressed, |
847 | 84 | @Arg("_flag|y|Copyback pages before starting") boolean copyback) throws Exception { | 84 | @Arg("_flag|f|Emit a list of files that need to be copied") final boolean showFiles, |
848 | 85 | @Arg("_flag|y|Copyback pages before starting") final boolean copyback) throws Exception { | ||
849 | 85 | final BackupTask task = new BackupTask(); | 86 | final BackupTask task = new BackupTask(); |
850 | 86 | task._toFile = file; | 87 | task._toFile = file; |
851 | 87 | task._start = start; | 88 | task._start = start; |
852 | @@ -103,7 +104,7 @@ | |||
853 | 103 | protected void runTask() throws Exception { | 104 | protected void runTask() throws Exception { |
854 | 104 | validate(); | 105 | validate(); |
855 | 105 | final Management management = _persistit.getManagement(); | 106 | final Management management = _persistit.getManagement(); |
857 | 106 | boolean wasAppendOnly = management.getJournalInfo().isAppendOnly(); | 107 | final boolean wasAppendOnly = management.getJournalInfo().isAppendOnly(); |
858 | 107 | if (_checkpoint) { | 108 | if (_checkpoint) { |
859 | 108 | postMessage("Waiting for checkpoint", 0); | 109 | postMessage("Waiting for checkpoint", 0); |
860 | 109 | final Checkpoint cp = _persistit.checkpoint(); | 110 | final Checkpoint cp = _persistit.checkpoint(); |
861 | @@ -115,9 +116,9 @@ | |||
862 | 115 | } | 116 | } |
863 | 116 | if (_copyback && !wasAppendOnly) { | 117 | if (_copyback && !wasAppendOnly) { |
864 | 117 | postMessage("Copying back pages from journal", 0); | 118 | postMessage("Copying back pages from journal", 0); |
866 | 118 | long start = _persistit.getJournalManager().getCopiedPageCount(); | 119 | final long start = _persistit.getJournalManager().getCopiedPageCount(); |
867 | 119 | _persistit.copyBackPages(); | 120 | _persistit.copyBackPages(); |
869 | 120 | long end = _persistit.getJournalManager().getCopiedPageCount(); | 121 | final long end = _persistit.getJournalManager().getCopiedPageCount(); |
870 | 121 | postMessage((end - start) + " pages copied", 0); | 122 | postMessage((end - start) + " pages copied", 0); |
871 | 122 | } | 123 | } |
872 | 123 | try { | 124 | try { |
873 | @@ -128,7 +129,7 @@ | |||
874 | 128 | doBackup(); | 129 | doBackup(); |
875 | 129 | } | 130 | } |
876 | 130 | } | 131 | } |
878 | 131 | } catch (Exception e) { | 132 | } catch (final Exception e) { |
879 | 132 | _backupStatus = "Failed: " + e; | 133 | _backupStatus = "Failed: " + e; |
880 | 133 | } finally { | 134 | } finally { |
881 | 134 | management.setAppendOnly(_start ? true : _end ? false : wasAppendOnly); | 135 | management.setAppendOnly(_start ? true : _end ? false : wasAppendOnly); |
882 | @@ -136,7 +137,7 @@ | |||
883 | 136 | } | 137 | } |
884 | 137 | 138 | ||
885 | 138 | @Override | 139 | @Override |
887 | 139 | protected void postMessage(final String message, int level) { | 140 | protected void postMessage(final String message, final int level) { |
888 | 140 | super.postMessage(message, level); | 141 | super.postMessage(message, level); |
889 | 141 | _backupStatus = message; | 142 | _backupStatus = message; |
890 | 142 | } | 143 | } |
891 | @@ -152,9 +153,9 @@ | |||
892 | 152 | final long baseAddress = info.getBaseAddress(); | 153 | final long baseAddress = info.getBaseAddress(); |
893 | 153 | final long currentAddress = info.getCurrentJournalAddress(); | 154 | final long currentAddress = info.getCurrentJournalAddress(); |
894 | 154 | final long blockSize = info.getBlockSize(); | 155 | final long blockSize = info.getBlockSize(); |
896 | 155 | String path = JournalManager.fileToPath(new File(info.getCurrentJournalFile())); | 156 | final String path = JournalManager.fileToPath(new File(info.getCurrentJournalFile())); |
897 | 156 | for (long generation = baseAddress / blockSize; generation <= currentAddress / blockSize; generation++) { | 157 | for (long generation = baseAddress / blockSize; generation <= currentAddress / blockSize; generation++) { |
899 | 157 | File file = JournalManager.generationToFile(path, generation); | 158 | final File file = JournalManager.generationToFile(path, generation); |
900 | 158 | _files.add(file.getAbsolutePath()); | 159 | _files.add(file.getAbsolutePath()); |
901 | 159 | } | 160 | } |
902 | 160 | final StringBuilder sb = new StringBuilder(); | 161 | final StringBuilder sb = new StringBuilder(); |
903 | 161 | 162 | ||
904 | === modified file 'src/main/java/com/persistit/Buffer.java' | |||
905 | --- src/main/java/com/persistit/Buffer.java 2012-08-02 04:45:28 +0000 | |||
906 | +++ src/main/java/com/persistit/Buffer.java 2012-08-24 18:20:24 +0000 | |||
907 | @@ -266,17 +266,18 @@ | |||
908 | 266 | 266 | ||
909 | 267 | abstract static class VerifyVisitor { | 267 | abstract static class VerifyVisitor { |
910 | 268 | 268 | ||
922 | 269 | protected void visitPage(long timestamp, Volume volume, long page, int type, int bufferSize, int keyBlockStart, | 269 | protected void visitPage(final long timestamp, final Volume volume, final long page, final int type, |
923 | 270 | int keyBlockEnd, int alloc, int available, long rightSibling) throws PersistitException { | 270 | final int bufferSize, final int keyBlockStart, final int keyBlockEnd, final int alloc, |
924 | 271 | } | 271 | final int available, final long rightSibling) throws PersistitException { |
925 | 272 | 272 | } | |
926 | 273 | protected void visitIndexRecord(Key key, int foundAt, int tail, int kLength, long pointer) | 273 | |
927 | 274 | throws PersistitException { | 274 | protected void visitIndexRecord(final Key key, final int foundAt, final int tail, final int kLength, |
928 | 275 | 275 | final long pointer) throws PersistitException { | |
929 | 276 | } | 276 | |
930 | 277 | 277 | } | |
931 | 278 | protected void visitDataRecord(Key key, int foundAt, int tail, int klength, int offset, int length, byte[] bytes) | 278 | |
932 | 279 | throws PersistitException { | 279 | protected void visitDataRecord(final Key key, final int foundAt, final int tail, final int klength, |
933 | 280 | final int offset, final int length, final byte[] bytes) throws PersistitException { | ||
934 | 280 | } | 281 | } |
935 | 281 | } | 282 | } |
936 | 282 | 283 | ||
937 | @@ -323,7 +324,7 @@ | |||
938 | 323 | * The bytes in this buffer. Note these bytes are also the backing store of | 324 | * The bytes in this buffer. Note these bytes are also the backing store of |
939 | 324 | * _byteBuffer. | 325 | * _byteBuffer. |
940 | 325 | */ | 326 | */ |
942 | 326 | private byte[] _bytes; | 327 | private final byte[] _bytes; |
943 | 327 | 328 | ||
944 | 328 | /** | 329 | /** |
945 | 329 | * FastIndex structure used for rapid page searching | 330 | * FastIndex structure used for rapid page searching |
946 | @@ -382,7 +383,7 @@ | |||
947 | 382 | * @param size | 383 | * @param size |
948 | 383 | * The buffer size, in bytes. | 384 | * The buffer size, in bytes. |
949 | 384 | */ | 385 | */ |
951 | 385 | Buffer(int size, int index, BufferPool pool, Persistit persistit) { | 386 | Buffer(int size, final int index, final BufferPool pool, final Persistit persistit) { |
952 | 386 | super(persistit); | 387 | super(persistit); |
953 | 387 | boolean ok = false; | 388 | boolean ok = false; |
954 | 388 | for (int s = MIN_BUFFER_SIZE; !ok && s <= MAX_BUFFER_SIZE; s *= 2) { | 389 | for (int s = MIN_BUFFER_SIZE; !ok && s <= MAX_BUFFER_SIZE; s *= 2) { |
955 | @@ -402,7 +403,7 @@ | |||
956 | 402 | _fastIndex = new FastIndex(this, 1 + (size - HEADER_SIZE) / MAX_KEY_RATIO); | 403 | _fastIndex = new FastIndex(this, 1 + (size - HEADER_SIZE) / MAX_KEY_RATIO); |
957 | 403 | } | 404 | } |
958 | 404 | 405 | ||
960 | 405 | Buffer(Buffer original) { | 406 | Buffer(final Buffer original) { |
961 | 406 | this(original._bufferSize, original._poolIndex, original._pool, original._persistit); | 407 | this(original._bufferSize, original._poolIndex, original._pool, original._persistit); |
962 | 407 | setStatus(original); | 408 | setStatus(original); |
963 | 408 | _type = original._type; | 409 | _type = original._type; |
964 | @@ -421,7 +422,7 @@ | |||
965 | 421 | /** | 422 | /** |
966 | 422 | * Initializes the buffer so that it contains no keys or data. | 423 | * Initializes the buffer so that it contains no keys or data. |
967 | 423 | */ | 424 | */ |
969 | 424 | void init(int type) { | 425 | void init(final int type) { |
970 | 425 | _type = type; | 426 | _type = type; |
971 | 426 | setKeyBlockEnd(KEY_BLOCK_START); | 427 | setKeyBlockEnd(KEY_BLOCK_START); |
972 | 427 | _tailHeaderSize = isIndexPage() ? TAILBLOCK_HDR_SIZE_INDEX : TAILBLOCK_HDR_SIZE_DATA; | 428 | _tailHeaderSize = isIndexPage() ? TAILBLOCK_HDR_SIZE_INDEX : TAILBLOCK_HDR_SIZE_DATA; |
973 | @@ -449,7 +450,7 @@ | |||
974 | 449 | * @throws InUseException | 450 | * @throws InUseException |
975 | 450 | * @throws PersistitInterruptedException | 451 | * @throws PersistitInterruptedException |
976 | 451 | */ | 452 | */ |
978 | 452 | void load(Volume vol, long page) throws PersistitIOException, InvalidPageAddressException, | 453 | void load(final Volume vol, final long page) throws PersistitIOException, InvalidPageAddressException, |
979 | 453 | InvalidPageStructureException, VolumeClosedException, InUseException, PersistitInterruptedException { | 454 | InvalidPageStructureException, VolumeClosedException, InUseException, PersistitInterruptedException { |
980 | 454 | _vol = vol; | 455 | _vol = vol; |
981 | 455 | _page = page; | 456 | _page = page; |
982 | @@ -463,7 +464,7 @@ | |||
983 | 463 | _timestamp = getLong(TIMESTAMP_OFFSET); | 464 | _timestamp = getLong(TIMESTAMP_OFFSET); |
984 | 464 | 465 | ||
985 | 465 | if (_page != 0) { | 466 | if (_page != 0) { |
987 | 466 | int type = getByte(TYPE_OFFSET); | 467 | final int type = getByte(TYPE_OFFSET); |
988 | 467 | if (type > PAGE_TYPE_MAX) { | 468 | if (type > PAGE_TYPE_MAX) { |
989 | 468 | throw new InvalidPageStructureException("Invalid type " + type); | 469 | throw new InvalidPageStructureException("Invalid type " + type); |
990 | 469 | } | 470 | } |
991 | @@ -519,6 +520,7 @@ | |||
992 | 519 | } | 520 | } |
993 | 520 | } | 521 | } |
994 | 521 | 522 | ||
995 | 523 | @Override | ||
996 | 522 | boolean clearDirty() { | 524 | boolean clearDirty() { |
997 | 523 | if (super.clearDirty()) { | 525 | if (super.clearDirty()) { |
998 | 524 | _pool.decrementDirtyPageCount(); | 526 | _pool.decrementDirtyPageCount(); |
999 | @@ -527,6 +529,7 @@ | |||
1000 | 527 | return false; | 529 | return false; |
1001 | 528 | } | 530 | } |
1002 | 529 | 531 | ||
1003 | 532 | @Override | ||
1004 | 530 | boolean setDirty() { | 533 | boolean setDirty() { |
1005 | 531 | throw new UnsupportedOperationException(); | 534 | throw new UnsupportedOperationException(); |
1006 | 532 | } | 535 | } |
1007 | @@ -543,12 +546,12 @@ | |||
1008 | 543 | } | 546 | } |
1009 | 544 | 547 | ||
1010 | 545 | @Override | 548 | @Override |
1012 | 546 | boolean claim(boolean writer) throws PersistitInterruptedException { | 549 | boolean claim(final boolean writer) throws PersistitInterruptedException { |
1013 | 547 | return claim(writer, DEFAULT_MAX_WAIT_TIME); | 550 | return claim(writer, DEFAULT_MAX_WAIT_TIME); |
1014 | 548 | } | 551 | } |
1015 | 549 | 552 | ||
1016 | 550 | @Override | 553 | @Override |
1018 | 551 | boolean claim(boolean writer, long timeout) throws PersistitInterruptedException { | 554 | boolean claim(final boolean writer, final long timeout) throws PersistitInterruptedException { |
1019 | 552 | if (super.claim(writer, timeout)) { | 555 | if (super.claim(writer, timeout)) { |
1020 | 553 | if (!isDirty()) { | 556 | if (!isDirty()) { |
1021 | 554 | _timestamp = _persistit.getCurrentTimestamp(); | 557 | _timestamp = _persistit.getCurrentTimestamp(); |
1022 | @@ -579,7 +582,7 @@ | |||
1023 | 579 | Util.clearBytes(_bytes, 0, _bufferSize); | 582 | Util.clearBytes(_bytes, 0, _bufferSize); |
1024 | 580 | } | 583 | } |
1025 | 581 | 584 | ||
1027 | 582 | void clearBytes(int from, int to) { | 585 | void clearBytes(final int from, final int to) { |
1028 | 583 | Util.clearBytes(_bytes, from, to); | 586 | Util.clearBytes(_bytes, from, to); |
1029 | 584 | } | 587 | } |
1030 | 585 | 588 | ||
1031 | @@ -733,7 +736,7 @@ | |||
1032 | 733 | * @param pageAddress | 736 | * @param pageAddress |
1033 | 734 | * the sibling's address | 737 | * the sibling's address |
1034 | 735 | */ | 738 | */ |
1036 | 736 | void setRightSibling(long pageAddress) { | 739 | void setRightSibling(final long pageAddress) { |
1037 | 737 | Debug.$assert0.t(isMine()); | 740 | Debug.$assert0.t(isMine()); |
1038 | 738 | _rightSibling = pageAddress; | 741 | _rightSibling = pageAddress; |
1039 | 739 | } | 742 | } |
1040 | @@ -803,15 +806,15 @@ | |||
1041 | 803 | * it follows the last key in the page. | 806 | * it follows the last key in the page. |
1042 | 804 | * @throws PersistitInterruptedException | 807 | * @throws PersistitInterruptedException |
1043 | 805 | */ | 808 | */ |
1045 | 806 | int findKey(Key key) throws PersistitInterruptedException { | 809 | int findKey(final Key key) throws PersistitInterruptedException { |
1046 | 807 | final FastIndex fastIndex = getFastIndex(); | 810 | final FastIndex fastIndex = getFastIndex(); |
1049 | 808 | byte[] kbytes = key.getEncodedBytes(); | 811 | final byte[] kbytes = key.getEncodedBytes(); |
1050 | 809 | int klength = key.getEncodedSize(); | 812 | final int klength = key.getEncodedSize(); |
1051 | 810 | int depth = 0; | 813 | int depth = 0; |
1052 | 811 | int left = KEY_BLOCK_START; | 814 | int left = KEY_BLOCK_START; |
1053 | 812 | int right = _keyBlockEnd; | 815 | int right = _keyBlockEnd; |
1056 | 813 | int start = left; | 816 | final int start = left; |
1057 | 814 | int tailHeaderSize = _tailHeaderSize; | 817 | final int tailHeaderSize = _tailHeaderSize; |
1058 | 815 | 818 | ||
1059 | 816 | for (int p = start; p < right;) { | 819 | for (int p = start; p < right;) { |
1060 | 817 | // | 820 | // |
1061 | @@ -820,7 +823,7 @@ | |||
1062 | 820 | int kbData = getInt(p); | 823 | int kbData = getInt(p); |
1063 | 821 | int index = (p - start) >> 2; | 824 | int index = (p - start) >> 2; |
1064 | 822 | int runCount = fastIndex.getRunCount(index); | 825 | int runCount = fastIndex.getRunCount(index); |
1066 | 823 | int ebc = decodeKeyBlockEbc(kbData); | 826 | final int ebc = decodeKeyBlockEbc(kbData); |
1067 | 824 | 827 | ||
1068 | 825 | if (depth < ebc) { | 828 | if (depth < ebc) { |
1069 | 826 | // We know that depth < ebc for a bunch of KeyBlocks - we | 829 | // We know that depth < ebc for a bunch of KeyBlocks - we |
1070 | @@ -836,7 +839,7 @@ | |||
1071 | 836 | } | 839 | } |
1072 | 837 | 840 | ||
1073 | 838 | else if (depth > ebc) { | 841 | else if (depth > ebc) { |
1075 | 839 | int result = p | (depth << DEPTH_SHIFT); | 842 | final int result = p | (depth << DEPTH_SHIFT); |
1076 | 840 | return result; | 843 | return result; |
1077 | 841 | } | 844 | } |
1078 | 842 | 845 | ||
1079 | @@ -847,7 +850,7 @@ | |||
1080 | 847 | int kb = kbytes[depth] & 0xFF; | 850 | int kb = kbytes[depth] & 0xFF; |
1081 | 848 | 851 | ||
1082 | 849 | if (kb < db) { | 852 | if (kb < db) { |
1084 | 850 | int result = p | (depth << DEPTH_SHIFT); | 853 | final int result = p | (depth << DEPTH_SHIFT); |
1085 | 851 | return result; | 854 | return result; |
1086 | 852 | } | 855 | } |
1087 | 853 | if (kb > db) { | 856 | if (kb > db) { |
1088 | @@ -858,13 +861,13 @@ | |||
1089 | 858 | // either do a linear search or perform a binary search | 861 | // either do a linear search or perform a binary search |
1090 | 859 | // within the run. | 862 | // within the run. |
1091 | 860 | // | 863 | // |
1093 | 861 | int p2 = p + (runCount * KEYBLOCK_LENGTH); | 864 | final int p2 = p + (runCount * KEYBLOCK_LENGTH); |
1094 | 862 | // | 865 | // |
1095 | 863 | // p2 now points to the last key block with the same | 866 | // p2 now points to the last key block with the same |
1096 | 864 | // ebc in this run. | 867 | // ebc in this run. |
1097 | 865 | // | 868 | // |
1100 | 866 | int kbData2 = getInt(p2); | 869 | final int kbData2 = getInt(p2); |
1101 | 867 | int db2 = decodeKeyBlockDb(kbData2); | 870 | final int db2 = decodeKeyBlockDb(kbData2); |
1102 | 868 | // | 871 | // |
1103 | 869 | // For the common case that runCount == 1, we avoid | 872 | // For the common case that runCount == 1, we avoid |
1104 | 870 | // setting up the binary search loop. Instead, the | 873 | // setting up the binary search loop. Instead, the |
1105 | @@ -877,7 +880,7 @@ | |||
1106 | 877 | // This is right because we already know | 880 | // This is right because we already know |
1107 | 878 | // that kb > db. | 881 | // that kb > db. |
1108 | 879 | // | 882 | // |
1110 | 880 | int result = p2 | (depth << DEPTH_SHIFT); | 883 | final int result = p2 | (depth << DEPTH_SHIFT); |
1111 | 881 | return result; | 884 | return result; |
1112 | 882 | } else if (db2 < kb) { | 885 | } else if (db2 < kb) { |
1113 | 883 | // | 886 | // |
1114 | @@ -888,7 +891,7 @@ | |||
1115 | 888 | // - | 891 | // - |
1116 | 889 | // in that case we use the cross count to skip | 892 | // in that case we use the cross count to skip |
1117 | 890 | // all of them. | 893 | // all of them. |
1119 | 891 | int runCount2 = fastIndex.getRunCount(index + runCount); | 894 | final int runCount2 = fastIndex.getRunCount(index + runCount); |
1120 | 892 | assert runCount2 <= 0; | 895 | assert runCount2 <= 0; |
1121 | 893 | p = p2 + KEYBLOCK_LENGTH * (-runCount + 1); | 896 | p = p2 + KEYBLOCK_LENGTH * (-runCount + 1); |
1122 | 894 | continue; | 897 | continue; |
1123 | @@ -921,8 +924,8 @@ | |||
1124 | 921 | // we are seeking. | 924 | // we are seeking. |
1125 | 922 | // | 925 | // |
1126 | 923 | if (runCount > BINARY_SEARCH_THRESHOLD) { | 926 | if (runCount > BINARY_SEARCH_THRESHOLD) { |
1129 | 924 | int distance = (right - left) >> 2; | 927 | final int distance = (right - left) >> 2; |
1130 | 925 | int oldRight = right; | 928 | final int oldRight = right; |
1131 | 926 | if (distance > kb - db + 1) { | 929 | if (distance > kb - db + 1) { |
1132 | 927 | right = left + ((kb - db + 1) << 2); | 930 | right = left + ((kb - db + 1) << 2); |
1133 | 928 | } | 931 | } |
1134 | @@ -942,7 +945,7 @@ | |||
1135 | 942 | // that kb > db and less than db2, so the | 945 | // that kb > db and less than db2, so the |
1136 | 943 | // final answer is know to be in right. | 946 | // final answer is know to be in right. |
1137 | 944 | // | 947 | // |
1139 | 945 | int result = right | (depth << DEPTH_SHIFT); | 948 | final int result = right | (depth << DEPTH_SHIFT); |
1140 | 946 | return result; | 949 | return result; |
1141 | 947 | } | 950 | } |
1142 | 948 | // | 951 | // |
1143 | @@ -950,7 +953,7 @@ | |||
1144 | 950 | // mid-point and | 953 | // mid-point and |
1145 | 951 | // adjust the ends depending on the comparison. | 954 | // adjust the ends depending on the comparison. |
1146 | 952 | // | 955 | // |
1148 | 953 | int db1 = getDb(p); | 956 | final int db1 = getDb(p); |
1149 | 954 | 957 | ||
1150 | 955 | if (db1 == kb) { | 958 | if (db1 == kb) { |
1151 | 956 | db = db1; | 959 | db = db1; |
1152 | @@ -998,10 +1001,10 @@ | |||
1153 | 998 | // for each byte in the key. | 1001 | // for each byte in the key. |
1154 | 999 | // | 1002 | // |
1155 | 1000 | kbData = getInt(p); | 1003 | kbData = getInt(p); |
1160 | 1001 | int tail = decodeKeyBlockTail(kbData); | 1004 | final int tail = decodeKeyBlockTail(kbData); |
1161 | 1002 | int tbData = getInt(tail); | 1005 | final int tbData = getInt(tail); |
1162 | 1003 | int tlength = decodeTailBlockKLength(tbData) + depth + 1; | 1006 | final int tlength = decodeTailBlockKLength(tbData) + depth + 1; |
1163 | 1004 | int qlength = tlength < klength ? tlength : klength; | 1007 | final int qlength = tlength < klength ? tlength : klength; |
1164 | 1005 | // | 1008 | // |
1165 | 1006 | // Walk down the key, increasing depth | 1009 | // Walk down the key, increasing depth |
1166 | 1007 | // | 1010 | // |
1167 | @@ -1025,7 +1028,7 @@ | |||
1168 | 1025 | // Key is less than tail, so we return | 1028 | // Key is less than tail, so we return |
1169 | 1026 | // this keyblock | 1029 | // this keyblock |
1170 | 1027 | // | 1030 | // |
1172 | 1028 | int result = p | (depth << DEPTH_SHIFT) | FIXUP_MASK; | 1031 | final int result = p | (depth << DEPTH_SHIFT) | FIXUP_MASK; |
1173 | 1029 | return result; | 1032 | return result; |
1174 | 1030 | } | 1033 | } |
1175 | 1031 | matched = false; | 1034 | matched = false; |
1176 | @@ -1045,7 +1048,7 @@ | |||
1177 | 1045 | // And the key lengths are equal so this is an | 1048 | // And the key lengths are equal so this is an |
1178 | 1046 | // exact match. | 1049 | // exact match. |
1179 | 1047 | // | 1050 | // |
1181 | 1048 | int result = p | (depth << DEPTH_SHIFT) | EXACT_MASK; | 1051 | final int result = p | (depth << DEPTH_SHIFT) | EXACT_MASK; |
1182 | 1049 | return result; | 1052 | return result; |
1183 | 1050 | } | 1053 | } |
1184 | 1051 | } else if (tlength > qlength) { | 1054 | } else if (tlength > qlength) { |
1185 | @@ -1054,7 +1057,7 @@ | |||
1186 | 1054 | // key is less than tail, so we return the | 1057 | // key is less than tail, so we return the |
1187 | 1055 | // this keyblock since it is greater than the key | 1058 | // this keyblock since it is greater than the key |
1188 | 1056 | // | 1059 | // |
1190 | 1057 | int result = p | (depth << DEPTH_SHIFT) | FIXUP_MASK; | 1060 | final int result = p | (depth << DEPTH_SHIFT) | FIXUP_MASK; |
1191 | 1058 | return result; | 1061 | return result; |
1192 | 1059 | } | 1062 | } |
1193 | 1060 | // Otherwise, the key is longer, so we move to the next | 1063 | // Otherwise, the key is longer, so we move to the next |
1194 | @@ -1066,7 +1069,7 @@ | |||
1195 | 1066 | 1069 | ||
1196 | 1067 | } | 1070 | } |
1197 | 1068 | 1071 | ||
1199 | 1069 | int result = right | (depth << DEPTH_SHIFT); | 1072 | final int result = right | (depth << DEPTH_SHIFT); |
1200 | 1070 | return result; | 1073 | return result; |
1201 | 1071 | } | 1074 | } |
1202 | 1072 | 1075 | ||
1203 | @@ -1074,13 +1077,13 @@ | |||
1204 | 1074 | if (isDataPage()) { | 1077 | if (isDataPage()) { |
1205 | 1075 | final int p = foundAt & P_MASK; | 1078 | final int p = foundAt & P_MASK; |
1206 | 1076 | if (p >= KEY_BLOCK_START && p < _keyBlockEnd) { | 1079 | if (p >= KEY_BLOCK_START && p < _keyBlockEnd) { |
1214 | 1077 | int kbData = getInt(p); | 1080 | final int kbData = getInt(p); |
1215 | 1078 | int tail = decodeKeyBlockTail(kbData); | 1081 | final int tail = decodeKeyBlockTail(kbData); |
1216 | 1079 | int tbData = getInt(tail); | 1082 | final int tbData = getInt(tail); |
1217 | 1080 | int klength = decodeTailBlockKLength(tbData); | 1083 | final int klength = decodeTailBlockKLength(tbData); |
1218 | 1081 | int size = decodeTailBlockSize(tbData); | 1084 | final int size = decodeTailBlockSize(tbData); |
1219 | 1082 | int offset = tail + _tailHeaderSize + klength; | 1085 | final int offset = tail + _tailHeaderSize + klength; |
1220 | 1083 | int valueSize = size - klength - _tailHeaderSize; | 1086 | final int valueSize = size - klength - _tailHeaderSize; |
1221 | 1084 | return valueSize == 1 && _bytes[offset] == MVV.TYPE_ANTIVALUE; | 1087 | return valueSize == 1 && _bytes[offset] == MVV.TYPE_ANTIVALUE; |
1222 | 1085 | } | 1088 | } |
1223 | 1086 | } | 1089 | } |
1224 | @@ -1099,13 +1102,13 @@ | |||
1225 | 1099 | if (isDataPage() || isIndexPage()) { | 1102 | if (isDataPage() || isIndexPage()) { |
1226 | 1100 | final int p = foundAt & P_MASK; | 1103 | final int p = foundAt & P_MASK; |
1227 | 1101 | if (p >= KEY_BLOCK_START && p < _keyBlockEnd) { | 1104 | if (p >= KEY_BLOCK_START && p < _keyBlockEnd) { |
1235 | 1102 | int kbData = getInt(p); | 1105 | final int kbData = getInt(p); |
1236 | 1103 | int tail = decodeKeyBlockTail(kbData); | 1106 | final int tail = decodeKeyBlockTail(kbData); |
1237 | 1104 | int tbData = getInt(tail); | 1107 | final int tbData = getInt(tail); |
1238 | 1105 | int klength = decodeTailBlockKLength(tbData); | 1108 | final int klength = decodeTailBlockKLength(tbData); |
1239 | 1106 | int size = decodeTailBlockSize(tbData); | 1109 | final int size = decodeTailBlockSize(tbData); |
1240 | 1107 | int offset = tail + _tailHeaderSize + klength; | 1110 | final int offset = tail + _tailHeaderSize + klength; |
1241 | 1108 | int valueSize = size - klength - _tailHeaderSize; | 1111 | final int valueSize = size - klength - _tailHeaderSize; |
1242 | 1109 | return ((long) offset) << 32 | valueSize; | 1112 | return ((long) offset) << 32 | valueSize; |
1243 | 1110 | } | 1113 | } |
1244 | 1111 | } | 1114 | } |
1245 | @@ -1116,13 +1119,13 @@ | |||
1246 | 1116 | Debug.$assert0.t(foundAt > 0 && foundAt < _keyBlockEnd); | 1119 | Debug.$assert0.t(foundAt > 0 && foundAt < _keyBlockEnd); |
1247 | 1117 | if (isDataPage() || isIndexPage()) { | 1120 | if (isDataPage() || isIndexPage()) { |
1248 | 1118 | for (int p = KEY_BLOCK_START; p <= foundAt; p += KEYBLOCK_LENGTH) { | 1121 | for (int p = KEY_BLOCK_START; p <= foundAt; p += KEYBLOCK_LENGTH) { |
1256 | 1119 | int kbData = getInt(p); | 1122 | final int kbData = getInt(p); |
1257 | 1120 | int tail = decodeKeyBlockTail(kbData); | 1123 | final int tail = decodeKeyBlockTail(kbData); |
1258 | 1121 | int ebc = decodeKeyBlockEbc(kbData); | 1124 | final int ebc = decodeKeyBlockEbc(kbData); |
1259 | 1122 | int db = decodeKeyBlockDb(kbData); | 1125 | final int db = decodeKeyBlockDb(kbData); |
1260 | 1123 | int tbData = getInt(tail); | 1126 | final int tbData = getInt(tail); |
1261 | 1124 | int klength = decodeTailBlockKLength(tbData); | 1127 | final int klength = decodeTailBlockKLength(tbData); |
1262 | 1125 | byte[] keyBytes = key.getEncodedBytes(); | 1128 | final byte[] keyBytes = key.getEncodedBytes(); |
1263 | 1126 | keyBytes[ebc] = (byte) db; | 1129 | keyBytes[ebc] = (byte) db; |
1264 | 1127 | System.arraycopy(_bytes, tail + _tailHeaderSize, keyBytes, ebc + 1, klength); | 1130 | System.arraycopy(_bytes, tail + _tailHeaderSize, keyBytes, ebc + 1, klength); |
1265 | 1128 | key.setEncodedSize(ebc + klength + 1); | 1131 | key.setEncodedSize(ebc + klength + 1); |
1266 | @@ -1130,32 +1133,32 @@ | |||
1267 | 1130 | } | 1133 | } |
1268 | 1131 | } | 1134 | } |
1269 | 1132 | 1135 | ||
1271 | 1133 | Value fetch(int foundAt, Value value) { | 1136 | Value fetch(final int foundAt, final Value value) { |
1272 | 1134 | if ((foundAt & EXACT_MASK) == 0) { | 1137 | if ((foundAt & EXACT_MASK) == 0) { |
1273 | 1135 | value.clear(); | 1138 | value.clear(); |
1274 | 1136 | } else { | 1139 | } else { |
1275 | 1137 | Debug.$assert0.t(foundAt > 0 && (foundAt & P_MASK) < _keyBlockEnd); | 1140 | Debug.$assert0.t(foundAt > 0 && (foundAt & P_MASK) < _keyBlockEnd); |
1282 | 1138 | int kbData = getInt(foundAt & P_MASK); | 1141 | final int kbData = getInt(foundAt & P_MASK); |
1283 | 1139 | int tail = decodeKeyBlockTail(kbData); | 1142 | final int tail = decodeKeyBlockTail(kbData); |
1284 | 1140 | int tbData = getInt(tail); | 1143 | final int tbData = getInt(tail); |
1285 | 1141 | int klength = decodeTailBlockKLength(tbData); | 1144 | final int klength = decodeTailBlockKLength(tbData); |
1286 | 1142 | int size = decodeTailBlockSize(tbData); | 1145 | final int size = decodeTailBlockSize(tbData); |
1287 | 1143 | int valueSize = size - klength - _tailHeaderSize; | 1146 | final int valueSize = size - klength - _tailHeaderSize; |
1288 | 1144 | value.putEncodedBytes(_bytes, tail + _tailHeaderSize + klength, valueSize); | 1147 | value.putEncodedBytes(_bytes, tail + _tailHeaderSize + klength, valueSize); |
1289 | 1145 | } | 1148 | } |
1290 | 1146 | return value; | 1149 | return value; |
1291 | 1147 | } | 1150 | } |
1292 | 1148 | 1151 | ||
1294 | 1149 | long fetchLongRecordPointer(int foundAt) { | 1152 | long fetchLongRecordPointer(final int foundAt) { |
1295 | 1150 | if (!isDataPage()) { | 1153 | if (!isDataPage()) { |
1296 | 1151 | return 0; | 1154 | return 0; |
1297 | 1152 | } | 1155 | } |
1304 | 1153 | int kbData = getInt(foundAt & P_MASK); | 1156 | final int kbData = getInt(foundAt & P_MASK); |
1305 | 1154 | int tail = decodeKeyBlockTail(kbData); | 1157 | final int tail = decodeKeyBlockTail(kbData); |
1306 | 1155 | int tbData = getInt(tail); | 1158 | final int tbData = getInt(tail); |
1307 | 1156 | int klength = decodeTailBlockKLength(tbData); | 1159 | final int klength = decodeTailBlockKLength(tbData); |
1308 | 1157 | int size = decodeTailBlockSize(tbData); | 1160 | final int size = decodeTailBlockSize(tbData); |
1309 | 1158 | int valueSize = size - klength - _tailHeaderSize; | 1161 | final int valueSize = size - klength - _tailHeaderSize; |
1310 | 1159 | if (valueSize != LONGREC_SIZE) { | 1162 | if (valueSize != LONGREC_SIZE) { |
1311 | 1160 | return 0; | 1163 | return 0; |
1312 | 1161 | } | 1164 | } |
1313 | @@ -1163,16 +1166,16 @@ | |||
1314 | 1163 | return 0; | 1166 | return 0; |
1315 | 1164 | } | 1167 | } |
1316 | 1165 | 1168 | ||
1318 | 1166 | long pointer = getLong(tail + _tailHeaderSize + klength + LONGREC_PAGE_OFFSET); | 1169 | final long pointer = getLong(tail + _tailHeaderSize + klength + LONGREC_PAGE_OFFSET); |
1319 | 1167 | return pointer; | 1170 | return pointer; |
1320 | 1168 | } | 1171 | } |
1321 | 1169 | 1172 | ||
1323 | 1170 | long getPointer(int foundAt) throws PersistitException { | 1173 | long getPointer(final int foundAt) throws PersistitException { |
1324 | 1171 | if (!isIndexPage()) { | 1174 | if (!isIndexPage()) { |
1325 | 1172 | throw new InvalidPageTypeException("type=" + _type); | 1175 | throw new InvalidPageTypeException("type=" + _type); |
1326 | 1173 | } | 1176 | } |
1329 | 1174 | int kbData = getInt(foundAt & P_MASK); | 1177 | final int kbData = getInt(foundAt & P_MASK); |
1330 | 1175 | int tail = decodeKeyBlockTail(kbData); | 1178 | final int tail = decodeKeyBlockTail(kbData); |
1331 | 1176 | return getInt(tail + 4); | 1179 | return getInt(tail + 4); |
1332 | 1177 | } | 1180 | } |
1333 | 1178 | 1181 | ||
1334 | @@ -1185,8 +1188,8 @@ | |||
1335 | 1185 | * @param foundAt | 1188 | * @param foundAt |
1336 | 1186 | * @return | 1189 | * @return |
1337 | 1187 | */ | 1190 | */ |
1340 | 1188 | int traverse(Key key, Key.Direction mode, int foundAt) { | 1191 | int traverse(final Key key, final Key.Direction mode, final int foundAt) { |
1341 | 1189 | boolean exactMatch = (foundAt & EXACT_MASK) > 0; | 1192 | final boolean exactMatch = (foundAt & EXACT_MASK) > 0; |
1342 | 1190 | if (mode == Key.EQ || exactMatch && (mode == Key.LTEQ || mode == Key.GTEQ)) { | 1193 | if (mode == Key.EQ || exactMatch && (mode == Key.LTEQ || mode == Key.GTEQ)) { |
1343 | 1191 | return foundAt; | 1194 | return foundAt; |
1344 | 1192 | } | 1195 | } |
1345 | @@ -1205,21 +1208,21 @@ | |||
1346 | 1205 | * @param foundAt | 1208 | * @param foundAt |
1347 | 1206 | * @return | 1209 | * @return |
1348 | 1207 | */ | 1210 | */ |
1350 | 1208 | int previousKey(Key key, int foundAt) { | 1211 | int previousKey(final Key key, final int foundAt) { |
1351 | 1209 | int p = (foundAt & P_MASK) - KEYBLOCK_LENGTH; | 1212 | int p = (foundAt & P_MASK) - KEYBLOCK_LENGTH; |
1353 | 1210 | int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; | 1213 | final int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; |
1354 | 1211 | 1214 | ||
1355 | 1212 | if (p < KEY_BLOCK_START) | 1215 | if (p < KEY_BLOCK_START) |
1356 | 1213 | return foundAt; | 1216 | return foundAt; |
1357 | 1214 | 1217 | ||
1359 | 1215 | byte[] kbytes = key.getEncodedBytes(); | 1218 | final byte[] kbytes = key.getEncodedBytes(); |
1360 | 1216 | 1219 | ||
1361 | 1217 | // Compute the count of prefix bytes in the supplied key that | 1220 | // Compute the count of prefix bytes in the supplied key that |
1362 | 1218 | // are known to match. The leftmost knownGood bytes do not need | 1221 | // are known to match. The leftmost knownGood bytes do not need |
1363 | 1219 | // to be recovered by traversing keys in the page. | 1222 | // to be recovered by traversing keys in the page. |
1364 | 1220 | // | 1223 | // |
1367 | 1221 | int kbData2 = getInt(p + KEYBLOCK_LENGTH); | 1224 | final int kbData2 = getInt(p + KEYBLOCK_LENGTH); |
1368 | 1222 | int ebc2 = decodeKeyBlockEbc(kbData2); | 1225 | final int ebc2 = decodeKeyBlockEbc(kbData2); |
1369 | 1223 | int kbData = getInt(p); | 1226 | int kbData = getInt(p); |
1370 | 1224 | int ebc = decodeKeyBlockEbc(kbData); | 1227 | int ebc = decodeKeyBlockEbc(kbData); |
1371 | 1225 | int knownGood = ebc; | 1228 | int knownGood = ebc; |
1372 | @@ -1244,7 +1247,7 @@ | |||
1373 | 1244 | int unknown = decodeTailBlockKLength(getInt(tail)) + ebc + 1; | 1247 | int unknown = decodeTailBlockKLength(getInt(tail)) + ebc + 1; |
1374 | 1245 | key.setEncodedSize(unknown); | 1248 | key.setEncodedSize(unknown); |
1375 | 1246 | 1249 | ||
1377 | 1247 | int result = p | (unknown << DEPTH_SHIFT) | EXACT_MASK; | 1250 | final int result = p | (unknown << DEPTH_SHIFT) | EXACT_MASK; |
1378 | 1248 | // | 1251 | // |
1379 | 1249 | // Reconstruct the previous key. | 1252 | // Reconstruct the previous key. |
1380 | 1250 | // | 1253 | // |
1381 | @@ -1252,7 +1255,7 @@ | |||
1382 | 1252 | if (ebc < unknown) { | 1255 | if (ebc < unknown) { |
1383 | 1253 | // move bytes from this keyblock into the result key. | 1256 | // move bytes from this keyblock into the result key. |
1384 | 1254 | kbytes[ebc] = (byte) decodeKeyBlockDb(kbData); | 1257 | kbytes[ebc] = (byte) decodeKeyBlockDb(kbData); |
1386 | 1255 | int more = unknown - ebc - 1; | 1258 | final int more = unknown - ebc - 1; |
1387 | 1256 | if (more > 0) { | 1259 | if (more > 0) { |
1388 | 1257 | System.arraycopy(_bytes, tail + _tailHeaderSize, kbytes, ebc + 1, more); | 1260 | System.arraycopy(_bytes, tail + _tailHeaderSize, kbytes, ebc + 1, more); |
1389 | 1258 | } | 1261 | } |
1390 | @@ -1278,7 +1281,7 @@ | |||
1391 | 1278 | * @param foundAt | 1281 | * @param foundAt |
1392 | 1279 | * @return | 1282 | * @return |
1393 | 1280 | */ | 1283 | */ |
1395 | 1281 | int nextKey(Key key, int foundAt) { | 1284 | int nextKey(final Key key, final int foundAt) { |
1396 | 1282 | int p = foundAt & P_MASK; | 1285 | int p = foundAt & P_MASK; |
1397 | 1283 | if ((foundAt & EXACT_MASK) != 0) | 1286 | if ((foundAt & EXACT_MASK) != 0) |
1398 | 1284 | p += KEYBLOCK_LENGTH; | 1287 | p += KEYBLOCK_LENGTH; |
1399 | @@ -1286,16 +1289,16 @@ | |||
1400 | 1286 | if (p >= _keyBlockEnd) | 1289 | if (p >= _keyBlockEnd) |
1401 | 1287 | return foundAt; | 1290 | return foundAt; |
1402 | 1288 | 1291 | ||
1410 | 1289 | byte[] kbytes = key.getEncodedBytes(); | 1292 | final byte[] kbytes = key.getEncodedBytes(); |
1411 | 1290 | int kbData = getInt(p); | 1293 | final int kbData = getInt(p); |
1412 | 1291 | int ebc = decodeKeyBlockEbc(kbData); | 1294 | final int ebc = decodeKeyBlockEbc(kbData); |
1413 | 1292 | int tail = decodeKeyBlockTail(kbData); | 1295 | final int tail = decodeKeyBlockTail(kbData); |
1414 | 1293 | int tbData = getInt(tail); | 1296 | final int tbData = getInt(tail); |
1415 | 1294 | int klength = decodeTailBlockKLength(tbData); | 1297 | final int klength = decodeTailBlockKLength(tbData); |
1416 | 1295 | int keyLength = klength + ebc + 1; | 1298 | final int keyLength = klength + ebc + 1; |
1417 | 1296 | key.setEncodedSize(keyLength); | 1299 | key.setEncodedSize(keyLength); |
1418 | 1297 | 1300 | ||
1420 | 1298 | int result = p | (keyLength << DEPTH_SHIFT) | EXACT_MASK; | 1301 | final int result = p | (keyLength << DEPTH_SHIFT) | EXACT_MASK; |
1421 | 1299 | // | 1302 | // |
1422 | 1300 | // Note: the findKey method is guaranteed to return the offset of a | 1303 | // Note: the findKey method is guaranteed to return the offset of a |
1423 | 1301 | // keyblock whose first ebc bytes match the supplied key. | 1304 | // keyblock whose first ebc bytes match the supplied key. |
1424 | @@ -1313,15 +1316,15 @@ | |||
1425 | 1313 | * @param foundAt | 1316 | * @param foundAt |
1426 | 1314 | * @return | 1317 | * @return |
1427 | 1315 | */ | 1318 | */ |
1429 | 1316 | int nextLongRecord(Value value, int foundAt) { | 1319 | int nextLongRecord(final Value value, final int foundAt) { |
1430 | 1317 | Debug.$assert0.t(isDataPage()); | 1320 | Debug.$assert0.t(isDataPage()); |
1431 | 1318 | for (int p = foundAt & P_MASK; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { | 1321 | for (int p = foundAt & P_MASK; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { |
1438 | 1319 | int kbData = getInt(p); | 1322 | final int kbData = getInt(p); |
1439 | 1320 | int tail = decodeKeyBlockTail(kbData); | 1323 | final int tail = decodeKeyBlockTail(kbData); |
1440 | 1321 | int tbData = getInt(tail); | 1324 | final int tbData = getInt(tail); |
1441 | 1322 | int klength = decodeTailBlockKLength(tbData); | 1325 | final int klength = decodeTailBlockKLength(tbData); |
1442 | 1323 | int size = decodeTailBlockSize(tbData); | 1326 | final int size = decodeTailBlockSize(tbData); |
1443 | 1324 | int valueSize = size - klength - _tailHeaderSize; | 1327 | final int valueSize = size - klength - _tailHeaderSize; |
1444 | 1325 | if ((valueSize > 0) && ((_bytes[tail + _tailHeaderSize + klength] & 0xFF) == LONGREC_TYPE)) { | 1328 | if ((valueSize > 0) && ((_bytes[tail + _tailHeaderSize + klength] & 0xFF) == LONGREC_TYPE)) { |
1445 | 1326 | value.putEncodedBytes(_bytes, tail + _tailHeaderSize + klength, valueSize); | 1329 | value.putEncodedBytes(_bytes, tail + _tailHeaderSize + klength, valueSize); |
1446 | 1327 | return p; | 1330 | return p; |
1447 | @@ -1330,15 +1333,15 @@ | |||
1448 | 1330 | return -1; | 1333 | return -1; |
1449 | 1331 | } | 1334 | } |
1450 | 1332 | 1335 | ||
1453 | 1333 | int previousKeyBlock(int foundAt) { | 1336 | int previousKeyBlock(final int foundAt) { |
1454 | 1334 | int p = (foundAt & P_MASK) - KEYBLOCK_LENGTH; | 1337 | final int p = (foundAt & P_MASK) - KEYBLOCK_LENGTH; |
1455 | 1335 | if (p < KEY_BLOCK_START || p > _keyBlockEnd) | 1338 | if (p < KEY_BLOCK_START || p > _keyBlockEnd) |
1456 | 1336 | return -1; | 1339 | return -1; |
1457 | 1337 | return p; | 1340 | return p; |
1458 | 1338 | } | 1341 | } |
1459 | 1339 | 1342 | ||
1462 | 1340 | int nextKeyBlock(int foundAt) { | 1343 | int nextKeyBlock(final int foundAt) { |
1463 | 1341 | int p = (foundAt & P_MASK) + KEYBLOCK_LENGTH; | 1344 | final int p = (foundAt & P_MASK) + KEYBLOCK_LENGTH; |
1464 | 1342 | if (p >= _keyBlockEnd || p < KEY_BLOCK_START) | 1345 | if (p >= _keyBlockEnd || p < KEY_BLOCK_START) |
1465 | 1343 | return -1; | 1346 | return -1; |
1466 | 1344 | return p; | 1347 | return p; |
1467 | @@ -1366,8 +1369,8 @@ | |||
1468 | 1366 | * The value, converted to a byte array | 1369 | * The value, converted to a byte array |
1469 | 1367 | * @throws PersistitInterruptedException | 1370 | * @throws PersistitInterruptedException |
1470 | 1368 | */ | 1371 | */ |
1473 | 1369 | int putValue(Key key, ValueHelper valueHelper) throws PersistitInterruptedException { | 1372 | int putValue(final Key key, final ValueHelper valueHelper) throws PersistitInterruptedException { |
1474 | 1370 | int p = findKey(key); | 1373 | final int p = findKey(key); |
1475 | 1371 | return putValue(key, valueHelper, p, false); | 1374 | return putValue(key, valueHelper, p, false); |
1476 | 1372 | } | 1375 | } |
1477 | 1373 | 1376 | ||
1478 | @@ -1383,13 +1386,13 @@ | |||
1479 | 1383 | * @param foundAt | 1386 | * @param foundAt |
1480 | 1384 | * The keyblock before which this record will be inserted | 1387 | * The keyblock before which this record will be inserted |
1481 | 1385 | */ | 1388 | */ |
1483 | 1386 | int putValue(Key key, ValueHelper valueHelper, int foundAt, boolean postSplit) { | 1389 | int putValue(final Key key, final ValueHelper valueHelper, final int foundAt, final boolean postSplit) { |
1484 | 1387 | if (Debug.ENABLED) { | 1390 | if (Debug.ENABLED) { |
1485 | 1388 | assertVerify(); | 1391 | assertVerify(); |
1486 | 1389 | } | 1392 | } |
1487 | 1390 | 1393 | ||
1490 | 1391 | boolean exactMatch = (foundAt & EXACT_MASK) > 0; | 1394 | final boolean exactMatch = (foundAt & EXACT_MASK) > 0; |
1491 | 1392 | int p = foundAt & P_MASK; | 1395 | final int p = foundAt & P_MASK; |
1492 | 1393 | 1396 | ||
1493 | 1394 | if (exactMatch) { | 1397 | if (exactMatch) { |
1494 | 1395 | return replaceValue(key, valueHelper, p); | 1398 | return replaceValue(key, valueHelper, p); |
1495 | @@ -1401,9 +1404,9 @@ | |||
1496 | 1401 | length = valueHelper.requiredLength(_bytes, 0, -1); | 1404 | length = valueHelper.requiredLength(_bytes, 0, -1); |
1497 | 1402 | } | 1405 | } |
1498 | 1403 | 1406 | ||
1502 | 1404 | int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; | 1407 | final int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; |
1503 | 1405 | boolean fixupSuccessor = (foundAt & FIXUP_MASK) > 0; | 1408 | final boolean fixupSuccessor = (foundAt & FIXUP_MASK) > 0; |
1504 | 1406 | byte[] kbytes = key.getEncodedBytes(); | 1409 | final byte[] kbytes = key.getEncodedBytes(); |
1505 | 1407 | 1410 | ||
1506 | 1408 | int ebcNew; | 1411 | int ebcNew; |
1507 | 1409 | int ebcSuccessor; | 1412 | int ebcSuccessor; |
1508 | @@ -1429,8 +1432,8 @@ | |||
1509 | 1429 | ebcSuccessor = 0; | 1432 | ebcSuccessor = 0; |
1510 | 1430 | ebcNew = depth; | 1433 | ebcNew = depth; |
1511 | 1431 | } | 1434 | } |
1514 | 1432 | int klength = key.getEncodedSize() - ebcNew - 1; | 1435 | final int klength = key.getEncodedSize() - ebcNew - 1; |
1515 | 1433 | int newTailSize = klength + length + _tailHeaderSize; | 1436 | final int newTailSize = klength + length + _tailHeaderSize; |
1516 | 1434 | 1437 | ||
1517 | 1435 | if (getKeyCount() >= _pool.getMaxKeys() || !willFit(newTailSize + KEYBLOCK_LENGTH - (free1 - free2))) { | 1438 | if (getKeyCount() >= _pool.getMaxKeys() || !willFit(newTailSize + KEYBLOCK_LENGTH - (free1 - free2))) { |
1518 | 1436 | Debug.$assert0.t(!postSplit); | 1439 | Debug.$assert0.t(!postSplit); |
1519 | @@ -1443,8 +1446,8 @@ | |||
1520 | 1443 | // is correct. | 1446 | // is correct. |
1521 | 1444 | // | 1447 | // |
1522 | 1445 | if (fixupSuccessor && ebcNew != ebcSuccessor) { | 1448 | if (fixupSuccessor && ebcNew != ebcSuccessor) { |
1525 | 1446 | int successorKeyLength = decodeTailBlockKLength(successorTailBlock); | 1449 | final int successorKeyLength = decodeTailBlockKLength(successorTailBlock); |
1526 | 1447 | int successorDb = getByte(successorTail + _tailHeaderSize + delta - 1); | 1450 | final int successorDb = getByte(successorTail + _tailHeaderSize + delta - 1); |
1527 | 1448 | 1451 | ||
1528 | 1449 | // Write updated successor tail block | 1452 | // Write updated successor tail block |
1529 | 1450 | putInt(successorTail, encodeTailBlock(successorTailSize - delta, successorKeyLength - delta)); | 1453 | putInt(successorTail, encodeTailBlock(successorTailSize - delta, successorKeyLength - delta)); |
1530 | @@ -1460,7 +1463,7 @@ | |||
1531 | 1460 | 1463 | ||
1532 | 1461 | putInt(p, kbSuccessor); | 1464 | putInt(p, kbSuccessor); |
1533 | 1462 | } | 1465 | } |
1535 | 1463 | int dbNew = kbytes[ebcNew] & 0xFF; | 1466 | final int dbNew = kbytes[ebcNew] & 0xFF; |
1536 | 1464 | // | 1467 | // |
1537 | 1465 | // Allocate space for the new tail block | 1468 | // Allocate space for the new tail block |
1538 | 1466 | // | 1469 | // |
1539 | @@ -1481,7 +1484,7 @@ | |||
1540 | 1481 | System.arraycopy(_bytes, p, _bytes, p + KEYBLOCK_LENGTH, _keyBlockEnd - p - KEYBLOCK_LENGTH); | 1484 | System.arraycopy(_bytes, p, _bytes, p + KEYBLOCK_LENGTH, _keyBlockEnd - p - KEYBLOCK_LENGTH); |
1541 | 1482 | 1485 | ||
1542 | 1483 | // Write new key block | 1486 | // Write new key block |
1544 | 1484 | int newKeyBlock = encodeKeyBlock(ebcNew, dbNew, newTail); | 1487 | final int newKeyBlock = encodeKeyBlock(ebcNew, dbNew, newTail); |
1545 | 1485 | putInt(p, newKeyBlock); | 1488 | putInt(p, newKeyBlock); |
1546 | 1486 | 1489 | ||
1547 | 1487 | // Write new tail block | 1490 | // Write new tail block |
1548 | @@ -1493,12 +1496,12 @@ | |||
1549 | 1493 | System.arraycopy(kbytes, ebcNew + 1, _bytes, newTail + _tailHeaderSize, klength); | 1496 | System.arraycopy(kbytes, ebcNew + 1, _bytes, newTail + _tailHeaderSize, klength); |
1550 | 1494 | 1497 | ||
1551 | 1495 | if (isIndexPage()) { | 1498 | if (isIndexPage()) { |
1553 | 1496 | int pointer = (int) valueHelper.getPointerValue(); | 1499 | final int pointer = (int) valueHelper.getPointerValue(); |
1554 | 1497 | 1500 | ||
1555 | 1498 | Debug.$assert0.t(p + KEYBLOCK_LENGTH < _keyBlockEnd ? pointer > 0 : true); | 1501 | Debug.$assert0.t(p + KEYBLOCK_LENGTH < _keyBlockEnd ? pointer > 0 : true); |
1556 | 1499 | putInt(newTail + TAILBLOCK_POINTER, pointer); | 1502 | putInt(newTail + TAILBLOCK_POINTER, pointer); |
1557 | 1500 | } else { | 1503 | } else { |
1559 | 1501 | int storedLength = valueHelper.storeVersion(_bytes, newTail + _tailHeaderSize + klength, -1, | 1504 | final int storedLength = valueHelper.storeVersion(_bytes, newTail + _tailHeaderSize + klength, -1, |
1560 | 1502 | _bytes.length); // TODO limit | 1505 | _bytes.length); // TODO limit |
1561 | 1503 | incCountIfMvv(_bytes, newTail + _tailHeaderSize + klength, storedLength & MVV.STORE_LENGTH_MASK); | 1506 | incCountIfMvv(_bytes, newTail + _tailHeaderSize + klength, storedLength & MVV.STORE_LENGTH_MASK); |
1562 | 1504 | } | 1507 | } |
1563 | @@ -1532,12 +1535,12 @@ | |||
1564 | 1532 | */ | 1535 | */ |
1565 | 1533 | private boolean adjacentKeyCheck(int p) { | 1536 | private boolean adjacentKeyCheck(int p) { |
1566 | 1534 | p &= P_MASK; | 1537 | p &= P_MASK; |
1573 | 1535 | int kbData1 = getInt(p); | 1538 | final int kbData1 = getInt(p); |
1574 | 1536 | int kbData2 = getInt(p + KEYBLOCK_LENGTH); | 1539 | final int kbData2 = getInt(p + KEYBLOCK_LENGTH); |
1575 | 1537 | int db1 = decodeKeyBlockDb(kbData1); | 1540 | final int db1 = decodeKeyBlockDb(kbData1); |
1576 | 1538 | int ebc1 = decodeKeyBlockEbc(kbData1); | 1541 | final int ebc1 = decodeKeyBlockEbc(kbData1); |
1577 | 1539 | int db2 = decodeKeyBlockDb(kbData2); | 1542 | final int db2 = decodeKeyBlockDb(kbData2); |
1578 | 1540 | int ebc2 = decodeKeyBlockEbc(kbData2); | 1543 | final int ebc2 = decodeKeyBlockEbc(kbData2); |
1579 | 1541 | 1544 | ||
1580 | 1542 | if (db1 == 0 && p > KEY_BLOCK_START) { | 1545 | if (db1 == 0 && p > KEY_BLOCK_START) { |
1581 | 1543 | return false; // Can set breakpoint here | 1546 | return false; // Can set breakpoint here |
1582 | @@ -1551,9 +1554,9 @@ | |||
1583 | 1551 | if (ebc2 < ebc1) | 1554 | if (ebc2 < ebc1) |
1584 | 1552 | return true; | 1555 | return true; |
1585 | 1553 | if (ebc2 > ebc1) { | 1556 | if (ebc2 > ebc1) { |
1589 | 1554 | int tail1 = decodeKeyBlockTail(kbData1); | 1557 | final int tail1 = decodeKeyBlockTail(kbData1); |
1590 | 1555 | int tbData1 = getInt(tail1); | 1558 | final int tbData1 = getInt(tail1); |
1591 | 1556 | int klength1 = decodeTailBlockKLength(tbData1); | 1559 | final int klength1 = decodeTailBlockKLength(tbData1); |
1592 | 1557 | int db = -1; | 1560 | int db = -1; |
1593 | 1558 | if (klength1 >= ebc2 - ebc1) { | 1561 | if (klength1 >= ebc2 - ebc1) { |
1594 | 1559 | db = _bytes[tail1 + _tailHeaderSize + ebc2 - ebc1 - 1] & DB_MASK; | 1562 | db = _bytes[tail1 + _tailHeaderSize + ebc2 - ebc1 - 1] & DB_MASK; |
1595 | @@ -1569,12 +1572,12 @@ | |||
1596 | 1569 | return false; // Can set breakpoint here | 1572 | return false; // Can set breakpoint here |
1597 | 1570 | } | 1573 | } |
1598 | 1571 | 1574 | ||
1605 | 1572 | private int replaceValue(Key key, ValueHelper valueHelper, int p) { | 1575 | private int replaceValue(final Key key, final ValueHelper valueHelper, final int p) { |
1606 | 1573 | int kbData = getInt(p); | 1576 | final int kbData = getInt(p); |
1607 | 1574 | int tail = decodeKeyBlockTail(kbData); | 1577 | final int tail = decodeKeyBlockTail(kbData); |
1608 | 1575 | int tbData = getInt(tail); | 1578 | final int tbData = getInt(tail); |
1609 | 1576 | int klength = decodeTailBlockKLength(tbData); | 1579 | final int klength = decodeTailBlockKLength(tbData); |
1610 | 1577 | int oldTailSize = decodeTailBlockSize(tbData); | 1580 | final int oldTailSize = decodeTailBlockSize(tbData); |
1611 | 1578 | boolean wasMVV = false; | 1581 | boolean wasMVV = false; |
1612 | 1579 | boolean isMVV = false; | 1582 | boolean isMVV = false; |
1613 | 1580 | 1583 | ||
1614 | @@ -1587,9 +1590,9 @@ | |||
1615 | 1587 | wasMVV = isValueMVV(_bytes, tail + _tailHeaderSize + klength, oldTailSize - _tailHeaderSize - klength); | 1590 | wasMVV = isValueMVV(_bytes, tail + _tailHeaderSize + klength, oldTailSize - _tailHeaderSize - klength); |
1616 | 1588 | } | 1591 | } |
1617 | 1589 | 1592 | ||
1621 | 1590 | int newTailSize = klength + length + _tailHeaderSize; | 1593 | final int newTailSize = klength + length + _tailHeaderSize; |
1622 | 1591 | int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 1594 | final int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1623 | 1592 | int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 1595 | final int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1624 | 1593 | int newTail = tail; | 1596 | int newTail = tail; |
1625 | 1594 | if (newNext < oldNext) { | 1597 | if (newNext < oldNext) { |
1626 | 1595 | // Free the remainder of the old tail block | 1598 | // Free the remainder of the old tail block |
1627 | @@ -1622,7 +1625,7 @@ | |||
1628 | 1622 | } | 1625 | } |
1629 | 1623 | 1626 | ||
1630 | 1624 | if (isIndexPage()) { | 1627 | if (isIndexPage()) { |
1632 | 1625 | long pointer = valueHelper.getPointerValue(); | 1628 | final long pointer = valueHelper.getPointerValue(); |
1633 | 1626 | Debug.$assert0.t(p + KEYBLOCK_LENGTH < _keyBlockEnd ? pointer > 0 : pointer == -1); | 1629 | Debug.$assert0.t(p + KEYBLOCK_LENGTH < _keyBlockEnd ? pointer > 0 : pointer == -1); |
1634 | 1627 | putInt(newTail + TAILBLOCK_POINTER, (int) pointer); | 1630 | putInt(newTail + TAILBLOCK_POINTER, (int) pointer); |
1635 | 1628 | } else { | 1631 | } else { |
1636 | @@ -1658,11 +1661,11 @@ | |||
1637 | 1658 | * @return <i>true</i> if the key was found and the value removed, else | 1661 | * @return <i>true</i> if the key was found and the value removed, else |
1638 | 1659 | * <i>false</i> | 1662 | * <i>false</i> |
1639 | 1660 | */ | 1663 | */ |
1641 | 1661 | boolean removeKeys(int foundAt1, int foundAt2, Key spareKey) { | 1664 | boolean removeKeys(final int foundAt1, final int foundAt2, final Key spareKey) { |
1642 | 1662 | if (Debug.ENABLED) { | 1665 | if (Debug.ENABLED) { |
1643 | 1663 | assertVerify(); | 1666 | assertVerify(); |
1644 | 1664 | } | 1667 | } |
1646 | 1665 | int p1 = foundAt1 & P_MASK; | 1668 | final int p1 = foundAt1 & P_MASK; |
1647 | 1666 | int p2 = foundAt2 & P_MASK; | 1669 | int p2 = foundAt2 & P_MASK; |
1648 | 1667 | if ((foundAt2 & EXACT_MASK) != 0) | 1670 | if ((foundAt2 & EXACT_MASK) != 0) |
1649 | 1668 | p2 += KEYBLOCK_LENGTH; | 1671 | p2 += KEYBLOCK_LENGTH; |
1650 | @@ -1675,24 +1678,24 @@ | |||
1651 | 1675 | 1678 | ||
1652 | 1676 | int ebc = Integer.MAX_VALUE; | 1679 | int ebc = Integer.MAX_VALUE; |
1653 | 1677 | 1680 | ||
1655 | 1678 | byte[] spareBytes = spareKey.getEncodedBytes(); | 1681 | final byte[] spareBytes = spareKey.getEncodedBytes(); |
1656 | 1679 | int keySize = 0; | 1682 | int keySize = 0; |
1657 | 1680 | for (int p = p1; p < p2; p += KEYBLOCK_LENGTH) { | 1683 | for (int p = p1; p < p2; p += KEYBLOCK_LENGTH) { |
1660 | 1681 | int kbData = getInt(p); | 1684 | final int kbData = getInt(p); |
1661 | 1682 | int ebcCandidate = decodeKeyBlockEbc(kbData); | 1685 | final int ebcCandidate = decodeKeyBlockEbc(kbData); |
1662 | 1683 | if (ebcCandidate < ebc) { | 1686 | if (ebcCandidate < ebc) { |
1663 | 1684 | ebc = ebcCandidate; | 1687 | ebc = ebcCandidate; |
1664 | 1685 | } | 1688 | } |
1669 | 1686 | int db = decodeKeyBlockDb(kbData); | 1689 | final int db = decodeKeyBlockDb(kbData); |
1670 | 1687 | int tail = decodeKeyBlockTail(kbData); | 1690 | final int tail = decodeKeyBlockTail(kbData); |
1671 | 1688 | int tbData = getInt(tail); | 1691 | final int tbData = getInt(tail); |
1672 | 1689 | int klength = decodeTailBlockKLength(tbData); | 1692 | final int klength = decodeTailBlockKLength(tbData); |
1673 | 1690 | spareBytes[ebcCandidate] = (byte) db; | 1693 | spareBytes[ebcCandidate] = (byte) db; |
1674 | 1691 | if (klength > 0) { | 1694 | if (klength > 0) { |
1675 | 1692 | System.arraycopy(_bytes, tail + _tailHeaderSize, spareBytes, ebcCandidate + 1, klength); | 1695 | System.arraycopy(_bytes, tail + _tailHeaderSize, spareBytes, ebcCandidate + 1, klength); |
1676 | 1693 | } | 1696 | } |
1677 | 1694 | keySize = klength + ebcCandidate + 1; | 1697 | keySize = klength + ebcCandidate + 1; |
1679 | 1695 | int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 1698 | final int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1680 | 1696 | deallocTail(tail, size); | 1699 | deallocTail(tail, size); |
1681 | 1697 | } | 1700 | } |
1682 | 1698 | spareKey.setEncodedSize(keySize); | 1701 | spareKey.setEncodedSize(keySize); |
1683 | @@ -1711,22 +1714,22 @@ | |||
1684 | 1711 | // | 1714 | // |
1685 | 1712 | if (p1 < _keyBlockEnd) { | 1715 | if (p1 < _keyBlockEnd) { |
1686 | 1713 | int kbNext = getInt(p1); | 1716 | int kbNext = getInt(p1); |
1688 | 1714 | int ebcNext = decodeKeyBlockEbc(kbNext); | 1717 | final int ebcNext = decodeKeyBlockEbc(kbNext); |
1689 | 1715 | 1718 | ||
1690 | 1716 | // | 1719 | // |
1691 | 1717 | // If ebcNext > ebc then the successor key will need to expand. | 1720 | // If ebcNext > ebc then the successor key will need to expand. |
1692 | 1718 | // | 1721 | // |
1693 | 1719 | if (ebcNext > ebc) { | 1722 | if (ebcNext > ebc) { |
1694 | 1720 | int tailNext = decodeKeyBlockTail(kbNext); | 1723 | int tailNext = decodeKeyBlockTail(kbNext); |
1704 | 1721 | int dbNext = decodeKeyBlockDb(kbNext); | 1724 | final int dbNext = decodeKeyBlockDb(kbNext); |
1705 | 1722 | int tbNext = getInt(tailNext); | 1725 | final int tbNext = getInt(tailNext); |
1706 | 1723 | int nextTailSize = decodeTailBlockSize(tbNext); | 1726 | final int nextTailSize = decodeTailBlockSize(tbNext); |
1707 | 1724 | 1727 | ||
1708 | 1725 | int nextTailBlockSize = (nextTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 1728 | final int nextTailBlockSize = (nextTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1709 | 1726 | 1729 | ||
1710 | 1727 | int newNextTailBlockSize = (nextTailSize + ebcNext - ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 1730 | final int newNextTailBlockSize = (nextTailSize + ebcNext - ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1711 | 1728 | 1731 | ||
1712 | 1729 | int delta = newNextTailBlockSize - nextTailBlockSize; | 1732 | final int delta = newNextTailBlockSize - nextTailBlockSize; |
1713 | 1730 | boolean freeNextTailBlock = false; | 1733 | boolean freeNextTailBlock = false; |
1714 | 1731 | int newNextTail = tailNext; | 1734 | int newNextTail = tailNext; |
1715 | 1732 | if (delta > 0) { | 1735 | if (delta > 0) { |
1716 | @@ -1786,17 +1789,17 @@ | |||
1717 | 1786 | // | 1789 | // |
1718 | 1787 | // Now construct the new tail block | 1790 | // Now construct the new tail block |
1719 | 1788 | // | 1791 | // |
1722 | 1789 | int newNextKLength = decodeTailBlockKLength(tbNext) + ebcNext - ebc; | 1792 | final int newNextKLength = decodeTailBlockKLength(tbNext) + ebcNext - ebc; |
1723 | 1790 | int newNextTailSize = nextTailSize + ebcNext - ebc; | 1793 | final int newNextTailSize = nextTailSize + ebcNext - ebc; |
1724 | 1791 | putInt(newNextTail, encodeTailBlock(newNextTailSize, newNextKLength)); | 1794 | putInt(newNextTail, encodeTailBlock(newNextTailSize, newNextKLength)); |
1725 | 1792 | if (freeNextTailBlock) { | 1795 | if (freeNextTailBlock) { |
1727 | 1793 | int toFree = (nextTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 1796 | final int toFree = (nextTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1728 | 1794 | deallocTail(tailNext, toFree); | 1797 | deallocTail(tailNext, toFree); |
1729 | 1795 | } | 1798 | } |
1730 | 1796 | // | 1799 | // |
1731 | 1797 | // Fix up the successor key block | 1800 | // Fix up the successor key block |
1732 | 1798 | // | 1801 | // |
1734 | 1799 | int kbNewNext = encodeKeyBlock(ebc, spareBytes[ebc], newNextTail); | 1802 | final int kbNewNext = encodeKeyBlock(ebc, spareBytes[ebc], newNextTail); |
1735 | 1800 | putInt(p1, kbNewNext); | 1803 | putInt(p1, kbNewNext); |
1736 | 1801 | } | 1804 | } |
1737 | 1802 | } | 1805 | } |
1738 | @@ -1820,7 +1823,7 @@ | |||
1739 | 1820 | * The amount by which that block is to be expanded. | 1823 | * The amount by which that block is to be expanded. |
1740 | 1821 | * @return int Offset of the expanded tail block, or -1 if it does not fit. | 1824 | * @return int Offset of the expanded tail block, or -1 if it does not fit. |
1741 | 1822 | */ | 1825 | */ |
1743 | 1823 | private int wedgeTail(int tail, int delta) { | 1826 | private int wedgeTail(final int tail, int delta) { |
1744 | 1824 | delta = (delta + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 1827 | delta = (delta + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1745 | 1825 | if (delta == 0) { | 1828 | if (delta == 0) { |
1746 | 1826 | return tail; | 1829 | return tail; |
1747 | @@ -1836,8 +1839,8 @@ | |||
1748 | 1836 | _alloc -= delta; | 1839 | _alloc -= delta; |
1749 | 1837 | 1840 | ||
1750 | 1838 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { | 1841 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { |
1753 | 1839 | int kbData = getInt(p); | 1842 | final int kbData = getInt(p); |
1754 | 1840 | int oldTail = decodeKeyBlockTail(kbData); | 1843 | final int oldTail = decodeKeyBlockTail(kbData); |
1755 | 1841 | if (oldTail < tail) { | 1844 | if (oldTail < tail) { |
1756 | 1842 | putInt(p, encodeKeyBlockTail(kbData, oldTail - delta)); | 1845 | putInt(p, encodeKeyBlockTail(kbData, oldTail - delta)); |
1757 | 1843 | } | 1846 | } |
1758 | @@ -1869,8 +1872,8 @@ | |||
1759 | 1869 | * the right sibling Buffer. | 1872 | * the right sibling Buffer. |
1760 | 1870 | * @throws PersistitException | 1873 | * @throws PersistitException |
1761 | 1871 | */ | 1874 | */ |
1764 | 1872 | final int split(Buffer rightSibling, Key key, ValueHelper valueHelper, int foundAt, Key indexKey, | 1875 | final int split(final Buffer rightSibling, final Key key, final ValueHelper valueHelper, int foundAt, |
1765 | 1873 | Sequence sequence, SplitPolicy policy) throws PersistitException { | 1876 | final Key indexKey, final Sequence sequence, final SplitPolicy policy) throws PersistitException { |
1766 | 1874 | // Make sure the right sibling page is empty. | 1877 | // Make sure the right sibling page is empty. |
1767 | 1875 | 1878 | ||
1768 | 1876 | Debug.$assert0.t(rightSibling._keyBlockEnd == KEY_BLOCK_START); | 1879 | Debug.$assert0.t(rightSibling._keyBlockEnd == KEY_BLOCK_START); |
1769 | @@ -1888,10 +1891,10 @@ | |||
1770 | 1888 | // | 1891 | // |
1771 | 1889 | int currentSize = _bufferSize - _alloc - _slack + _keyBlockEnd - KEY_BLOCK_START; | 1892 | int currentSize = _bufferSize - _alloc - _slack + _keyBlockEnd - KEY_BLOCK_START; |
1772 | 1890 | 1893 | ||
1775 | 1891 | int foundAtPosition = foundAt & P_MASK; | 1894 | final int foundAtPosition = foundAt & P_MASK; |
1776 | 1892 | boolean exact = (foundAt & EXACT_MASK) != 0; | 1895 | final boolean exact = (foundAt & EXACT_MASK) != 0; |
1777 | 1893 | int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; | 1896 | int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; |
1779 | 1894 | boolean fixupSuccessor = (foundAt & FIXUP_MASK) > 0; | 1897 | final boolean fixupSuccessor = (foundAt & FIXUP_MASK) > 0; |
1780 | 1895 | 1898 | ||
1781 | 1896 | int ebcNew; | 1899 | int ebcNew; |
1782 | 1897 | int ebcSuccessor; | 1900 | int ebcSuccessor; |
1783 | @@ -1899,18 +1902,18 @@ | |||
1784 | 1899 | int deltaSuccessorEbc = 0; | 1902 | int deltaSuccessorEbc = 0; |
1785 | 1900 | 1903 | ||
1786 | 1901 | if (fixupSuccessor) { | 1904 | if (fixupSuccessor) { |
1789 | 1902 | int kbSuccessor = getInt(foundAtPosition); | 1905 | final int kbSuccessor = getInt(foundAtPosition); |
1790 | 1903 | int tbSuccessor = getInt(decodeKeyBlockTail(kbSuccessor)); | 1906 | final int tbSuccessor = getInt(decodeKeyBlockTail(kbSuccessor)); |
1791 | 1904 | ebcNew = decodeKeyBlockEbc(kbSuccessor); | 1907 | ebcNew = decodeKeyBlockEbc(kbSuccessor); |
1792 | 1905 | ebcSuccessor = depth; | 1908 | ebcSuccessor = depth; |
1794 | 1906 | int tbSize = decodeTailBlockSize(tbSuccessor); | 1909 | final int tbSize = decodeTailBlockSize(tbSuccessor); |
1795 | 1907 | 1910 | ||
1796 | 1908 | // This is the number of bytes by which the successor key | 1911 | // This is the number of bytes by which the successor key |
1797 | 1909 | // can have its elided byte count increased. | 1912 | // can have its elided byte count increased. |
1798 | 1910 | deltaSuccessorEbc = ebcSuccessor - ebcNew; | 1913 | deltaSuccessorEbc = ebcSuccessor - ebcNew; |
1799 | 1911 | 1914 | ||
1802 | 1912 | int oldSize = (tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 1915 | final int oldSize = (tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1803 | 1913 | int newSize = (tbSize - deltaSuccessorEbc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 1916 | final int newSize = (tbSize - deltaSuccessorEbc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1804 | 1914 | 1917 | ||
1805 | 1915 | // This is the number of bytes by which the successor tail block | 1918 | // This is the number of bytes by which the successor tail block |
1806 | 1916 | // can be reduced (because its elision count has increased.) | 1919 | // can be reduced (because its elision count has increased.) |
1807 | @@ -1924,11 +1927,11 @@ | |||
1808 | 1924 | int newTailBlockSize; | 1927 | int newTailBlockSize; |
1809 | 1925 | int newValueSize; | 1928 | int newValueSize; |
1810 | 1926 | if (exact) { | 1929 | if (exact) { |
1816 | 1927 | int kbData = getInt(foundAtPosition); | 1930 | final int kbData = getInt(foundAtPosition); |
1817 | 1928 | int tail = decodeKeyBlockTail(kbData); | 1931 | final int tail = decodeKeyBlockTail(kbData); |
1818 | 1929 | int tbData = getInt(tail); | 1932 | final int tbData = getInt(tail); |
1819 | 1930 | int tbSize = decodeTailBlockSize(tbData); | 1933 | final int tbSize = decodeTailBlockSize(tbData); |
1820 | 1931 | int klength = decodeTailBlockKLength(tbData); | 1934 | final int klength = decodeTailBlockKLength(tbData); |
1821 | 1932 | oldTailBlockSize = (tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 1935 | oldTailBlockSize = (tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1822 | 1933 | keyBlockSizeDelta = 0; | 1936 | keyBlockSizeDelta = 0; |
1823 | 1934 | ebcNew = decodeKeyBlockEbc(kbData); | 1937 | ebcNew = decodeKeyBlockEbc(kbData); |
1824 | @@ -1940,7 +1943,7 @@ | |||
1825 | 1940 | newTailBlockSize = ((isIndexPage() ? 0 : newValueSize) + _tailHeaderSize + key.getEncodedSize() - ebcNew - 1 + ~TAILBLOCK_MASK) | 1943 | newTailBlockSize = ((isIndexPage() ? 0 : newValueSize) + _tailHeaderSize + key.getEncodedSize() - ebcNew - 1 + ~TAILBLOCK_MASK) |
1826 | 1941 | & TAILBLOCK_MASK; | 1944 | & TAILBLOCK_MASK; |
1827 | 1942 | 1945 | ||
1829 | 1943 | int virtualSize = currentSize + newTailBlockSize - oldTailBlockSize + keyBlockSizeDelta | 1946 | final int virtualSize = currentSize + newTailBlockSize - oldTailBlockSize + keyBlockSizeDelta |
1830 | 1944 | - deltaSuccessorTailSize; | 1947 | - deltaSuccessorTailSize; |
1831 | 1945 | 1948 | ||
1832 | 1946 | int splitBest = 0; // Maximal fitness measure | 1949 | int splitBest = 0; // Maximal fitness measure |
1833 | @@ -1951,7 +1954,7 @@ | |||
1834 | 1951 | boolean armed = true; | 1954 | boolean armed = true; |
1835 | 1952 | int whereInserted = -1; | 1955 | int whereInserted = -1; |
1836 | 1953 | 1956 | ||
1838 | 1954 | int rightKeyBlock = _keyBlockEnd - KEYBLOCK_LENGTH; | 1957 | final int rightKeyBlock = _keyBlockEnd - KEYBLOCK_LENGTH; |
1839 | 1955 | for (int p = KEY_BLOCK_START; p < rightKeyBlock;) { | 1958 | for (int p = KEY_BLOCK_START; p < rightKeyBlock;) { |
1840 | 1956 | int splitCandidate = 0; | 1959 | int splitCandidate = 0; |
1841 | 1957 | if (p == foundAtPosition && armed) { | 1960 | if (p == foundAtPosition && armed) { |
1842 | @@ -1968,18 +1971,18 @@ | |||
1843 | 1968 | // Compute the number of bytes by which the successor tailblock | 1971 | // Compute the number of bytes by which the successor tailblock |
1844 | 1969 | // will grow due to its elision count becoming zero. | 1972 | // will grow due to its elision count becoming zero. |
1845 | 1970 | // | 1973 | // |
1851 | 1971 | int kbData = getInt(p); | 1974 | final int kbData = getInt(p); |
1852 | 1972 | int tbData = getInt(decodeKeyBlockTail(kbData)); | 1975 | final int tbData = getInt(decodeKeyBlockTail(kbData)); |
1853 | 1973 | int ebc = decodeKeyBlockEbc(kbData); | 1976 | final int ebc = decodeKeyBlockEbc(kbData); |
1854 | 1974 | int tbSize = decodeTailBlockSize(tbData); | 1977 | final int tbSize = decodeTailBlockSize(tbData); |
1855 | 1975 | int tbSizeDelta = ((tbSize + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) | 1978 | final int tbSizeDelta = ((tbSize + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
1856 | 1976 | - ((tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); | 1979 | - ((tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); |
1857 | 1977 | 1980 | ||
1859 | 1978 | int edgeTailBlockSize = (decodeTailBlockKLength(tbData) - deltaSuccessorEbc + _tailHeaderSize + ~TAILBLOCK_MASK) | 1981 | final int edgeTailBlockSize = (decodeTailBlockKLength(tbData) - deltaSuccessorEbc + _tailHeaderSize + ~TAILBLOCK_MASK) |
1860 | 1979 | & TAILBLOCK_MASK; | 1982 | & TAILBLOCK_MASK; |
1861 | 1980 | 1983 | ||
1862 | 1981 | if (p < rightKeyBlock) { | 1984 | if (p < rightKeyBlock) { |
1864 | 1982 | int rightSize = virtualSize - leftSize + tbSizeDelta; | 1985 | final int rightSize = virtualSize - leftSize + tbSizeDelta; |
1865 | 1983 | 1986 | ||
1866 | 1984 | splitCandidate = policy.splitFit(this, p, foundAtPosition, exact, leftSize + KEYBLOCK_LENGTH | 1987 | splitCandidate = policy.splitFit(this, p, foundAtPosition, exact, leftSize + KEYBLOCK_LENGTH |
1867 | 1985 | + edgeTailBlockSize, rightSize, currentSize, virtualSize, _bufferSize - KEY_BLOCK_START, | 1988 | + edgeTailBlockSize, rightSize, currentSize, virtualSize, _bufferSize - KEY_BLOCK_START, |
1868 | @@ -1996,7 +1999,7 @@ | |||
1869 | 1996 | int kbData = getInt(p); | 1999 | int kbData = getInt(p); |
1870 | 1997 | int tbData = getInt(decodeKeyBlockTail(kbData)); | 2000 | int tbData = getInt(decodeKeyBlockTail(kbData)); |
1871 | 1998 | int tbSizeDelta; | 2001 | int tbSizeDelta; |
1873 | 1999 | int tailBlockSize = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 2002 | final int tailBlockSize = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1874 | 2000 | leftSize += tailBlockSize + KEYBLOCK_LENGTH; | 2003 | leftSize += tailBlockSize + KEYBLOCK_LENGTH; |
1875 | 2001 | 2004 | ||
1876 | 2002 | p += KEYBLOCK_LENGTH; | 2005 | p += KEYBLOCK_LENGTH; |
1877 | @@ -2011,8 +2014,8 @@ | |||
1878 | 2011 | } else { | 2014 | } else { |
1879 | 2012 | kbData = getInt(p); | 2015 | kbData = getInt(p); |
1880 | 2013 | tbData = getInt(decodeKeyBlockTail(kbData)); | 2016 | tbData = getInt(decodeKeyBlockTail(kbData)); |
1883 | 2014 | int ebc = decodeKeyBlockEbc(kbData); | 2017 | final int ebc = decodeKeyBlockEbc(kbData); |
1884 | 2015 | int tbSize = decodeTailBlockSize(tbData); | 2018 | final int tbSize = decodeTailBlockSize(tbData); |
1885 | 2016 | 2019 | ||
1886 | 2017 | tbSizeDelta = ((tbSize + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) | 2020 | tbSizeDelta = ((tbSize + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
1887 | 2018 | - ((tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); | 2021 | - ((tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); |
1888 | @@ -2022,7 +2025,7 @@ | |||
1889 | 2022 | } | 2025 | } |
1890 | 2023 | 2026 | ||
1891 | 2024 | if (p < rightKeyBlock) { | 2027 | if (p < rightKeyBlock) { |
1893 | 2025 | int rightSize = virtualSize - leftSize + tbSizeDelta; | 2028 | final int rightSize = virtualSize - leftSize + tbSizeDelta; |
1894 | 2026 | 2029 | ||
1895 | 2027 | splitCandidate = policy.splitFit(this, p, foundAtPosition, exact, leftSize + KEYBLOCK_LENGTH | 2030 | splitCandidate = policy.splitFit(this, p, foundAtPosition, exact, leftSize + KEYBLOCK_LENGTH |
1896 | 2028 | + edgeTailBlockSize, rightSize, currentSize, virtualSize, _bufferSize - KEY_BLOCK_START, | 2031 | + edgeTailBlockSize, rightSize, currentSize, virtualSize, _bufferSize - KEY_BLOCK_START, |
1897 | @@ -2048,11 +2051,11 @@ | |||
1898 | 2048 | // | 2051 | // |
1899 | 2049 | // Now move the keys and records. | 2052 | // Now move the keys and records. |
1900 | 2050 | // | 2053 | // |
1903 | 2051 | byte[] indexKeyBytes = indexKey.getEncodedBytes(); | 2054 | final byte[] indexKeyBytes = indexKey.getEncodedBytes(); |
1904 | 2052 | int splitAtPosition = splitAt & P_MASK; | 2055 | final int splitAtPosition = splitAt & P_MASK; |
1905 | 2053 | 2056 | ||
1908 | 2054 | boolean lastLeft = (splitAt & EXACT_MASK) != 0; | 2057 | final boolean lastLeft = (splitAt & EXACT_MASK) != 0; |
1909 | 2055 | boolean firstRight = !lastLeft && splitAtPosition == foundAtPosition; | 2058 | final boolean firstRight = !lastLeft && splitAtPosition == foundAtPosition; |
1910 | 2056 | int indexKeyDepth = 0; | 2059 | int indexKeyDepth = 0; |
1911 | 2057 | // | 2060 | // |
1912 | 2058 | // First we need to compute the full key in the right sibling page. | 2061 | // First we need to compute the full key in the right sibling page. |
1913 | @@ -2074,18 +2077,18 @@ | |||
1914 | 2074 | // | 2077 | // |
1915 | 2075 | if (!firstRight) { | 2078 | if (!firstRight) { |
1916 | 2076 | for (int p = scanStart; p <= splitAtPosition; p += KEYBLOCK_LENGTH) { | 2079 | for (int p = scanStart; p <= splitAtPosition; p += KEYBLOCK_LENGTH) { |
1921 | 2077 | int kbData = getInt(p); | 2080 | final int kbData = getInt(p); |
1922 | 2078 | int ebc = decodeKeyBlockEbc(kbData); | 2081 | final int ebc = decodeKeyBlockEbc(kbData); |
1923 | 2079 | int db = decodeKeyBlockDb(kbData); | 2082 | final int db = decodeKeyBlockDb(kbData); |
1924 | 2080 | int tail = decodeKeyBlockTail(kbData); | 2083 | final int tail = decodeKeyBlockTail(kbData); |
1925 | 2081 | if (ebc > indexKeyDepth) { | 2084 | if (ebc > indexKeyDepth) { |
1926 | 2082 | throw new InvalidPageStructureException("ebc at " + p + " ebc=" + ebc + " > indexKeyDepth=" | 2085 | throw new InvalidPageStructureException("ebc at " + p + " ebc=" + ebc + " > indexKeyDepth=" |
1927 | 2083 | + indexKeyDepth); | 2086 | + indexKeyDepth); |
1928 | 2084 | } | 2087 | } |
1929 | 2085 | indexKeyDepth = ebc; | 2088 | indexKeyDepth = ebc; |
1930 | 2086 | indexKeyBytes[indexKeyDepth++] = (byte) db; | 2089 | indexKeyBytes[indexKeyDepth++] = (byte) db; |
1933 | 2087 | int tbData = getInt(tail); | 2090 | final int tbData = getInt(tail); |
1934 | 2088 | int klength = decodeTailBlockKLength(tbData); | 2091 | final int klength = decodeTailBlockKLength(tbData); |
1935 | 2089 | 2092 | ||
1936 | 2090 | System.arraycopy(_bytes, tail + _tailHeaderSize, indexKeyBytes, indexKeyDepth, klength); | 2093 | System.arraycopy(_bytes, tail + _tailHeaderSize, indexKeyBytes, indexKeyDepth, klength); |
1937 | 2091 | indexKeyDepth += klength; | 2094 | indexKeyDepth += klength; |
1938 | @@ -2202,7 +2205,7 @@ | |||
1939 | 2202 | if (isDataPage()) { | 2205 | if (isDataPage()) { |
1940 | 2203 | currentSize = (tailBlockSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 2206 | currentSize = (tailBlockSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1941 | 2204 | 2207 | ||
1943 | 2205 | int newSize = (tailBlockSize - dataSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 2208 | final int newSize = (tailBlockSize - dataSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1944 | 2206 | if (newSize != currentSize) { | 2209 | if (newSize != currentSize) { |
1945 | 2207 | deallocTail(tail + newSize, currentSize - newSize); | 2210 | deallocTail(tail + newSize, currentSize - newSize); |
1946 | 2208 | } | 2211 | } |
1947 | @@ -2217,9 +2220,9 @@ | |||
1948 | 2217 | // | 2220 | // |
1949 | 2218 | // Fix up the right edge key in the left page. | 2221 | // Fix up the right edge key in the left page. |
1950 | 2219 | // | 2222 | // |
1952 | 2220 | int kbData = getInt(splitAtPosition); | 2223 | final int kbData = getInt(splitAtPosition); |
1953 | 2221 | int edgeTail = decodeKeyBlockTail(kbData); | 2224 | int edgeTail = decodeKeyBlockTail(kbData); |
1955 | 2222 | int ebc = decodeKeyBlockEbc(kbData); | 2225 | final int ebc = decodeKeyBlockEbc(kbData); |
1956 | 2223 | depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; | 2226 | depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; |
1957 | 2224 | 2227 | ||
1958 | 2225 | if (firstRight && !exact) { | 2228 | if (firstRight && !exact) { |
1959 | @@ -2230,10 +2233,10 @@ | |||
1960 | 2230 | if (fixupSuccessor) { | 2233 | if (fixupSuccessor) { |
1961 | 2231 | depth = ebc; | 2234 | depth = ebc; |
1962 | 2232 | } | 2235 | } |
1964 | 2233 | int db = indexKeyBytes[depth]; | 2236 | final int db = indexKeyBytes[depth]; |
1965 | 2234 | 2237 | ||
1968 | 2235 | int edgeKeyLength = indexKey.getEncodedSize() - depth - 1; | 2238 | final int edgeKeyLength = indexKey.getEncodedSize() - depth - 1; |
1969 | 2236 | int edgeTailBlockSize = edgeKeyLength + _tailHeaderSize; | 2239 | final int edgeTailBlockSize = edgeKeyLength + _tailHeaderSize; |
1970 | 2237 | edgeTail = allocTail(edgeTailBlockSize); | 2240 | edgeTail = allocTail(edgeTailBlockSize); |
1971 | 2238 | if (edgeTail == -1) { | 2241 | if (edgeTail == -1) { |
1972 | 2239 | setKeyBlockEnd(splitAtPosition); | 2242 | setKeyBlockEnd(splitAtPosition); |
1973 | @@ -2367,8 +2370,8 @@ | |||
1974 | 2367 | * in the rare case where no rearrangement of the records is | 2370 | * in the rare case where no rearrangement of the records is |
1975 | 2368 | * possible. | 2371 | * possible. |
1976 | 2369 | */ | 2372 | */ |
1979 | 2370 | final boolean join(Buffer buffer, int foundAt1, int foundAt2, Key indexKey, Key spareKey, JoinPolicy policy) | 2373 | final boolean join(final Buffer buffer, int foundAt1, int foundAt2, final Key indexKey, final Key spareKey, |
1980 | 2371 | throws RebalanceException { | 2374 | final JoinPolicy policy) throws RebalanceException { |
1981 | 2372 | foundAt1 &= P_MASK; | 2375 | foundAt1 &= P_MASK; |
1982 | 2373 | foundAt2 &= P_MASK; | 2376 | foundAt2 &= P_MASK; |
1983 | 2374 | 2377 | ||
1984 | @@ -2401,17 +2404,17 @@ | |||
1985 | 2401 | // | 2404 | // |
1986 | 2402 | buffer.keyAt(foundAt2, spareKey); | 2405 | buffer.keyAt(foundAt2, spareKey); |
1987 | 2403 | 2406 | ||
1990 | 2404 | long measureLeft = joinMeasure(foundAt1, _keyBlockEnd); | 2407 | final long measureLeft = joinMeasure(foundAt1, _keyBlockEnd); |
1991 | 2405 | long measureRight = buffer.joinMeasure(KEY_BLOCK_START, foundAt2); | 2408 | final long measureRight = buffer.joinMeasure(KEY_BLOCK_START, foundAt2); |
1992 | 2406 | kbData = buffer.getInt(foundAt2); | 2409 | kbData = buffer.getInt(foundAt2); |
1995 | 2407 | int oldEbc = decodeKeyBlockEbc(kbData); | 2410 | final int oldEbc = decodeKeyBlockEbc(kbData); |
1996 | 2408 | int newEbc = Math.min(oldEbc, Math.min((int) (measureLeft >>> 32), (int) (measureRight >>> 32))); | 2411 | final int newEbc = Math.min(oldEbc, Math.min((int) (measureLeft >>> 32), (int) (measureRight >>> 32))); |
1997 | 2409 | tail = decodeKeyBlockTail(kbData); | 2412 | tail = decodeKeyBlockTail(kbData); |
1998 | 2410 | tbData = buffer.getInt(tail); | 2413 | tbData = buffer.getInt(tail); |
1999 | 2411 | 2414 | ||
2003 | 2412 | int oldSize = decodeTailBlockSize(tbData); | 2415 | final int oldSize = decodeTailBlockSize(tbData); |
2004 | 2413 | int newSize = oldSize + (oldEbc - newEbc); | 2416 | final int newSize = oldSize + (oldEbc - newEbc); |
2005 | 2414 | int adjustmentForNewEbc = ((newSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) | 2417 | final int adjustmentForNewEbc = ((newSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
2006 | 2415 | - ((oldSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); | 2418 | - ((oldSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); |
2007 | 2416 | 2419 | ||
2008 | 2417 | /* | 2420 | /* |
2009 | @@ -2424,7 +2427,7 @@ | |||
2010 | 2424 | final int virtualKeyCount = ((foundAt1 - KEY_BLOCK_START) + (buffer.getKeyBlockEnd() - foundAt2)) | 2427 | final int virtualKeyCount = ((foundAt1 - KEY_BLOCK_START) + (buffer.getKeyBlockEnd() - foundAt2)) |
2011 | 2425 | / KEYBLOCK_LENGTH; | 2428 | / KEYBLOCK_LENGTH; |
2012 | 2426 | 2429 | ||
2014 | 2427 | boolean okayToRejoin = virtualKeyCount < _pool.getMaxKeys() && policy.acceptJoin(this, virtualSize); | 2430 | final boolean okayToRejoin = virtualKeyCount < _pool.getMaxKeys() && policy.acceptJoin(this, virtualSize); |
2015 | 2428 | 2431 | ||
2016 | 2429 | boolean result; | 2432 | boolean result; |
2017 | 2430 | 2433 | ||
2018 | @@ -2473,7 +2476,7 @@ | |||
2019 | 2473 | /* | 2476 | /* |
2020 | 2474 | * unsplice the right buffer from the right sibling chain. | 2477 | * unsplice the right buffer from the right sibling chain. |
2021 | 2475 | */ | 2478 | */ |
2023 | 2476 | long rightSibling = buffer.getRightSibling(); | 2479 | final long rightSibling = buffer.getRightSibling(); |
2024 | 2477 | setRightSibling(rightSibling); | 2480 | setRightSibling(rightSibling); |
2025 | 2478 | if (hasMVV) { | 2481 | if (hasMVV) { |
2026 | 2479 | _mvvCount = Integer.MAX_VALUE; | 2482 | _mvvCount = Integer.MAX_VALUE; |
2027 | @@ -2520,7 +2523,7 @@ | |||
2028 | 2520 | buffer.joinDeallocateTails(KEY_BLOCK_START, foundAt2); | 2523 | buffer.joinDeallocateTails(KEY_BLOCK_START, foundAt2); |
2029 | 2521 | buffer.clearBytes(KEY_BLOCK_START, foundAt2); | 2524 | buffer.clearBytes(KEY_BLOCK_START, foundAt2); |
2030 | 2522 | buffer.reduceEbc(foundAt2, newEbc, spareKeyBytes); | 2525 | buffer.reduceEbc(foundAt2, newEbc, spareKeyBytes); |
2032 | 2523 | int rightSize = buffer._keyBlockEnd - joinOffset; | 2526 | final int rightSize = buffer._keyBlockEnd - joinOffset; |
2033 | 2524 | 2527 | ||
2034 | 2525 | moveRecords(buffer, foundAt2, joinOffset, _keyBlockEnd, true); | 2528 | moveRecords(buffer, foundAt2, joinOffset, _keyBlockEnd, true); |
2035 | 2526 | 2529 | ||
2036 | @@ -2540,7 +2543,7 @@ | |||
2037 | 2540 | 2543 | ||
2038 | 2541 | buffer.joinDeallocateTails(KEY_BLOCK_START, foundAt2); | 2544 | buffer.joinDeallocateTails(KEY_BLOCK_START, foundAt2); |
2039 | 2542 | 2545 | ||
2041 | 2543 | int rightSize = buffer._keyBlockEnd - foundAt2; | 2546 | final int rightSize = buffer._keyBlockEnd - foundAt2; |
2042 | 2544 | System.arraycopy(buffer._bytes, foundAt2, buffer._bytes, KEY_BLOCK_START, rightSize); | 2547 | System.arraycopy(buffer._bytes, foundAt2, buffer._bytes, KEY_BLOCK_START, rightSize); |
2043 | 2545 | buffer.clearBytes(KEY_BLOCK_START + rightSize, buffer._keyBlockEnd); | 2548 | buffer.clearBytes(KEY_BLOCK_START + rightSize, buffer._keyBlockEnd); |
2044 | 2546 | buffer.setKeyBlockEnd(KEY_BLOCK_START + rightSize); | 2549 | buffer.setKeyBlockEnd(KEY_BLOCK_START + rightSize); |
2045 | @@ -2629,18 +2632,18 @@ | |||
2046 | 2629 | * @return long encoding the size being deleted and the minimum ebc | 2632 | * @return long encoding the size being deleted and the minimum ebc |
2047 | 2630 | * | 2633 | * |
2048 | 2631 | */ | 2634 | */ |
2050 | 2632 | long joinMeasure(int from, int to) { | 2635 | long joinMeasure(final int from, final int to) { |
2051 | 2633 | int minimumEbc = Integer.MAX_VALUE; | 2636 | int minimumEbc = Integer.MAX_VALUE; |
2052 | 2634 | int totalDeallocatedSize = 0; | 2637 | int totalDeallocatedSize = 0; |
2053 | 2635 | for (int index = from; index < to; index += KEYBLOCK_LENGTH) { | 2638 | for (int index = from; index < to; index += KEYBLOCK_LENGTH) { |
2056 | 2636 | int kbData = getInt(index); | 2639 | final int kbData = getInt(index); |
2057 | 2637 | int ebc = decodeKeyBlockEbc(kbData); | 2640 | final int ebc = decodeKeyBlockEbc(kbData); |
2058 | 2638 | if (index != KEY_BLOCK_START && ebc < minimumEbc) { | 2641 | if (index != KEY_BLOCK_START && ebc < minimumEbc) { |
2059 | 2639 | minimumEbc = ebc; | 2642 | minimumEbc = ebc; |
2060 | 2640 | } | 2643 | } |
2064 | 2641 | int tail = decodeKeyBlockTail(kbData); | 2644 | final int tail = decodeKeyBlockTail(kbData); |
2065 | 2642 | int tbData = getInt(tail); | 2645 | final int tbData = getInt(tail); |
2066 | 2643 | int size = decodeTailBlockSize(tbData); | 2646 | final int size = decodeTailBlockSize(tbData); |
2067 | 2644 | totalDeallocatedSize += ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) + KEYBLOCK_LENGTH; | 2647 | totalDeallocatedSize += ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) + KEYBLOCK_LENGTH; |
2068 | 2645 | } | 2648 | } |
2069 | 2646 | return (((long) minimumEbc) << 32) | totalDeallocatedSize; | 2649 | return (((long) minimumEbc) << 32) | totalDeallocatedSize; |
2070 | @@ -2660,12 +2663,12 @@ | |||
2071 | 2660 | * @param to | 2663 | * @param to |
2072 | 2661 | * offset of the next key block not being deleted | 2664 | * offset of the next key block not being deleted |
2073 | 2662 | */ | 2665 | */ |
2075 | 2663 | void joinDeallocateTails(int from, int to) { | 2666 | void joinDeallocateTails(final int from, final int to) { |
2076 | 2664 | for (int index = from; index < to; index += KEYBLOCK_LENGTH) { | 2667 | for (int index = from; index < to; index += KEYBLOCK_LENGTH) { |
2081 | 2665 | int kbData = getInt(index); | 2668 | final int kbData = getInt(index); |
2082 | 2666 | int tail = decodeKeyBlockTail(kbData); | 2669 | final int tail = decodeKeyBlockTail(kbData); |
2083 | 2667 | int tbData = getInt(tail); | 2670 | final int tbData = getInt(tail); |
2084 | 2668 | int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 2671 | final int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2085 | 2669 | deallocTail(tail, size); | 2672 | deallocTail(tail, size); |
2086 | 2670 | } | 2673 | } |
2087 | 2671 | } | 2674 | } |
2088 | @@ -2739,23 +2742,24 @@ | |||
2089 | 2739 | // | 2742 | // |
2090 | 2740 | for (int p = KEY_BLOCK_START; p < foundAt1; p += KEYBLOCK_LENGTH) { | 2743 | for (int p = KEY_BLOCK_START; p < foundAt1; p += KEYBLOCK_LENGTH) { |
2091 | 2741 | kbData = getInt(p); | 2744 | kbData = getInt(p); |
2093 | 2742 | int ebc = decodeKeyBlockEbc(kbData); | 2745 | final int ebc = decodeKeyBlockEbc(kbData); |
2094 | 2743 | tail = decodeKeyBlockTail(kbData); | 2746 | tail = decodeKeyBlockTail(kbData); |
2095 | 2744 | tbData = getInt(tail); | 2747 | tbData = getInt(tail); |
2097 | 2745 | int size = decodeTailBlockSize(tbData); | 2748 | final int size = decodeTailBlockSize(tbData); |
2098 | 2746 | klength = decodeTailBlockKLength(tbData); | 2749 | klength = decodeTailBlockKLength(tbData); |
2099 | 2747 | 2750 | ||
2105 | 2748 | int delta = ((size + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); | 2751 | final int delta = ((size + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
2106 | 2749 | 2752 | - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); | |
2107 | 2750 | int candidateRightSize = virtualSize - leftSize + delta; | 2753 | |
2108 | 2751 | 2754 | final int candidateRightSize = virtualSize - leftSize + delta; | |
2109 | 2752 | int candidateLeftSize = leftSize + KEYBLOCK_LENGTH + ((klength + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) | 2755 | |
2110 | 2756 | final int candidateLeftSize = leftSize + KEYBLOCK_LENGTH + ((klength + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) | ||
2111 | 2753 | + _tailHeaderSize; | 2757 | + _tailHeaderSize; |
2112 | 2754 | 2758 | ||
2114 | 2755 | int rightKeyCount = ((buffer.getKeyBlockEnd() - foundAt2) + (foundAt1 - p)) / KEYBLOCK_LENGTH; | 2759 | final int rightKeyCount = ((buffer.getKeyBlockEnd() - foundAt2) + (foundAt1 - p)) / KEYBLOCK_LENGTH; |
2115 | 2756 | 2760 | ||
2118 | 2757 | int joinFit = policy.rebalanceFit(this, buffer, p, foundAt1, foundAt2, virtualSize, candidateLeftSize, | 2761 | final int joinFit = policy.rebalanceFit(this, buffer, p, foundAt1, foundAt2, virtualSize, |
2119 | 2758 | candidateRightSize, _bufferSize - KEY_BLOCK_START); | 2762 | candidateLeftSize, candidateRightSize, _bufferSize - KEY_BLOCK_START); |
2120 | 2759 | 2763 | ||
2121 | 2760 | if (joinFit > joinBest && rightKeyCount < _pool.getMaxKeys()) { | 2764 | if (joinFit > joinBest && rightKeyCount < _pool.getMaxKeys()) { |
2122 | 2761 | joinBest = joinFit; | 2765 | joinBest = joinFit; |
2123 | @@ -2770,10 +2774,10 @@ | |||
2124 | 2770 | */ | 2774 | */ |
2125 | 2771 | for (int p = foundAt2; p < buffer._keyBlockEnd; p += KEYBLOCK_LENGTH) { | 2775 | for (int p = foundAt2; p < buffer._keyBlockEnd; p += KEYBLOCK_LENGTH) { |
2126 | 2772 | kbData = buffer.getInt(p); | 2776 | kbData = buffer.getInt(p); |
2128 | 2773 | int ebc = decodeKeyBlockEbc(kbData); | 2777 | final int ebc = decodeKeyBlockEbc(kbData); |
2129 | 2774 | tail = decodeKeyBlockTail(kbData); | 2778 | tail = decodeKeyBlockTail(kbData); |
2130 | 2775 | tbData = buffer.getInt(tail); | 2779 | tbData = buffer.getInt(tail); |
2132 | 2776 | int size = decodeTailBlockSize(tbData); | 2780 | final int size = decodeTailBlockSize(tbData); |
2133 | 2777 | klength = decodeTailBlockKLength(tbData); | 2781 | klength = decodeTailBlockKLength(tbData); |
2134 | 2778 | 2782 | ||
2135 | 2779 | /* | 2783 | /* |
2136 | @@ -2781,23 +2785,24 @@ | |||
2137 | 2781 | * rebalance key would have to grow if it became the first key on | 2785 | * rebalance key would have to grow if it became the first key on |
2138 | 2782 | * the right page and its ebc became zero. | 2786 | * the right page and its ebc became zero. |
2139 | 2783 | */ | 2787 | */ |
2141 | 2784 | int delta = ((size + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); | 2788 | final int delta = ((size + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
2142 | 2789 | - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); | ||
2143 | 2785 | 2790 | ||
2144 | 2786 | /* | 2791 | /* |
2145 | 2787 | * Amount by which the current tail block needs to grow to | 2792 | * Amount by which the current tail block needs to grow to |
2146 | 2788 | * accommodate reduced ebc. | 2793 | * accommodate reduced ebc. |
2147 | 2789 | */ | 2794 | */ |
2153 | 2790 | int adjustment = (p == foundAt2) ? adjustmentForNewEbc : 0; | 2795 | final int adjustment = (p == foundAt2) ? adjustmentForNewEbc : 0; |
2154 | 2791 | 2796 | ||
2155 | 2792 | int candidateRightSize = virtualSize - leftSize + delta; | 2797 | final int candidateRightSize = virtualSize - leftSize + delta; |
2156 | 2793 | 2798 | ||
2157 | 2794 | int candidateLeftSize = leftSize + ((klength + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) + adjustment | 2799 | final int candidateLeftSize = leftSize + ((klength + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) + adjustment |
2158 | 2795 | + _tailHeaderSize + KEYBLOCK_LENGTH; | 2800 | + _tailHeaderSize + KEYBLOCK_LENGTH; |
2159 | 2796 | 2801 | ||
2161 | 2797 | int leftKeyCount = ((foundAt1 - KEY_BLOCK_START) + (p - foundAt2)) / KEYBLOCK_LENGTH; | 2802 | final int leftKeyCount = ((foundAt1 - KEY_BLOCK_START) + (p - foundAt2)) / KEYBLOCK_LENGTH; |
2162 | 2798 | 2803 | ||
2165 | 2799 | int joinFit = policy.rebalanceFit(this, buffer, p, foundAt1, foundAt2, virtualSize, candidateLeftSize, | 2804 | final int joinFit = policy.rebalanceFit(this, buffer, p, foundAt1, foundAt2, virtualSize, |
2166 | 2800 | candidateRightSize, _bufferSize - KEY_BLOCK_START); | 2805 | candidateLeftSize, candidateRightSize, _bufferSize - KEY_BLOCK_START); |
2167 | 2801 | 2806 | ||
2168 | 2802 | if (joinFit > joinBest && leftKeyCount < _pool.getMaxKeys()) { | 2807 | if (joinFit > joinBest && leftKeyCount < _pool.getMaxKeys()) { |
2169 | 2803 | joinBest = joinFit; | 2808 | joinBest = joinFit; |
2170 | @@ -2821,12 +2826,12 @@ | |||
2171 | 2821 | return _fastIndex; | 2826 | return _fastIndex; |
2172 | 2822 | } | 2827 | } |
2173 | 2823 | 2828 | ||
2175 | 2824 | private void reduceEbc(int p, int newEbc, byte[] indexKeyBytes) { | 2829 | private void reduceEbc(final int p, final int newEbc, final byte[] indexKeyBytes) { |
2176 | 2825 | int kbData = getInt(p); | 2830 | int kbData = getInt(p); |
2179 | 2826 | int oldDb = decodeKeyBlockDb(kbData); | 2831 | final int oldDb = decodeKeyBlockDb(kbData); |
2180 | 2827 | int oldEbc = decodeKeyBlockEbc(kbData); | 2832 | final int oldEbc = decodeKeyBlockEbc(kbData); |
2181 | 2828 | int tail = decodeKeyBlockTail(kbData); | 2833 | int tail = decodeKeyBlockTail(kbData); |
2183 | 2829 | int tbData = getInt(tail); | 2834 | final int tbData = getInt(tail); |
2184 | 2830 | int size = decodeTailBlockSize(tbData); | 2835 | int size = decodeTailBlockSize(tbData); |
2185 | 2831 | int klength = decodeTailBlockKLength(tbData); | 2836 | int klength = decodeTailBlockKLength(tbData); |
2186 | 2832 | 2837 | ||
2187 | @@ -2836,7 +2841,7 @@ | |||
2188 | 2836 | throw new IllegalArgumentException("newEbc=" + newEbc + " must be less than oldEbc=" + oldEbc); | 2841 | throw new IllegalArgumentException("newEbc=" + newEbc + " must be less than oldEbc=" + oldEbc); |
2189 | 2837 | } | 2842 | } |
2190 | 2838 | 2843 | ||
2192 | 2839 | int delta = ((size + oldEbc - newEbc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) | 2844 | final int delta = ((size + oldEbc - newEbc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
2193 | 2840 | - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); | 2845 | - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); |
2194 | 2841 | int newTail; | 2846 | int newTail; |
2195 | 2842 | boolean wedged = false; | 2847 | boolean wedged = false; |
2196 | @@ -2881,7 +2886,7 @@ | |||
2197 | 2881 | 2886 | ||
2198 | 2882 | size += oldEbc - newEbc; | 2887 | size += oldEbc - newEbc; |
2199 | 2883 | klength += oldEbc - newEbc; | 2888 | klength += oldEbc - newEbc; |
2201 | 2884 | int newDb = indexKeyBytes[newEbc] & 0xFF; | 2889 | final int newDb = indexKeyBytes[newEbc] & 0xFF; |
2202 | 2885 | 2890 | ||
2203 | 2886 | putInt(newTail, encodeTailBlock(size, klength)); | 2891 | putInt(newTail, encodeTailBlock(size, klength)); |
2204 | 2887 | 2892 | ||
2205 | @@ -2897,7 +2902,7 @@ | |||
2206 | 2897 | * @param insertAt | 2902 | * @param insertAt |
2207 | 2898 | * @param includesRightEdge | 2903 | * @param includesRightEdge |
2208 | 2899 | */ | 2904 | */ |
2210 | 2900 | void moveRecords(Buffer buffer, int p1, int p2, int insertAt, boolean includesRightEdge) { | 2905 | void moveRecords(final Buffer buffer, final int p1, final int p2, int insertAt, final boolean includesRightEdge) { |
2211 | 2901 | if (p2 - p1 + _keyBlockEnd > _alloc) { | 2906 | if (p2 - p1 + _keyBlockEnd > _alloc) { |
2212 | 2902 | repack(); | 2907 | repack(); |
2213 | 2903 | } | 2908 | } |
2214 | @@ -2912,15 +2917,15 @@ | |||
2215 | 2912 | setKeyBlockEnd(getKeyBlockEnd() + KEYBLOCK_LENGTH); | 2917 | setKeyBlockEnd(getKeyBlockEnd() + KEYBLOCK_LENGTH); |
2216 | 2913 | 2918 | ||
2217 | 2914 | for (int p = p1; p < p2 || includesRightEdge && p == p2; p += KEYBLOCK_LENGTH) { | 2919 | for (int p = p1; p < p2 || includesRightEdge && p == p2; p += KEYBLOCK_LENGTH) { |
2225 | 2915 | int kbData = buffer.getInt(p); | 2920 | final int kbData = buffer.getInt(p); |
2226 | 2916 | int ebc = decodeKeyBlockEbc(kbData); | 2921 | final int ebc = decodeKeyBlockEbc(kbData); |
2227 | 2917 | int db = decodeKeyBlockDb(kbData); | 2922 | final int db = decodeKeyBlockDb(kbData); |
2228 | 2918 | int tail = decodeKeyBlockTail(kbData); | 2923 | final int tail = decodeKeyBlockTail(kbData); |
2229 | 2919 | int tbData = buffer.getInt(tail); | 2924 | final int tbData = buffer.getInt(tail); |
2230 | 2920 | int size = decodeTailBlockSize(tbData); | 2925 | final int size = decodeTailBlockSize(tbData); |
2231 | 2921 | int klength = decodeTailBlockKLength(tbData); | 2926 | final int klength = decodeTailBlockKLength(tbData); |
2232 | 2922 | int newSize = size; | 2927 | int newSize = size; |
2234 | 2923 | boolean edgeCase = includesRightEdge && p == p2; | 2928 | final boolean edgeCase = includesRightEdge && p == p2; |
2235 | 2924 | if (edgeCase) { | 2929 | if (edgeCase) { |
2236 | 2925 | // this is just for the right edge key of the left page | 2930 | // this is just for the right edge key of the left page |
2237 | 2926 | newSize = _tailHeaderSize + klength; | 2931 | newSize = _tailHeaderSize + klength; |
2238 | @@ -2972,7 +2977,7 @@ | |||
2239 | 2972 | */ | 2977 | */ |
2240 | 2973 | private int allocTail(int size) { | 2978 | private int allocTail(int size) { |
2241 | 2974 | size = (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 2979 | size = (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2243 | 2975 | int alloc = _alloc - size; | 2980 | final int alloc = _alloc - size; |
2244 | 2976 | if (alloc >= _keyBlockEnd) { | 2981 | if (alloc >= _keyBlockEnd) { |
2245 | 2977 | _alloc = alloc; | 2982 | _alloc = alloc; |
2246 | 2978 | return alloc; | 2983 | return alloc; |
2247 | @@ -2981,7 +2986,7 @@ | |||
2248 | 2981 | } | 2986 | } |
2249 | 2982 | } | 2987 | } |
2250 | 2983 | 2988 | ||
2252 | 2984 | private void deallocTail(int tail, int size) { | 2989 | private void deallocTail(final int tail, int size) { |
2253 | 2985 | size = (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 2990 | size = (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2254 | 2986 | 2991 | ||
2255 | 2987 | Debug.$assert0.t((size > 0 && size <= _bufferSize - _alloc) && (tail >= _alloc && tail < _bufferSize) | 2992 | Debug.$assert0.t((size > 0 && size <= _bufferSize - _alloc) && (tail >= _alloc && tail < _bufferSize) |
2256 | @@ -2993,9 +2998,9 @@ | |||
2257 | 2993 | // any free space above this block. | 2998 | // any free space above this block. |
2258 | 2994 | // | 2999 | // |
2259 | 2995 | while (tail + size < _bufferSize) { | 3000 | while (tail + size < _bufferSize) { |
2261 | 2996 | int kbNext = getInt(tail + size); | 3001 | final int kbNext = getInt(tail + size); |
2262 | 2997 | if ((kbNext & TAILBLOCK_INUSE_MASK) == 0) { | 3002 | if ((kbNext & TAILBLOCK_INUSE_MASK) == 0) { |
2264 | 2998 | int sizeNext = decodeTailBlockSize(kbNext); | 3003 | final int sizeNext = decodeTailBlockSize(kbNext); |
2265 | 2999 | Debug.$assert0.t((sizeNext & ~TAILBLOCK_MASK) == 0 && sizeNext != 0); | 3004 | Debug.$assert0.t((sizeNext & ~TAILBLOCK_MASK) == 0 && sizeNext != 0); |
2266 | 3000 | _slack -= sizeNext; | 3005 | _slack -= sizeNext; |
2267 | 3001 | putInt(tail + size, 0); | 3006 | putInt(tail + size, 0); |
2268 | @@ -3018,7 +3023,7 @@ | |||
2269 | 3018 | private void repack() { | 3023 | private void repack() { |
2270 | 3019 | Debug.$assert0.t(isMine()); | 3024 | Debug.$assert0.t(isMine()); |
2271 | 3020 | 3025 | ||
2273 | 3021 | int[] plan = getRepackPlanBuffer(); | 3026 | final int[] plan = getRepackPlanBuffer(); |
2274 | 3022 | // | 3027 | // |
2275 | 3023 | // Phase 1: | 3028 | // Phase 1: |
2276 | 3024 | // For each allocated tail block, post the offset of its | 3029 | // For each allocated tail block, post the offset of its |
2277 | @@ -3028,9 +3033,9 @@ | |||
2278 | 3028 | int free = 0; | 3033 | int free = 0; |
2279 | 3029 | int back = 0; | 3034 | int back = 0; |
2280 | 3030 | for (int tail = _alloc; tail < _bufferSize;) { | 3035 | for (int tail = _alloc; tail < _bufferSize;) { |
2282 | 3031 | int tbData = getInt(tail); | 3036 | final int tbData = getInt(tail); |
2283 | 3032 | 3037 | ||
2285 | 3033 | int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 3038 | final int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2286 | 3034 | if (size <= 0) { | 3039 | if (size <= 0) { |
2287 | 3035 | _persistit.fatal("Buffer has invalid tailblock length " + size + " at " + tail + " in " + this, null); | 3040 | _persistit.fatal("Buffer has invalid tailblock length " + size + " at " + tail + " in " + this, null); |
2288 | 3036 | } | 3041 | } |
2289 | @@ -3058,9 +3063,9 @@ | |||
2290 | 3058 | if (free > 0) | 3063 | if (free > 0) |
2291 | 3059 | moveSize += alloc - tail - free; | 3064 | moveSize += alloc - tail - free; |
2292 | 3060 | alloc = tail + free; | 3065 | alloc = tail + free; |
2294 | 3061 | int planData = plan[tail / TAILBLOCK_FACTOR]; | 3066 | final int planData = plan[tail / TAILBLOCK_FACTOR]; |
2295 | 3062 | plan[tail / TAILBLOCK_FACTOR] = free + tail; | 3067 | plan[tail / TAILBLOCK_FACTOR] = free + tail; |
2297 | 3063 | int deltaFree = planData & 0xFFFF; | 3068 | final int deltaFree = planData & 0xFFFF; |
2298 | 3064 | if (deltaFree > 0 && moveSize > 0 && free > 0) { | 3069 | if (deltaFree > 0 && moveSize > 0 && free > 0) { |
2299 | 3065 | System.arraycopy(_bytes, moveFrom, _bytes, moveFrom + free, moveSize); | 3070 | System.arraycopy(_bytes, moveFrom, _bytes, moveFrom + free, moveSize); |
2300 | 3066 | moveSize = 0; | 3071 | moveSize = 0; |
2301 | @@ -3080,14 +3085,14 @@ | |||
2302 | 3080 | // | 3085 | // |
2303 | 3081 | if (free > 0) { | 3086 | if (free > 0) { |
2304 | 3082 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { | 3087 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { |
2306 | 3083 | int kbData = getInt(p); | 3088 | final int kbData = getInt(p); |
2307 | 3084 | // | 3089 | // |
2308 | 3085 | // For certain remove operations, we may have invalid keyblocks | 3090 | // For certain remove operations, we may have invalid keyblocks |
2309 | 3086 | // in range. We can safely ignore them here. | 3091 | // in range. We can safely ignore them here. |
2310 | 3087 | // | 3092 | // |
2311 | 3088 | if (kbData != 0) { | 3093 | if (kbData != 0) { |
2314 | 3089 | int tail = decodeKeyBlockTail(kbData); | 3094 | final int tail = decodeKeyBlockTail(kbData); |
2315 | 3090 | int newTail = plan[tail / KEYBLOCK_LENGTH]; | 3095 | final int newTail = plan[tail / KEYBLOCK_LENGTH]; |
2316 | 3091 | 3096 | ||
2317 | 3092 | if (newTail != tail) { | 3097 | if (newTail != tail) { |
2318 | 3093 | putInt(p, encodeKeyBlockTail(kbData, newTail)); | 3098 | putInt(p, encodeKeyBlockTail(kbData, newTail)); |
2319 | @@ -3105,7 +3110,7 @@ | |||
2320 | 3105 | * The size required by the proposed new tailblock. | 3110 | * The size required by the proposed new tailblock. |
2321 | 3106 | * @return boolean <i>true</i> if it will fit, else <i>false</i>. | 3111 | * @return boolean <i>true</i> if it will fit, else <i>false</i>. |
2322 | 3107 | */ | 3112 | */ |
2324 | 3108 | private boolean willFit(int needed) { | 3113 | private boolean willFit(final int needed) { |
2325 | 3109 | return needed <= (_alloc - _keyBlockEnd + _slack); | 3114 | return needed <= (_alloc - _keyBlockEnd + _slack); |
2326 | 3110 | } | 3115 | } |
2327 | 3111 | 3116 | ||
2328 | @@ -3116,8 +3121,8 @@ | |||
2329 | 3116 | * @param foundAt | 3121 | * @param foundAt |
2330 | 3117 | * The keyblock index | 3122 | * The keyblock index |
2331 | 3118 | */ | 3123 | */ |
2334 | 3119 | boolean isAfterRightEdge(int foundAt) { | 3124 | boolean isAfterRightEdge(final int foundAt) { |
2335 | 3120 | int p = foundAt & P_MASK; | 3125 | final int p = foundAt & P_MASK; |
2336 | 3121 | return (p >= _keyBlockEnd) || ((p == _keyBlockEnd - KEYBLOCK_LENGTH && (foundAt & EXACT_MASK) != 0)); | 3126 | return (p >= _keyBlockEnd) || ((p == _keyBlockEnd - KEYBLOCK_LENGTH && (foundAt & EXACT_MASK) != 0)); |
2337 | 3122 | } | 3127 | } |
2338 | 3123 | 3128 | ||
2339 | @@ -3127,7 +3132,7 @@ | |||
2340 | 3127 | * | 3132 | * |
2341 | 3128 | * @param foundAt | 3133 | * @param foundAt |
2342 | 3129 | */ | 3134 | */ |
2344 | 3130 | boolean isBeforeLeftEdge(int foundAt) { | 3135 | boolean isBeforeLeftEdge(final int foundAt) { |
2345 | 3131 | return (((foundAt & EXACT_MASK) == 0 && (foundAt & P_MASK) <= KEY_BLOCK_START) || (foundAt & P_MASK) < KEY_BLOCK_START); | 3136 | return (((foundAt & EXACT_MASK) == 0 && (foundAt & P_MASK) <= KEY_BLOCK_START) || (foundAt & P_MASK) < KEY_BLOCK_START); |
2346 | 3132 | } | 3137 | } |
2347 | 3133 | 3138 | ||
2348 | @@ -3136,11 +3141,11 @@ | |||
2349 | 3136 | return _bytes; | 3141 | return _bytes; |
2350 | 3137 | } | 3142 | } |
2351 | 3138 | 3143 | ||
2353 | 3139 | int getByte(int index) { | 3144 | int getByte(final int index) { |
2354 | 3140 | return (_bytes[index] & 0xFF); | 3145 | return (_bytes[index] & 0xFF); |
2355 | 3141 | } | 3146 | } |
2356 | 3142 | 3147 | ||
2358 | 3143 | int getChar(int index) { | 3148 | int getChar(final int index) { |
2359 | 3144 | if (Persistit.BIG_ENDIAN) { | 3149 | if (Persistit.BIG_ENDIAN) { |
2360 | 3145 | return (_bytes[index + 1] & 0xFF) | (_bytes[index] & 0xFF) << 8; | 3150 | return (_bytes[index + 1] & 0xFF) | (_bytes[index] & 0xFF) << 8; |
2361 | 3146 | } else { | 3151 | } else { |
2362 | @@ -3148,7 +3153,7 @@ | |||
2363 | 3148 | } | 3153 | } |
2364 | 3149 | } | 3154 | } |
2365 | 3150 | 3155 | ||
2367 | 3151 | int getInt(int index) { | 3156 | int getInt(final int index) { |
2368 | 3152 | if (Persistit.BIG_ENDIAN) { | 3157 | if (Persistit.BIG_ENDIAN) { |
2369 | 3153 | return (_bytes[index + 3] & 0xFF) | (_bytes[index + 2] & 0xFF) << 8 | (_bytes[index + 1] & 0xFF) << 16 | 3158 | return (_bytes[index + 3] & 0xFF) | (_bytes[index + 2] & 0xFF) << 8 | (_bytes[index + 1] & 0xFF) << 16 |
2370 | 3154 | | (_bytes[index] & 0xFF) << 24; | 3159 | | (_bytes[index] & 0xFF) << 24; |
2371 | @@ -3158,21 +3163,21 @@ | |||
2372 | 3158 | } | 3163 | } |
2373 | 3159 | } | 3164 | } |
2374 | 3160 | 3165 | ||
2376 | 3161 | long getLong(int index) { | 3166 | long getLong(final int index) { |
2377 | 3162 | if (Persistit.BIG_ENDIAN) { | 3167 | if (Persistit.BIG_ENDIAN) { |
2379 | 3163 | return (long) (_bytes[index + 7] & 0xFF) | (long) (_bytes[index + 6] & 0xFF) << 8 | 3168 | return _bytes[index + 7] & 0xFF | (long) (_bytes[index + 6] & 0xFF) << 8 |
2380 | 3164 | | (long) (_bytes[index + 5] & 0xFF) << 16 | (long) (_bytes[index + 4] & 0xFF) << 24 | 3169 | | (long) (_bytes[index + 5] & 0xFF) << 16 | (long) (_bytes[index + 4] & 0xFF) << 24 |
2381 | 3165 | | (long) (_bytes[index + 3] & 0xFF) << 32 | (long) (_bytes[index + 2] & 0xFF) << 40 | 3170 | | (long) (_bytes[index + 3] & 0xFF) << 32 | (long) (_bytes[index + 2] & 0xFF) << 40 |
2382 | 3166 | | (long) (_bytes[index + 1] & 0xFF) << 48 | (long) (_bytes[index] & 0xFF) << 56; | 3171 | | (long) (_bytes[index + 1] & 0xFF) << 48 | (long) (_bytes[index] & 0xFF) << 56; |
2383 | 3167 | } else { | 3172 | } else { |
2385 | 3168 | return (long) (_bytes[index] & 0xFF) | (long) (_bytes[index + 1] & 0xFF) << 8 | 3173 | return _bytes[index] & 0xFF | (long) (_bytes[index + 1] & 0xFF) << 8 |
2386 | 3169 | | (long) (_bytes[index + 2] & 0xFF) << 16 | (long) (_bytes[index + 3] & 0xFF) << 24 | 3174 | | (long) (_bytes[index + 2] & 0xFF) << 16 | (long) (_bytes[index + 3] & 0xFF) << 24 |
2387 | 3170 | | (long) (_bytes[index + 4] & 0xFF) << 32 | (long) (_bytes[index + 5] & 0xFF) << 40 | 3175 | | (long) (_bytes[index + 4] & 0xFF) << 32 | (long) (_bytes[index + 5] & 0xFF) << 40 |
2388 | 3171 | | (long) (_bytes[index + 6] & 0xFF) << 48 | (long) (_bytes[index + 7] & 0xFF) << 56; | 3176 | | (long) (_bytes[index + 6] & 0xFF) << 48 | (long) (_bytes[index + 7] & 0xFF) << 56; |
2389 | 3172 | } | 3177 | } |
2390 | 3173 | } | 3178 | } |
2391 | 3174 | 3179 | ||
2393 | 3175 | int getDb(int index) { | 3180 | int getDb(final int index) { |
2394 | 3176 | if (Persistit.BIG_ENDIAN) { | 3181 | if (Persistit.BIG_ENDIAN) { |
2395 | 3177 | return _bytes[index + 3] & 0xFF; | 3182 | return _bytes[index + 3] & 0xFF; |
2396 | 3178 | } else { | 3183 | } else { |
2397 | @@ -3180,12 +3185,12 @@ | |||
2398 | 3180 | } | 3185 | } |
2399 | 3181 | } | 3186 | } |
2400 | 3182 | 3187 | ||
2402 | 3183 | void putByte(int index, int value) { | 3188 | void putByte(final int index, final int value) { |
2403 | 3184 | Debug.$assert0.t(index >= 0 && index + 1 <= _bytes.length); | 3189 | Debug.$assert0.t(index >= 0 && index + 1 <= _bytes.length); |
2404 | 3185 | _bytes[index] = (byte) (value); | 3190 | _bytes[index] = (byte) (value); |
2405 | 3186 | } | 3191 | } |
2406 | 3187 | 3192 | ||
2408 | 3188 | void putChar(int index, int value) { | 3193 | void putChar(final int index, final int value) { |
2409 | 3189 | Debug.$assert0.t(index >= 0 && index + 2 <= _bytes.length); | 3194 | Debug.$assert0.t(index >= 0 && index + 2 <= _bytes.length); |
2410 | 3190 | if (Persistit.BIG_ENDIAN) { | 3195 | if (Persistit.BIG_ENDIAN) { |
2411 | 3191 | _bytes[index + 1] = (byte) (value); | 3196 | _bytes[index + 1] = (byte) (value); |
2412 | @@ -3196,7 +3201,7 @@ | |||
2413 | 3196 | } | 3201 | } |
2414 | 3197 | } | 3202 | } |
2415 | 3198 | 3203 | ||
2417 | 3199 | void putInt(int index, int value) { | 3204 | void putInt(final int index, final int value) { |
2418 | 3200 | Debug.$assert0.t(index >= 0 && index + 4 <= _bytes.length); | 3205 | Debug.$assert0.t(index >= 0 && index + 4 <= _bytes.length); |
2419 | 3201 | if (Persistit.BIG_ENDIAN) { | 3206 | if (Persistit.BIG_ENDIAN) { |
2420 | 3202 | _bytes[index + 3] = (byte) (value); | 3207 | _bytes[index + 3] = (byte) (value); |
2421 | @@ -3211,7 +3216,7 @@ | |||
2422 | 3211 | } | 3216 | } |
2423 | 3212 | } | 3217 | } |
2424 | 3213 | 3218 | ||
2426 | 3214 | void putLong(int index, long value) { | 3219 | void putLong(final int index, final long value) { |
2427 | 3215 | Debug.$assert0.t(index >= 0 && index + 8 <= _bytes.length); | 3220 | Debug.$assert0.t(index >= 0 && index + 8 <= _bytes.length); |
2428 | 3216 | 3221 | ||
2429 | 3217 | if (Persistit.BIG_ENDIAN) { | 3222 | if (Persistit.BIG_ENDIAN) { |
2430 | @@ -3235,7 +3240,7 @@ | |||
2431 | 3235 | } | 3240 | } |
2432 | 3236 | } | 3241 | } |
2433 | 3237 | 3242 | ||
2435 | 3238 | static void writeLongRecordDescriptor(byte[] bytes, int size, long pageAddr) { | 3243 | static void writeLongRecordDescriptor(final byte[] bytes, final int size, final long pageAddr) { |
2436 | 3239 | if (bytes.length != LONGREC_SIZE) { | 3244 | if (bytes.length != LONGREC_SIZE) { |
2437 | 3240 | throw new IllegalArgumentException("Bad LONG_RECORD descriptor size: " + size); | 3245 | throw new IllegalArgumentException("Bad LONG_RECORD descriptor size: " + size); |
2438 | 3241 | } | 3246 | } |
2439 | @@ -3246,7 +3251,7 @@ | |||
2440 | 3246 | Util.putLong(bytes, LONGREC_PAGE_OFFSET, pageAddr); | 3251 | Util.putLong(bytes, LONGREC_PAGE_OFFSET, pageAddr); |
2441 | 3247 | } | 3252 | } |
2442 | 3248 | 3253 | ||
2444 | 3249 | static int decodeLongRecordDescriptorSize(byte[] bytes, int offset) { | 3254 | static int decodeLongRecordDescriptorSize(final byte[] bytes, final int offset) { |
2445 | 3250 | int type; | 3255 | int type; |
2446 | 3251 | if ((type = (bytes[offset] & 0xFF)) != LONGREC_TYPE) { | 3256 | if ((type = (bytes[offset] & 0xFF)) != LONGREC_TYPE) { |
2447 | 3252 | throw new IllegalArgumentException("Bad LONG_RECORD descriptor type: " + type); | 3257 | throw new IllegalArgumentException("Bad LONG_RECORD descriptor type: " + type); |
2448 | @@ -3254,7 +3259,7 @@ | |||
2449 | 3254 | return (int) Util.getLong(bytes, offset + LONGREC_SIZE_OFFSET); | 3259 | return (int) Util.getLong(bytes, offset + LONGREC_SIZE_OFFSET); |
2450 | 3255 | } | 3260 | } |
2451 | 3256 | 3261 | ||
2453 | 3257 | static long decodeLongRecordDescriptorPointer(byte[] bytes, int offset) { | 3262 | static long decodeLongRecordDescriptorPointer(final byte[] bytes, final int offset) { |
2454 | 3258 | int type; | 3263 | int type; |
2455 | 3259 | if ((type = (bytes[offset] & 0xFF)) != LONGREC_TYPE) { | 3264 | if ((type = (bytes[offset] & 0xFF)) != LONGREC_TYPE) { |
2456 | 3260 | throw new IllegalArgumentException("Bad LONG_RECORD descriptor type: " + type); | 3265 | throw new IllegalArgumentException("Bad LONG_RECORD descriptor type: " + type); |
2457 | @@ -3263,7 +3268,7 @@ | |||
2458 | 3263 | } | 3268 | } |
2459 | 3264 | 3269 | ||
2460 | 3265 | static int bufferSizeWithOverhead(final int bufferSize) { | 3270 | static int bufferSizeWithOverhead(final int bufferSize) { |
2462 | 3266 | int fastIndexSize = ((bufferSize - HEADER_SIZE) / MAX_KEY_RATIO) * FastIndex.BYTES_PER_ENTRY; | 3271 | final int fastIndexSize = ((bufferSize - HEADER_SIZE) / MAX_KEY_RATIO) * FastIndex.BYTES_PER_ENTRY; |
2463 | 3267 | return bufferSize + fastIndexSize + ESTIMATED_FIXED_BUFFER_OVERHEAD; | 3272 | return bufferSize + fastIndexSize + ESTIMATED_FIXED_BUFFER_OVERHEAD; |
2464 | 3268 | } | 3273 | } |
2465 | 3269 | 3274 | ||
2466 | @@ -3314,16 +3319,16 @@ | |||
2467 | 3314 | return (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 3319 | return (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2468 | 3315 | } | 3320 | } |
2469 | 3316 | 3321 | ||
2471 | 3317 | static int encodeKeyBlock(int ebc, int db, int tail) { | 3322 | static int encodeKeyBlock(final int ebc, final int db, final int tail) { |
2472 | 3318 | return ((ebc << EBC_SHIFT) & EBC_MASK) | ((db /* << DB_SHIFT */) & DB_MASK) | 3323 | return ((ebc << EBC_SHIFT) & EBC_MASK) | ((db /* << DB_SHIFT */) & DB_MASK) |
2473 | 3319 | | ((tail << TAIL_SHIFT) & TAIL_MASK); | 3324 | | ((tail << TAIL_SHIFT) & TAIL_MASK); |
2474 | 3320 | } | 3325 | } |
2475 | 3321 | 3326 | ||
2477 | 3322 | static int encodeKeyBlockTail(int kbData, int tail) { | 3327 | static int encodeKeyBlockTail(final int kbData, final int tail) { |
2478 | 3323 | return (kbData & ~TAIL_MASK) | ((tail << TAIL_SHIFT) & TAIL_MASK); | 3328 | return (kbData & ~TAIL_MASK) | ((tail << TAIL_SHIFT) & TAIL_MASK); |
2479 | 3324 | } | 3329 | } |
2480 | 3325 | 3330 | ||
2482 | 3326 | static int encodeTailBlock(int size, int klength) { | 3331 | static int encodeTailBlock(final int size, final int klength) { |
2483 | 3327 | return ((klength << TAILBLOCK_KLENGTH_SHIFT) & TAILBLOCK_KLENGTH_MASK) | ((size /* | 3332 | return ((klength << TAILBLOCK_KLENGTH_SHIFT) & TAILBLOCK_KLENGTH_MASK) | ((size /* |
2484 | 3328 | * << | 3333 | * << |
2485 | 3329 | * TAILBLOCK_SIZE_SHIFT | 3334 | * TAILBLOCK_SIZE_SHIFT |
2486 | @@ -3331,35 +3336,35 @@ | |||
2487 | 3331 | | TAILBLOCK_INUSE_MASK; | 3336 | | TAILBLOCK_INUSE_MASK; |
2488 | 3332 | } | 3337 | } |
2489 | 3333 | 3338 | ||
2491 | 3334 | static int encodeFreeBlock(int size) { | 3339 | static int encodeFreeBlock(final int size) { |
2492 | 3335 | return ((size /* << TAILBLOCK_SIZE_SHIFT */) & TAILBLOCK_SIZE_MASK); | 3340 | return ((size /* << TAILBLOCK_SIZE_SHIFT */) & TAILBLOCK_SIZE_MASK); |
2493 | 3336 | } | 3341 | } |
2494 | 3337 | 3342 | ||
2496 | 3338 | static int decodeKeyBlockEbc(int kbData) { | 3343 | static int decodeKeyBlockEbc(final int kbData) { |
2497 | 3339 | return (kbData & EBC_MASK) >>> EBC_SHIFT; | 3344 | return (kbData & EBC_MASK) >>> EBC_SHIFT; |
2498 | 3340 | } | 3345 | } |
2499 | 3341 | 3346 | ||
2501 | 3342 | static int decodeKeyBlockDb(int kbData) { | 3347 | static int decodeKeyBlockDb(final int kbData) { |
2502 | 3343 | return (kbData & DB_MASK) /* >>> DB_SHIFT */; | 3348 | return (kbData & DB_MASK) /* >>> DB_SHIFT */; |
2503 | 3344 | } | 3349 | } |
2504 | 3345 | 3350 | ||
2506 | 3346 | static int decodeKeyBlockTail(int kbData) { | 3351 | static int decodeKeyBlockTail(final int kbData) { |
2507 | 3347 | return (kbData & TAIL_MASK) >>> TAIL_SHIFT; | 3352 | return (kbData & TAIL_MASK) >>> TAIL_SHIFT; |
2508 | 3348 | } | 3353 | } |
2509 | 3349 | 3354 | ||
2511 | 3350 | static int decodeTailBlockSize(int tbData) { | 3355 | static int decodeTailBlockSize(final int tbData) { |
2512 | 3351 | return (tbData & TAILBLOCK_SIZE_MASK) /* >>> TAILBLOCK_SIZE_SHIFT */; | 3356 | return (tbData & TAILBLOCK_SIZE_MASK) /* >>> TAILBLOCK_SIZE_SHIFT */; |
2513 | 3352 | } | 3357 | } |
2514 | 3353 | 3358 | ||
2516 | 3354 | static int decodeTailBlockKLength(int tbData) { | 3359 | static int decodeTailBlockKLength(final int tbData) { |
2517 | 3355 | return (tbData & TAILBLOCK_KLENGTH_MASK) >>> TAILBLOCK_KLENGTH_SHIFT; | 3360 | return (tbData & TAILBLOCK_KLENGTH_MASK) >>> TAILBLOCK_KLENGTH_SHIFT; |
2518 | 3356 | } | 3361 | } |
2519 | 3357 | 3362 | ||
2521 | 3358 | static boolean decodeTailBlockInUse(int tbData) { | 3363 | static boolean decodeTailBlockInUse(final int tbData) { |
2522 | 3359 | return (tbData & TAILBLOCK_INUSE_MASK) != 0; | 3364 | return (tbData & TAILBLOCK_INUSE_MASK) != 0; |
2523 | 3360 | } | 3365 | } |
2524 | 3361 | 3366 | ||
2526 | 3362 | static int decodeDepth(int foundAt) { | 3367 | static int decodeDepth(final int foundAt) { |
2527 | 3363 | return (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; | 3368 | return (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; |
2528 | 3364 | } | 3369 | } |
2529 | 3365 | 3370 | ||
2530 | @@ -3367,7 +3372,7 @@ | |||
2531 | 3367 | return _persistit.getThreadLocalIntArray(MAX_BUFFER_SIZE / TAILBLOCK_FACTOR); | 3372 | return _persistit.getThreadLocalIntArray(MAX_BUFFER_SIZE / TAILBLOCK_FACTOR); |
2532 | 3368 | } | 3373 | } |
2533 | 3369 | 3374 | ||
2535 | 3370 | PersistitException verify(Key key, VerifyVisitor visitor) { | 3375 | PersistitException verify(Key key, final VerifyVisitor visitor) { |
2536 | 3371 | try { | 3376 | try { |
2537 | 3372 | if (_page == 0) { | 3377 | if (_page == 0) { |
2538 | 3373 | return new InvalidPageStructureException("head page is neither a data page nor an index page"); | 3378 | return new InvalidPageStructureException("head page is neither a data page nor an index page"); |
2539 | @@ -3380,8 +3385,8 @@ | |||
2540 | 3380 | key = new Key(_persistit); | 3385 | key = new Key(_persistit); |
2541 | 3381 | } | 3386 | } |
2542 | 3382 | 3387 | ||
2545 | 3383 | byte[] kb = key.getEncodedBytes(); | 3388 | final byte[] kb = key.getEncodedBytes(); |
2546 | 3384 | int[] plan = getRepackPlanBuffer(); | 3389 | final int[] plan = getRepackPlanBuffer(); |
2547 | 3385 | for (int index = 0; index < plan.length; index++) { | 3390 | for (int index = 0; index < plan.length; index++) { |
2548 | 3386 | plan[index] = 0; | 3391 | plan[index] = 0; |
2549 | 3387 | } | 3392 | } |
2550 | @@ -3392,10 +3397,10 @@ | |||
2551 | 3392 | } | 3397 | } |
2552 | 3393 | 3398 | ||
2553 | 3394 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { | 3399 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { |
2558 | 3395 | int kbData = getInt(p); | 3400 | final int kbData = getInt(p); |
2559 | 3396 | int db = decodeKeyBlockDb(kbData); | 3401 | final int db = decodeKeyBlockDb(kbData); |
2560 | 3397 | int ebc = decodeKeyBlockEbc(kbData); | 3402 | final int ebc = decodeKeyBlockEbc(kbData); |
2561 | 3398 | int tail = decodeKeyBlockTail(kbData); | 3403 | final int tail = decodeKeyBlockTail(kbData); |
2562 | 3399 | 3404 | ||
2563 | 3400 | if (p == KEY_BLOCK_START && ebc != 0) { | 3405 | if (p == KEY_BLOCK_START && ebc != 0) { |
2564 | 3401 | return new InvalidPageStructureException("invalid initial ebc " + ebc + " for keyblock at " + p | 3406 | return new InvalidPageStructureException("invalid initial ebc " + ebc + " for keyblock at " + p |
2565 | @@ -3407,8 +3412,8 @@ | |||
2566 | 3407 | return new InvalidPageStructureException("invalid tail block offset " + tail + " for keyblock at " | 3412 | return new InvalidPageStructureException("invalid tail block offset " + tail + " for keyblock at " |
2567 | 3408 | + p + " --[" + summarize() + "]"); | 3413 | + p + " --[" + summarize() + "]"); |
2568 | 3409 | } | 3414 | } |
2571 | 3410 | int tbData = getInt(tail); | 3415 | final int tbData = getInt(tail); |
2572 | 3411 | int klength = decodeTailBlockKLength(tbData); | 3416 | final int klength = decodeTailBlockKLength(tbData); |
2573 | 3412 | if ((tbData & TAILBLOCK_INUSE_MASK) == 0) { | 3417 | if ((tbData & TAILBLOCK_INUSE_MASK) == 0) { |
2574 | 3413 | return new InvalidPageStructureException("not in-use tail block offset " + tail | 3418 | return new InvalidPageStructureException("not in-use tail block offset " + tail |
2575 | 3414 | + " for keyblock at " + p + " --[" + summarize() + "]"); | 3419 | + " for keyblock at " + p + " --[" + summarize() + "]"); |
2576 | @@ -3426,14 +3431,14 @@ | |||
2577 | 3426 | compare = (kb[index] & 0xFF) - (_bytes[tail + _tailHeaderSize + index - 1] & 0xFF); | 3431 | compare = (kb[index] & 0xFF) - (_bytes[tail + _tailHeaderSize + index - 1] & 0xFF); |
2578 | 3427 | } | 3432 | } |
2579 | 3428 | if (compare != 0) { | 3433 | if (compare != 0) { |
2581 | 3429 | String s = compare < 0 ? "too big" : "too small"; | 3434 | final String s = compare < 0 ? "too big" : "too small"; |
2582 | 3430 | return new InvalidPageStructureException("initial key " + s + " at offset " + index | 3435 | return new InvalidPageStructureException("initial key " + s + " at offset " + index |
2583 | 3431 | + " for keyblock at " + p + " --[" + summarize() + "]"); | 3436 | + " for keyblock at " + p + " --[" + summarize() + "]"); |
2584 | 3432 | } | 3437 | } |
2585 | 3433 | } | 3438 | } |
2586 | 3434 | // Verify that successor keys follow in sequence. | 3439 | // Verify that successor keys follow in sequence. |
2587 | 3435 | if (p > KEY_BLOCK_START && ebc < key.getEncodedSize()) { | 3440 | if (p > KEY_BLOCK_START && ebc < key.getEncodedSize()) { |
2589 | 3436 | int dbPrev = kb[ebc] & 0xFF; | 3441 | final int dbPrev = kb[ebc] & 0xFF; |
2590 | 3437 | if (db < dbPrev) { | 3442 | if (db < dbPrev) { |
2591 | 3438 | return new InvalidPageStructureException("db not greater: db=" + db + " dbPrev=" + dbPrev | 3443 | return new InvalidPageStructureException("db not greater: db=" + db + " dbPrev=" + dbPrev |
2592 | 3439 | + " for keyblock at " + p + " --[" + summarize() + "]"); | 3444 | + " for keyblock at " + p + " --[" + summarize() + "]"); |
2593 | @@ -3444,7 +3449,7 @@ | |||
2594 | 3444 | // redundant | 3449 | // redundant |
2595 | 3445 | // | 3450 | // |
2596 | 3446 | if (isIndexPage()) { | 3451 | if (isIndexPage()) { |
2598 | 3447 | int pointer = getInt(tail + 4); | 3452 | final int pointer = getInt(tail + 4); |
2599 | 3448 | if (visitor != null) { | 3453 | if (visitor != null) { |
2600 | 3449 | visitor.visitIndexRecord(key, p, tail, klength, pointer); | 3454 | visitor.visitIndexRecord(key, p, tail, klength, pointer); |
2601 | 3450 | } | 3455 | } |
2602 | @@ -3455,9 +3460,9 @@ | |||
2603 | 3455 | } | 3460 | } |
2604 | 3456 | } | 3461 | } |
2605 | 3457 | } else if (isDataPage()) { | 3462 | } else if (isDataPage()) { |
2609 | 3458 | int size = decodeTailBlockSize(tbData); | 3463 | final int size = decodeTailBlockSize(tbData); |
2610 | 3459 | int offset = tail + _tailHeaderSize + klength; | 3464 | final int offset = tail + _tailHeaderSize + klength; |
2611 | 3460 | int length = size - klength - _tailHeaderSize; | 3465 | final int length = size - klength - _tailHeaderSize; |
2612 | 3461 | if (visitor != null) { | 3466 | if (visitor != null) { |
2613 | 3462 | visitor.visitDataRecord(key, p, tail, klength, offset, length, getBytes()); | 3467 | visitor.visitDataRecord(key, p, tail, klength, offset, length, getBytes()); |
2614 | 3463 | } | 3468 | } |
2615 | @@ -3477,13 +3482,13 @@ | |||
2616 | 3477 | 3482 | ||
2617 | 3478 | // Now check the free blocks | 3483 | // Now check the free blocks |
2618 | 3479 | 3484 | ||
2620 | 3480 | int formerBlock = _alloc; | 3485 | final int formerBlock = _alloc; |
2621 | 3481 | for (int tail = _alloc; tail < _bufferSize;) { | 3486 | for (int tail = _alloc; tail < _bufferSize;) { |
2622 | 3482 | if ((tail & ~TAILBLOCK_MASK) != 0 || tail < 0 || tail > _bufferSize) { | 3487 | if ((tail & ~TAILBLOCK_MASK) != 0 || tail < 0 || tail > _bufferSize) { |
2623 | 3483 | return new InvalidPageStructureException("Tail block at " + formerBlock + " is invalid"); | 3488 | return new InvalidPageStructureException("Tail block at " + formerBlock + " is invalid"); |
2624 | 3484 | } | 3489 | } |
2627 | 3485 | int tbData = getInt(tail); | 3490 | final int tbData = getInt(tail); |
2628 | 3486 | int size = decodeTailBlockSize(tbData); | 3491 | final int size = decodeTailBlockSize(tbData); |
2629 | 3487 | if (size <= ~TAILBLOCK_MASK || size >= _bufferSize - _keyBlockEnd) { | 3492 | if (size <= ~TAILBLOCK_MASK || size >= _bufferSize - _keyBlockEnd) { |
2630 | 3488 | return new InvalidPageStructureException("Tailblock at " + tail + " has invalid size=" + size); | 3493 | return new InvalidPageStructureException("Tailblock at " + tail + " has invalid size=" + size); |
2631 | 3489 | } | 3494 | } |
2632 | @@ -3492,7 +3497,7 @@ | |||
2633 | 3492 | return new InvalidPageStructureException("Tailblock at " + tail + " is in use, but no key " | 3497 | return new InvalidPageStructureException("Tailblock at " + tail + " is in use, but no key " |
2634 | 3493 | + " block points to it."); | 3498 | + " block points to it."); |
2635 | 3494 | } | 3499 | } |
2637 | 3495 | int klength = decodeTailBlockKLength(tbData); | 3500 | final int klength = decodeTailBlockKLength(tbData); |
2638 | 3496 | { | 3501 | { |
2639 | 3497 | if (klength + _tailHeaderSize > size) { | 3502 | if (klength + _tailHeaderSize > size) { |
2640 | 3498 | return new InvalidPageStructureException("Tailblock at " + tail + " has klength=" + klength | 3503 | return new InvalidPageStructureException("Tailblock at " + tail + " has klength=" + klength |
2641 | @@ -3508,7 +3513,7 @@ | |||
2642 | 3508 | tail += ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); | 3513 | tail += ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); |
2643 | 3509 | } | 3514 | } |
2644 | 3510 | return null; | 3515 | return null; |
2646 | 3511 | } catch (PersistitException pe) { | 3516 | } catch (final PersistitException pe) { |
2647 | 3512 | return pe; | 3517 | return pe; |
2648 | 3513 | } | 3518 | } |
2649 | 3514 | 3519 | ||
2650 | @@ -3528,7 +3533,7 @@ | |||
2651 | 3528 | * @return | 3533 | * @return |
2652 | 3529 | * @throws PersistitException | 3534 | * @throws PersistitException |
2653 | 3530 | */ | 3535 | */ |
2655 | 3531 | boolean pruneMvvValues(final Tree tree, boolean pruneLongMVVs) throws PersistitException { | 3536 | boolean pruneMvvValues(final Tree tree, final boolean pruneLongMVVs) throws PersistitException { |
2656 | 3532 | 3537 | ||
2657 | 3533 | boolean changed = false; | 3538 | boolean changed = false; |
2658 | 3534 | try { | 3539 | try { |
2659 | @@ -3541,7 +3546,7 @@ | |||
2660 | 3541 | final long timestamp = _persistit.getTimestampAllocator().updateTimestamp(); | 3546 | final long timestamp = _persistit.getTimestampAllocator().updateTimestamp(); |
2661 | 3542 | _mvvCount = 0; | 3547 | _mvvCount = 0; |
2662 | 3543 | writePageOnCheckpoint(timestamp); | 3548 | writePageOnCheckpoint(timestamp); |
2664 | 3544 | List<PrunedVersion> prunedVersions = new ArrayList<PrunedVersion>(); | 3549 | final List<PrunedVersion> prunedVersions = new ArrayList<PrunedVersion>(); |
2665 | 3545 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { | 3550 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { |
2666 | 3546 | final int kbData = getInt(p); | 3551 | final int kbData = getInt(p); |
2667 | 3547 | final int tail = decodeKeyBlockTail(kbData); | 3552 | final int tail = decodeKeyBlockTail(kbData); |
2668 | @@ -3567,9 +3572,9 @@ | |||
2669 | 3567 | true, prunedVersions); | 3572 | true, prunedVersions); |
2670 | 3568 | if (newSize != oldSize) { | 3573 | if (newSize != oldSize) { |
2671 | 3569 | changed = true; | 3574 | changed = true; |
2675 | 3570 | int newTailSize = klength + newSize + _tailHeaderSize; | 3575 | final int newTailSize = klength + newSize + _tailHeaderSize; |
2676 | 3571 | int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 3576 | final int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2677 | 3572 | int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 3577 | final int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2678 | 3573 | if (newNext < oldNext) { | 3578 | if (newNext < oldNext) { |
2679 | 3574 | // Free the remainder of the old tail block | 3579 | // Free the remainder of the old tail block |
2680 | 3575 | deallocTail(newNext, oldNext - newNext); | 3580 | deallocTail(newNext, oldNext - newNext); |
2681 | @@ -3600,11 +3605,11 @@ | |||
2682 | 3600 | prunedVersions.clear(); | 3605 | prunedVersions.clear(); |
2683 | 3601 | 3606 | ||
2684 | 3602 | if (pruneLongMVVs && hasLongMvvRecords) { | 3607 | if (pruneLongMVVs && hasLongMvvRecords) { |
2687 | 3603 | List<PersistitException> deferredExceptions = new ArrayList<PersistitException>(); | 3608 | final List<PersistitException> deferredExceptions = new ArrayList<PersistitException>(); |
2688 | 3604 | List<Long> oldChainsToDeallocate = new ArrayList<Long>(); | 3609 | final List<Long> oldChainsToDeallocate = new ArrayList<Long>(); |
2689 | 3605 | 3610 | ||
2692 | 3606 | Buffer copy = new Buffer(this); | 3611 | final Buffer copy = new Buffer(this); |
2693 | 3607 | boolean copyChanged = copy.pruneLongMvvValues(tree, prunedVersions, deferredExceptions, | 3612 | final boolean copyChanged = copy.pruneLongMvvValues(tree, prunedVersions, deferredExceptions, |
2694 | 3608 | oldChainsToDeallocate); | 3613 | oldChainsToDeallocate); |
2695 | 3609 | if (copyChanged) { | 3614 | if (copyChanged) { |
2696 | 3610 | changed = true; | 3615 | changed = true; |
2697 | @@ -3666,17 +3671,17 @@ | |||
2698 | 3666 | boolean pruned = false; | 3671 | boolean pruned = false; |
2699 | 3667 | try { | 3672 | try { |
2700 | 3668 | pruned = pruneLongMvv(_bytes, offset, oldSize, value, prunedVersions, toDeallocate); | 3673 | pruned = pruneLongMvv(_bytes, offset, oldSize, value, prunedVersions, toDeallocate); |
2702 | 3669 | } catch (PersistitException pe) { | 3674 | } catch (final PersistitException pe) { |
2703 | 3670 | deferredExceptions.add(pe); | 3675 | deferredExceptions.add(pe); |
2704 | 3671 | } | 3676 | } |
2705 | 3672 | if (pruned) { | 3677 | if (pruned) { |
2706 | 3673 | changed = true; | 3678 | changed = true; |
2708 | 3674 | int newSize = value.getEncodedSize(); | 3679 | final int newSize = value.getEncodedSize(); |
2709 | 3675 | assert newSize <= oldSize : "Pruned long value overflow"; | 3680 | assert newSize <= oldSize : "Pruned long value overflow"; |
2710 | 3676 | System.arraycopy(value.getEncodedBytes(), 0, _bytes, offset, newSize); | 3681 | System.arraycopy(value.getEncodedBytes(), 0, _bytes, offset, newSize); |
2714 | 3677 | int newTailSize = klength + newSize + _tailHeaderSize; | 3682 | final int newTailSize = klength + newSize + _tailHeaderSize; |
2715 | 3678 | int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 3683 | final int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2716 | 3679 | int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 3684 | final int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2717 | 3680 | if (newNext < oldNext) { | 3685 | if (newNext < oldNext) { |
2718 | 3681 | // Free the remainder of the old tail block | 3686 | // Free the remainder of the old tail block |
2719 | 3682 | deallocTail(newNext, oldNext - newNext); | 3687 | deallocTail(newNext, oldNext - newNext); |
2720 | @@ -3709,8 +3714,7 @@ | |||
2721 | 3709 | if (!_enqueuedForAntiValuePruning) { | 3714 | if (!_enqueuedForAntiValuePruning) { |
2722 | 3710 | final int treeHandle = tree.getHandle(); | 3715 | final int treeHandle = tree.getHandle(); |
2723 | 3711 | assert treeHandle != 0 : "MVV found in a temporary tree " + tree; | 3716 | assert treeHandle != 0 : "MVV found in a temporary tree " + tree; |
2726 | 3712 | if (_persistit.getCleanupManager().offer( | 3717 | if (_persistit.getCleanupManager().offer(new CleanupAntiValue(treeHandle, getPageAddress()))) { |
2725 | 3713 | new CleanupAntiValue(treeHandle, getPageAddress()))) { | ||
2727 | 3714 | _enqueuedForAntiValuePruning = true; | 3718 | _enqueuedForAntiValuePruning = true; |
2728 | 3715 | } | 3719 | } |
2729 | 3716 | } | 3720 | } |
2730 | @@ -3731,19 +3735,19 @@ | |||
2731 | 3731 | private boolean pruneLongMvv(final byte[] bytes, final int offset, final int oldSize, final Value value, | 3735 | private boolean pruneLongMvv(final byte[] bytes, final int offset, final int oldSize, final Value value, |
2732 | 3732 | final List<PrunedVersion> prunedVersions, final List<Long> toDeallocate) throws PersistitException { | 3736 | final List<PrunedVersion> prunedVersions, final List<Long> toDeallocate) throws PersistitException { |
2733 | 3733 | assert isLongMVV(bytes, offset, oldSize) : "Not a long MVV"; | 3737 | assert isLongMVV(bytes, offset, oldSize) : "Not a long MVV"; |
2735 | 3734 | long oldLongRecordChain = decodeLongRecordDescriptorPointer(bytes, offset); | 3738 | final long oldLongRecordChain = decodeLongRecordDescriptorPointer(bytes, offset); |
2736 | 3735 | value.changeLongRecordMode(false); | 3739 | value.changeLongRecordMode(false); |
2737 | 3736 | value.ensureFit(oldSize); | 3740 | value.ensureFit(oldSize); |
2738 | 3737 | System.arraycopy(bytes, offset, value.getEncodedBytes(), 0, oldSize); | 3741 | System.arraycopy(bytes, offset, value.getEncodedBytes(), 0, oldSize); |
2739 | 3738 | value.setEncodedSize(oldSize); | 3742 | value.setEncodedSize(oldSize); |
2740 | 3739 | final LongRecordHelper helper = new LongRecordHelper(_persistit, _vol); | 3743 | final LongRecordHelper helper = new LongRecordHelper(_persistit, _vol); |
2741 | 3740 | helper.fetchLongRecord(value, Integer.MAX_VALUE); | 3744 | helper.fetchLongRecord(value, Integer.MAX_VALUE); |
2744 | 3741 | byte[] rawBytes = value.getEncodedBytes(); | 3745 | final byte[] rawBytes = value.getEncodedBytes(); |
2745 | 3742 | int oldLongSize = value.getEncodedSize(); | 3746 | final int oldLongSize = value.getEncodedSize(); |
2746 | 3743 | // TODO - perhaps remove. Done as a precaution for now. | 3747 | // TODO - perhaps remove. Done as a precaution for now. |
2747 | 3744 | MVV.verify(rawBytes, 0, oldLongSize); | 3748 | MVV.verify(rawBytes, 0, oldLongSize); |
2750 | 3745 | List<PrunedVersion> provisionalPrunedVersions = new ArrayList<PrunedVersion>(); | 3749 | final List<PrunedVersion> provisionalPrunedVersions = new ArrayList<PrunedVersion>(); |
2751 | 3746 | int newLongSize = MVV.prune(rawBytes, 0, oldLongSize, _persistit.getTransactionIndex(), true, | 3750 | final int newLongSize = MVV.prune(rawBytes, 0, oldLongSize, _persistit.getTransactionIndex(), true, |
2752 | 3747 | provisionalPrunedVersions); | 3751 | provisionalPrunedVersions); |
2753 | 3748 | if (newLongSize == oldLongSize) { | 3752 | if (newLongSize == oldLongSize) { |
2754 | 3749 | // No pruning done. | 3753 | // No pruning done. |
2755 | @@ -3771,6 +3775,7 @@ | |||
2756 | 3771 | getTimestamp(), getGeneration()); | 3775 | getTimestamp(), getGeneration()); |
2757 | 3772 | } | 3776 | } |
2758 | 3773 | 3777 | ||
2759 | 3778 | @Override | ||
2760 | 3774 | public String toString() { | 3779 | public String toString() { |
2761 | 3775 | if (_toStringDebug) { | 3780 | if (_toStringDebug) { |
2762 | 3776 | return toStringDetail(); | 3781 | return toStringDetail(); |
2763 | @@ -3818,7 +3823,7 @@ | |||
2764 | 3818 | } | 3823 | } |
2765 | 3819 | boolean elision = false; | 3824 | boolean elision = false; |
2766 | 3820 | for (int index = 0; index < records.length; index++) { | 3825 | for (int index = 0; index < records.length; index++) { |
2768 | 3821 | RecordInfo r = records[index]; | 3826 | final RecordInfo r = records[index]; |
2769 | 3822 | r.getKeyState().copyTo(key); | 3827 | r.getKeyState().copyTo(key); |
2770 | 3823 | String mark = " "; | 3828 | String mark = " "; |
2771 | 3824 | boolean selected = all | index < contextLines || index >= records.length - contextLines; | 3829 | boolean selected = all | index < contextLines || index >= records.length - contextLines; |
2772 | @@ -3843,16 +3848,16 @@ | |||
2773 | 3843 | r.getValueState().getEncodedBytes().length, Util.abridge(value.toString(), | 3848 | r.getValueState().getEncodedBytes().length, Util.abridge(value.toString(), |
2774 | 3844 | maxValueDisplayLength))); | 3849 | maxValueDisplayLength))); |
2775 | 3845 | } else { | 3850 | } else { |
2779 | 3846 | sb.append(String.format("\n%s %5d: db=%3d ebc=%3d tb=%,5d [%,d]%s->%,d", mark, r | 3851 | sb.append(String.format("\n%s %5d: db=%3d ebc=%3d tb=%,5d [%,d]%s->%,d", mark, |
2780 | 3847 | .getKbOffset(), r.getDb(), r.getEbc(), r.getTbOffset(), r.getKLength(), Util | 3852 | r.getKbOffset(), r.getDb(), r.getEbc(), r.getTbOffset(), r.getKLength(), |
2781 | 3848 | .abridge(key.toString(), maxKeyDisplayLength), r.getPointerValue())); | 3853 | Util.abridge(key.toString(), maxKeyDisplayLength), r.getPointerValue())); |
2782 | 3849 | } | 3854 | } |
2783 | 3850 | } else { | 3855 | } else { |
2784 | 3851 | elision = true; | 3856 | elision = true; |
2785 | 3852 | } | 3857 | } |
2786 | 3853 | 3858 | ||
2787 | 3854 | } | 3859 | } |
2789 | 3855 | } catch (Exception e) { | 3860 | } catch (final Exception e) { |
2790 | 3856 | sb.append(" - " + e); | 3861 | sb.append(" - " + e); |
2791 | 3857 | } | 3862 | } |
2792 | 3858 | } else if (isHeadPage()) { | 3863 | } else if (isHeadPage()) { |
2793 | @@ -3876,7 +3881,7 @@ | |||
2794 | 3876 | } | 3881 | } |
2795 | 3877 | 3882 | ||
2796 | 3878 | String foundAtString(int p) { | 3883 | String foundAtString(int p) { |
2798 | 3879 | StringBuilder sb = new StringBuilder("<"); | 3884 | final StringBuilder sb = new StringBuilder("<"); |
2799 | 3880 | sb.append(p & P_MASK); | 3885 | sb.append(p & P_MASK); |
2800 | 3881 | if ((p & EXACT_MASK) != 0) | 3886 | if ((p & EXACT_MASK) != 0) |
2801 | 3882 | sb.append(":exact"); | 3887 | sb.append(":exact"); |
2802 | @@ -3892,7 +3897,7 @@ | |||
2803 | 3892 | else if (p + KEYBLOCK_LENGTH == _keyBlockEnd) | 3897 | else if (p + KEYBLOCK_LENGTH == _keyBlockEnd) |
2804 | 3893 | sb.append(":end"); | 3898 | sb.append(":end"); |
2805 | 3894 | else { | 3899 | else { |
2807 | 3895 | int kbData = getInt(p); | 3900 | final int kbData = getInt(p); |
2808 | 3896 | sb.append(":ebc=" + decodeKeyBlockEbc(kbData)); | 3901 | sb.append(":ebc=" + decodeKeyBlockEbc(kbData)); |
2809 | 3897 | sb.append(":db=" + decodeKeyBlockDb(kbData)); | 3902 | sb.append(":db=" + decodeKeyBlockDb(kbData)); |
2810 | 3898 | sb.append(":tail=" + decodeKeyBlockTail(kbData)); | 3903 | sb.append(":tail=" + decodeKeyBlockTail(kbData)); |
2811 | @@ -3908,23 +3913,23 @@ | |||
2812 | 3908 | ManagementImpl.RecordInfo[] result = null; | 3913 | ManagementImpl.RecordInfo[] result = null; |
2813 | 3909 | 3914 | ||
2814 | 3910 | if (isIndexPage() || isDataPage()) { | 3915 | if (isIndexPage() || isDataPage()) { |
2817 | 3911 | Key key = new Key(_persistit); | 3916 | final Key key = new Key(_persistit); |
2818 | 3912 | Value value = new Value(_persistit); | 3917 | final Value value = new Value(_persistit); |
2819 | 3913 | 3918 | ||
2821 | 3914 | int count = (_keyBlockEnd - KEY_BLOCK_START) / KEYBLOCK_LENGTH; | 3919 | final int count = (_keyBlockEnd - KEY_BLOCK_START) / KEYBLOCK_LENGTH; |
2822 | 3915 | result = new ManagementImpl.RecordInfo[count]; | 3920 | result = new ManagementImpl.RecordInfo[count]; |
2823 | 3916 | int n = 0; | 3921 | int n = 0; |
2824 | 3917 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { | 3922 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { |
2833 | 3918 | int kbData = getInt(p); | 3923 | final int kbData = getInt(p); |
2834 | 3919 | int db = decodeKeyBlockDb(kbData); | 3924 | final int db = decodeKeyBlockDb(kbData); |
2835 | 3920 | int ebc = decodeKeyBlockEbc(kbData); | 3925 | final int ebc = decodeKeyBlockEbc(kbData); |
2836 | 3921 | int tail = decodeKeyBlockTail(kbData); | 3926 | final int tail = decodeKeyBlockTail(kbData); |
2837 | 3922 | int tbData = tail != 0 ? getInt(tail) : 0; | 3927 | final int tbData = tail != 0 ? getInt(tail) : 0; |
2838 | 3923 | int size = decodeTailBlockSize(tbData); | 3928 | final int size = decodeTailBlockSize(tbData); |
2839 | 3924 | int klength = decodeTailBlockKLength(tbData); | 3929 | final int klength = decodeTailBlockKLength(tbData); |
2840 | 3925 | boolean inUse = decodeTailBlockInUse(tbData); | 3930 | final boolean inUse = decodeTailBlockInUse(tbData); |
2841 | 3926 | 3931 | ||
2843 | 3927 | ManagementImpl.RecordInfo rec = new ManagementImpl.RecordInfo(); | 3932 | final ManagementImpl.RecordInfo rec = new ManagementImpl.RecordInfo(); |
2844 | 3928 | rec._kbOffset = p; | 3933 | rec._kbOffset = p; |
2845 | 3929 | rec._tbOffset = tail; | 3934 | rec._tbOffset = tail; |
2846 | 3930 | rec._ebc = ebc; | 3935 | rec._ebc = ebc; |
2847 | @@ -3933,7 +3938,7 @@ | |||
2848 | 3933 | rec._size = size; | 3938 | rec._size = size; |
2849 | 3934 | rec._inUse = inUse; | 3939 | rec._inUse = inUse; |
2850 | 3935 | 3940 | ||
2852 | 3936 | byte[] kbytes = key.getEncodedBytes(); | 3941 | final byte[] kbytes = key.getEncodedBytes(); |
2853 | 3937 | kbytes[ebc] = (byte) db; | 3942 | kbytes[ebc] = (byte) db; |
2854 | 3938 | System.arraycopy(_bytes, tail + _tailHeaderSize, kbytes, ebc + 1, klength); | 3943 | System.arraycopy(_bytes, tail + _tailHeaderSize, kbytes, ebc + 1, klength); |
2855 | 3939 | key.setEncodedSize(ebc + 1 + klength); | 3944 | key.setEncodedSize(ebc + 1 + klength); |
2856 | @@ -3956,11 +3961,11 @@ | |||
2857 | 3956 | result[n++] = rec; | 3961 | result[n++] = rec; |
2858 | 3957 | } | 3962 | } |
2859 | 3958 | } else if (isGarbagePage()) { | 3963 | } else if (isGarbagePage()) { |
2861 | 3959 | int count = (_bufferSize - _alloc) / GARBAGE_BLOCK_SIZE; | 3964 | final int count = (_bufferSize - _alloc) / GARBAGE_BLOCK_SIZE; |
2862 | 3960 | result = new ManagementImpl.RecordInfo[count]; | 3965 | result = new ManagementImpl.RecordInfo[count]; |
2863 | 3961 | int n = 0; | 3966 | int n = 0; |
2864 | 3962 | for (int p = _alloc; p < _bufferSize; p += GARBAGE_BLOCK_SIZE) { | 3967 | for (int p = _alloc; p < _bufferSize; p += GARBAGE_BLOCK_SIZE) { |
2866 | 3963 | ManagementImpl.RecordInfo rec = new ManagementImpl.RecordInfo(); | 3968 | final ManagementImpl.RecordInfo rec = new ManagementImpl.RecordInfo(); |
2867 | 3964 | rec._tbOffset = p; | 3969 | rec._tbOffset = p; |
2868 | 3965 | rec._garbageStatus = getInt(p + GARBAGE_BLOCK_STATUS); | 3970 | rec._garbageStatus = getInt(p + GARBAGE_BLOCK_STATUS); |
2869 | 3966 | rec._garbageLeftPage = getLong(p + GARBAGE_BLOCK_LEFT_PAGE); | 3971 | rec._garbageLeftPage = getLong(p + GARBAGE_BLOCK_LEFT_PAGE); |
2870 | @@ -3973,12 +3978,12 @@ | |||
2871 | 3973 | 3978 | ||
2872 | 3974 | void assertVerify() { | 3979 | void assertVerify() { |
2873 | 3975 | if (Debug.VERIFY_PAGES) { | 3980 | if (Debug.VERIFY_PAGES) { |
2875 | 3976 | Exception verifyException = verify(null, null); | 3981 | final Exception verifyException = verify(null, null); |
2876 | 3977 | Debug.$assert1.t(verifyException == null); | 3982 | Debug.$assert1.t(verifyException == null); |
2877 | 3978 | } | 3983 | } |
2878 | 3979 | } | 3984 | } |
2879 | 3980 | 3985 | ||
2881 | 3981 | boolean addGarbageChain(long left, long right, long expectedCount) { | 3986 | boolean addGarbageChain(final long left, final long right, final long expectedCount) { |
2882 | 3982 | Debug.$assert0.t(left > 0 && left <= MAX_VALID_PAGE_ADDR && left != _page && right != _page && isGarbagePage()); | 3987 | Debug.$assert0.t(left > 0 && left <= MAX_VALID_PAGE_ADDR && left != _page && right != _page && isGarbagePage()); |
2883 | 3983 | 3988 | ||
2884 | 3984 | if (_alloc - GARBAGE_BLOCK_SIZE < _keyBlockEnd) { | 3989 | if (_alloc - GARBAGE_BLOCK_SIZE < _keyBlockEnd) { |
2885 | @@ -4006,7 +4011,7 @@ | |||
2886 | 4006 | Debug.$assert0.t(isGarbagePage()); | 4011 | Debug.$assert0.t(isGarbagePage()); |
2887 | 4007 | if (_alloc + GARBAGE_BLOCK_SIZE > _bufferSize) | 4012 | if (_alloc + GARBAGE_BLOCK_SIZE > _bufferSize) |
2888 | 4008 | return -1; | 4013 | return -1; |
2890 | 4009 | long page = getLong(_alloc + GARBAGE_BLOCK_LEFT_PAGE); | 4014 | final long page = getLong(_alloc + GARBAGE_BLOCK_LEFT_PAGE); |
2891 | 4010 | Debug.$assert0.t(page > 0 && page <= MAX_VALID_PAGE_ADDR && page != _page); | 4015 | Debug.$assert0.t(page > 0 && page <= MAX_VALID_PAGE_ADDR && page != _page); |
2892 | 4011 | return page; | 4016 | return page; |
2893 | 4012 | } | 4017 | } |
2894 | @@ -4019,13 +4024,13 @@ | |||
2895 | 4019 | return getLong(_alloc + GARBAGE_BLOCK_RIGHT_PAGE); | 4024 | return getLong(_alloc + GARBAGE_BLOCK_RIGHT_PAGE); |
2896 | 4020 | } | 4025 | } |
2897 | 4021 | 4026 | ||
2900 | 4022 | long getGarbageChainLeftPage(int p) { | 4027 | long getGarbageChainLeftPage(final int p) { |
2901 | 4023 | long page = getLong(p + GARBAGE_BLOCK_LEFT_PAGE); | 4028 | final long page = getLong(p + GARBAGE_BLOCK_LEFT_PAGE); |
2902 | 4024 | Debug.$assert1.t(page > 0 && page <= MAX_VALID_PAGE_ADDR && page != _page); | 4029 | Debug.$assert1.t(page > 0 && page <= MAX_VALID_PAGE_ADDR && page != _page); |
2903 | 4025 | return page; | 4030 | return page; |
2904 | 4026 | } | 4031 | } |
2905 | 4027 | 4032 | ||
2907 | 4028 | long getGarbageChainRightPage(int p) { | 4033 | long getGarbageChainRightPage(final int p) { |
2908 | 4029 | return getLong(p + GARBAGE_BLOCK_RIGHT_PAGE); | 4034 | return getLong(p + GARBAGE_BLOCK_RIGHT_PAGE); |
2909 | 4030 | } | 4035 | } |
2910 | 4031 | 4036 | ||
2911 | @@ -4036,18 +4041,18 @@ | |||
2912 | 4036 | bumpGeneration(); | 4041 | bumpGeneration(); |
2913 | 4037 | } | 4042 | } |
2914 | 4038 | 4043 | ||
2916 | 4039 | void setGarbageLeftPage(long left) { | 4044 | void setGarbageLeftPage(final long left) { |
2917 | 4040 | Debug.$assert1.t(isMine() && isGarbagePage() && left > 0 && left <= MAX_VALID_PAGE_ADDR && left != _page | 4045 | Debug.$assert1.t(isMine() && isGarbagePage() && left > 0 && left <= MAX_VALID_PAGE_ADDR && left != _page |
2918 | 4041 | && _alloc + GARBAGE_BLOCK_SIZE <= _bufferSize && _alloc >= _keyBlockEnd); | 4046 | && _alloc + GARBAGE_BLOCK_SIZE <= _bufferSize && _alloc >= _keyBlockEnd); |
2919 | 4042 | putLong(_alloc + GARBAGE_BLOCK_LEFT_PAGE, left); | 4047 | putLong(_alloc + GARBAGE_BLOCK_LEFT_PAGE, left); |
2920 | 4043 | bumpGeneration(); | 4048 | bumpGeneration(); |
2921 | 4044 | } | 4049 | } |
2922 | 4045 | 4050 | ||
2924 | 4046 | void populateInfo(ManagementImpl.BufferInfo info) { | 4051 | void populateInfo(final ManagementImpl.BufferInfo info) { |
2925 | 4047 | info.poolIndex = _poolIndex; | 4052 | info.poolIndex = _poolIndex; |
2926 | 4048 | info.pageAddress = _page; | 4053 | info.pageAddress = _page; |
2927 | 4049 | info.rightSiblingAddress = _rightSibling; | 4054 | info.rightSiblingAddress = _rightSibling; |
2929 | 4050 | Volume vol = _vol; | 4055 | final Volume vol = _vol; |
2930 | 4051 | if (vol != null) { | 4056 | if (vol != null) { |
2931 | 4052 | info.volumeName = vol.getPath(); | 4057 | info.volumeName = vol.getPath(); |
2932 | 4053 | } else { | 4058 | } else { |
2933 | @@ -4064,7 +4069,7 @@ | |||
2934 | 4064 | info.timestamp = _timestamp; | 4069 | info.timestamp = _timestamp; |
2935 | 4065 | info.status = getStatus(); | 4070 | info.status = getStatus(); |
2936 | 4066 | info.statusName = getStatusCode(); | 4071 | info.statusName = getStatusCode(); |
2938 | 4067 | Thread writerThread = getWriterThread(); | 4072 | final Thread writerThread = getWriterThread(); |
2939 | 4068 | if (writerThread != null) { | 4073 | if (writerThread != null) { |
2940 | 4069 | info.writerThreadName = writerThread.getName(); | 4074 | info.writerThreadName = writerThread.getName(); |
2941 | 4070 | } else { | 4075 | } else { |
2942 | @@ -4075,10 +4080,10 @@ | |||
2943 | 4075 | 4080 | ||
2944 | 4076 | void enqueuePruningAction(final int treeHandle) { | 4081 | void enqueuePruningAction(final int treeHandle) { |
2945 | 4077 | if (_mvvCount > 0) { | 4082 | if (_mvvCount > 0) { |
2947 | 4078 | long delay = _persistit.getCleanupManager().getMinimumPruningDelay(); | 4083 | final long delay = _persistit.getCleanupManager().getMinimumPruningDelay(); |
2948 | 4079 | if (delay > 0) { | 4084 | if (delay > 0) { |
2951 | 4080 | long last = _lastPrunedTime; | 4085 | final long last = _lastPrunedTime; |
2952 | 4081 | long now = System.currentTimeMillis(); | 4086 | final long now = System.currentTimeMillis(); |
2953 | 4082 | if (now - last > delay) { | 4087 | if (now - last > delay) { |
2954 | 4083 | _lastPrunedTime = now; | 4088 | _lastPrunedTime = now; |
2955 | 4084 | _persistit.getCleanupManager().offer( | 4089 | _persistit.getCleanupManager().offer( |
2956 | @@ -4105,9 +4110,9 @@ | |||
2957 | 4105 | * writes an IV record. | 4110 | * writes an IV record. |
2958 | 4106 | * @throws Exception | 4111 | * @throws Exception |
2959 | 4107 | */ | 4112 | */ |
2961 | 4108 | void dump(final ByteBuffer bb, final boolean secure, boolean verbose, final Set<Volume> identifiedVolumes) | 4113 | void dump(final ByteBuffer bb, final boolean secure, final boolean verbose, final Set<Volume> identifiedVolumes) |
2962 | 4109 | throws Exception { | 4114 | throws Exception { |
2964 | 4110 | byte[] bytes = new byte[_bufferSize]; | 4115 | final byte[] bytes = new byte[_bufferSize]; |
2965 | 4111 | int type; | 4116 | int type; |
2966 | 4112 | int keyBlockEnd; | 4117 | int keyBlockEnd; |
2967 | 4113 | int alloc; | 4118 | int alloc; |
2968 | @@ -4120,7 +4125,7 @@ | |||
2969 | 4120 | /* | 4125 | /* |
2970 | 4121 | * Copy all the information needed quickly and then release the buffer. | 4126 | * Copy all the information needed quickly and then release the buffer. |
2971 | 4122 | */ | 4127 | */ |
2973 | 4123 | boolean claimed = claim(false, Persistit.SHORT_DELAY); | 4128 | final boolean claimed = claim(false, Persistit.SHORT_DELAY); |
2974 | 4124 | try { | 4129 | try { |
2975 | 4125 | bufferSize = _bufferSize; | 4130 | bufferSize = _bufferSize; |
2976 | 4126 | type = _type; | 4131 | type = _type; |
2977 | @@ -4138,12 +4143,12 @@ | |||
2978 | 4138 | } | 4143 | } |
2979 | 4139 | } | 4144 | } |
2980 | 4140 | 4145 | ||
2982 | 4141 | String toString = toString(); | 4146 | final String toString = toString(); |
2983 | 4142 | if (verbose) { | 4147 | if (verbose) { |
2984 | 4143 | System.out.println(toString); | 4148 | System.out.println(toString); |
2985 | 4144 | } | 4149 | } |
2986 | 4145 | 4150 | ||
2988 | 4146 | int volumeHandle = volume == null ? 0 : volume.getHandle(); | 4151 | final int volumeHandle = volume == null ? 0 : volume.getHandle(); |
2989 | 4147 | if (volume != null && !identifiedVolumes.contains(volume)) { | 4152 | if (volume != null && !identifiedVolumes.contains(volume)) { |
2990 | 4148 | IV.putType(bb); | 4153 | IV.putType(bb); |
2991 | 4149 | IV.putHandle(bb, volumeHandle); | 4154 | IV.putHandle(bb, volumeHandle); |
2992 | @@ -4154,9 +4159,9 @@ | |||
2993 | 4154 | identifiedVolumes.add(volume); | 4159 | identifiedVolumes.add(volume); |
2994 | 4155 | } | 4160 | } |
2995 | 4156 | 4161 | ||
2999 | 4157 | boolean isDataPage = type == PAGE_TYPE_DATA; | 4162 | final boolean isDataPage = type == PAGE_TYPE_DATA; |
3000 | 4158 | boolean isIndexPage = type >= PAGE_TYPE_INDEX_MIN && type <= PAGE_TYPE_INDEX_MAX; | 4163 | final boolean isIndexPage = type >= PAGE_TYPE_INDEX_MIN && type <= PAGE_TYPE_INDEX_MAX; |
3001 | 4159 | boolean isLongRecordPage = type == PAGE_TYPE_LONG_RECORD; | 4164 | final boolean isLongRecordPage = type == PAGE_TYPE_LONG_RECORD; |
3002 | 4160 | 4165 | ||
3003 | 4161 | /* | 4166 | /* |
3004 | 4162 | * Following is equivalent to the save method, except written to the | 4167 | * Following is equivalent to the save method, except written to the |
3005 | @@ -4187,7 +4192,7 @@ | |||
3006 | 4187 | } else if (secure && isLongRecordPage) { | 4192 | } else if (secure && isLongRecordPage) { |
3007 | 4188 | left = KEY_BLOCK_START; | 4193 | left = KEY_BLOCK_START; |
3008 | 4189 | } | 4194 | } |
3010 | 4190 | int recordSize = PA.OVERHEAD + left + right; | 4195 | final int recordSize = PA.OVERHEAD + left + right; |
3011 | 4191 | PA.putLength(bb, recordSize); | 4196 | PA.putLength(bb, recordSize); |
3012 | 4192 | PA.putType(bb); | 4197 | PA.putType(bb); |
3013 | 4193 | PA.putVolumeHandle(bb, volumeHandle); | 4198 | PA.putVolumeHandle(bb, volumeHandle); |
3014 | @@ -4207,7 +4212,7 @@ | |||
3015 | 4207 | * @param bytes | 4212 | * @param bytes |
3016 | 4208 | * buffer image | 4213 | * buffer image |
3017 | 4209 | */ | 4214 | */ |
3019 | 4210 | private void dumpSecureOverwriteValues(byte[] bytes) { | 4215 | private void dumpSecureOverwriteValues(final byte[] bytes) { |
3020 | 4211 | if (bytes[0] != PAGE_TYPE_DATA) { | 4216 | if (bytes[0] != PAGE_TYPE_DATA) { |
3021 | 4212 | return; | 4217 | return; |
3022 | 4213 | } | 4218 | } |
3023 | @@ -4216,12 +4221,12 @@ | |||
3024 | 4216 | * overwrite values. | 4221 | * overwrite values. |
3025 | 4217 | */ | 4222 | */ |
3026 | 4218 | for (int p = KEY_BLOCK_START; p < Util.getInt(bytes, KEY_BLOCK_END_OFFSET); p += KEYBLOCK_LENGTH) { | 4223 | for (int p = KEY_BLOCK_START; p < Util.getInt(bytes, KEY_BLOCK_END_OFFSET); p += KEYBLOCK_LENGTH) { |
3029 | 4219 | int kbData = Util.getInt(bytes, p); | 4224 | final int kbData = Util.getInt(bytes, p); |
3030 | 4220 | int db = decodeKeyBlockDb(kbData); | 4225 | final int db = decodeKeyBlockDb(kbData); |
3031 | 4221 | if (db == 0 && p == KEY_BLOCK_START) { | 4226 | if (db == 0 && p == KEY_BLOCK_START) { |
3032 | 4222 | continue; | 4227 | continue; |
3033 | 4223 | } else if (db == Key.TYPE_STRING) { | 4228 | } else if (db == Key.TYPE_STRING) { |
3035 | 4224 | int tail = decodeKeyBlockTail(kbData); | 4229 | final int tail = decodeKeyBlockTail(kbData); |
3036 | 4225 | if (bytes[tail + TAILBLOCK_HDR_SIZE_DATA] == '_') { | 4230 | if (bytes[tail + TAILBLOCK_HDR_SIZE_DATA] == '_') { |
3037 | 4226 | // Probably a system key - don't overwrite values | 4231 | // Probably a system key - don't overwrite values |
3038 | 4227 | return; | 4232 | return; |
3039 | @@ -4235,9 +4240,9 @@ | |||
3040 | 4235 | 4240 | ||
3041 | 4236 | int tail = Util.getChar(bytes, FREE_OFFSET); | 4241 | int tail = Util.getChar(bytes, FREE_OFFSET); |
3042 | 4237 | for (; tail < bytes.length;) { | 4242 | for (; tail < bytes.length;) { |
3046 | 4238 | int tbData = Util.getInt(bytes, tail); | 4243 | final int tbData = Util.getInt(bytes, tail); |
3047 | 4239 | int tbSize = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; | 4244 | final int tbSize = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
3048 | 4240 | int tbKLength = decodeTailBlockKLength(tbData); | 4245 | final int tbKLength = decodeTailBlockKLength(tbData); |
3049 | 4241 | // | 4246 | // |
3050 | 4242 | // If the tbSize field is corrupt then just dump the | 4247 | // If the tbSize field is corrupt then just dump the |
3051 | 4243 | // remainder of the buffer | 4248 | // remainder of the buffer |
3052 | @@ -4250,7 +4255,7 @@ | |||
3053 | 4250 | // Otherwise, dump just the portion of the tailblock we | 4255 | // Otherwise, dump just the portion of the tailblock we |
3054 | 4251 | // need for analysis and fill the rest with 'x's. | 4256 | // need for analysis and fill the rest with 'x's. |
3055 | 4252 | // | 4257 | // |
3057 | 4253 | boolean tbInUse = decodeTailBlockInUse(tbData); | 4258 | final boolean tbInUse = decodeTailBlockInUse(tbData); |
3058 | 4254 | // Number of bytes we need to dump | 4259 | // Number of bytes we need to dump |
3059 | 4255 | int keep; | 4260 | int keep; |
3060 | 4256 | if (tbInUse) { | 4261 | if (tbInUse) { |
3061 | @@ -4272,7 +4277,8 @@ | |||
3062 | 4272 | } | 4277 | } |
3063 | 4273 | } | 4278 | } |
3064 | 4274 | 4279 | ||
3066 | 4275 | static void deallocatePrunedVersions(Persistit persistit, Volume volume, List<PrunedVersion> prunedVersions) { | 4280 | static void deallocatePrunedVersions(final Persistit persistit, final Volume volume, |
3067 | 4281 | final List<PrunedVersion> prunedVersions) { | ||
3068 | 4276 | for (final PrunedVersion pv : prunedVersions) { | 4282 | for (final PrunedVersion pv : prunedVersions) { |
3069 | 4277 | final TransactionStatus ts = persistit.getTransactionIndex().getStatus(pv.getTs()); | 4283 | final TransactionStatus ts = persistit.getTransactionIndex().getStatus(pv.getTs()); |
3070 | 4278 | if (ts != null && ts.getTc() == TransactionStatus.ABORTED) { | 4284 | if (ts != null && ts.getTc() == TransactionStatus.ABORTED) { |
3071 | @@ -4281,7 +4287,7 @@ | |||
3072 | 4281 | if (pv.getLongRecordPage() != 0) { | 4287 | if (pv.getLongRecordPage() != 0) { |
3073 | 4282 | try { | 4288 | try { |
3074 | 4283 | volume.getStructure().deallocateGarbageChain(pv.getLongRecordPage(), 0); | 4289 | volume.getStructure().deallocateGarbageChain(pv.getLongRecordPage(), 0); |
3076 | 4284 | } catch (PersistitException e) { | 4290 | } catch (final PersistitException e) { |
3077 | 4285 | persistit.getLogBase().pruneException.log(e, ts); | 4291 | persistit.getLogBase().pruneException.log(e, ts); |
3078 | 4286 | } | 4292 | } |
3079 | 4287 | } | 4293 | } |
3080 | @@ -4289,20 +4295,20 @@ | |||
3081 | 4289 | prunedVersions.clear(); | 4295 | prunedVersions.clear(); |
3082 | 4290 | } | 4296 | } |
3083 | 4291 | 4297 | ||
3085 | 4292 | static boolean isLongRecord(byte[] bytes, int offset, int length) { | 4298 | static boolean isLongRecord(final byte[] bytes, final int offset, final int length) { |
3086 | 4293 | return (length > 0) && ((bytes[offset] & 0xFF) == LONGREC_TYPE); | 4299 | return (length > 0) && ((bytes[offset] & 0xFF) == LONGREC_TYPE); |
3087 | 4294 | } | 4300 | } |
3088 | 4295 | 4301 | ||
3090 | 4296 | static boolean isLongMVV(byte[] bytes, int offset, int length) { | 4302 | static boolean isLongMVV(final byte[] bytes, final int offset, final int length) { |
3091 | 4297 | return isLongRecord(bytes, offset, length) && (length > LONGREC_PREFIX_OFFSET) | 4303 | return isLongRecord(bytes, offset, length) && (length > LONGREC_PREFIX_OFFSET) |
3092 | 4298 | && MVV.isArrayMVV(bytes, offset + LONGREC_PREFIX_OFFSET, length - LONGREC_PREFIX_OFFSET); | 4304 | && MVV.isArrayMVV(bytes, offset + LONGREC_PREFIX_OFFSET, length - LONGREC_PREFIX_OFFSET); |
3093 | 4299 | } | 4305 | } |
3094 | 4300 | 4306 | ||
3096 | 4301 | static boolean isValueMVV(byte[] bytes, int offset, int length) { | 4307 | static boolean isValueMVV(final byte[] bytes, final int offset, final int length) { |
3097 | 4302 | return MVV.isArrayMVV(bytes, offset, length) || isLongMVV(bytes, offset, length); | 4308 | return MVV.isArrayMVV(bytes, offset, length) || isLongMVV(bytes, offset, length); |
3098 | 4303 | } | 4309 | } |
3099 | 4304 | 4310 | ||
3101 | 4305 | private void incCountIfMvv(byte[] bytes, int offset, int length) { | 4311 | private void incCountIfMvv(final byte[] bytes, final int offset, final int length) { |
3102 | 4306 | if (isValueMVV(bytes, offset, length)) { | 4312 | if (isValueMVV(bytes, offset, length)) { |
3103 | 4307 | ++_mvvCount; | 4313 | ++_mvvCount; |
3104 | 4308 | } | 4314 | } |
3105 | 4309 | 4315 | ||
3106 | === modified file 'src/main/java/com/persistit/BufferPool.java' | |||
3107 | --- src/main/java/com/persistit/BufferPool.java 2012-08-07 21:11:28 +0000 | |||
3108 | +++ src/main/java/com/persistit/BufferPool.java 2012-08-24 18:20:24 +0000 | |||
3109 | @@ -15,7 +15,13 @@ | |||
3110 | 15 | 15 | ||
3111 | 16 | package com.persistit; | 16 | package com.persistit; |
3112 | 17 | 17 | ||
3113 | 18 | import java.io.BufferedReader; | ||
3114 | 19 | import java.io.BufferedWriter; | ||
3115 | 18 | import java.io.DataOutputStream; | 20 | import java.io.DataOutputStream; |
3116 | 21 | import java.io.File; | ||
3117 | 22 | import java.io.FileReader; | ||
3118 | 23 | import java.io.FileWriter; | ||
3119 | 24 | import java.io.IOException; | ||
3120 | 19 | import java.nio.ByteBuffer; | 25 | import java.nio.ByteBuffer; |
3121 | 20 | import java.util.Arrays; | 26 | import java.util.Arrays; |
3122 | 21 | import java.util.HashSet; | 27 | import java.util.HashSet; |
3123 | @@ -36,7 +42,6 @@ | |||
3124 | 36 | import com.persistit.exception.VolumeClosedException; | 42 | import com.persistit.exception.VolumeClosedException; |
3125 | 37 | import com.persistit.util.Debug; | 43 | import com.persistit.util.Debug; |
3126 | 38 | import com.persistit.util.Util; | 44 | import com.persistit.util.Util; |
3127 | 39 | import java.io.*; | ||
3128 | 40 | 45 | ||
3129 | 41 | /** | 46 | /** |
3130 | 42 | * A pool of {@link Buffer} objects, maintained on various lists that permit | 47 | * A pool of {@link Buffer} objects, maintained on various lists that permit |
3131 | @@ -52,7 +57,7 @@ | |||
3132 | 52 | private final static long DEFAULT_WRITER_POLL_INTERVAL = 5000; | 57 | private final static long DEFAULT_WRITER_POLL_INTERVAL = 5000; |
3133 | 53 | 58 | ||
3134 | 54 | private final static int PAGE_WRITER_TRANCHE_SIZE = 5000; | 59 | private final static int PAGE_WRITER_TRANCHE_SIZE = 5000; |
3136 | 55 | 60 | ||
3137 | 56 | /** | 61 | /** |
3138 | 57 | * Sleep time when buffers are exhausted | 62 | * Sleep time when buffers are exhausted |
3139 | 58 | */ | 63 | */ |
3140 | @@ -148,7 +153,7 @@ | |||
3141 | 148 | /** | 153 | /** |
3142 | 149 | * Count of newly created pages | 154 | * Count of newly created pages |
3143 | 150 | */ | 155 | */ |
3145 | 151 | private AtomicLong _newCounter = new AtomicLong(); | 156 | private final AtomicLong _newCounter = new AtomicLong(); |
3146 | 152 | 157 | ||
3147 | 153 | /** | 158 | /** |
3148 | 154 | * Count of valid buffers evicted to make room for another page. | 159 | * Count of valid buffers evicted to make room for another page. |
3149 | @@ -188,7 +193,7 @@ | |||
3150 | 188 | * Timestamp to which all dirty pages should be written. PAGE_WRITER writes | 193 | * Timestamp to which all dirty pages should be written. PAGE_WRITER writes |
3151 | 189 | * any page with a lower update timestamp regardless of urgency. | 194 | * any page with a lower update timestamp regardless of urgency. |
3152 | 190 | */ | 195 | */ |
3154 | 191 | private AtomicLong _flushTimestamp = new AtomicLong(); | 196 | private final AtomicLong _flushTimestamp = new AtomicLong(); |
3155 | 192 | 197 | ||
3156 | 193 | /** | 198 | /** |
3157 | 194 | * Polling interval for PageWriter | 199 | * Polling interval for PageWriter |
3158 | @@ -196,24 +201,24 @@ | |||
3159 | 196 | private volatile long _writerPollInterval = DEFAULT_WRITER_POLL_INTERVAL; | 201 | private volatile long _writerPollInterval = DEFAULT_WRITER_POLL_INTERVAL; |
3160 | 197 | 202 | ||
3161 | 198 | private volatile int _pageWriterTrancheSize = PAGE_WRITER_TRANCHE_SIZE; | 203 | private volatile int _pageWriterTrancheSize = PAGE_WRITER_TRANCHE_SIZE; |
3163 | 199 | 204 | ||
3164 | 200 | /** | 205 | /** |
3165 | 201 | * Polling interval for PageCacher | 206 | * Polling interval for PageCacher |
3166 | 202 | */ | 207 | */ |
3167 | 203 | private volatile long _cacherPollInterval; | 208 | private volatile long _cacherPollInterval; |
3169 | 204 | 209 | ||
3170 | 205 | /** | 210 | /** |
3171 | 206 | * The PAGE_WRITER IOTaskRunnable | 211 | * The PAGE_WRITER IOTaskRunnable |
3172 | 207 | */ | 212 | */ |
3173 | 208 | private PageWriter _writer; | 213 | private PageWriter _writer; |
3175 | 209 | 214 | ||
3176 | 210 | /** | 215 | /** |
3177 | 211 | * The PAGE_CACHER IOTaskRunnable | 216 | * The PAGE_CACHER IOTaskRunnable |
3178 | 212 | */ | 217 | */ |
3179 | 213 | private PageCacher _cacher; | 218 | private PageCacher _cacher; |
3181 | 214 | 219 | ||
3182 | 215 | private String _defaultLogPath; | 220 | private String _defaultLogPath; |
3184 | 216 | 221 | ||
3185 | 217 | /** | 222 | /** |
3186 | 218 | * Construct a BufferPool with the specified count of <code>Buffer</code>s | 223 | * Construct a BufferPool with the specified count of <code>Buffer</code>s |
3187 | 219 | * of the specified size. | 224 | * of the specified size. |
3188 | @@ -223,7 +228,7 @@ | |||
3189 | 223 | * @param size | 228 | * @param size |
3190 | 224 | * The size (in bytes) of each buffer | 229 | * The size (in bytes) of each buffer |
3191 | 225 | */ | 230 | */ |
3193 | 226 | BufferPool(int count, int size, Persistit persistit) { | 231 | BufferPool(final int count, final int size, final Persistit persistit) { |
3194 | 227 | _persistit = persistit; | 232 | _persistit = persistit; |
3195 | 228 | if (count < MINIMUM_POOL_COUNT) { | 233 | if (count < MINIMUM_POOL_COUNT) { |
3196 | 229 | throw new IllegalArgumentException("Buffer pool count too small: " + count); | 234 | throw new IllegalArgumentException("Buffer pool count too small: " + count); |
3197 | @@ -250,7 +255,7 @@ | |||
3198 | 250 | _hashTable = new Buffer[_bufferCount * HASH_MULTIPLE]; | 255 | _hashTable = new Buffer[_bufferCount * HASH_MULTIPLE]; |
3199 | 251 | _hashLocks = new ReentrantLock[HASH_LOCKS]; | 256 | _hashLocks = new ReentrantLock[HASH_LOCKS]; |
3200 | 252 | _maxKeys = (_bufferSize - Buffer.HEADER_SIZE) / Buffer.MAX_KEY_RATIO; | 257 | _maxKeys = (_bufferSize - Buffer.HEADER_SIZE) / Buffer.MAX_KEY_RATIO; |
3202 | 253 | 258 | ||
3203 | 254 | for (int index = 0; index < HASH_LOCKS; index++) { | 259 | for (int index = 0; index < HASH_LOCKS; index++) { |
3204 | 255 | _hashLocks[index] = new ReentrantLock(); | 260 | _hashLocks[index] = new ReentrantLock(); |
3205 | 256 | } | 261 | } |
3206 | @@ -263,11 +268,11 @@ | |||
3207 | 263 | byte[] reserve = new byte[1024 * 1024]; | 268 | byte[] reserve = new byte[1024 * 1024]; |
3208 | 264 | try { | 269 | try { |
3209 | 265 | for (int index = 0; index < _bufferCount; index++) { | 270 | for (int index = 0; index < _bufferCount; index++) { |
3211 | 266 | Buffer buffer = new Buffer(size, index, this, _persistit); | 271 | final Buffer buffer = new Buffer(size, index, this, _persistit); |
3212 | 267 | _buffers[index] = buffer; | 272 | _buffers[index] = buffer; |
3213 | 268 | buffers++; | 273 | buffers++; |
3214 | 269 | } | 274 | } |
3216 | 270 | } catch (OutOfMemoryError e) { | 275 | } catch (final OutOfMemoryError e) { |
3217 | 271 | // | 276 | // |
3218 | 272 | // Note: written this way to try to avoid another OOME. | 277 | // Note: written this way to try to avoid another OOME. |
3219 | 273 | // Do not use String.format here. | 278 | // Do not use String.format here. |
3220 | @@ -286,34 +291,33 @@ | |||
3221 | 286 | _writer = new PageWriter(); | 291 | _writer = new PageWriter(); |
3222 | 287 | _cacher = new PageCacher(); | 292 | _cacher = new PageCacher(); |
3223 | 288 | } | 293 | } |
3227 | 289 | 294 | ||
3228 | 290 | void warmupBufferPool(String pathName, String fname) throws PersistitException { | 295 | void warmupBufferPool(final String pathName, final String fname) throws PersistitException { |
3229 | 291 | File file = new File(pathName, fname + ".log"); | 296 | final File file = new File(pathName, fname + ".log"); |
3230 | 292 | _defaultLogPath = file.getAbsolutePath(); | 297 | _defaultLogPath = file.getAbsolutePath(); |
3232 | 293 | 298 | ||
3233 | 294 | try { | 299 | try { |
3234 | 295 | if (!file.exists()) { | 300 | if (!file.exists()) { |
3236 | 296 | file.createNewFile(); | 301 | file.createNewFile(); |
3237 | 297 | } | 302 | } |
3240 | 298 | 303 | ||
3241 | 299 | BufferedReader reader = new BufferedReader(new FileReader(file)); | 304 | final BufferedReader reader = new BufferedReader(new FileReader(file)); |
3242 | 300 | String currLine; | 305 | String currLine; |
3243 | 301 | while ((currLine = reader.readLine()) != null) { | 306 | while ((currLine = reader.readLine()) != null) { |
3245 | 302 | String[] info = currLine.split(" "); | 307 | final String[] info = currLine.split(" "); |
3246 | 303 | if (info.length == 2) { | 308 | if (info.length == 2) { |
3248 | 304 | Volume vol = _persistit.getVolume(info[1]); | 309 | final Volume vol = _persistit.getVolume(info[1]); |
3249 | 305 | if (vol != null) { | 310 | if (vol != null) { |
3253 | 306 | long page = Long.parseLong(info[0]); | 311 | final long page = Long.parseLong(info[0]); |
3254 | 307 | Buffer buff = get(vol, page, false, true); | 312 | final Buffer buff = get(vol, page, false, true); |
3255 | 308 | buff.release(); | 313 | buff.release(); |
3256 | 309 | } | 314 | } |
3257 | 310 | } | 315 | } |
3258 | 311 | } | 316 | } |
3259 | 312 | reader.close(); | 317 | reader.close(); |
3260 | 313 | _cacherPollInterval = _persistit.getConfiguration().getBufferInventoryPollingInterval(); | 318 | _cacherPollInterval = _persistit.getConfiguration().getBufferInventoryPollingInterval(); |
3261 | 314 | _cacher.start(); | 319 | _cacher.start(); |
3264 | 315 | } | 320 | } catch (final IOException e) { |
3263 | 316 | catch (IOException e) { | ||
3265 | 317 | throw new PersistitException(e); | 321 | throw new PersistitException(e); |
3266 | 318 | } | 322 | } |
3267 | 319 | } | 323 | } |
3268 | @@ -331,8 +335,8 @@ | |||
3269 | 331 | } | 335 | } |
3270 | 332 | 336 | ||
3271 | 333 | /** | 337 | /** |
3274 | 334 | * Abruptly stop (using {@link Thread#stop()}) the writer, cacher, and collector | 338 | * Abruptly stop (using {@link Thread#stop()}) the writer, cacher, and |
3275 | 335 | * threads. This method should be used only by tests. | 339 | * collector threads. This method should be used only by tests. |
3276 | 336 | */ | 340 | */ |
3277 | 337 | void crash() { | 341 | void crash() { |
3278 | 338 | IOTaskRunnable.crash(_writer); | 342 | IOTaskRunnable.crash(_writer); |
3279 | @@ -351,14 +355,14 @@ | |||
3280 | 351 | return _flushTimestamp.get() != 0; | 355 | return _flushTimestamp.get() != 0; |
3281 | 352 | } | 356 | } |
3282 | 353 | 357 | ||
3284 | 354 | int hashIndex(Volume vol, long page) { | 358 | int hashIndex(final Volume vol, final long page) { |
3285 | 355 | return (int) (((page ^ vol.hashCode()) & Integer.MAX_VALUE) % _hashTable.length); | 359 | return (int) (((page ^ vol.hashCode()) & Integer.MAX_VALUE) % _hashTable.length); |
3286 | 356 | } | 360 | } |
3287 | 357 | 361 | ||
3289 | 358 | int countInUse(Volume vol, boolean writer) { | 362 | int countInUse(final Volume vol, final boolean writer) { |
3290 | 359 | int count = 0; | 363 | int count = 0; |
3291 | 360 | for (int i = 0; i < _bufferCount; i++) { | 364 | for (int i = 0; i < _bufferCount; i++) { |
3293 | 361 | Buffer buffer = _buffers[i]; | 365 | final Buffer buffer = _buffers[i]; |
3294 | 362 | if ((vol == null || buffer.getVolume() == vol) | 366 | if ((vol == null || buffer.getVolume() == vol) |
3295 | 363 | && ((buffer.getStatus() & SharedResource.CLAIMED_MASK) != 0 && (!writer || (buffer.getStatus() & SharedResource.WRITER_MASK) != 0))) { | 367 | && ((buffer.getStatus() & SharedResource.CLAIMED_MASK) != 0 && (!writer || (buffer.getStatus() & SharedResource.WRITER_MASK) != 0))) { |
3296 | 364 | count++; | 368 | count++; |
3297 | @@ -367,7 +371,7 @@ | |||
3298 | 367 | return count; | 371 | return count; |
3299 | 368 | } | 372 | } |
3300 | 369 | 373 | ||
3302 | 370 | void populateBufferPoolInfo(ManagementImpl.BufferPoolInfo info) { | 374 | void populateBufferPoolInfo(final ManagementImpl.BufferPoolInfo info) { |
3303 | 371 | info.bufferCount = _bufferCount; | 375 | info.bufferCount = _bufferCount; |
3304 | 372 | info.bufferSize = _bufferSize; | 376 | info.bufferSize = _bufferSize; |
3305 | 373 | info.missCount = _missCounter.get(); | 377 | info.missCount = _missCounter.get(); |
3306 | @@ -383,8 +387,8 @@ | |||
3307 | 383 | int writerClaimedPages = 0; | 387 | int writerClaimedPages = 0; |
3308 | 384 | 388 | ||
3309 | 385 | for (int index = 0; index < _bufferCount; index++) { | 389 | for (int index = 0; index < _bufferCount; index++) { |
3312 | 386 | Buffer buffer = _buffers[index]; | 390 | final Buffer buffer = _buffers[index]; |
3313 | 387 | int status = buffer.getStatus(); | 391 | final int status = buffer.getStatus(); |
3314 | 388 | if ((status & SharedResource.VALID_MASK) != 0) | 392 | if ((status & SharedResource.VALID_MASK) != 0) |
3315 | 389 | validPages++; | 393 | validPages++; |
3316 | 390 | if ((status & SharedResource.WRITER_MASK) != 0) | 394 | if ((status & SharedResource.WRITER_MASK) != 0) |
3317 | @@ -400,12 +404,13 @@ | |||
3318 | 400 | info.updateAcquisitonTime(); | 404 | info.updateAcquisitonTime(); |
3319 | 401 | } | 405 | } |
3320 | 402 | 406 | ||
3322 | 403 | int populateInfo(ManagementImpl.BufferInfo[] array, int traveralType, int includeMask, int excludeMask) { | 407 | int populateInfo(final ManagementImpl.BufferInfo[] array, final int traveralType, final int includeMask, |
3323 | 408 | final int excludeMask) { | ||
3324 | 404 | int index = 0; | 409 | int index = 0; |
3325 | 405 | switch (traveralType) { | 410 | switch (traveralType) { |
3326 | 406 | case 0: | 411 | case 0: |
3327 | 407 | for (int i = 0; i < _bufferCount; i++) { | 412 | for (int i = 0; i < _bufferCount; i++) { |
3329 | 408 | Buffer buffer = _buffers[i]; | 413 | final Buffer buffer = _buffers[i]; |
3330 | 409 | if (selected(buffer, includeMask, excludeMask)) { | 414 | if (selected(buffer, includeMask, excludeMask)) { |
3331 | 410 | populateInfo1(array, index, buffer); | 415 | populateInfo1(array, index, buffer); |
3332 | 411 | index++; | 416 | index++; |
3333 | @@ -420,31 +425,31 @@ | |||
3334 | 420 | return index; | 425 | return index; |
3335 | 421 | } | 426 | } |
3336 | 422 | 427 | ||
3338 | 423 | private static void populateInfo1(ManagementImpl.BufferInfo[] array, int index, Buffer buffer) { | 428 | private static void populateInfo1(final ManagementImpl.BufferInfo[] array, final int index, final Buffer buffer) { |
3339 | 424 | if (index < array.length) { | 429 | if (index < array.length) { |
3340 | 425 | if (array[index] == null) | 430 | if (array[index] == null) |
3341 | 426 | array[index] = new ManagementImpl.BufferInfo(); | 431 | array[index] = new ManagementImpl.BufferInfo(); |
3342 | 427 | buffer.populateInfo(array[index]); | 432 | buffer.populateInfo(array[index]); |
3343 | 428 | } | 433 | } |
3344 | 429 | } | 434 | } |
3346 | 430 | 435 | ||
3347 | 431 | private void populateWarmupFile() throws PersistitException { | 436 | private void populateWarmupFile() throws PersistitException { |
3350 | 432 | File file = new File(_defaultLogPath); | 437 | final File file = new File(_defaultLogPath); |
3351 | 433 | 438 | ||
3352 | 434 | try { | 439 | try { |
3354 | 435 | BufferedWriter writer = new BufferedWriter(new FileWriter(file)); | 440 | final BufferedWriter writer = new BufferedWriter(new FileWriter(file)); |
3355 | 436 | for (int i = 0; i < _buffers.length; ++i) { | 441 | for (int i = 0; i < _buffers.length; ++i) { |
3357 | 437 | Buffer b = _buffers[i]; | 442 | final Buffer b = _buffers[i]; |
3358 | 438 | if (b != null && b.isValid() && !b.isDirty()) { | 443 | if (b != null && b.isValid() && !b.isDirty()) { |
3364 | 439 | long page = b.getPageAddress(); | 444 | final long page = b.getPageAddress(); |
3365 | 440 | Volume volume = b.getVolume(); | 445 | final Volume volume = b.getVolume(); |
3366 | 441 | long page2 = b.getPageAddress(); | 446 | final long page2 = b.getPageAddress(); |
3367 | 442 | Volume volume2 = b.getVolume(); | 447 | final Volume volume2 = b.getVolume(); |
3368 | 443 | 448 | ||
3369 | 444 | // Check if buffer has changed while reading | 449 | // Check if buffer has changed while reading |
3370 | 445 | if (page == page2 && volume == volume2 && volume != null) { | 450 | if (page == page2 && volume == volume2 && volume != null) { |
3373 | 446 | String addr = Long.toString(page); | 451 | final String addr = Long.toString(page); |
3374 | 447 | String vol = volume.getName(); | 452 | final String vol = volume.getName(); |
3375 | 448 | writer.append(addr + " " + vol); | 453 | writer.append(addr + " " + vol); |
3376 | 449 | writer.newLine(); | 454 | writer.newLine(); |
3377 | 450 | writer.flush(); | 455 | writer.flush(); |
3378 | @@ -452,12 +457,12 @@ | |||
3379 | 452 | } | 457 | } |
3380 | 453 | } | 458 | } |
3381 | 454 | writer.close(); | 459 | writer.close(); |
3383 | 455 | } catch (IOException e) { | 460 | } catch (final IOException e) { |
3384 | 456 | throw new PersistitException(e); | 461 | throw new PersistitException(e); |
3385 | 457 | } | 462 | } |
3386 | 458 | } | 463 | } |
3387 | 459 | 464 | ||
3389 | 460 | private boolean selected(Buffer buffer, int includeMask, int excludeMask) { | 465 | private boolean selected(final Buffer buffer, final int includeMask, final int excludeMask) { |
3390 | 461 | return ((includeMask == 0) || (buffer.getStatus() & includeMask) != 0) | 466 | return ((includeMask == 0) || (buffer.getStatus() & includeMask) != 0) |
3391 | 462 | && (buffer.getStatus() & excludeMask) == 0; | 467 | && (buffer.getStatus() & excludeMask) == 0; |
3392 | 463 | } | 468 | } |
3393 | @@ -599,7 +604,7 @@ | |||
3394 | 599 | * The volume | 604 | * The volume |
3395 | 600 | * @throws PersistitInterruptedException | 605 | * @throws PersistitInterruptedException |
3396 | 601 | */ | 606 | */ |
3398 | 602 | boolean invalidate(Volume volume) throws PersistitInterruptedException { | 607 | boolean invalidate(final Volume volume) throws PersistitInterruptedException { |
3399 | 603 | final float ratio = (float) volume.getStorage().getNextAvailablePage() / (float) _bufferCount; | 608 | final float ratio = (float) volume.getStorage().getNextAvailablePage() / (float) _bufferCount; |
3400 | 604 | if (ratio < SMALL_VOLUME_RATIO) { | 609 | if (ratio < SMALL_VOLUME_RATIO) { |
3401 | 605 | return invalidateSmallVolume(volume); | 610 | return invalidateSmallVolume(volume); |
3402 | @@ -612,7 +617,7 @@ | |||
3403 | 612 | boolean result = true; | 617 | boolean result = true; |
3404 | 613 | int markedAvailable = 0; | 618 | int markedAvailable = 0; |
3405 | 614 | for (long page = 1; page < volume.getStorage().getNextAvailablePage(); page++) { | 619 | for (long page = 1; page < volume.getStorage().getNextAvailablePage(); page++) { |
3407 | 615 | int hashIndex = hashIndex(volume, page); | 620 | final int hashIndex = hashIndex(volume, page); |
3408 | 616 | _hashLocks[hashIndex % HASH_LOCKS].lock(); | 621 | _hashLocks[hashIndex % HASH_LOCKS].lock(); |
3409 | 617 | try { | 622 | try { |
3410 | 618 | for (Buffer buffer = _hashTable[hashIndex]; buffer != null; buffer = buffer.getNext()) { | 623 | for (Buffer buffer = _hashTable[hashIndex]; buffer != null; buffer = buffer.getNext()) { |
3411 | @@ -630,9 +635,9 @@ | |||
3412 | 630 | buffer.release(); | 635 | buffer.release(); |
3413 | 631 | } | 636 | } |
3414 | 632 | if (invalidated) { | 637 | if (invalidated) { |
3418 | 633 | int q = buffer.getIndex() / 64; | 638 | final int q = buffer.getIndex() / 64; |
3419 | 634 | int p = buffer.getIndex() % 64; | 639 | final int p = buffer.getIndex() % 64; |
3420 | 635 | long bits = _availablePagesBits.get(q); | 640 | final long bits = _availablePagesBits.get(q); |
3421 | 636 | if (_availablePagesBits.compareAndSet(q, bits, bits | (1L << p))) { | 641 | if (_availablePagesBits.compareAndSet(q, bits, bits | (1L << p))) { |
3422 | 637 | markedAvailable++; | 642 | markedAvailable++; |
3423 | 638 | } | 643 | } |
3424 | @@ -657,7 +662,7 @@ | |||
3425 | 657 | boolean result = true; | 662 | boolean result = true; |
3426 | 658 | int markedAvailable = 0; | 663 | int markedAvailable = 0; |
3427 | 659 | for (int index = 0; index < _bufferCount; index++) { | 664 | for (int index = 0; index < _bufferCount; index++) { |
3429 | 660 | Buffer buffer = _buffers[index]; | 665 | final Buffer buffer = _buffers[index]; |
3430 | 661 | if ((buffer.getVolume() == volume || volume == null) && !buffer.isFixed() && buffer.isValid()) { | 666 | if ((buffer.getVolume() == volume || volume == null) && !buffer.isFixed() && buffer.isValid()) { |
3431 | 662 | if (buffer.claim(true, 0)) { | 667 | if (buffer.claim(true, 0)) { |
3432 | 663 | // re-check after claim | 668 | // re-check after claim |
3433 | @@ -671,9 +676,9 @@ | |||
3434 | 671 | buffer.release(); | 676 | buffer.release(); |
3435 | 672 | } | 677 | } |
3436 | 673 | if (invalidated) { | 678 | if (invalidated) { |
3440 | 674 | int q = buffer.getIndex() / 64; | 679 | final int q = buffer.getIndex() / 64; |
3441 | 675 | int p = buffer.getIndex() % 64; | 680 | final int p = buffer.getIndex() % 64; |
3442 | 676 | long bits = _availablePagesBits.get(q); | 681 | final long bits = _availablePagesBits.get(q); |
3443 | 677 | if (_availablePagesBits.compareAndSet(q, bits, bits | (1L << p))) { | 682 | if (_availablePagesBits.compareAndSet(q, bits, bits | (1L << p))) { |
3444 | 678 | markedAvailable++; | 683 | markedAvailable++; |
3445 | 679 | } | 684 | } |
3446 | @@ -689,29 +694,33 @@ | |||
3447 | 689 | return result; | 694 | return result; |
3448 | 690 | } | 695 | } |
3449 | 691 | 696 | ||
3451 | 692 | private void invalidate(Buffer buffer) { | 697 | private void invalidate(final Buffer buffer) { |
3452 | 693 | Debug.$assert0.t(buffer.isValid() && buffer.isMine()); | 698 | Debug.$assert0.t(buffer.isValid() && buffer.isMine()); |
3453 | 694 | 699 | ||
3454 | 695 | while (!detach(buffer)) { | 700 | while (!detach(buffer)) { |
3455 | 696 | // | 701 | // |
3460 | 697 | // Spin until detach succeeds. Note: this method must not throw an Exception | 702 | // Spin until detach succeeds. Note: this method must not throw an |
3461 | 698 | // because it is called in at at critical time when cleanup must be done. | 703 | // Exception |
3462 | 699 | // It is not possible to lock the hash bucket here due to possible deadlock. | 704 | // because it is called in at at critical time when cleanup must be |
3463 | 700 | // However, the likelihood of a lengthy live-lock is infinitesimal so polling | 705 | // done. |
3464 | 706 | // It is not possible to lock the hash bucket here due to possible | ||
3465 | 707 | // deadlock. | ||
3466 | 708 | // However, the likelihood of a lengthy live-lock is infinitesimal | ||
3467 | 709 | // so polling | ||
3468 | 701 | // is acceptable. | 710 | // is acceptable. |
3469 | 702 | // | 711 | // |
3475 | 703 | try { | 712 | try { |
3476 | 704 | Thread.sleep(1); | 713 | Thread.sleep(1); |
3477 | 705 | } catch (InterruptedException ie) { | 714 | } catch (final InterruptedException ie) { |
3478 | 706 | // ignore | 715 | // ignore |
3479 | 707 | } | 716 | } |
3480 | 708 | } | 717 | } |
3481 | 709 | buffer.clearValid(); | 718 | buffer.clearValid(); |
3482 | 710 | buffer.clearDirty(); | 719 | buffer.clearDirty(); |
3483 | 711 | buffer.setPageAddressAndVolume(0, null); | 720 | buffer.setPageAddressAndVolume(0, null); |
3484 | 712 | } | 721 | } |
3485 | 713 | 722 | ||
3487 | 714 | private boolean detach(Buffer buffer) { | 723 | private boolean detach(final Buffer buffer) { |
3488 | 715 | final int hash = hashIndex(buffer.getVolume(), buffer.getPageAddress()); | 724 | final int hash = hashIndex(buffer.getVolume(), buffer.getPageAddress()); |
3489 | 716 | if (!_hashLocks[hash % HASH_LOCKS].tryLock()) { | 725 | if (!_hashLocks[hash % HASH_LOCKS].tryLock()) { |
3490 | 717 | return false; | 726 | return false; |
3491 | @@ -756,8 +765,9 @@ | |||
3492 | 756 | * @return Buffer The Buffer describing the buffer containing the page. | 765 | * @return Buffer The Buffer describing the buffer containing the page. |
3493 | 757 | * @throws InUseException | 766 | * @throws InUseException |
3494 | 758 | */ | 767 | */ |
3497 | 759 | Buffer get(Volume vol, long page, boolean writer, boolean wantRead) throws PersistitException { | 768 | Buffer get(final Volume vol, final long page, final boolean writer, final boolean wantRead) |
3498 | 760 | int hash = hashIndex(vol, page); | 769 | throws PersistitException { |
3499 | 770 | final int hash = hashIndex(vol, page); | ||
3500 | 761 | Buffer buffer = null; | 771 | Buffer buffer = null; |
3501 | 762 | 772 | ||
3502 | 763 | for (;;) { | 773 | for (;;) { |
3503 | @@ -904,10 +914,10 @@ | |||
3504 | 904 | * @throws RetryException | 914 | * @throws RetryException |
3505 | 905 | * @throws IOException | 915 | * @throws IOException |
3506 | 906 | */ | 916 | */ |
3508 | 907 | public Buffer getBufferCopy(Volume vol, long page) throws InvalidPageAddressException, | 917 | public Buffer getBufferCopy(final Volume vol, final long page) throws InvalidPageAddressException, |
3509 | 908 | InvalidPageStructureException, VolumeClosedException, InUseException, PersistitIOException, | 918 | InvalidPageStructureException, VolumeClosedException, InUseException, PersistitIOException, |
3510 | 909 | PersistitInterruptedException { | 919 | PersistitInterruptedException { |
3512 | 910 | int hash = hashIndex(vol, page); | 920 | final int hash = hashIndex(vol, page); |
3513 | 911 | Buffer buffer = null; | 921 | Buffer buffer = null; |
3514 | 912 | _hashLocks[hash % HASH_LOCKS].lock(); | 922 | _hashLocks[hash % HASH_LOCKS].lock(); |
3515 | 913 | try { | 923 | try { |
3516 | @@ -934,7 +944,7 @@ | |||
3517 | 934 | // Didn't find it in the pool, so we'll read a copy. | 944 | // Didn't find it in the pool, so we'll read a copy. |
3518 | 935 | // | 945 | // |
3519 | 936 | buffer = new Buffer(_bufferSize, -1, this, _persistit); | 946 | buffer = new Buffer(_bufferSize, -1, this, _persistit); |
3521 | 937 | boolean acquired = buffer.claim(true); | 947 | final boolean acquired = buffer.claim(true); |
3522 | 938 | assert acquired : "buffer not unavailable"; | 948 | assert acquired : "buffer not unavailable"; |
3523 | 939 | buffer.load(vol, page); | 949 | buffer.load(vol, page); |
3524 | 940 | buffer.setValid(); | 950 | buffer.setValid(); |
3525 | @@ -968,7 +978,7 @@ | |||
3526 | 968 | // since no valid page will need to be evicted. | 978 | // since no valid page will need to be evicted. |
3527 | 969 | // | 979 | // |
3528 | 970 | if (_availablePages.get()) { | 980 | if (_availablePages.get()) { |
3530 | 971 | int start = (_clock.get() / 64) * 64; | 981 | final int start = (_clock.get() / 64) * 64; |
3531 | 972 | for (int q = start;;) { | 982 | for (int q = start;;) { |
3532 | 973 | q += 64; | 983 | q += 64; |
3533 | 974 | if (q >= _bufferCount) { | 984 | if (q >= _bufferCount) { |
3534 | @@ -1007,12 +1017,12 @@ | |||
3535 | 1007 | // Look for a page to evict. | 1017 | // Look for a page to evict. |
3536 | 1008 | // | 1018 | // |
3537 | 1009 | for (int retry = 0; retry < _bufferCount * 2;) { | 1019 | for (int retry = 0; retry < _bufferCount * 2;) { |
3539 | 1010 | int clock = _clock.get(); | 1020 | final int clock = _clock.get(); |
3540 | 1011 | assert clock < _bufferCount; | 1021 | assert clock < _bufferCount; |
3541 | 1012 | if (!_clock.compareAndSet(clock, (clock + 1) % _bufferCount)) { | 1022 | if (!_clock.compareAndSet(clock, (clock + 1) % _bufferCount)) { |
3542 | 1013 | continue; | 1023 | continue; |
3543 | 1014 | } | 1024 | } |
3545 | 1015 | Buffer buffer = _buffers[clock]; | 1025 | final Buffer buffer = _buffers[clock]; |
3546 | 1016 | if (buffer.isTouched()) { | 1026 | if (buffer.isTouched()) { |
3547 | 1017 | buffer.clearTouched(); | 1027 | buffer.clearTouched(); |
3548 | 1018 | } else { | 1028 | } else { |
3549 | @@ -1081,7 +1091,7 @@ | |||
3550 | 1081 | 1091 | ||
3551 | 1082 | void setFlushTimestamp(final long timestamp) { | 1092 | void setFlushTimestamp(final long timestamp) { |
3552 | 1083 | while (true) { | 1093 | while (true) { |
3554 | 1084 | long current = _flushTimestamp.get(); | 1094 | final long current = _flushTimestamp.get(); |
3555 | 1085 | if (timestamp > current) { | 1095 | if (timestamp > current) { |
3556 | 1086 | if (_flushTimestamp.compareAndSet(current, timestamp)) { | 1096 | if (_flushTimestamp.compareAndSet(current, timestamp)) { |
3557 | 1087 | break; | 1097 | break; |
3558 | @@ -1099,7 +1109,7 @@ | |||
3559 | 1099 | * polling cycle | 1109 | * polling cycle |
3560 | 1100 | */ | 1110 | */ |
3561 | 1101 | boolean shouldWritePages() { | 1111 | boolean shouldWritePages() { |
3563 | 1102 | int cleanCount = _bufferCount - _dirtyPageCount.get(); | 1112 | final int cleanCount = _bufferCount - _dirtyPageCount.get(); |
3564 | 1103 | if (getEarliestDirtyTimestamp() < _flushTimestamp.get()) { | 1113 | if (getEarliestDirtyTimestamp() < _flushTimestamp.get()) { |
3565 | 1104 | return true; | 1114 | return true; |
3566 | 1105 | } | 1115 | } |
3567 | @@ -1116,7 +1126,7 @@ | |||
3568 | 1116 | } | 1126 | } |
3569 | 1117 | 1127 | ||
3570 | 1118 | void writeDirtyBuffers(final int[] priorities, final BufferHolder[] selectedBuffers) throws PersistitException { | 1128 | void writeDirtyBuffers(final int[] priorities, final BufferHolder[] selectedBuffers) throws PersistitException { |
3572 | 1119 | int count = selectDirtyBuffers(priorities, selectedBuffers); | 1129 | final int count = selectDirtyBuffers(priorities, selectedBuffers); |
3573 | 1120 | if (count > 0) { | 1130 | if (count > 0) { |
3574 | 1121 | Arrays.sort(selectedBuffers, 0, count); | 1131 | Arrays.sort(selectedBuffers, 0, count); |
3575 | 1122 | for (int index = 0; index < count; index++) { | 1132 | for (int index = 0; index < count; index++) { |
3576 | @@ -1144,7 +1154,7 @@ | |||
3577 | 1144 | final long currentTimestamp = _persistit.getCurrentTimestamp(); | 1154 | final long currentTimestamp = _persistit.getCurrentTimestamp(); |
3578 | 1145 | 1155 | ||
3579 | 1146 | long earliestDirtyTimestamp = currentTimestamp; | 1156 | long earliestDirtyTimestamp = currentTimestamp; |
3581 | 1147 | long flushTimestamp = _flushTimestamp.get(); | 1157 | final long flushTimestamp = _flushTimestamp.get(); |
3582 | 1148 | 1158 | ||
3583 | 1149 | boolean flushed = true; | 1159 | boolean flushed = true; |
3584 | 1150 | for (int index = clock; index < clock + _bufferCount; index++) { | 1160 | for (int index = clock; index < clock + _bufferCount; index++) { |
3585 | @@ -1202,8 +1212,9 @@ | |||
3586 | 1202 | } | 1212 | } |
3587 | 1203 | return count; | 1213 | return count; |
3588 | 1204 | } | 1214 | } |
3591 | 1205 | 1215 | ||
3592 | 1206 | int addSelectedBufferByPriority(final Buffer buffer, final int priority, final int[] priorities, final BufferHolder[] holders, final int initialCount) { | 1216 | int addSelectedBufferByPriority(final Buffer buffer, final int priority, final int[] priorities, |
3593 | 1217 | final BufferHolder[] holders, final int initialCount) { | ||
3594 | 1207 | int count = initialCount; | 1218 | int count = initialCount; |
3595 | 1208 | if (priority > 0) { | 1219 | if (priority > 0) { |
3596 | 1209 | if (count == 0 || priorities[count - 1] > priority) { | 1220 | if (count == 0 || priorities[count - 1] > priority) { |
3597 | @@ -1214,13 +1225,13 @@ | |||
3598 | 1214 | } | 1225 | } |
3599 | 1215 | } else { | 1226 | } else { |
3600 | 1216 | count = Math.min(count, priorities.length - 1); | 1227 | count = Math.min(count, priorities.length - 1); |
3602 | 1217 | int where = count; | 1228 | int where = count; |
3603 | 1218 | while (where > 0 && priorities[where - 1] < priority) { | 1229 | while (where > 0 && priorities[where - 1] < priority) { |
3604 | 1219 | where--; | 1230 | where--; |
3605 | 1220 | } | 1231 | } |
3607 | 1221 | int move = count - where ; | 1232 | final int move = count - where; |
3608 | 1222 | if (move > 0) { | 1233 | if (move > 0) { |
3610 | 1223 | BufferHolder lastHolder = holders[count]; | 1234 | final BufferHolder lastHolder = holders[count]; |
3611 | 1224 | System.arraycopy(priorities, where, priorities, where + 1, move); | 1235 | System.arraycopy(priorities, where, priorities, where + 1, move); |
3612 | 1225 | System.arraycopy(holders, where, holders, where + 1, move); | 1236 | System.arraycopy(holders, where, holders, where + 1, move); |
3613 | 1226 | holders[where] = lastHolder; | 1237 | holders[where] = lastHolder; |
3614 | @@ -1240,8 +1251,8 @@ | |||
3615 | 1240 | * | 1251 | * |
3616 | 1241 | * @return priority | 1252 | * @return priority |
3617 | 1242 | */ | 1253 | */ |
3620 | 1243 | int writePriority(final Buffer buffer, int clock, long checkpointTimestamp, final long currentTimestamp) { | 1254 | int writePriority(final Buffer buffer, final int clock, final long checkpointTimestamp, final long currentTimestamp) { |
3621 | 1244 | int status = buffer.getStatus(); | 1255 | final int status = buffer.getStatus(); |
3622 | 1245 | if ((status & Buffer.VALID_MASK) == 0 || (status & Buffer.DIRTY_MASK) == 0) { | 1256 | if ((status & Buffer.VALID_MASK) == 0 || (status & Buffer.DIRTY_MASK) == 0) { |
3623 | 1246 | // ineligible | 1257 | // ineligible |
3624 | 1247 | return 0; | 1258 | return 0; |
3625 | @@ -1336,7 +1347,7 @@ | |||
3626 | 1336 | * address order. | 1347 | * address order. |
3627 | 1337 | */ | 1348 | */ |
3628 | 1338 | @Override | 1349 | @Override |
3630 | 1339 | public int compareTo(BufferHolder buffer) { | 1350 | public int compareTo(final BufferHolder buffer) { |
3631 | 1340 | return _volumeId > buffer._volumeId ? 1 : _volumeId < buffer._volumeId ? -1 : _page > buffer._page ? 1 | 1351 | return _volumeId > buffer._volumeId ? 1 : _volumeId < buffer._volumeId ? -1 : _page > buffer._page ? 1 |
3632 | 1341 | : _page < buffer._page ? -1 : 0; | 1352 | : _page < buffer._page ? -1 : 0; |
3633 | 1342 | 1353 | ||
3634 | @@ -1367,7 +1378,7 @@ | |||
3635 | 1367 | 1378 | ||
3636 | 1368 | @Override | 1379 | @Override |
3637 | 1369 | public void runTask() throws PersistitException { | 1380 | public void runTask() throws PersistitException { |
3639 | 1370 | int size = _pageWriterTrancheSize; | 1381 | final int size = _pageWriterTrancheSize; |
3640 | 1371 | if (size != _priorities.length) { | 1382 | if (size != _priorities.length) { |
3641 | 1372 | _priorities = new int[size]; | 1383 | _priorities = new int[size]; |
3642 | 1373 | _selectedBuffers = new BufferHolder[size]; | 1384 | _selectedBuffers = new BufferHolder[size]; |
3643 | @@ -1391,16 +1402,16 @@ | |||
3644 | 1391 | return isFlushing() ? 0 : _writerPollInterval; | 1402 | return isFlushing() ? 0 : _writerPollInterval; |
3645 | 1392 | } | 1403 | } |
3646 | 1393 | } | 1404 | } |
3648 | 1394 | 1405 | ||
3649 | 1395 | /** | 1406 | /** |
3650 | 1396 | * Implementation of PAGE_CACHER thread | 1407 | * Implementation of PAGE_CACHER thread |
3651 | 1397 | */ | 1408 | */ |
3652 | 1398 | class PageCacher extends IOTaskRunnable { | 1409 | class PageCacher extends IOTaskRunnable { |
3654 | 1399 | 1410 | ||
3655 | 1400 | PageCacher() { | 1411 | PageCacher() { |
3656 | 1401 | super(BufferPool.this._persistit); | 1412 | super(BufferPool.this._persistit); |
3657 | 1402 | } | 1413 | } |
3659 | 1403 | 1414 | ||
3660 | 1404 | void start() { | 1415 | void start() { |
3661 | 1405 | start("PAGE_CACHER:" + _bufferSize, _cacherPollInterval); | 1416 | start("PAGE_CACHER:" + _bufferSize, _cacherPollInterval); |
3662 | 1406 | } | 1417 | } |
3663 | @@ -1409,12 +1420,12 @@ | |||
3664 | 1409 | public void runTask() throws Exception { | 1420 | public void runTask() throws Exception { |
3665 | 1410 | populateWarmupFile(); | 1421 | populateWarmupFile(); |
3666 | 1411 | } | 1422 | } |
3668 | 1412 | 1423 | ||
3669 | 1413 | @Override | 1424 | @Override |
3670 | 1414 | protected boolean shouldStop() { | 1425 | protected boolean shouldStop() { |
3671 | 1415 | return _closed.get() && !isFlushing(); | 1426 | return _closed.get() && !isFlushing(); |
3672 | 1416 | } | 1427 | } |
3674 | 1417 | 1428 | ||
3675 | 1418 | @Override | 1429 | @Override |
3676 | 1419 | protected long pollInterval() { | 1430 | protected long pollInterval() { |
3677 | 1420 | return isFlushing() ? 0 : _cacherPollInterval; | 1431 | return isFlushing() ? 0 : _cacherPollInterval; |
3678 | @@ -1431,7 +1442,7 @@ | |||
3679 | 1431 | * @param detail | 1442 | * @param detail |
3680 | 1432 | * @return toString value for buffer at index <code>i</code>. | 1443 | * @return toString value for buffer at index <code>i</code>. |
3681 | 1433 | */ | 1444 | */ |
3683 | 1434 | String toString(int i, boolean detail) { | 1445 | String toString(final int i, final boolean detail) { |
3684 | 1435 | if (detail) { | 1446 | if (detail) { |
3685 | 1436 | return _buffers[i].toStringDetail(); | 1447 | return _buffers[i].toStringDetail(); |
3686 | 1437 | } else { | 1448 | } else { |
3687 | 1438 | 1449 | ||
3688 | === modified file 'src/main/java/com/persistit/BufferPoolMXBeanImpl.java' | |||
3689 | --- src/main/java/com/persistit/BufferPoolMXBeanImpl.java 2012-08-02 04:45:28 +0000 | |||
3690 | +++ src/main/java/com/persistit/BufferPoolMXBeanImpl.java 2012-08-24 18:20:24 +0000 | |||
3691 | @@ -23,8 +23,9 @@ | |||
3692 | 23 | 23 | ||
3693 | 24 | /** | 24 | /** |
3694 | 25 | * MXBean that exposes information about a {@link BufferPool}. | 25 | * MXBean that exposes information about a {@link BufferPool}. |
3695 | 26 | * | ||
3696 | 26 | * @author peter | 27 | * @author peter |
3698 | 27 | * | 28 | * |
3699 | 28 | */ | 29 | */ |
3700 | 29 | class BufferPoolMXBeanImpl implements BufferPoolMXBean { | 30 | class BufferPoolMXBeanImpl implements BufferPoolMXBean { |
3701 | 30 | 31 | ||
3702 | @@ -47,16 +48,16 @@ | |||
3703 | 47 | } | 48 | } |
3704 | 48 | 49 | ||
3705 | 49 | private BufferPoolInfo recent() { | 50 | private BufferPoolInfo recent() { |
3707 | 50 | long now = System.currentTimeMillis(); | 51 | final long now = System.currentTimeMillis(); |
3708 | 51 | if (_recent.getAcquisitionTime() < now - MAX_STALE) { | 52 | if (_recent.getAcquisitionTime() < now - MAX_STALE) { |
3709 | 52 | try { | 53 | try { |
3712 | 53 | BufferPoolInfo[] array = _persistit.getManagement().getBufferPoolInfoArray(); | 54 | final BufferPoolInfo[] array = _persistit.getManagement().getBufferPoolInfoArray(); |
3713 | 54 | for (BufferPoolInfo info : array) { | 55 | for (final BufferPoolInfo info : array) { |
3714 | 55 | if (info.getBufferSize() == _bufferSize) { | 56 | if (info.getBufferSize() == _bufferSize) { |
3715 | 56 | _recent = info; | 57 | _recent = info; |
3716 | 57 | } | 58 | } |
3717 | 58 | } | 59 | } |
3719 | 59 | } catch (RemoteException e) { | 60 | } catch (final RemoteException e) { |
3720 | 60 | // TODO Auto-generated catch block | 61 | // TODO Auto-generated catch block |
3721 | 61 | e.printStackTrace(); | 62 | e.printStackTrace(); |
3722 | 62 | } | 63 | } |
3723 | 63 | 64 | ||
3724 | === modified file 'src/main/java/com/persistit/CLI.java' | |||
3725 | --- src/main/java/com/persistit/CLI.java 2012-08-02 04:45:28 +0000 | |||
3726 | +++ src/main/java/com/persistit/CLI.java 2012-08-24 18:20:24 +0000 | |||
3727 | @@ -168,12 +168,12 @@ | |||
3728 | 168 | public static void registerCommands(final Class<?> clazz) { | 168 | public static void registerCommands(final Class<?> clazz) { |
3729 | 169 | for (final Method method : clazz.getDeclaredMethods()) { | 169 | for (final Method method : clazz.getDeclaredMethods()) { |
3730 | 170 | if (method.isAnnotationPresent(Cmd.class)) { | 170 | if (method.isAnnotationPresent(Cmd.class)) { |
3734 | 171 | String name = method.getAnnotation(Cmd.class).value(); | 171 | final String name = method.getAnnotation(Cmd.class).value(); |
3735 | 172 | Annotation[][] parameters = method.getParameterAnnotations(); | 172 | final Annotation[][] parameters = method.getParameterAnnotations(); |
3736 | 173 | String[] argTemplate = new String[parameters.length]; | 173 | final String[] argTemplate = new String[parameters.length]; |
3737 | 174 | int index = 0; | 174 | int index = 0; |
3740 | 175 | for (Annotation[] annotations : parameters) { | 175 | for (final Annotation[] annotations : parameters) { |
3741 | 176 | Arg argAnnotation = (Arg) annotations[0]; | 176 | final Arg argAnnotation = (Arg) annotations[0]; |
3742 | 177 | argTemplate[index++] = argAnnotation.value(); | 177 | argTemplate[index++] = argAnnotation.value(); |
3743 | 178 | } | 178 | } |
3744 | 179 | COMMANDS.put(name, new Command(name, argTemplate, method)); | 179 | COMMANDS.put(name, new Command(name, argTemplate, method)); |
3745 | @@ -228,7 +228,7 @@ | |||
3746 | 228 | int port = -1; | 228 | int port = -1; |
3747 | 229 | String host = null; | 229 | String host = null; |
3748 | 230 | 230 | ||
3750 | 231 | String[] hostPieces = args[0].split(":"); | 231 | final String[] hostPieces = args[0].split(":"); |
3751 | 232 | switch (hostPieces.length) { | 232 | switch (hostPieces.length) { |
3752 | 233 | case 1: | 233 | case 1: |
3753 | 234 | port = Integer.parseInt(hostPieces[0]); | 234 | port = Integer.parseInt(hostPieces[0]); |
3754 | @@ -275,7 +275,7 @@ | |||
3755 | 275 | */ | 275 | */ |
3756 | 276 | public static void runScript(final Persistit persistit, final BufferedReader reader, final PrintWriter writer) | 276 | public static void runScript(final Persistit persistit, final BufferedReader reader, final PrintWriter writer) |
3757 | 277 | throws Exception { | 277 | throws Exception { |
3759 | 278 | CLI cli = new CLI(persistit, reader, writer); | 278 | final CLI cli = new CLI(persistit, reader, writer); |
3760 | 279 | cli.commandLoop(); | 279 | cli.commandLoop(); |
3761 | 280 | cli.close(false); | 280 | cli.close(false); |
3762 | 281 | writer.println(); | 281 | writer.println(); |
3763 | @@ -307,7 +307,7 @@ | |||
3764 | 307 | 307 | ||
3765 | 308 | boolean quoted = false; | 308 | boolean quoted = false; |
3766 | 309 | for (int index = 0; index < commandLine.length(); index++) { | 309 | for (int index = 0; index < commandLine.length(); index++) { |
3768 | 310 | char c = commandLine.charAt(index); | 310 | final char c = commandLine.charAt(index); |
3769 | 311 | if (index == 0 && !Character.isLetter(c)) { | 311 | if (index == 0 && !Character.isLetter(c)) { |
3770 | 312 | commandDelimiter = c; | 312 | commandDelimiter = c; |
3771 | 313 | continue; | 313 | continue; |
3772 | @@ -342,17 +342,17 @@ | |||
3773 | 342 | } | 342 | } |
3774 | 343 | 343 | ||
3775 | 344 | static Task parseTask(final Persistit persistit, final String line) throws Exception { | 344 | static Task parseTask(final Persistit persistit, final String line) throws Exception { |
3777 | 345 | List<String> pieces = pieces(line); | 345 | final List<String> pieces = pieces(line); |
3778 | 346 | if (pieces.isEmpty()) { | 346 | if (pieces.isEmpty()) { |
3779 | 347 | return null; | 347 | return null; |
3780 | 348 | } | 348 | } |
3781 | 349 | final String commandName = pieces.remove(0); | 349 | final String commandName = pieces.remove(0); |
3783 | 350 | Command command = COMMANDS.get(commandName); | 350 | final Command command = COMMANDS.get(commandName); |
3784 | 351 | if (command == null) { | 351 | if (command == null) { |
3785 | 352 | return null; | 352 | return null; |
3786 | 353 | } | 353 | } |
3789 | 354 | Task task = command.createTask(persistit, new ArgParser(commandName, pieces.toArray(new String[pieces.size()]), | 354 | final Task task = command.createTask(persistit, |
3790 | 355 | command.argTemplate).strict()); | 355 | new ArgParser(commandName, pieces.toArray(new String[pieces.size()]), command.argTemplate).strict()); |
3791 | 356 | if (task != null) { | 356 | if (task != null) { |
3792 | 357 | task.setPersistit(persistit); | 357 | task.setPersistit(persistit); |
3793 | 358 | } | 358 | } |
3794 | @@ -433,14 +433,14 @@ | |||
3795 | 433 | private final BufferedReader _reader; | 433 | private final BufferedReader _reader; |
3796 | 434 | private final PrintWriter _writer; | 434 | private final PrintWriter _writer; |
3797 | 435 | 435 | ||
3799 | 436 | private ScriptReader(final BufferedReader reader, PrintWriter writer) { | 436 | private ScriptReader(final BufferedReader reader, final PrintWriter writer) { |
3800 | 437 | _reader = reader; | 437 | _reader = reader; |
3801 | 438 | _writer = writer; | 438 | _writer = writer; |
3802 | 439 | } | 439 | } |
3803 | 440 | 440 | ||
3804 | 441 | @Override | 441 | @Override |
3805 | 442 | public String readLine() throws IOException { | 442 | public String readLine() throws IOException { |
3807 | 443 | String line = _reader.readLine(); | 443 | final String line = _reader.readLine(); |
3808 | 444 | if (line != null) { | 444 | if (line != null) { |
3809 | 445 | _writer.println(); | 445 | _writer.println(); |
3810 | 446 | _writer.println(">> " + line); | 446 | _writer.println(">> " + line); |
3811 | @@ -476,10 +476,10 @@ | |||
3812 | 476 | private String execute(final CLI cli, final ArgParser ap) throws Exception { | 476 | private String execute(final CLI cli, final ArgParser ap) throws Exception { |
3813 | 477 | final Object[] args = invocationArgs(ap); | 477 | final Object[] args = invocationArgs(ap); |
3814 | 478 | if (method.getReturnType() == String.class) { | 478 | if (method.getReturnType() == String.class) { |
3816 | 479 | String result = (String) method.invoke(cli, args); | 479 | final String result = (String) method.invoke(cli, args); |
3817 | 480 | return result; | 480 | return result; |
3818 | 481 | } else if (Task.class.isAssignableFrom(method.getReturnType())) { | 481 | } else if (Task.class.isAssignableFrom(method.getReturnType())) { |
3820 | 482 | Task task = (Task) method.invoke(cli, args); | 482 | final Task task = (Task) method.invoke(cli, args); |
3821 | 483 | task.setPersistit(cli._persistit); | 483 | task.setPersistit(cli._persistit); |
3822 | 484 | task.setMaximumTime(-1); | 484 | task.setMaximumTime(-1); |
3823 | 485 | task.setMessageWriter(cli._writer); | 485 | task.setMessageWriter(cli._writer); |
3824 | @@ -493,9 +493,9 @@ | |||
3825 | 493 | 493 | ||
3826 | 494 | private Task createTask(final Persistit persistit, final ArgParser ap) throws Exception { | 494 | private Task createTask(final Persistit persistit, final ArgParser ap) throws Exception { |
3827 | 495 | if (Task.class.isAssignableFrom(method.getReturnType())) { | 495 | if (Task.class.isAssignableFrom(method.getReturnType())) { |
3829 | 496 | CLI cli = persistit.getSessionCLI(); | 496 | final CLI cli = persistit.getSessionCLI(); |
3830 | 497 | final Object[] args = invocationArgs(ap); | 497 | final Object[] args = invocationArgs(ap); |
3832 | 498 | Task task = (Task) method.invoke(cli, args); | 498 | final Task task = (Task) method.invoke(cli, args); |
3833 | 499 | return task; | 499 | return task; |
3834 | 500 | } else { | 500 | } else { |
3835 | 501 | return null; | 501 | return null; |
3836 | @@ -503,10 +503,10 @@ | |||
3837 | 503 | } | 503 | } |
3838 | 504 | 504 | ||
3839 | 505 | private Object[] invocationArgs(final ArgParser ap) { | 505 | private Object[] invocationArgs(final ArgParser ap) { |
3841 | 506 | Class<?>[] types = method.getParameterTypes(); | 506 | final Class<?>[] types = method.getParameterTypes(); |
3842 | 507 | final Object[] args = new Object[types.length]; | 507 | final Object[] args = new Object[types.length]; |
3843 | 508 | for (int index = 0; index < types.length; index++) { | 508 | for (int index = 0; index < types.length; index++) { |
3845 | 509 | Class<?> type = types[index]; | 509 | final Class<?> type = types[index]; |
3846 | 510 | if (String.class.equals(type)) { | 510 | if (String.class.equals(type)) { |
3847 | 511 | args[index] = ap.stringValue(index); | 511 | args[index] = ap.stringValue(index); |
3848 | 512 | } else if (int.class.equals(type)) { | 512 | } else if (int.class.equals(type)) { |
3849 | @@ -525,7 +525,7 @@ | |||
3850 | 525 | 525 | ||
3851 | 526 | @Override | 526 | @Override |
3852 | 527 | public String toString() { | 527 | public String toString() { |
3854 | 528 | StringBuilder sb = new StringBuilder(name); | 528 | final StringBuilder sb = new StringBuilder(name); |
3855 | 529 | sb.append(Util.NEW_LINE); | 529 | sb.append(Util.NEW_LINE); |
3856 | 530 | sb.append(new ArgParser(name, new String[0], argTemplate).strict()); | 530 | sb.append(new ArgParser(name, new String[0], argTemplate).strict()); |
3857 | 531 | return sb.toString(); | 531 | return sb.toString(); |
3858 | @@ -540,7 +540,7 @@ | |||
3859 | 540 | 540 | ||
3860 | 541 | private LineReader _lineReader; | 541 | private LineReader _lineReader; |
3861 | 542 | PrintWriter _writer = new PrintWriter(System.out); | 542 | PrintWriter _writer = new PrintWriter(System.out); |
3863 | 543 | private Stack<BufferedReader> _sourceStack = new Stack<BufferedReader>(); | 543 | private final Stack<BufferedReader> _sourceStack = new Stack<BufferedReader>(); |
3864 | 544 | private Persistit _persistit; | 544 | private Persistit _persistit; |
3865 | 545 | private boolean _stop = false; | 545 | private boolean _stop = false; |
3866 | 546 | private Volume _currentVolume; | 546 | private Volume _currentVolume; |
3867 | @@ -635,19 +635,19 @@ | |||
3868 | 635 | final String[] args = list.toArray(new String[list.size()]); | 635 | final String[] args = list.toArray(new String[list.size()]); |
3869 | 636 | final ArgParser ap = new ArgParser(commandName, args, command.argTemplate).strict(); | 636 | final ArgParser ap = new ArgParser(commandName, args, command.argTemplate).strict(); |
3870 | 637 | if (!ap.isUsageOnly()) { | 637 | if (!ap.isUsageOnly()) { |
3872 | 638 | String result = command.execute(this, ap); | 638 | final String result = command.execute(this, ap); |
3873 | 639 | if (result != null) { | 639 | if (result != null) { |
3874 | 640 | _writer.println(result); | 640 | _writer.println(result); |
3875 | 641 | } | 641 | } |
3876 | 642 | _lastStatus += " - done"; | 642 | _lastStatus += " - done"; |
3877 | 643 | } | 643 | } |
3879 | 644 | } catch (InvocationTargetException e) { | 644 | } catch (final InvocationTargetException e) { |
3880 | 645 | _lastStatus += e.getTargetException(); | 645 | _lastStatus += e.getTargetException(); |
3881 | 646 | _writer.println(e.getTargetException()); | 646 | _writer.println(e.getTargetException()); |
3883 | 647 | } catch (RuntimeException e) { | 647 | } catch (final RuntimeException e) { |
3884 | 648 | _lastStatus += e; | 648 | _lastStatus += e; |
3885 | 649 | e.printStackTrace(_writer); | 649 | e.printStackTrace(_writer); |
3887 | 650 | } catch (Exception e) { | 650 | } catch (final Exception e) { |
3888 | 651 | _lastStatus += e; | 651 | _lastStatus += e; |
3889 | 652 | _writer.println(e); | 652 | _writer.println(e); |
3890 | 653 | } | 653 | } |
3891 | @@ -680,28 +680,28 @@ | |||
3892 | 680 | * @throws Exception | 680 | * @throws Exception |
3893 | 681 | */ | 681 | */ |
3894 | 682 | @Cmd("open") | 682 | @Cmd("open") |
3900 | 683 | String open(@Arg("datapath|string|Data path") String datapath, | 683 | String open(@Arg("datapath|string|Data path") final String datapath, |
3901 | 684 | @Arg("journalpath|string|Journal path") String journalpath, | 684 | @Arg("journalpath|string|Journal path") final String journalpath, |
3902 | 685 | @Arg("volumepath|string|Volume file") String volumepath, | 685 | @Arg("volumepath|string|Volume file") final String volumepath, |
3903 | 686 | @Arg("rmiport|int:1099:0:99999|RMI Management port") int rmiport, | 686 | @Arg("rmiport|int:1099:0:99999|RMI Management port") final int rmiport, |
3904 | 687 | @Arg("_flag|y|Recover committed transactions") boolean y) throws Exception { | 687 | @Arg("_flag|y|Recover committed transactions") final boolean y) throws Exception { |
3905 | 688 | 688 | ||
3906 | 689 | if (_live) { | 689 | if (_live) { |
3907 | 690 | return "Cannot open another Persistit instance within a live system"; | 690 | return "Cannot open another Persistit instance within a live system"; |
3908 | 691 | } | 691 | } |
3909 | 692 | close(false); | 692 | close(false); |
3910 | 693 | 693 | ||
3913 | 694 | String jpath = journalPath(filesOnPath(journalpath.isEmpty() ? datapath : journalpath)); | 694 | final String jpath = journalPath(filesOnPath(journalpath.isEmpty() ? datapath : journalpath)); |
3914 | 695 | List<VolumeSpecification> volumeSpecifications = volumeSpecifications( | 695 | final List<VolumeSpecification> volumeSpecifications = volumeSpecifications( |
3915 | 696 | filesOnPath(volumepath.isEmpty() ? datapath : volumepath), Long.MAX_VALUE); | 696 | filesOnPath(volumepath.isEmpty() ? datapath : volumepath), Long.MAX_VALUE); |
3917 | 697 | Set<Integer> bufferSizes = new HashSet<Integer>(); | 697 | final Set<Integer> bufferSizes = new HashSet<Integer>(); |
3918 | 698 | for (final VolumeSpecification vs : volumeSpecifications) { | 698 | for (final VolumeSpecification vs : volumeSpecifications) { |
3919 | 699 | bufferSizes.add(vs.getPageSize()); | 699 | bufferSizes.add(vs.getPageSize()); |
3920 | 700 | } | 700 | } |
3921 | 701 | final Properties properties = new Properties(); | 701 | final Properties properties = new Properties(); |
3923 | 702 | long bpoolMemory = availableMemory() / 2; | 702 | final long bpoolMemory = availableMemory() / 2; |
3924 | 703 | for (final Integer size : bufferSizes) { | 703 | for (final Integer size : bufferSizes) { |
3926 | 704 | int alloc = (int) (size * 1.25); | 704 | final int alloc = (int) (size * 1.25); |
3927 | 705 | final int count = (int) ((bpoolMemory / bufferSizes.size()) / alloc); | 705 | final int count = (int) ((bpoolMemory / bufferSizes.size()) / alloc); |
3928 | 706 | properties.put(Persistit.BUFFERS_PROPERTY_NAME + size, Integer.toString(count)); | 706 | properties.put(Persistit.BUFFERS_PROPERTY_NAME + size, Integer.toString(count)); |
3929 | 707 | } | 707 | } |
3930 | @@ -755,7 +755,7 @@ | |||
3931 | 755 | } | 755 | } |
3932 | 756 | 756 | ||
3933 | 757 | @Cmd("close") | 757 | @Cmd("close") |
3935 | 758 | String close(@Arg("_flag|f|Flush modifications to disk") boolean flush) throws Exception { | 758 | String close(@Arg("_flag|f|Flush modifications to disk") final boolean flush) throws Exception { |
3936 | 759 | if (_persistit != null) { | 759 | if (_persistit != null) { |
3937 | 760 | try { | 760 | try { |
3938 | 761 | if (_live) { | 761 | if (_live) { |
3939 | @@ -764,7 +764,7 @@ | |||
3940 | 764 | _persistit.shutdownGUI(); | 764 | _persistit.shutdownGUI(); |
3941 | 765 | _persistit.close(flush); | 765 | _persistit.close(flush); |
3942 | 766 | } | 766 | } |
3944 | 767 | } catch (Exception e) { | 767 | } catch (final Exception e) { |
3945 | 768 | return e.toString(); | 768 | return e.toString(); |
3946 | 769 | } finally { | 769 | } finally { |
3947 | 770 | _persistit = null; | 770 | _persistit = null; |
3948 | @@ -832,6 +832,7 @@ | |||
3949 | 832 | public void runTask() throws Exception { | 832 | public void runTask() throws Exception { |
3950 | 833 | final JournalTool jt = new JournalTool(_persistit); | 833 | final JournalTool jt = new JournalTool(_persistit); |
3951 | 834 | jt.setAction(jt.new SimpleDumpAction() { | 834 | jt.setAction(jt.new SimpleDumpAction() { |
3952 | 835 | @Override | ||
3953 | 835 | protected void write(final String msg) { | 836 | protected void write(final String msg) { |
3954 | 836 | postMessage(msg, LOG_NORMAL); | 837 | postMessage(msg, LOG_NORMAL); |
3955 | 837 | } | 838 | } |
3956 | @@ -923,7 +924,7 @@ | |||
3957 | 923 | return; | 924 | return; |
3958 | 924 | } | 925 | } |
3959 | 925 | 926 | ||
3961 | 926 | List<Object> selected = new ArrayList<Object>(); | 927 | final List<Object> selected = new ArrayList<Object>(); |
3962 | 927 | final TreeSelector selector = TreeSelector.parseSelector(tstring, r, '\\'); | 928 | final TreeSelector selector = TreeSelector.parseSelector(tstring, r, '\\'); |
3963 | 928 | 929 | ||
3964 | 929 | for (final Volume volume : _persistit.getVolumes()) { | 930 | for (final Volume volume : _persistit.getVolumes()) { |
3965 | @@ -988,10 +989,10 @@ | |||
3966 | 988 | if (!keyString.isEmpty()) { | 989 | if (!keyString.isEmpty()) { |
3967 | 989 | new KeyParser(keyString).parseKey(exchange.getKey()); | 990 | new KeyParser(keyString).parseKey(exchange.getKey()); |
3968 | 990 | } | 991 | } |
3971 | 991 | StringBuilder sb = new StringBuilder(); | 992 | final StringBuilder sb = new StringBuilder(); |
3972 | 992 | int depth = _currentTree.getDepth(); | 993 | final int depth = _currentTree.getDepth(); |
3973 | 993 | for (int level = depth; --level >= 0;) { | 994 | for (int level = depth; --level >= 0;) { |
3975 | 994 | Buffer copy = exchange.fetchBufferCopy(level); | 995 | final Buffer copy = exchange.fetchBufferCopy(level); |
3976 | 995 | if (sb.length() > 0) { | 996 | if (sb.length() > 0) { |
3977 | 996 | sb.append(Util.NEW_LINE); | 997 | sb.append(Util.NEW_LINE); |
3978 | 997 | } | 998 | } |
3979 | @@ -1051,7 +1052,7 @@ | |||
3980 | 1051 | return; | 1052 | return; |
3981 | 1052 | } | 1053 | } |
3982 | 1053 | if (index >= 0) { | 1054 | if (index >= 0) { |
3984 | 1054 | BufferPool pool = _persistit.getBufferPool(pageSize); | 1055 | final BufferPool pool = _persistit.getBufferPool(pageSize); |
3985 | 1055 | buffer = pool.getBufferCopy(index); | 1056 | buffer = pool.getBufferCopy(index); |
3986 | 1056 | } else if (journalAddress >= 0) { | 1057 | } else if (journalAddress >= 0) { |
3987 | 1057 | buffer = _persistit.getJournalManager().readPageBuffer(journalAddress); | 1058 | buffer = _persistit.getJournalManager().readPageBuffer(journalAddress); |
3988 | @@ -1088,12 +1089,13 @@ | |||
3989 | 1088 | } | 1089 | } |
3990 | 1089 | } | 1090 | } |
3991 | 1090 | 1091 | ||
3992 | 1092 | @Override | ||
3993 | 1091 | public String getStatus() { | 1093 | public String getStatus() { |
3994 | 1092 | return ""; | 1094 | return ""; |
3995 | 1093 | } | 1095 | } |
3996 | 1094 | }; | 1096 | }; |
3997 | 1095 | } | 1097 | } |
3999 | 1096 | 1098 | ||
4000 | 1097 | @Cmd("pviewchain") | 1099 | @Cmd("pviewchain") |
4001 | 1098 | Task pviewchain(final @Arg("page|long:0:0:99999999999999999|Starting page address") long pageAddress, | 1100 | Task pviewchain(final @Arg("page|long:0:0:99999999999999999|Starting page address") long pageAddress, |
4002 | 1099 | final @Arg("find|long:-1:0:99999999999999999|Optional page pointer to find") long findPointer, | 1101 | final @Arg("find|long:-1:0:99999999999999999|Optional page pointer to find") long findPointer, |
4003 | @@ -1102,7 +1104,7 @@ | |||
4004 | 1102 | final @Arg("maxvalue|int:42:4:100000|Maximum displayed value length") int maxvalue, | 1104 | final @Arg("maxvalue|int:42:4:100000|Maximum displayed value length") int maxvalue, |
4005 | 1103 | final @Arg("context|int:3:0:100000|Context lines") int context, | 1105 | final @Arg("context|int:3:0:100000|Context lines") int context, |
4006 | 1104 | final @Arg("_flag|a|All lines") boolean allLines, final @Arg("_flag|s|Summary only") boolean summary) { | 1106 | final @Arg("_flag|a|All lines") boolean allLines, final @Arg("_flag|s|Summary only") boolean summary) { |
4008 | 1105 | 1107 | ||
4009 | 1106 | return new Task() { | 1108 | return new Task() { |
4010 | 1107 | 1109 | ||
4011 | 1108 | @Override | 1110 | @Override |
4012 | @@ -1121,15 +1123,15 @@ | |||
4013 | 1121 | postMessage(buffer.toStringDetail(findPointer, maxkey, maxvalue, context, allLines), LOG_NORMAL); | 1123 | postMessage(buffer.toStringDetail(findPointer, maxkey, maxvalue, context, allLines), LOG_NORMAL); |
4014 | 1122 | } | 1124 | } |
4015 | 1123 | currentPage = buffer.getRightSibling(); | 1125 | currentPage = buffer.getRightSibling(); |
4017 | 1124 | } | 1126 | } |
4018 | 1125 | } | 1127 | } |
4019 | 1126 | 1128 | ||
4020 | 1127 | @Override | 1129 | @Override |
4021 | 1128 | public String getStatus() { | 1130 | public String getStatus() { |
4022 | 1129 | return ""; | 1131 | return ""; |
4023 | 1130 | } | 1132 | } |
4026 | 1131 | 1133 | ||
4027 | 1132 | }; | 1134 | }; |
4028 | 1133 | } | 1135 | } |
4029 | 1134 | 1136 | ||
4030 | 1135 | @Cmd("jquery") | 1137 | @Cmd("jquery") |
4031 | @@ -1140,6 +1142,7 @@ | |||
4032 | 1140 | final @Arg("_flag|V|Show volume handle map") boolean showTreeMap, | 1142 | final @Arg("_flag|V|Show volume handle map") boolean showTreeMap, |
4033 | 1141 | final @Arg("_flag|T|Show tree handle map") boolean showVolumeMap) { | 1143 | final @Arg("_flag|T|Show tree handle map") boolean showVolumeMap) { |
4034 | 1142 | return new Task() { | 1144 | return new Task() { |
4035 | 1145 | @Override | ||
4036 | 1143 | public void runTask() throws Exception { | 1146 | public void runTask() throws Exception { |
4037 | 1144 | if (!showVolumeMap && !showTreeMap && pageAddress == -1 && ts == -1) { | 1147 | if (!showVolumeMap && !showTreeMap && pageAddress == -1 && ts == -1) { |
4038 | 1145 | postMessage("No items requested", LOG_NORMAL); | 1148 | postMessage("No items requested", LOG_NORMAL); |
4039 | @@ -1147,20 +1150,20 @@ | |||
4040 | 1147 | } | 1150 | } |
4041 | 1148 | if (showVolumeMap) { | 1151 | if (showVolumeMap) { |
4042 | 1149 | postMessage("Volume Handle Map", LOG_NORMAL); | 1152 | postMessage("Volume Handle Map", LOG_NORMAL); |
4044 | 1150 | Map<Integer, Volume> map = _persistit.getJournalManager().queryVolumeMap(); | 1153 | final Map<Integer, Volume> map = _persistit.getJournalManager().queryVolumeMap(); |
4045 | 1151 | for (final Map.Entry<Integer, Volume> entry : map.entrySet()) { | 1154 | for (final Map.Entry<Integer, Volume> entry : map.entrySet()) { |
4046 | 1152 | postMessage(String.format("%,5d -> %s", entry.getKey(), entry.getValue()), LOG_NORMAL); | 1155 | postMessage(String.format("%,5d -> %s", entry.getKey(), entry.getValue()), LOG_NORMAL); |
4047 | 1153 | } | 1156 | } |
4048 | 1154 | } | 1157 | } |
4049 | 1155 | if (showVolumeMap) { | 1158 | if (showVolumeMap) { |
4050 | 1156 | postMessage("Tree Handle Map", LOG_NORMAL); | 1159 | postMessage("Tree Handle Map", LOG_NORMAL); |
4052 | 1157 | Map<Integer, TreeDescriptor> map = _persistit.getJournalManager().queryTreeMap(); | 1160 | final Map<Integer, TreeDescriptor> map = _persistit.getJournalManager().queryTreeMap(); |
4053 | 1158 | for (final Map.Entry<Integer, TreeDescriptor> entry : map.entrySet()) { | 1161 | for (final Map.Entry<Integer, TreeDescriptor> entry : map.entrySet()) { |
4054 | 1159 | postMessage(String.format("%,5d -> %s", entry.getKey(), entry.getValue()), LOG_NORMAL); | 1162 | postMessage(String.format("%,5d -> %s", entry.getKey(), entry.getValue()), LOG_NORMAL); |
4055 | 1160 | } | 1163 | } |
4056 | 1161 | } | 1164 | } |
4057 | 1162 | if (ts != -1) { | 1165 | if (ts != -1) { |
4059 | 1163 | TransactionMapItem item = _persistit.getJournalManager().queryTransactionMap(ts); | 1166 | final TransactionMapItem item = _persistit.getJournalManager().queryTransactionMap(ts); |
4060 | 1164 | postMessage(String.format("TransactionMapItem for ts=%,d -> %s", ts, item), LOG_NORMAL); | 1167 | postMessage(String.format("TransactionMapItem for ts=%,d -> %s", ts, item), LOG_NORMAL); |
4061 | 1165 | } | 1168 | } |
4062 | 1166 | if (pageAddress != -1) { | 1169 | if (pageAddress != -1) { |
4063 | @@ -1168,7 +1171,7 @@ | |||
4064 | 1168 | if (volumeHandle != -1) { | 1171 | if (volumeHandle != -1) { |
4065 | 1169 | queryPageNode(volumeHandle, pageAddress, verbose); | 1172 | queryPageNode(volumeHandle, pageAddress, verbose); |
4066 | 1170 | } else { | 1173 | } else { |
4068 | 1171 | Map<Integer, Volume> volumeMap = _persistit.getJournalManager().queryVolumeMap(); | 1174 | final Map<Integer, Volume> volumeMap = _persistit.getJournalManager().queryVolumeMap(); |
4069 | 1172 | for (final int handle : volumeMap.keySet()) { | 1175 | for (final int handle : volumeMap.keySet()) { |
4070 | 1173 | queryPageNode(handle, pageAddress, verbose); | 1176 | queryPageNode(handle, pageAddress, verbose); |
4071 | 1174 | } | 1177 | } |
4072 | @@ -1202,6 +1205,7 @@ | |||
4073 | 1202 | final @Arg("_flag|v|Verbose") boolean verbose) throws Exception { | 1205 | final @Arg("_flag|v|Verbose") boolean verbose) throws Exception { |
4074 | 1203 | 1206 | ||
4075 | 1204 | return new Task() { | 1207 | return new Task() { |
4076 | 1208 | @Override | ||
4077 | 1205 | public void runTask() throws Exception { | 1209 | public void runTask() throws Exception { |
4078 | 1206 | final File target = new File(file); | 1210 | final File target = new File(file); |
4079 | 1207 | if (target.exists() && !ovewrite) { | 1211 | if (target.exists() && !ovewrite) { |
4080 | @@ -1255,12 +1259,12 @@ | |||
4081 | 1255 | zos.closeEntry(); | 1259 | zos.closeEntry(); |
4082 | 1256 | bb.clear(); | 1260 | bb.clear(); |
4083 | 1257 | 1261 | ||
4085 | 1258 | PrintWriter writer = new PrintWriter(zos); | 1262 | final PrintWriter writer = new PrintWriter(zos); |
4086 | 1259 | ze = new ZipEntry(basePath + ".txt"); | 1263 | ze = new ZipEntry(basePath + ".txt"); |
4087 | 1260 | ze.setSize(Integer.MAX_VALUE); | 1264 | ze.setSize(Integer.MAX_VALUE); |
4088 | 1261 | ze.setTime(baseTime); | 1265 | ze.setTime(baseTime); |
4089 | 1262 | zos.putNextEntry(ze); | 1266 | zos.putNextEntry(ze); |
4091 | 1263 | List<Volume> volumes = _persistit.getVolumes(); | 1267 | final List<Volume> volumes = _persistit.getVolumes(); |
4092 | 1264 | 1268 | ||
4093 | 1265 | writer.printf("@volumes=%d\n", volumes.size()); | 1269 | writer.printf("@volumes=%d\n", volumes.size()); |
4094 | 1266 | for (final Volume volume : volumes) { | 1270 | for (final Volume volume : volumes) { |
4095 | @@ -1314,7 +1318,7 @@ | |||
4096 | 1314 | 1318 | ||
4097 | 1315 | @Cmd("cliserver") | 1319 | @Cmd("cliserver") |
4098 | 1316 | static Task cliserver(final @Arg("port|int:9999:1024:99999999") int port) throws Exception { | 1320 | static Task cliserver(final @Arg("port|int:9999:1024:99999999") int port) throws Exception { |
4100 | 1317 | Task task = new Task() { | 1321 | final Task task = new Task() { |
4101 | 1318 | CLI _cli; | 1322 | CLI _cli; |
4102 | 1319 | 1323 | ||
4103 | 1320 | @Override | 1324 | @Override |
4104 | @@ -1325,9 +1329,9 @@ | |||
4105 | 1325 | 1329 | ||
4106 | 1326 | @Override | 1330 | @Override |
4107 | 1327 | public String getStatus() { | 1331 | public String getStatus() { |
4109 | 1328 | CLI cli = _cli; | 1332 | final CLI cli = _cli; |
4110 | 1329 | if (cli != null) { | 1333 | if (cli != null) { |
4112 | 1330 | String status = cli._lastStatus; | 1334 | final String status = cli._lastStatus; |
4113 | 1331 | if (status != null) { | 1335 | if (status != null) { |
4114 | 1332 | return status; | 1336 | return status; |
4115 | 1333 | } | 1337 | } |
4116 | @@ -1339,12 +1343,12 @@ | |||
4117 | 1339 | return task; | 1343 | return task; |
4118 | 1340 | } | 1344 | } |
4119 | 1341 | 1345 | ||
4121 | 1342 | private static String journalPath(List<String> files) { | 1346 | private static String journalPath(final List<String> files) { |
4122 | 1343 | String journalPath = null; | 1347 | String journalPath = null; |
4123 | 1344 | for (final String file : files) { | 1348 | for (final String file : files) { |
4125 | 1345 | Matcher matcher = JournalManager.PATH_PATTERN.matcher(file); | 1349 | final Matcher matcher = JournalManager.PATH_PATTERN.matcher(file); |
4126 | 1346 | if (matcher.matches()) { | 1350 | if (matcher.matches()) { |
4128 | 1347 | String path = matcher.group(1); | 1351 | final String path = matcher.group(1); |
4129 | 1348 | if (journalPath == null) { | 1352 | if (journalPath == null) { |
4130 | 1349 | journalPath = path; | 1353 | journalPath = path; |
4131 | 1350 | } else if (!journalPath.equals(path)) { | 1354 | } else if (!journalPath.equals(path)) { |
4132 | @@ -1355,7 +1359,7 @@ | |||
4133 | 1355 | return journalPath; | 1359 | return journalPath; |
4134 | 1356 | } | 1360 | } |
4135 | 1357 | 1361 | ||
4137 | 1358 | private static List<VolumeSpecification> volumeSpecifications(List<String> files, long systemTimestamp) { | 1362 | private static List<VolumeSpecification> volumeSpecifications(final List<String> files, final long systemTimestamp) { |
4138 | 1359 | final List<VolumeSpecification> list = new ArrayList<VolumeSpecification>(); | 1363 | final List<VolumeSpecification> list = new ArrayList<VolumeSpecification>(); |
4139 | 1360 | for (final String path : files) { | 1364 | for (final String path : files) { |
4140 | 1361 | if (JournalManager.PATH_PATTERN.matcher(path).matches()) { | 1365 | if (JournalManager.PATH_PATTERN.matcher(path).matches()) { |
4141 | @@ -1366,7 +1370,7 @@ | |||
4142 | 1366 | if (VolumeHeader.verifyVolumeHeader(specification, systemTimestamp)) { | 1370 | if (VolumeHeader.verifyVolumeHeader(specification, systemTimestamp)) { |
4143 | 1367 | list.add(specification); | 1371 | list.add(specification); |
4144 | 1368 | } | 1372 | } |
4146 | 1369 | } catch (PersistitException e) { | 1373 | } catch (final PersistitException e) { |
4147 | 1370 | // ignore this file | 1374 | // ignore this file |
4148 | 1371 | } | 1375 | } |
4149 | 1372 | } | 1376 | } |
4150 | 1373 | 1377 | ||
4151 | === modified file 'src/main/java/com/persistit/CheckpointManager.java' | |||
4152 | --- src/main/java/com/persistit/CheckpointManager.java 2012-08-02 04:45:28 +0000 | |||
4153 | +++ src/main/java/com/persistit/CheckpointManager.java 2012-08-24 18:20:24 +0000 | |||
4154 | @@ -43,7 +43,7 @@ | |||
4155 | 43 | private final long _systemTime; | 43 | private final long _systemTime; |
4156 | 44 | 44 | ||
4157 | 45 | private volatile boolean _completed = false; | 45 | private volatile boolean _completed = false; |
4159 | 46 | 46 | ||
4160 | 47 | Checkpoint(final long timestamp, final long systemTime) { | 47 | Checkpoint(final long timestamp, final long systemTime) { |
4161 | 48 | _timestamp = timestamp; | 48 | _timestamp = timestamp; |
4162 | 49 | _systemTime = systemTime; | 49 | _systemTime = systemTime; |
4163 | @@ -72,8 +72,8 @@ | |||
4164 | 72 | 72 | ||
4165 | 73 | @Override | 73 | @Override |
4166 | 74 | public String toString() { | 74 | public String toString() { |
4169 | 75 | return String.format("Checkpoint %,d%s @ %s", _timestamp, isCompleted() ? "c" : "u", SDF.format(new Date( | 75 | return String.format("Checkpoint %,d%s @ %s", _timestamp, isCompleted() ? "c" : "u", |
4170 | 76 | _systemTime))); | 76 | SDF.format(new Date(_systemTime))); |
4171 | 77 | } | 77 | } |
4172 | 78 | 78 | ||
4173 | 79 | @Override | 79 | @Override |
4174 | @@ -81,7 +81,7 @@ | |||
4175 | 81 | if (!(object instanceof Checkpoint)) { | 81 | if (!(object instanceof Checkpoint)) { |
4176 | 82 | return false; | 82 | return false; |
4177 | 83 | } | 83 | } |
4179 | 84 | Checkpoint cp = (Checkpoint) object; | 84 | final Checkpoint cp = (Checkpoint) object; |
4180 | 85 | return cp._systemTime == _systemTime && cp._timestamp == _timestamp; | 85 | return cp._systemTime == _systemTime && cp._timestamp == _timestamp; |
4181 | 86 | } | 86 | } |
4182 | 87 | } | 87 | } |
4183 | @@ -92,9 +92,9 @@ | |||
4184 | 92 | * Default interval in nanoseconds between checkpoints - two minutes. | 92 | * Default interval in nanoseconds between checkpoints - two minutes. |
4185 | 93 | */ | 93 | */ |
4186 | 94 | private final static long DEFAULT_CHECKPOINT_INTERVAL = 120; | 94 | private final static long DEFAULT_CHECKPOINT_INTERVAL = 120; |
4188 | 95 | 95 | ||
4189 | 96 | private final static long MINIMUM_CHECKPOINT_INTERVAL = 10; | 96 | private final static long MINIMUM_CHECKPOINT_INTERVAL = 10; |
4191 | 97 | 97 | ||
4192 | 98 | private final static long MAXIMUM_CHECKPOINT_INTERVAL = 1800; | 98 | private final static long MAXIMUM_CHECKPOINT_INTERVAL = 1800; |
4193 | 99 | 99 | ||
4194 | 100 | private final static Checkpoint UNAVALABLE_CHECKPOINT = new Checkpoint(0, 0); | 100 | private final static Checkpoint UNAVALABLE_CHECKPOINT = new Checkpoint(0, 0); |
4195 | @@ -110,13 +110,12 @@ | |||
4196 | 110 | private final static long FLUSH_CHECKPOINT_INTERVAL = 5000; | 110 | private final static long FLUSH_CHECKPOINT_INTERVAL = 5000; |
4197 | 111 | 111 | ||
4198 | 112 | private volatile Checkpoint _currentCheckpoint = new Checkpoint(0, 0, true); | 112 | private volatile Checkpoint _currentCheckpoint = new Checkpoint(0, 0, true); |
4206 | 113 | 113 | ||
4207 | 114 | private List<Checkpoint> _outstandingCheckpoints = new ArrayList<Checkpoint>(); | 114 | private final List<Checkpoint> _outstandingCheckpoints = new ArrayList<Checkpoint>(); |
4208 | 115 | 115 | ||
4209 | 116 | 116 | private final AtomicBoolean _closed = new AtomicBoolean(); | |
4210 | 117 | private AtomicBoolean _closed = new AtomicBoolean(); | 117 | |
4211 | 118 | 118 | private final AtomicBoolean _fastClose = new AtomicBoolean(); | |
4205 | 119 | private AtomicBoolean _fastClose = new AtomicBoolean(); | ||
4212 | 120 | 119 | ||
4213 | 121 | CheckpointManager(final Persistit persistit) { | 120 | CheckpointManager(final Persistit persistit) { |
4214 | 122 | super(persistit); | 121 | super(persistit); |
4215 | @@ -139,12 +138,12 @@ | |||
4216 | 139 | Checkpoint getCurrentCheckpoint() { | 138 | Checkpoint getCurrentCheckpoint() { |
4217 | 140 | return _currentCheckpoint; | 139 | return _currentCheckpoint; |
4218 | 141 | } | 140 | } |
4220 | 142 | 141 | ||
4221 | 143 | long getCheckpointIntervalNanos() { | 142 | long getCheckpointIntervalNanos() { |
4222 | 144 | return _checkpointIntervalNanos; | 143 | return _checkpointIntervalNanos; |
4223 | 145 | } | 144 | } |
4224 | 146 | 145 | ||
4226 | 147 | void setCheckpointIntervalNanos(long interval) { | 146 | void setCheckpointIntervalNanos(final long interval) { |
4227 | 148 | _checkpointIntervalNanos = interval; | 147 | _checkpointIntervalNanos = interval; |
4228 | 149 | } | 148 | } |
4229 | 150 | 149 | ||
4230 | @@ -159,19 +158,19 @@ | |||
4231 | 159 | } | 158 | } |
4232 | 160 | 159 | ||
4233 | 161 | @Override | 160 | @Override |
4235 | 162 | public void setCheckpointInterval(long interval) { | 161 | public void setCheckpointInterval(final long interval) { |
4236 | 163 | Util.rangeCheck(interval, MINIMUM_CHECKPOINT_INTERVAL, MAXIMUM_CHECKPOINT_INTERVAL); | 162 | Util.rangeCheck(interval, MINIMUM_CHECKPOINT_INTERVAL, MAXIMUM_CHECKPOINT_INTERVAL); |
4237 | 164 | _checkpointIntervalNanos = interval * NS_PER_S; | 163 | _checkpointIntervalNanos = interval * NS_PER_S; |
4238 | 165 | } | 164 | } |
4240 | 166 | 165 | ||
4241 | 167 | @Override | 166 | @Override |
4243 | 168 | public synchronized int getOutstandingCheckpointCount() { | 167 | public synchronized int getOutstandingCheckpointCount() { |
4244 | 169 | return _outstandingCheckpoints.size(); | 168 | return _outstandingCheckpoints.size(); |
4245 | 170 | } | 169 | } |
4247 | 171 | 170 | ||
4248 | 172 | @Override | 171 | @Override |
4249 | 173 | public synchronized String outstandingCheckpointReport() { | 172 | public synchronized String outstandingCheckpointReport() { |
4251 | 174 | StringBuilder sb = new StringBuilder(); | 173 | final StringBuilder sb = new StringBuilder(); |
4252 | 175 | for (final Checkpoint cp : _outstandingCheckpoints) { | 174 | for (final Checkpoint cp : _outstandingCheckpoints) { |
4253 | 176 | sb.append(cp); | 175 | sb.append(cp); |
4254 | 177 | sb.append(Util.NEW_LINE); | 176 | sb.append(Util.NEW_LINE); |
4255 | @@ -180,7 +179,7 @@ | |||
4256 | 180 | } | 179 | } |
4257 | 181 | 180 | ||
4258 | 182 | Checkpoint checkpoint() throws PersistitException { | 181 | Checkpoint checkpoint() throws PersistitException { |
4260 | 183 | Checkpoint checkpoint = createCheckpoint(); | 182 | final Checkpoint checkpoint = createCheckpoint(); |
4261 | 184 | _persistit.flushBuffers(checkpoint.getTimestamp()); | 183 | _persistit.flushBuffers(checkpoint.getTimestamp()); |
4262 | 185 | 184 | ||
4263 | 186 | while (true) { | 185 | while (true) { |
4264 | @@ -239,14 +238,14 @@ | |||
4265 | 239 | final SessionId saveSessionId = _persistit.getSessionId(); | 238 | final SessionId saveSessionId = _persistit.getSessionId(); |
4266 | 240 | try { | 239 | try { |
4267 | 241 | _persistit.setSessionId(_checkpointTxnSessionId); | 240 | _persistit.setSessionId(_checkpointTxnSessionId); |
4269 | 242 | Transaction txn = _persistit.getTransaction(); | 241 | final Transaction txn = _persistit.getTransaction(); |
4270 | 243 | 242 | ||
4271 | 244 | _lastCheckpointNanos = System.nanoTime(); | 243 | _lastCheckpointNanos = System.nanoTime(); |
4272 | 245 | 244 | ||
4273 | 246 | txn.beginCheckpoint(); | 245 | txn.beginCheckpoint(); |
4274 | 247 | try { | 246 | try { |
4275 | 248 | _persistit.flushTransactions(txn.getStartTimestamp()); | 247 | _persistit.flushTransactions(txn.getStartTimestamp()); |
4277 | 249 | List<Accumulator> accumulators = _persistit.getCheckpointAccumulators(); | 248 | final List<Accumulator> accumulators = _persistit.getCheckpointAccumulators(); |
4278 | 250 | _persistit.getTransactionIndex().checkpointAccumulatorSnapshots(txn.getStartTimestamp(), accumulators); | 249 | _persistit.getTransactionIndex().checkpointAccumulatorSnapshots(txn.getStartTimestamp(), accumulators); |
4279 | 251 | Accumulator.saveAccumulatorCheckpointValues(accumulators); | 250 | Accumulator.saveAccumulatorCheckpointValues(accumulators); |
4280 | 252 | txn.commit(CommitPolicy.HARD); | 251 | txn.commit(CommitPolicy.HARD); |
4281 | @@ -254,7 +253,7 @@ | |||
4282 | 254 | _outstandingCheckpoints.add(_currentCheckpoint); | 253 | _outstandingCheckpoints.add(_currentCheckpoint); |
4283 | 255 | _persistit.getLogBase().checkpointProposed.log(_currentCheckpoint); | 254 | _persistit.getLogBase().checkpointProposed.log(_currentCheckpoint); |
4284 | 256 | return _currentCheckpoint; | 255 | return _currentCheckpoint; |
4286 | 257 | } catch (InterruptedException ie) { | 256 | } catch (final InterruptedException ie) { |
4287 | 258 | throw new PersistitInterruptedException(ie); | 257 | throw new PersistitInterruptedException(ie); |
4288 | 259 | } finally { | 258 | } finally { |
4289 | 260 | txn.end(); | 259 | txn.end(); |
4290 | @@ -272,9 +271,9 @@ | |||
4291 | 272 | void pollFlushCheckpoint() { | 271 | void pollFlushCheckpoint() { |
4292 | 273 | final long earliestDirtyTimestamp = _persistit.earliestDirtyTimestamp(); | 272 | final long earliestDirtyTimestamp = _persistit.earliestDirtyTimestamp(); |
4293 | 274 | Checkpoint checkpoint = null; | 273 | Checkpoint checkpoint = null; |
4295 | 275 | synchronized(this) { | 274 | synchronized (this) { |
4296 | 276 | while (!_outstandingCheckpoints.isEmpty()) { | 275 | while (!_outstandingCheckpoints.isEmpty()) { |
4298 | 277 | Checkpoint cp = _outstandingCheckpoints.get(0); | 276 | final Checkpoint cp = _outstandingCheckpoints.get(0); |
4299 | 278 | if (cp.getTimestamp() <= earliestDirtyTimestamp) { | 277 | if (cp.getTimestamp() <= earliestDirtyTimestamp) { |
4300 | 279 | checkpoint = cp; | 278 | checkpoint = cp; |
4301 | 280 | _outstandingCheckpoints.remove(0); | 279 | _outstandingCheckpoints.remove(0); |
4302 | @@ -286,7 +285,7 @@ | |||
4303 | 286 | if (checkpoint != null) { | 285 | if (checkpoint != null) { |
4304 | 287 | try { | 286 | try { |
4305 | 288 | _persistit.getJournalManager().writeCheckpointToJournal(checkpoint); | 287 | _persistit.getJournalManager().writeCheckpointToJournal(checkpoint); |
4307 | 289 | } catch (PersistitException e) { | 288 | } catch (final PersistitException e) { |
4308 | 290 | _persistit.getLogBase().exception.log(e); | 289 | _persistit.getLogBase().exception.log(e); |
4309 | 291 | } | 290 | } |
4310 | 292 | } | 291 | } |
4311 | 293 | 292 | ||
4312 | === modified file 'src/main/java/com/persistit/ClassIndex.java' | |||
4313 | --- src/main/java/com/persistit/ClassIndex.java 2012-08-02 04:45:28 +0000 | |||
4314 | +++ src/main/java/com/persistit/ClassIndex.java 2012-08-24 18:20:24 +0000 | |||
4315 | @@ -71,8 +71,8 @@ | |||
4316 | 71 | INITIAL_CAPACITY); | 71 | INITIAL_CAPACITY); |
4317 | 72 | 72 | ||
4318 | 73 | private int _testIdFloor = Integer.MIN_VALUE; | 73 | private int _testIdFloor = Integer.MIN_VALUE; |
4321 | 74 | private AtomicInteger _cacheMisses = new AtomicInteger(); | 74 | private final AtomicInteger _cacheMisses = new AtomicInteger(); |
4322 | 75 | private AtomicInteger _discardedDuplicates = new AtomicInteger(); | 75 | private final AtomicInteger _discardedDuplicates = new AtomicInteger(); |
4323 | 76 | 76 | ||
4324 | 77 | /** | 77 | /** |
4325 | 78 | * A structure holding a ClassInfo, plus links to other related | 78 | * A structure holding a ClassInfo, plus links to other related |
4326 | @@ -82,7 +82,7 @@ | |||
4327 | 82 | final ClassInfoEntry _next; | 82 | final ClassInfoEntry _next; |
4328 | 83 | final ClassInfo _classInfo; | 83 | final ClassInfo _classInfo; |
4329 | 84 | 84 | ||
4331 | 85 | ClassInfoEntry(ClassInfo ci, ClassInfoEntry next) { | 85 | ClassInfoEntry(final ClassInfo ci, final ClassInfoEntry next) { |
4332 | 86 | _classInfo = ci; | 86 | _classInfo = ci; |
4333 | 87 | _next = next; | 87 | _next = next; |
4334 | 88 | } | 88 | } |
4335 | @@ -95,7 +95,7 @@ | |||
4336 | 95 | * @param persistit | 95 | * @param persistit |
4337 | 96 | * Owning Persistit instance. | 96 | * Owning Persistit instance. |
4338 | 97 | */ | 97 | */ |
4340 | 98 | ClassIndex(Persistit persistit) { | 98 | ClassIndex(final Persistit persistit) { |
4341 | 99 | _persistit = persistit; | 99 | _persistit = persistit; |
4342 | 100 | } | 100 | } |
4343 | 101 | 101 | ||
4344 | @@ -117,8 +117,8 @@ | |||
4345 | 117 | * The handle | 117 | * The handle |
4346 | 118 | * @return The associated ClassInfo, or <i>null</i> if there is none. | 118 | * @return The associated ClassInfo, or <i>null</i> if there is none. |
4347 | 119 | */ | 119 | */ |
4350 | 120 | public ClassInfo lookupByHandle(int handle) { | 120 | public ClassInfo lookupByHandle(final int handle) { |
4351 | 121 | AtomicReferenceArray<ClassInfoEntry> hashTable = _hashTable; | 121 | final AtomicReferenceArray<ClassInfoEntry> hashTable = _hashTable; |
4352 | 122 | ClassInfoEntry cie = hashTable.get(handle % hashTable.length()); | 122 | ClassInfoEntry cie = hashTable.get(handle % hashTable.length()); |
4353 | 123 | while (cie != null) { | 123 | while (cie != null) { |
4354 | 124 | if (cie._classInfo.getHandle() == handle) | 124 | if (cie._classInfo.getHandle() == handle) |
4355 | @@ -138,43 +138,44 @@ | |||
4356 | 138 | try { | 138 | try { |
4357 | 139 | ex.clear().append(BY_HANDLE).append(handle).fetch(); | 139 | ex.clear().append(BY_HANDLE).append(handle).fetch(); |
4358 | 140 | txn.commit(); | 140 | txn.commit(); |
4360 | 141 | } catch (Exception e) { | 141 | } catch (final Exception e) { |
4361 | 142 | _persistit.getLogBase().exception.log(e); | 142 | _persistit.getLogBase().exception.log(e); |
4362 | 143 | throw new ConversionException(e); | 143 | throw new ConversionException(e); |
4363 | 144 | } finally { | 144 | } finally { |
4364 | 145 | txn.end(); | 145 | txn.end(); |
4365 | 146 | } | 146 | } |
4367 | 147 | Value value = ex.getValue(); | 147 | final Value value = ex.getValue(); |
4368 | 148 | if (value.isDefined()) { | 148 | if (value.isDefined()) { |
4369 | 149 | value.setStreamMode(true); | 149 | value.setStreamMode(true); |
4373 | 150 | int storedId = value.getInt(); | 150 | final int storedId = value.getInt(); |
4374 | 151 | String storedName = value.getString(); | 151 | final String storedName = value.getString(); |
4375 | 152 | long storedSuid = value.getLong(); | 152 | final long storedSuid = value.getLong(); |
4376 | 153 | if (storedId != handle) { | 153 | if (storedId != handle) { |
4377 | 154 | throw new IllegalStateException("ClassInfo stored for handle=" + handle | 154 | throw new IllegalStateException("ClassInfo stored for handle=" + handle |
4378 | 155 | + " has invalid stored handle=" + storedId); | 155 | + " has invalid stored handle=" + storedId); |
4379 | 156 | } | 156 | } |
4381 | 157 | Class<?> cl = Class.forName(storedName, false, Thread.currentThread().getContextClassLoader()); | 157 | final Class<?> cl = Class |
4382 | 158 | .forName(storedName, false, Thread.currentThread().getContextClassLoader()); | ||
4383 | 158 | 159 | ||
4384 | 159 | long suid = 0; | 160 | long suid = 0; |
4386 | 160 | ObjectStreamClass osc = ObjectStreamClass.lookupAny(cl); | 161 | final ObjectStreamClass osc = ObjectStreamClass.lookupAny(cl); |
4387 | 161 | if (osc != null) | 162 | if (osc != null) |
4388 | 162 | suid = osc.getSerialVersionUID(); | 163 | suid = osc.getSerialVersionUID(); |
4389 | 163 | if (storedSuid != suid) { | 164 | if (storedSuid != suid) { |
4390 | 164 | throw new ConversionException("Class " + cl.getName() + " persistent SUID=" + storedSuid | 165 | throw new ConversionException("Class " + cl.getName() + " persistent SUID=" + storedSuid |
4391 | 165 | + " does not match current class SUID=" + suid); | 166 | + " does not match current class SUID=" + suid); |
4392 | 166 | } | 167 | } |
4394 | 167 | ClassInfo ci = new ClassInfo(cl, suid, handle, osc); | 168 | final ClassInfo ci = new ClassInfo(cl, suid, handle, osc); |
4395 | 168 | hashClassInfo(ci); | 169 | hashClassInfo(ci); |
4396 | 169 | return ci; | 170 | return ci; |
4397 | 170 | } else { | 171 | } else { |
4399 | 171 | ClassInfo ci = new ClassInfo(null, 0, handle, null); | 172 | final ClassInfo ci = new ClassInfo(null, 0, handle, null); |
4400 | 172 | hashClassInfo(ci); | 173 | hashClassInfo(ci); |
4401 | 173 | return ci; | 174 | return ci; |
4402 | 174 | } | 175 | } |
4404 | 175 | } catch (ClassNotFoundException cnfe) { | 176 | } catch (final ClassNotFoundException cnfe) { |
4405 | 176 | throw new ConversionException(cnfe); | 177 | throw new ConversionException(cnfe); |
4407 | 177 | } catch (PersistitException pe) { | 178 | } catch (final PersistitException pe) { |
4408 | 178 | throw new ConversionException(pe); | 179 | throw new ConversionException(pe); |
4409 | 179 | } finally { | 180 | } finally { |
4410 | 180 | if (ex != null) | 181 | if (ex != null) |
4411 | @@ -191,13 +192,13 @@ | |||
4412 | 191 | * The <code>Class</code> | 192 | * The <code>Class</code> |
4413 | 192 | * @return The ClassInfo for the specified Class. | 193 | * @return The ClassInfo for the specified Class. |
4414 | 193 | */ | 194 | */ |
4417 | 194 | public ClassInfo lookupByClass(Class<?> clazz) { | 195 | public ClassInfo lookupByClass(final Class<?> clazz) { |
4418 | 195 | AtomicReferenceArray<ClassInfoEntry> hashTable = _hashTable; | 196 | final AtomicReferenceArray<ClassInfoEntry> hashTable = _hashTable; |
4419 | 196 | 197 | ||
4420 | 197 | ObjectStreamClass osc = null; | 198 | ObjectStreamClass osc = null; |
4421 | 198 | long suid = 0; | 199 | long suid = 0; |
4422 | 199 | 200 | ||
4424 | 200 | int nh = clazz.getName().hashCode() & 0x7FFFFFFF; | 201 | final int nh = clazz.getName().hashCode() & 0x7FFFFFFF; |
4425 | 201 | ClassInfoEntry cie = hashTable.get(nh % hashTable.length()); | 202 | ClassInfoEntry cie = hashTable.get(nh % hashTable.length()); |
4426 | 202 | 203 | ||
4427 | 203 | while (cie != null) { | 204 | while (cie != null) { |
4428 | @@ -260,14 +261,14 @@ | |||
4429 | 260 | final int handle; | 261 | final int handle; |
4430 | 261 | txn.begin(); | 262 | txn.begin(); |
4431 | 262 | ex.clear().append(BY_NAME).append(clazz.getName()).append(suid).fetch(); | 263 | ex.clear().append(BY_NAME).append(clazz.getName()).append(suid).fetch(); |
4433 | 263 | Value value = ex.getValue(); | 264 | final Value value = ex.getValue(); |
4434 | 264 | try { | 265 | try { |
4435 | 265 | if (value.isDefined()) { | 266 | if (value.isDefined()) { |
4436 | 266 | value.setStreamMode(true); | 267 | value.setStreamMode(true); |
4437 | 267 | 268 | ||
4438 | 268 | handle = value.getInt(); | 269 | handle = value.getInt(); |
4441 | 269 | String storedName = value.getString(); | 270 | final String storedName = value.getString(); |
4442 | 270 | long storedSuid = value.getLong(); | 271 | final long storedSuid = value.getLong(); |
4443 | 271 | 272 | ||
4444 | 272 | if (storedSuid != suid || !clazz.getName().equals(storedName)) { | 273 | if (storedSuid != suid || !clazz.getName().equals(storedName)) { |
4445 | 273 | throw new ConversionException("Class " + clazz.getName() + " persistent SUID=" + storedSuid | 274 | throw new ConversionException("Class " + clazz.getName() + " persistent SUID=" + storedSuid |
4446 | @@ -301,7 +302,7 @@ | |||
4447 | 301 | } finally { | 302 | } finally { |
4448 | 302 | txn.end(); | 303 | txn.end(); |
4449 | 303 | } | 304 | } |
4451 | 304 | } catch (PersistitException pe) { | 305 | } catch (final PersistitException pe) { |
4452 | 305 | throw new ConversionException(pe); | 306 | throw new ConversionException(pe); |
4453 | 306 | } finally { | 307 | } finally { |
4454 | 307 | if (ex != null) { | 308 | if (ex != null) { |
4455 | @@ -322,16 +323,16 @@ | |||
4456 | 322 | * @param clazz | 323 | * @param clazz |
4457 | 323 | * Class instance to register. | 324 | * Class instance to register. |
4458 | 324 | */ | 325 | */ |
4460 | 325 | public void registerClass(Class<?> clazz) { | 326 | public void registerClass(final Class<?> clazz) { |
4461 | 326 | lookupByClass(clazz); | 327 | lookupByClass(clazz); |
4462 | 327 | } | 328 | } |
4463 | 328 | 329 | ||
4466 | 329 | private void hashClassInfo(ClassInfo ci) { | 330 | private void hashClassInfo(final ClassInfo ci) { |
4467 | 330 | int size = _size.get(); | 331 | final int size = _size.get(); |
4468 | 331 | if (size * EXTRA_FACTOR > _hashTable.length()) { | 332 | if (size * EXTRA_FACTOR > _hashTable.length()) { |
4472 | 332 | int discarded = _discardedDuplicates.get(); | 333 | final int discarded = _discardedDuplicates.get(); |
4473 | 333 | AtomicReferenceArray<ClassInfoEntry> newHashTable = new AtomicReferenceArray<ClassInfoEntry>(EXTRA_FACTOR | 334 | final AtomicReferenceArray<ClassInfoEntry> newHashTable = new AtomicReferenceArray<ClassInfoEntry>( |
4474 | 334 | * 2 * size); | 335 | EXTRA_FACTOR * 2 * size); |
4475 | 335 | for (int i = 0; i < _hashTable.length(); i++) { | 336 | for (int i = 0; i < _hashTable.length(); i++) { |
4476 | 336 | ClassInfoEntry cie = _hashTable.get(i); | 337 | ClassInfoEntry cie = _hashTable.get(i); |
4477 | 337 | while (cie != null) { | 338 | while (cie != null) { |
4478 | @@ -345,7 +346,7 @@ | |||
4479 | 345 | addHashEntry(_hashTable, ci); | 346 | addHashEntry(_hashTable, ci); |
4480 | 346 | } | 347 | } |
4481 | 347 | 348 | ||
4483 | 348 | private void addHashEntry(final AtomicReferenceArray<ClassInfoEntry> hashTable, ClassInfo ci) { | 349 | private void addHashEntry(final AtomicReferenceArray<ClassInfoEntry> hashTable, final ClassInfo ci) { |
4484 | 349 | final int hh = ci.getHandle() % hashTable.length(); | 350 | final int hh = ci.getHandle() % hashTable.length(); |
4485 | 350 | final int nh = ci.getDescribedClass() == null ? -1 | 351 | final int nh = ci.getDescribedClass() == null ? -1 |
4486 | 351 | : ((ci.getDescribedClass().getName().hashCode() & 0x7FFFFFFF) % hashTable.length()); | 352 | : ((ci.getDescribedClass().getName().hashCode() & 0x7FFFFFFF) % hashTable.length()); |
4487 | @@ -358,7 +359,8 @@ | |||
4488 | 358 | } | 359 | } |
4489 | 359 | } | 360 | } |
4490 | 360 | 361 | ||
4492 | 361 | private boolean addHashEntry(final AtomicReferenceArray<ClassInfoEntry> hashTable, ClassInfo ci, final int hash) { | 362 | private boolean addHashEntry(final AtomicReferenceArray<ClassInfoEntry> hashTable, final ClassInfo ci, |
4493 | 363 | final int hash) { | ||
4494 | 362 | ClassInfoEntry cie = hashTable.get(hash); | 364 | ClassInfoEntry cie = hashTable.get(hash); |
4495 | 363 | while (cie != null) { | 365 | while (cie != null) { |
4496 | 364 | if (ci.equals(cie._classInfo)) { | 366 | if (ci.equals(cie._classInfo)) { |
4497 | @@ -367,7 +369,7 @@ | |||
4498 | 367 | cie = cie._next; | 369 | cie = cie._next; |
4499 | 368 | } | 370 | } |
4500 | 369 | cie = hashTable.get(hash); | 371 | cie = hashTable.get(hash); |
4502 | 370 | ClassInfoEntry newCie = new ClassInfoEntry(ci, cie); | 372 | final ClassInfoEntry newCie = new ClassInfoEntry(ci, cie); |
4503 | 371 | hashTable.set(hash, newCie); | 373 | hashTable.set(hash, newCie); |
4504 | 372 | _size.incrementAndGet(); | 374 | _size.incrementAndGet(); |
4505 | 373 | return true; | 375 | return true; |
4506 | @@ -375,14 +377,14 @@ | |||
4507 | 375 | 377 | ||
4508 | 376 | private Exchange getExchange() throws PersistitException { | 378 | private Exchange getExchange() throws PersistitException { |
4509 | 377 | try { | 379 | try { |
4511 | 378 | Volume volume = _persistit.getSystemVolume(); | 380 | final Volume volume = _persistit.getSystemVolume(); |
4512 | 379 | return _persistit.getExchange(volume, CLASS_INDEX_TREE_NAME, true); | 381 | return _persistit.getExchange(volume, CLASS_INDEX_TREE_NAME, true); |
4514 | 380 | } catch (PersistitException pe) { | 382 | } catch (final PersistitException pe) { |
4515 | 381 | throw new ConversionException(pe); | 383 | throw new ConversionException(pe); |
4516 | 382 | } | 384 | } |
4517 | 383 | } | 385 | } |
4518 | 384 | 386 | ||
4520 | 385 | private void releaseExchange(Exchange ex) { | 387 | private void releaseExchange(final Exchange ex) { |
4521 | 386 | _persistit.releaseExchange(ex); | 388 | _persistit.releaseExchange(ex); |
4522 | 387 | } | 389 | } |
4523 | 388 | 390 | ||
4524 | 389 | 391 | ||
4525 | === modified file 'src/main/java/com/persistit/ClassInfo.java' | |||
4526 | --- src/main/java/com/persistit/ClassInfo.java 2012-08-02 04:45:28 +0000 | |||
4527 | +++ src/main/java/com/persistit/ClassInfo.java 2012-08-24 18:20:24 +0000 | |||
4528 | @@ -24,21 +24,22 @@ | |||
4529 | 24 | */ | 24 | */ |
4530 | 25 | 25 | ||
4531 | 26 | class ClassInfo { | 26 | class ClassInfo { |
4536 | 27 | private Class<?> _class; | 27 | private final Class<?> _class; |
4537 | 28 | private long _suid; | 28 | private final long _suid; |
4538 | 29 | private int _handle; | 29 | private final int _handle; |
4539 | 30 | private ObjectStreamClass _osc; | 30 | private final ObjectStreamClass _osc; |
4540 | 31 | 31 | ||
4542 | 32 | ClassInfo(Class<?> cl, long suid, int handle, ObjectStreamClass osc) { | 32 | ClassInfo(final Class<?> cl, final long suid, final int handle, final ObjectStreamClass osc) { |
4543 | 33 | _class = cl; | 33 | _class = cl; |
4544 | 34 | _suid = suid; | 34 | _suid = suid; |
4545 | 35 | _handle = handle; | 35 | _handle = handle; |
4546 | 36 | _osc = osc; | 36 | _osc = osc; |
4547 | 37 | } | 37 | } |
4548 | 38 | 38 | ||
4549 | 39 | @Override | ||
4550 | 39 | public boolean equals(final Object object) { | 40 | public boolean equals(final Object object) { |
4551 | 40 | if (object instanceof ClassInfo) { | 41 | if (object instanceof ClassInfo) { |
4553 | 41 | ClassInfo ci = (ClassInfo) object; | 42 | final ClassInfo ci = (ClassInfo) object; |
4554 | 42 | if (equals(_class, ci._class) && _handle == ci._handle && _suid == ci._suid) { | 43 | if (equals(_class, ci._class) && _handle == ci._handle && _suid == ci._suid) { |
4555 | 43 | return true; | 44 | return true; |
4556 | 44 | } | 45 | } |
4557 | @@ -46,6 +47,7 @@ | |||
4558 | 46 | return false; | 47 | return false; |
4559 | 47 | } | 48 | } |
4560 | 48 | 49 | ||
4561 | 50 | @Override | ||
4562 | 49 | public int hashCode() { | 51 | public int hashCode() { |
4563 | 50 | return _class.hashCode() ^ _handle ^ (int) _suid; | 52 | return _class.hashCode() ^ _handle ^ (int) _suid; |
4564 | 51 | } | 53 | } |
4565 | @@ -86,9 +88,8 @@ | |||
4566 | 86 | public ObjectStreamClass getClassDescriptor() { | 88 | public ObjectStreamClass getClassDescriptor() { |
4567 | 87 | return _osc; | 89 | return _osc; |
4568 | 88 | } | 90 | } |
4571 | 89 | 91 | ||
4572 | 90 | private boolean equals(Class<?> a, Class<?> b) { | 92 | private boolean equals(final Class<?> a, final Class<?> b) { |
4573 | 91 | return a == null ? b == null : a.equals(b); | 93 | return a == null ? b == null : a.equals(b); |
4574 | 92 | } | 94 | } |
4575 | 93 | } | 95 | } |
4576 | 94 | |||
4577 | 95 | 96 | ||
4578 | === modified file 'src/main/java/com/persistit/CleanupManager.java' | |||
4579 | --- src/main/java/com/persistit/CleanupManager.java 2012-08-02 04:45:28 +0000 | |||
4580 | +++ src/main/java/com/persistit/CleanupManager.java 2012-08-24 18:20:24 +0000 | |||
4581 | @@ -46,17 +46,17 @@ | |||
4582 | 46 | 46 | ||
4583 | 47 | final Queue<CleanupAction> _cleanupActionQueue = new ArrayBlockingQueue<CleanupAction>(DEFAULT_QUEUE_SIZE); | 47 | final Queue<CleanupAction> _cleanupActionQueue = new ArrayBlockingQueue<CleanupAction>(DEFAULT_QUEUE_SIZE); |
4584 | 48 | 48 | ||
4596 | 49 | private AtomicBoolean _closed = new AtomicBoolean(); | 49 | private final AtomicBoolean _closed = new AtomicBoolean(); |
4597 | 50 | 50 | ||
4598 | 51 | private AtomicLong _accepted = new AtomicLong(); | 51 | private final AtomicLong _accepted = new AtomicLong(); |
4599 | 52 | 52 | ||
4600 | 53 | private AtomicLong _refused = new AtomicLong(); | 53 | private final AtomicLong _refused = new AtomicLong(); |
4601 | 54 | 54 | ||
4602 | 55 | private AtomicLong _performed = new AtomicLong(); | 55 | private final AtomicLong _performed = new AtomicLong(); |
4603 | 56 | 56 | ||
4604 | 57 | private AtomicLong _errors = new AtomicLong(); | 57 | private final AtomicLong _errors = new AtomicLong(); |
4605 | 58 | 58 | ||
4606 | 59 | private AtomicLong _minimumPruningDelay = new AtomicLong(DEFAULT_MINIMUM_PRUNING_DELAY); | 59 | private final AtomicLong _minimumPruningDelay = new AtomicLong(DEFAULT_MINIMUM_PRUNING_DELAY); |
4607 | 60 | 60 | ||
4608 | 61 | CleanupManager(final Persistit persistit) { | 61 | CleanupManager(final Persistit persistit) { |
4609 | 62 | super(persistit); | 62 | super(persistit); |
4610 | @@ -81,8 +81,8 @@ | |||
4611 | 81 | return _closed.get(); | 81 | return _closed.get(); |
4612 | 82 | } | 82 | } |
4613 | 83 | 83 | ||
4616 | 84 | synchronized boolean offer(CleanupAction action) { | 84 | synchronized boolean offer(final CleanupAction action) { |
4617 | 85 | boolean accepted = _cleanupActionQueue.offer(action); | 85 | final boolean accepted = _cleanupActionQueue.offer(action); |
4618 | 86 | if (accepted) { | 86 | if (accepted) { |
4619 | 87 | _accepted.incrementAndGet(); | 87 | _accepted.incrementAndGet(); |
4620 | 88 | } else { | 88 | } else { |
4621 | @@ -148,9 +148,10 @@ | |||
4622 | 148 | try { | 148 | try { |
4623 | 149 | action.performAction(_persistit); | 149 | action.performAction(_persistit); |
4624 | 150 | _performed.incrementAndGet(); | 150 | _performed.incrementAndGet(); |
4626 | 151 | } catch (PersistitException e) { | 151 | } catch (final PersistitException e) { |
4627 | 152 | lastException(e); | 152 | lastException(e); |
4629 | 153 | _persistit.getAlertMonitor().post(new Event(AlertLevel.ERROR, _persistit.getLogBase().cleanupException, e, action), | 153 | _persistit.getAlertMonitor().post( |
4630 | 154 | new Event(AlertLevel.ERROR, _persistit.getLogBase().cleanupException, e, action), | ||
4631 | 154 | AlertMonitor.CLEANUP_CATEGORY); | 155 | AlertMonitor.CLEANUP_CATEGORY); |
4632 | 155 | _errors.incrementAndGet(); | 156 | _errors.incrementAndGet(); |
4633 | 156 | } | 157 | } |
4634 | @@ -164,7 +165,7 @@ | |||
4635 | 164 | 165 | ||
4636 | 165 | @Override | 166 | @Override |
4637 | 166 | public synchronized String toString() { | 167 | public synchronized String toString() { |
4639 | 167 | StringBuilder sb = new StringBuilder("["); | 168 | final StringBuilder sb = new StringBuilder("["); |
4640 | 168 | for (final CleanupAction a : _cleanupActionQueue) { | 169 | for (final CleanupAction a : _cleanupActionQueue) { |
4641 | 169 | if (sb.length() > 1) { | 170 | if (sb.length() > 1) { |
4642 | 170 | sb.append(",\n "); | 171 | sb.append(",\n "); |
4643 | @@ -188,9 +189,9 @@ | |||
4644 | 188 | } | 189 | } |
4645 | 189 | 190 | ||
4646 | 190 | @Override | 191 | @Override |
4648 | 191 | public boolean equals(Object other) { | 192 | public boolean equals(final Object other) { |
4649 | 192 | if (other instanceof CleanupTreePage) { | 193 | if (other instanceof CleanupTreePage) { |
4651 | 193 | CleanupTreePage a = (CleanupTreePage) other; | 194 | final CleanupTreePage a = (CleanupTreePage) other; |
4652 | 194 | return a._page == _page && a._treeHandle == _treeHandle && getClass().equals(a.getClass()); | 195 | return a._page == _page && a._treeHandle == _treeHandle && getClass().equals(a.getClass()); |
4653 | 195 | } else { | 196 | } else { |
4654 | 196 | return false; | 197 | return false; |
4655 | @@ -199,10 +200,10 @@ | |||
4656 | 199 | } | 200 | } |
4657 | 200 | 201 | ||
4658 | 201 | @Override | 202 | @Override |
4660 | 202 | public int compareTo(CleanupAction other) { | 203 | public int compareTo(final CleanupAction other) { |
4661 | 203 | if (other instanceof CleanupTreePage) { | 204 | if (other instanceof CleanupTreePage) { |
4664 | 204 | CleanupTreePage a = (CleanupTreePage) other; | 205 | final CleanupTreePage a = (CleanupTreePage) other; |
4665 | 205 | int d = _treeHandle - a._treeHandle; | 206 | final int d = _treeHandle - a._treeHandle; |
4666 | 206 | if (d != 0) { | 207 | if (d != 0) { |
4667 | 207 | return d; | 208 | return d; |
4668 | 208 | } | 209 | } |
4669 | @@ -222,15 +223,15 @@ | |||
4670 | 222 | if (tree == null) { | 223 | if (tree == null) { |
4671 | 223 | return null; | 224 | return null; |
4672 | 224 | } | 225 | } |
4674 | 225 | WeakReference<Exchange> ref = _exchangeThreadLocal.get(); | 226 | final WeakReference<Exchange> ref = _exchangeThreadLocal.get(); |
4675 | 226 | if (ref != null) { | 227 | if (ref != null) { |
4677 | 227 | Exchange exchange = ref.get(); | 228 | final Exchange exchange = ref.get(); |
4678 | 228 | if (exchange != null) { | 229 | if (exchange != null) { |
4679 | 229 | exchange.init(tree); | 230 | exchange.init(tree); |
4680 | 230 | return exchange; | 231 | return exchange; |
4681 | 231 | } | 232 | } |
4682 | 232 | } | 233 | } |
4684 | 233 | Exchange exchange = new Exchange(tree); | 234 | final Exchange exchange = new Exchange(tree); |
4685 | 234 | _exchangeThreadLocal.set(new WeakReference<Exchange>(exchange)); | 235 | _exchangeThreadLocal.set(new WeakReference<Exchange>(exchange)); |
4686 | 235 | return exchange; | 236 | return exchange; |
4687 | 236 | } | 237 | } |
4688 | @@ -253,7 +254,7 @@ | |||
4689 | 253 | 254 | ||
4690 | 254 | static class CleanupPruneAction extends CleanupTreePage { | 255 | static class CleanupPruneAction extends CleanupTreePage { |
4691 | 255 | 256 | ||
4693 | 256 | CleanupPruneAction(int treeHandle, long page) { | 257 | CleanupPruneAction(final int treeHandle, final long page) { |
4694 | 257 | super(treeHandle, page); | 258 | super(treeHandle, page); |
4695 | 258 | } | 259 | } |
4696 | 259 | 260 | ||
4697 | @@ -269,7 +270,7 @@ | |||
4698 | 269 | static class CleanupIndexHole extends CleanupTreePage { | 270 | static class CleanupIndexHole extends CleanupTreePage { |
4699 | 270 | int _level; | 271 | int _level; |
4700 | 271 | 272 | ||
4702 | 272 | CleanupIndexHole(int treeHandle, long page, int level) { | 273 | CleanupIndexHole(final int treeHandle, final long page, final int level) { |
4703 | 273 | super(treeHandle, page); | 274 | super(treeHandle, page); |
4704 | 274 | _level = level; | 275 | _level = level; |
4705 | 275 | } | 276 | } |
4706 | 276 | 277 | ||
4707 | === modified file 'src/main/java/com/persistit/Configuration.java' | |||
4708 | --- src/main/java/com/persistit/Configuration.java 2012-08-07 21:11:28 +0000 | |||
4709 | +++ src/main/java/com/persistit/Configuration.java 2012-08-24 18:20:24 +0000 | |||
4710 | @@ -264,22 +264,22 @@ | |||
4711 | 264 | * Property name for the "append only" property. | 264 | * Property name for the "append only" property. |
4712 | 265 | */ | 265 | */ |
4713 | 266 | public final static String APPEND_ONLY_PROPERTY = "appendonly"; | 266 | public final static String APPEND_ONLY_PROPERTY = "appendonly"; |
4715 | 267 | 267 | ||
4716 | 268 | /** | 268 | /** |
4717 | 269 | * Property name for the "ignore missing volumes" property. | 269 | * Property name for the "ignore missing volumes" property. |
4718 | 270 | */ | 270 | */ |
4719 | 271 | public final static String IGNORE_MISSING_VOLUMES_PROPERTY = "ignoremissingvolumes"; | 271 | public final static String IGNORE_MISSING_VOLUMES_PROPERTY = "ignoremissingvolumes"; |
4721 | 272 | 272 | ||
4722 | 273 | /** | 273 | /** |
4723 | 274 | * Property name to specify the default {@link SplitPolicy}. | 274 | * Property name to specify the default {@link SplitPolicy}. |
4724 | 275 | */ | 275 | */ |
4725 | 276 | public final static String SPLIT_POLICY_PROPERTY_NAME = "splitpolicy"; | 276 | public final static String SPLIT_POLICY_PROPERTY_NAME = "splitpolicy"; |
4727 | 277 | 277 | ||
4728 | 278 | /** | 278 | /** |
4729 | 279 | * Property name to specify the"buffer inventory" property name. | 279 | * Property name to specify the"buffer inventory" property name. |
4730 | 280 | */ | 280 | */ |
4731 | 281 | public final static String BUFFER_INVENTORY_PROPERTY_NAME = "bufferinventory"; | 281 | public final static String BUFFER_INVENTORY_PROPERTY_NAME = "bufferinventory"; |
4733 | 282 | 282 | ||
4734 | 283 | public final static String BUFFER_POLLING_INTERVAL_PROPERTY = "bufferpollinginterval"; | 283 | public final static String BUFFER_POLLING_INTERVAL_PROPERTY = "bufferpollinginterval"; |
4735 | 284 | 284 | ||
4736 | 285 | /** | 285 | /** |
4737 | @@ -392,7 +392,7 @@ | |||
4738 | 392 | * @param minimumCount | 392 | * @param minimumCount |
4739 | 393 | * the minimumCount to set | 393 | * the minimumCount to set |
4740 | 394 | */ | 394 | */ |
4742 | 395 | public void setMinimumCount(int minimumCount) { | 395 | public void setMinimumCount(final int minimumCount) { |
4743 | 396 | this.minimumCount = minimumCount; | 396 | this.minimumCount = minimumCount; |
4744 | 397 | } | 397 | } |
4745 | 398 | 398 | ||
4746 | @@ -407,7 +407,7 @@ | |||
4747 | 407 | * @param maximumCount | 407 | * @param maximumCount |
4748 | 408 | * the maximumCount to set | 408 | * the maximumCount to set |
4749 | 409 | */ | 409 | */ |
4751 | 410 | public void setMaximumCount(int maximumCount) { | 410 | public void setMaximumCount(final int maximumCount) { |
4752 | 411 | this.maximumCount = maximumCount; | 411 | this.maximumCount = maximumCount; |
4753 | 412 | } | 412 | } |
4754 | 413 | 413 | ||
4755 | @@ -416,7 +416,7 @@ | |||
4756 | 416 | * | 416 | * |
4757 | 417 | * @param count | 417 | * @param count |
4758 | 418 | */ | 418 | */ |
4760 | 419 | public void setCount(int count) { | 419 | public void setCount(final int count) { |
4761 | 420 | setMinimumCount(count); | 420 | setMinimumCount(count); |
4762 | 421 | setMaximumCount(count); | 421 | setMaximumCount(count); |
4763 | 422 | } | 422 | } |
4764 | @@ -432,7 +432,7 @@ | |||
4765 | 432 | * @param minimumMemory | 432 | * @param minimumMemory |
4766 | 433 | * the minimumMemory to set | 433 | * the minimumMemory to set |
4767 | 434 | */ | 434 | */ |
4769 | 435 | public void setMinimumMemory(long minimumMemory) { | 435 | public void setMinimumMemory(final long minimumMemory) { |
4770 | 436 | this.minimumMemory = minimumMemory; | 436 | this.minimumMemory = minimumMemory; |
4771 | 437 | } | 437 | } |
4772 | 438 | 438 | ||
4773 | @@ -447,7 +447,7 @@ | |||
4774 | 447 | * @param maximumMemory | 447 | * @param maximumMemory |
4775 | 448 | * the maximumMemory to set | 448 | * the maximumMemory to set |
4776 | 449 | */ | 449 | */ |
4778 | 450 | public void setMaximumMemory(long maximumMemory) { | 450 | public void setMaximumMemory(final long maximumMemory) { |
4779 | 451 | this.maximumMemory = maximumMemory; | 451 | this.maximumMemory = maximumMemory; |
4780 | 452 | } | 452 | } |
4781 | 453 | 453 | ||
4782 | @@ -462,7 +462,7 @@ | |||
4783 | 462 | * @param reservedMemory | 462 | * @param reservedMemory |
4784 | 463 | * the reservedMemory to set | 463 | * the reservedMemory to set |
4785 | 464 | */ | 464 | */ |
4787 | 465 | public void setReservedMemory(long reservedMemory) { | 465 | public void setReservedMemory(final long reservedMemory) { |
4788 | 466 | this.reservedMemory = reservedMemory; | 466 | this.reservedMemory = reservedMemory; |
4789 | 467 | } | 467 | } |
4790 | 468 | 468 | ||
4791 | @@ -477,7 +477,7 @@ | |||
4792 | 477 | * @param fraction | 477 | * @param fraction |
4793 | 478 | * the fraction to set | 478 | * the fraction to set |
4794 | 479 | */ | 479 | */ |
4796 | 480 | public void setFraction(float fraction) { | 480 | public void setFraction(final float fraction) { |
4797 | 481 | this.fraction = fraction; | 481 | this.fraction = fraction; |
4798 | 482 | } | 482 | } |
4799 | 483 | 483 | ||
4800 | @@ -496,10 +496,11 @@ | |||
4801 | 496 | if (maximumCount == 0) { | 496 | if (maximumCount == 0) { |
4802 | 497 | return 0; | 497 | return 0; |
4803 | 498 | } | 498 | } |
4808 | 499 | long maximumAvailable = (long) ((availableHeapMemory - reservedMemory) * fraction); | 499 | final long maximumAvailable = (long) ((availableHeapMemory - reservedMemory) * fraction); |
4809 | 500 | long allocation = Math.min(maximumAvailable, maximumMemory); | 500 | final long allocation = Math.min(maximumAvailable, maximumMemory); |
4810 | 501 | int bufferSizeWithOverhead = Buffer.bufferSizeWithOverhead(bufferSize); | 501 | final int bufferSizeWithOverhead = Buffer.bufferSizeWithOverhead(bufferSize); |
4811 | 502 | int buffers = Math.max(minimumCount, Math.min(maximumCount, (int) (allocation / bufferSizeWithOverhead))); | 502 | final int buffers = Math.max(minimumCount, |
4812 | 503 | Math.min(maximumCount, (int) (allocation / bufferSizeWithOverhead))); | ||
4813 | 503 | if (buffers < BufferPool.MINIMUM_POOL_COUNT || buffers > BufferPool.MAXIMUM_POOL_COUNT | 504 | if (buffers < BufferPool.MINIMUM_POOL_COUNT || buffers > BufferPool.MAXIMUM_POOL_COUNT |
4814 | 504 | || (long) buffers * (long) bufferSizeWithOverhead > maximumAvailable | 505 | || (long) buffers * (long) bufferSizeWithOverhead > maximumAvailable |
4815 | 505 | || (long) (buffers + 1) * (long) bufferSizeWithOverhead < minimumMemory) { | 506 | || (long) (buffers + 1) * (long) bufferSizeWithOverhead < minimumMemory) { |
4816 | @@ -510,8 +511,9 @@ | |||
4817 | 510 | return buffers; | 511 | return buffers; |
4818 | 511 | } | 512 | } |
4819 | 512 | 513 | ||
4820 | 514 | @Override | ||
4821 | 513 | public String toString() { | 515 | public String toString() { |
4823 | 514 | StringBuilder sb = new StringBuilder("BufferPoolConfiguration("); | 516 | final StringBuilder sb = new StringBuilder("BufferPoolConfiguration("); |
4824 | 515 | sb.append(String.format("size=%d", bufferSize)); | 517 | sb.append(String.format("size=%d", bufferSize)); |
4825 | 516 | if (minimumCount == maximumCount) { | 518 | if (minimumCount == maximumCount) { |
4826 | 517 | sb.append(String.format(",count=%d", minimumCount)); | 519 | sb.append(String.format(",count=%d", minimumCount)); |
4827 | @@ -545,7 +547,7 @@ | |||
4828 | 545 | */ | 547 | */ |
4829 | 546 | public void parseBufferCount(final int bufferSize, final String propertyName, final String propertyValue) { | 548 | public void parseBufferCount(final int bufferSize, final String propertyName, final String propertyValue) { |
4830 | 547 | reset(); | 549 | reset(); |
4832 | 548 | int count = (int) parseLongProperty(propertyName, propertyValue); | 550 | final int count = (int) parseLongProperty(propertyName, propertyValue); |
4833 | 549 | Util.rangeCheck(count, BufferPool.MINIMUM_POOL_COUNT, BufferPool.MAXIMUM_POOL_COUNT); | 551 | Util.rangeCheck(count, BufferPool.MINIMUM_POOL_COUNT, BufferPool.MAXIMUM_POOL_COUNT); |
4834 | 550 | setMaximumCount(count); | 552 | setMaximumCount(count); |
4835 | 551 | setMinimumCount(count); | 553 | setMinimumCount(count); |
4836 | @@ -633,7 +635,8 @@ | |||
4837 | 633 | private boolean jmx = true; | 635 | private boolean jmx = true; |
4838 | 634 | private boolean appendOnly; | 636 | private boolean appendOnly; |
4839 | 635 | private String bufferInventoryPathName; | 637 | private String bufferInventoryPathName; |
4841 | 636 | private long bufferInventoryPollInterval = 3000000; // default five minute polling | 638 | private long bufferInventoryPollInterval = 3000000; // default five minute |
4842 | 639 | // polling | ||
4843 | 637 | private boolean ignoreMissingVolumes; | 640 | private boolean ignoreMissingVolumes; |
4844 | 638 | private String tmpVolDir; | 641 | private String tmpVolDir; |
4845 | 639 | private int tmpVolPageSize; | 642 | private int tmpVolPageSize; |
4846 | @@ -644,8 +647,8 @@ | |||
4847 | 644 | * passed to the {@link Persistit#initialize(Configuration)} method. | 647 | * passed to the {@link Persistit#initialize(Configuration)} method. |
4848 | 645 | */ | 648 | */ |
4849 | 646 | public Configuration() { | 649 | public Configuration() { |
4852 | 647 | Map<Integer, BufferPoolConfiguration> map = new TreeMap<Integer, BufferPoolConfiguration>(); | 650 | final Map<Integer, BufferPoolConfiguration> map = new TreeMap<Integer, BufferPoolConfiguration>(); |
4853 | 648 | for (int bufferSize : BUFFER_SIZES) { | 651 | for (final int bufferSize : BUFFER_SIZES) { |
4854 | 649 | map.put(bufferSize, new BufferPoolConfiguration(bufferSize)); | 652 | map.put(bufferSize, new BufferPoolConfiguration(bufferSize)); |
4855 | 650 | } | 653 | } |
4856 | 651 | bufferPoolMap = Collections.unmodifiableMap(map); | 654 | bufferPoolMap = Collections.unmodifiableMap(map); |
4857 | @@ -673,22 +676,22 @@ | |||
4858 | 673 | } | 676 | } |
4859 | 674 | 677 | ||
4860 | 675 | void readPropertiesFile(final String propertiesFileName) throws PersistitException { | 678 | void readPropertiesFile(final String propertiesFileName) throws PersistitException { |
4862 | 676 | Properties properties = new Properties(); | 679 | final Properties properties = new Properties(); |
4863 | 677 | try { | 680 | try { |
4864 | 678 | if (propertiesFileName.contains(DEFAULT_PROPERTIES_FILE_SUFFIX) | 681 | if (propertiesFileName.contains(DEFAULT_PROPERTIES_FILE_SUFFIX) |
4865 | 679 | || propertiesFileName.contains(File.separator)) { | 682 | || propertiesFileName.contains(File.separator)) { |
4866 | 680 | properties.load(new FileInputStream(propertiesFileName)); | 683 | properties.load(new FileInputStream(propertiesFileName)); |
4867 | 681 | } else { | 684 | } else { |
4870 | 682 | ResourceBundle bundle = ResourceBundle.getBundle(propertiesFileName); | 685 | final ResourceBundle bundle = ResourceBundle.getBundle(propertiesFileName); |
4871 | 683 | for (Enumeration<String> e = bundle.getKeys(); e.hasMoreElements();) { | 686 | for (final Enumeration<String> e = bundle.getKeys(); e.hasMoreElements();) { |
4872 | 684 | final String key = e.nextElement(); | 687 | final String key = e.nextElement(); |
4873 | 685 | properties.put(key, bundle.getString(key)); | 688 | properties.put(key, bundle.getString(key)); |
4874 | 686 | } | 689 | } |
4875 | 687 | } | 690 | } |
4877 | 688 | } catch (FileNotFoundException fnfe) { | 691 | } catch (final FileNotFoundException fnfe) { |
4878 | 689 | // A friendlier exception when the properties file is not found. | 692 | // A friendlier exception when the properties file is not found. |
4879 | 690 | throw new PropertiesNotFoundException(fnfe.getMessage()); | 693 | throw new PropertiesNotFoundException(fnfe.getMessage()); |
4881 | 691 | } catch (IOException ioe) { | 694 | } catch (final IOException ioe) { |
4882 | 692 | throw new PersistitIOException(ioe); | 695 | throw new PersistitIOException(ioe); |
4883 | 693 | } | 696 | } |
4884 | 694 | merge(properties); | 697 | merge(properties); |
4885 | @@ -696,7 +699,7 @@ | |||
4886 | 696 | } | 699 | } |
4887 | 697 | 700 | ||
4888 | 698 | final static void checkBufferSize(final int bufferSize) { | 701 | final static void checkBufferSize(final int bufferSize) { |
4890 | 699 | for (int size : BUFFER_SIZES) { | 702 | for (final int size : BUFFER_SIZES) { |
4891 | 700 | if (size == bufferSize) { | 703 | if (size == bufferSize) { |
4892 | 701 | return; | 704 | return; |
4893 | 702 | } | 705 | } |
4894 | @@ -741,13 +744,13 @@ | |||
4895 | 741 | 744 | ||
4896 | 742 | void loadPropertiesBufferSpecifications() { | 745 | void loadPropertiesBufferSpecifications() { |
4897 | 743 | for (int index = 0; index < BUFFER_SIZES.length; index++) { | 746 | for (int index = 0; index < BUFFER_SIZES.length; index++) { |
4899 | 744 | int size = BUFFER_SIZES[index]; | 747 | final int size = BUFFER_SIZES[index]; |
4900 | 745 | 748 | ||
4901 | 746 | final String countPropertyName = BUFFERS_PROPERTY_NAME + size; | 749 | final String countPropertyName = BUFFERS_PROPERTY_NAME + size; |
4902 | 747 | final String memPropertyName = BUFFER_MEM_PROPERTY_NAME + size; | 750 | final String memPropertyName = BUFFER_MEM_PROPERTY_NAME + size; |
4903 | 748 | 751 | ||
4906 | 749 | String countSpec = getProperty(countPropertyName); | 752 | final String countSpec = getProperty(countPropertyName); |
4907 | 750 | String memSpec = getProperty(memPropertyName); | 753 | final String memSpec = getProperty(memPropertyName); |
4908 | 751 | int count = 0; | 754 | int count = 0; |
4909 | 752 | final BufferPoolConfiguration bpc = bufferPoolMap.get(size); | 755 | final BufferPoolConfiguration bpc = bufferPoolMap.get(size); |
4910 | 753 | 756 | ||
4911 | @@ -770,13 +773,13 @@ | |||
4912 | 770 | } | 773 | } |
4913 | 771 | 774 | ||
4914 | 772 | void loadPropertiesVolumeSpecifications() throws InvalidVolumeSpecificationException { | 775 | void loadPropertiesVolumeSpecifications() throws InvalidVolumeSpecificationException { |
4917 | 773 | for (Enumeration<?> enumeration = _properties.propertyNames(); enumeration.hasMoreElements();) { | 776 | for (final Enumeration<?> enumeration = _properties.propertyNames(); enumeration.hasMoreElements();) { |
4918 | 774 | String key = (String) enumeration.nextElement(); | 777 | final String key = (String) enumeration.nextElement(); |
4919 | 775 | if (key.startsWith(VOLUME_PROPERTY_PREFIX)) { | 778 | if (key.startsWith(VOLUME_PROPERTY_PREFIX)) { |
4920 | 776 | boolean isOne = true; | 779 | boolean isOne = true; |
4921 | 777 | try { | 780 | try { |
4922 | 778 | Integer.parseInt(key.substring(VOLUME_PROPERTY_PREFIX.length())); | 781 | Integer.parseInt(key.substring(VOLUME_PROPERTY_PREFIX.length())); |
4924 | 779 | } catch (NumberFormatException nfe) { | 782 | } catch (final NumberFormatException nfe) { |
4925 | 780 | isOne = false; | 783 | isOne = false; |
4926 | 781 | } | 784 | } |
4927 | 782 | if (isOne) { | 785 | if (isOne) { |
4928 | @@ -789,12 +792,12 @@ | |||
4929 | 789 | 792 | ||
4930 | 790 | final static int bufferSizeFromPropertyName(final String propertyName) { | 793 | final static int bufferSizeFromPropertyName(final String propertyName) { |
4931 | 791 | if (propertyName.startsWith(BUFFERS_PROPERTY_NAME) || propertyName.startsWith(BUFFER_MEM_PROPERTY_NAME)) { | 794 | if (propertyName.startsWith(BUFFERS_PROPERTY_NAME) || propertyName.startsWith(BUFFER_MEM_PROPERTY_NAME)) { |
4933 | 792 | String[] s = propertyName.split("\\."); | 795 | final String[] s = propertyName.split("\\."); |
4934 | 793 | try { | 796 | try { |
4936 | 794 | int size = Integer.parseInt(s[2]); | 797 | final int size = Integer.parseInt(s[2]); |
4937 | 795 | checkBufferSize(size); | 798 | checkBufferSize(size); |
4938 | 796 | return size; | 799 | return size; |
4940 | 797 | } catch (Exception e) { | 800 | } catch (final Exception e) { |
4941 | 798 | // default to -1 | 801 | // default to -1 |
4942 | 799 | } | 802 | } |
4943 | 800 | } | 803 | } |
4944 | @@ -812,7 +815,7 @@ | |||
4945 | 812 | * Properties containing substitution values | 815 | * Properties containing substitution values |
4946 | 813 | * @return text with substituted property values | 816 | * @return text with substituted property values |
4947 | 814 | */ | 817 | */ |
4949 | 815 | public String substituteProperties(String text, Properties properties) { | 818 | public String substituteProperties(final String text, final Properties properties) { |
4950 | 816 | return substituteProperties(text, properties, 0); | 819 | return substituteProperties(text, properties, 0); |
4951 | 817 | } | 820 | } |
4952 | 818 | 821 | ||
4953 | @@ -828,13 +831,13 @@ | |||
4954 | 828 | * Count of recursive calls - maximum depth is 20. | 831 | * Count of recursive calls - maximum depth is 20. |
4955 | 829 | * @return | 832 | * @return |
4956 | 830 | */ | 833 | */ |
4958 | 831 | String substituteProperties(String text, Properties properties, int depth) { | 834 | String substituteProperties(String text, final Properties properties, final int depth) { |
4959 | 832 | int p = text.indexOf("${"); | 835 | int p = text.indexOf("${"); |
4960 | 833 | while (p >= 0 && p < text.length()) { | 836 | while (p >= 0 && p < text.length()) { |
4961 | 834 | p += 2; | 837 | p += 2; |
4963 | 835 | int q = text.indexOf("}", p); | 838 | final int q = text.indexOf("}", p); |
4964 | 836 | if (q > 0) { | 839 | if (q > 0) { |
4966 | 837 | String propertyName = text.substring(p, q); | 840 | final String propertyName = text.substring(p, q); |
4967 | 838 | if (Util.isValidName(propertyName)) { | 841 | if (Util.isValidName(propertyName)) { |
4968 | 839 | // sanity check to prevent stack overflow | 842 | // sanity check to prevent stack overflow |
4969 | 840 | // due to infinite loop | 843 | // due to infinite loop |
4970 | @@ -898,7 +901,7 @@ | |||
4971 | 898 | * The property name | 901 | * The property name |
4972 | 899 | * @return The resulting string | 902 | * @return The resulting string |
4973 | 900 | */ | 903 | */ |
4975 | 901 | public String getProperty(String propertyName) { | 904 | public String getProperty(final String propertyName) { |
4976 | 902 | return getProperty(propertyName, null); | 905 | return getProperty(propertyName, null); |
4977 | 903 | } | 906 | } |
4978 | 904 | 907 | ||
4979 | @@ -937,12 +940,12 @@ | |||
4980 | 937 | * The default value | 940 | * The default value |
4981 | 938 | * @return The resulting string | 941 | * @return The resulting string |
4982 | 939 | */ | 942 | */ |
4985 | 940 | public String getProperty(String propertyName, String defaultValue) { | 943 | public String getProperty(final String propertyName, final String defaultValue) { |
4986 | 941 | String value = getProperty(propertyName, 0, _properties); | 944 | final String value = getProperty(propertyName, 0, _properties); |
4987 | 942 | return value == null ? defaultValue : value; | 945 | return value == null ? defaultValue : value; |
4988 | 943 | } | 946 | } |
4989 | 944 | 947 | ||
4991 | 945 | private String getProperty(String propertyName, int depth, Properties properties) { | 948 | private String getProperty(final String propertyName, final int depth, final Properties properties) { |
4992 | 946 | String value = null; | 949 | String value = null; |
4993 | 947 | 950 | ||
4994 | 948 | value = getSystemProperty(SYSTEM_PROPERTY_PREFIX + propertyName); | 951 | value = getSystemProperty(SYSTEM_PROPERTY_PREFIX + propertyName); |
4995 | @@ -983,14 +986,15 @@ | |||
4996 | 983 | 986 | ||
4997 | 984 | private String getSystemProperty(final String propertyName) { | 987 | private String getSystemProperty(final String propertyName) { |
4998 | 985 | return (String) AccessController.doPrivileged(new PrivilegedAction() { | 988 | return (String) AccessController.doPrivileged(new PrivilegedAction() { |
4999 | 989 | @Override | ||
5000 | 986 | public Object run() { | 990 | public Object run() { |
Looks to be minor conflicts in a couple files.
The eclipse-format.xml would fit nicely next to the other files in src/etc/, but that is pretty minor.
Other than that, I'm not terribly religious on any of the choices. However, this is the 2nd or 3rd time we've taken a big format hammer to the code. Can we use something like maven-eclipse- format- plugin in the process-sources section to do this mostly automatically? And hopefully prevent the need for large formatting in the future.