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 | | |
6 | | |
7 | |
8 | + |
9 | +************************************ |
10 | +3.1.6 |
11 | +************************************ |
12 | + |
13 | +Release Date |
14 | +============ |
15 | +August 24, 2012 |
16 | + |
17 | +Overview |
18 | +======== |
19 | +This version of Persistit fixes one bug. |
20 | + |
21 | +Fixed Issues |
22 | +============ |
23 | + |
24 | +https://bugs.launchpad.net/akiban-persistit/+bug/1036422 |
25 | + |
26 | +With CommitPolicy HARD we observed a CPU-soaking loop in the commit logic. |
27 | + |
28 | ************************************ |
29 | 3.1.5 |
30 | ************************************ |
31 | |
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 | </dependency> |
37 | </dependencies> |
38 | |
39 | + <pluginRepositories> |
40 | + <pluginRepository> |
41 | + <id>maven-java-formatter-plugin</id> |
42 | + <name>Maven2 Java Formatter Plugin repository</name> |
43 | + <url>https://raw.github.com/benalexau/maven-java-formatter-plugin/master/releases/</url> |
44 | + </pluginRepository> |
45 | + </pluginRepositories> |
46 | + |
47 | <build> |
48 | <finalName>${project.artifactId}-${project.version}${BZR_REVISION}</finalName> |
49 | <resources> |
50 | @@ -256,6 +264,7 @@ |
51 | <exclude>.project</exclude> |
52 | <exclude>.classpath</exclude> |
53 | <exclude>.bzrignore</exclude> |
54 | + <exclude>src/etc/eclipse*.xml</exclude> |
55 | <!-- Other --> |
56 | <exclude>LICENSE.txt</exclude> |
57 | </excludes> |
58 | @@ -273,6 +282,21 @@ |
59 | <artifactId>maven-eclipse-plugin</artifactId> |
60 | <version>2.6</version> |
61 | </plugin> |
62 | + <plugin> |
63 | + <groupId>com.googlecode.maven-java-formatter-plugin</groupId> |
64 | + <artifactId>maven-java-formatter-plugin</artifactId> |
65 | + <version>0.4.0.e371sr1</version> |
66 | + <configuration> |
67 | + <configFile>${project.basedir}/src/etc/eclipse-format-config.xml</configFile> |
68 | + </configuration> |
69 | + <executions> |
70 | + <execution> |
71 | + <goals> |
72 | + <goal>format</goal> |
73 | + </goals> |
74 | + </execution> |
75 | + </executions> |
76 | + </plugin> |
77 | </plugins> |
78 | <pluginManagement> |
79 | <plugins> |
80 | @@ -324,6 +348,19 @@ |
81 | <ignore /> |
82 | </action> |
83 | </pluginExecution> |
84 | + <pluginExecution> |
85 | + <pluginExecutionFilter> |
86 | + <groupId>com.googlecode.maven-java-formatter-plugin</groupId> |
87 | + <artifactId>maven-java-formatter-plugin</artifactId> |
88 | + <versionRange>[0.4.0.e371sr1,)</versionRange> |
89 | + <goals> |
90 | + <goal>format</goal> |
91 | + </goals> |
92 | + </pluginExecutionFilter> |
93 | + <action> |
94 | + <ignore></ignore> |
95 | + </action> |
96 | + </pluginExecution> |
97 | </pluginExecutions> |
98 | </lifecycleMappingMetadata> |
99 | </configuration> |
100 | @@ -331,7 +368,6 @@ |
101 | </plugins> |
102 | </pluginManagement> |
103 | </build> |
104 | - |
105 | <reporting> |
106 | <plugins> |
107 | <plugin> |
108 | |
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 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
114 | +<profiles version="2"> |
115 | +<profile kind="CleanUpProfile" name="Akiban-Persistit" version="2"> |
116 | +<setting id="cleanup.format_source_code" value="true"/> |
117 | +<setting id="cleanup.add_missing_annotations" value="true"/> |
118 | +<setting id="cleanup.use_this_for_non_static_method_access_only_if_necessary" value="true"/> |
119 | +<setting id="cleanup.remove_unused_private_types" value="true"/> |
120 | +<setting id="cleanup.qualify_static_member_accesses_through_instances_with_declaring_class" value="true"/> |
121 | +<setting id="cleanup.qualify_static_method_accesses_with_declaring_class" value="false"/> |
122 | +<setting id="cleanup.add_generated_serial_version_id" value="false"/> |
123 | +<setting id="cleanup.make_variable_declarations_final" value="true"/> |
124 | +<setting id="cleanup.add_missing_methods" value="false"/> |
125 | +<setting id="cleanup.always_use_this_for_non_static_field_access" value="false"/> |
126 | +<setting id="cleanup.remove_trailing_whitespaces_ignore_empty" value="false"/> |
127 | +<setting id="cleanup.correct_indentation" value="true"/> |
128 | +<setting id="cleanup.never_use_parentheses_in_expressions" value="true"/> |
129 | +<setting id="cleanup.add_serial_version_id" value="false"/> |
130 | +<setting id="cleanup.remove_unused_private_methods" value="true"/> |
131 | +<setting id="cleanup.use_this_for_non_static_field_access" value="false"/> |
132 | +<setting id="cleanup.use_blocks_only_for_return_and_throw" value="false"/> |
133 | +<setting id="cleanup.remove_unused_private_members" value="false"/> |
134 | +<setting id="cleanup.add_missing_override_annotations_interface_methods" value="true"/> |
135 | +<setting id="cleanup.remove_trailing_whitespaces_all" value="true"/> |
136 | +<setting id="cleanup.make_type_abstract_if_missing_method" value="false"/> |
137 | +<setting id="cleanup.always_use_this_for_non_static_method_access" value="false"/> |
138 | +<setting id="cleanup.remove_unnecessary_nls_tags" value="true"/> |
139 | +<setting id="cleanup.format_source_code_changes_only" value="false"/> |
140 | +<setting id="cleanup.qualify_static_field_accesses_with_declaring_class" value="false"/> |
141 | +<setting id="cleanup.add_missing_nls_tags" value="false"/> |
142 | +<setting id="cleanup.use_this_for_non_static_field_access_only_if_necessary" value="true"/> |
143 | +<setting id="cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class" value="false"/> |
144 | +<setting id="cleanup.remove_unnecessary_casts" value="true"/> |
145 | +<setting id="cleanup.qualify_static_member_accesses_with_declaring_class" value="true"/> |
146 | +<setting id="cleanup.use_parentheses_in_expressions" value="false"/> |
147 | +<setting id="cleanup.remove_unused_private_fields" value="true"/> |
148 | +<setting id="cleanup.make_parameters_final" value="true"/> |
149 | +<setting id="cleanup.remove_trailing_whitespaces" value="true"/> |
150 | +<setting id="cleanup.remove_unused_imports" value="true"/> |
151 | +<setting id="cleanup.organize_imports" value="true"/> |
152 | +<setting id="cleanup.sort_members" value="false"/> |
153 | +<setting id="cleanup.remove_private_constructors" value="true"/> |
154 | +<setting id="cleanup.convert_to_enhanced_for_loop" value="false"/> |
155 | +<setting id="cleanup.always_use_blocks" value="true"/> |
156 | +<setting id="cleanup.never_use_blocks" value="false"/> |
157 | +<setting id="cleanup.always_use_parentheses_in_expressions" value="false"/> |
158 | +<setting id="cleanup.use_this_for_non_static_method_access" value="false"/> |
159 | +<setting id="cleanup.remove_unused_local_variables" value="false"/> |
160 | +<setting id="cleanup.make_private_fields_final" value="true"/> |
161 | +<setting id="cleanup.add_missing_deprecated_annotations" value="true"/> |
162 | +<setting id="cleanup.add_default_serial_version_id" value="true"/> |
163 | +<setting id="cleanup.sort_members_all" value="false"/> |
164 | +<setting id="cleanup.use_blocks" value="false"/> |
165 | +<setting id="cleanup.add_missing_override_annotations" value="true"/> |
166 | +<setting id="cleanup.make_local_variable_final" value="true"/> |
167 | +</profile> |
168 | +</profiles> |
169 | |
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 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
175 | +<profiles version="12"> |
176 | +<profile kind="CodeFormatterProfile" name="Akiban-code-format" version="12"> |
177 | +<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/> |
178 | +<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/> |
179 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/> |
180 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/> |
181 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/> |
182 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/> |
183 | +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/> |
184 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/> |
185 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/> |
186 | +<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/> |
187 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/> |
188 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/> |
189 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/> |
190 | +<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/> |
191 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/> |
192 | +<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/> |
193 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/> |
194 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/> |
195 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/> |
196 | +<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/> |
197 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/> |
198 | +<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/> |
199 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/> |
200 | +<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/> |
201 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/> |
202 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/> |
203 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/> |
204 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/> |
205 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/> |
206 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/> |
207 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/> |
208 | +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/> |
209 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/> |
210 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/> |
211 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/> |
212 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/> |
213 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/> |
214 | +<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/> |
215 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/> |
216 | +<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/> |
217 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/> |
218 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/> |
219 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/> |
220 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/> |
221 | +<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/> |
222 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/> |
223 | +<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/> |
224 | +<setting id="org.eclipse.jdt.core.compiler.source" value="1.7"/> |
225 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/> |
226 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/> |
227 | +<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/> |
228 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/> |
229 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/> |
230 | +<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/> |
231 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/> |
232 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/> |
233 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/> |
234 | +<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/> |
235 | +<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/> |
236 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/> |
237 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/> |
238 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/> |
239 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/> |
240 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/> |
241 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/> |
242 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/> |
243 | +<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/> |
244 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/> |
245 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/> |
246 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/> |
247 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/> |
248 | +<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/> |
249 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/> |
250 | +<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/> |
251 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/> |
252 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/> |
253 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/> |
254 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/> |
255 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/> |
256 | +<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/> |
257 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/> |
258 | +<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/> |
259 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/> |
260 | +<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/> |
261 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/> |
262 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/> |
263 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/> |
264 | +<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/> |
265 | +<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/> |
266 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/> |
267 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/> |
268 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/> |
269 | +<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/> |
270 | +<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/> |
271 | +<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/> |
272 | +<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/> |
273 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/> |
274 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/> |
275 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/> |
276 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/> |
277 | +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/> |
278 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/> |
279 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/> |
280 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/> |
281 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/> |
282 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/> |
283 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/> |
284 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/> |
285 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/> |
286 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/> |
287 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/> |
288 | +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/> |
289 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/> |
290 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/> |
291 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/> |
292 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/> |
293 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/> |
294 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/> |
295 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/> |
296 | +<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/> |
297 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/> |
298 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/> |
299 | +<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/> |
300 | +<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/> |
301 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/> |
302 | +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/> |
303 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/> |
304 | +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/> |
305 | +<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/> |
306 | +<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/> |
307 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/> |
308 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/> |
309 | +<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/> |
310 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/> |
311 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/> |
312 | +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/> |
313 | +<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/> |
314 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/> |
315 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/> |
316 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/> |
317 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/> |
318 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/> |
319 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/> |
320 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/> |
321 | +<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/> |
322 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/> |
323 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/> |
324 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/> |
325 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/> |
326 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/> |
327 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/> |
328 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/> |
329 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/> |
330 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/> |
331 | +<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/> |
332 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/> |
333 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/> |
334 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/> |
335 | +<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/> |
336 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/> |
337 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/> |
338 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/> |
339 | +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/> |
340 | +<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/> |
341 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/> |
342 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/> |
343 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/> |
344 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/> |
345 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/> |
346 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/> |
347 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/> |
348 | +<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.7"/> |
349 | +<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/> |
350 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/> |
351 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/> |
352 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/> |
353 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/> |
354 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/> |
355 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/> |
356 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/> |
357 | +<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/> |
358 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/> |
359 | +<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/> |
360 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/> |
361 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/> |
362 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/> |
363 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/> |
364 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/> |
365 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/> |
366 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/> |
367 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/> |
368 | +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/> |
369 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/> |
370 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/> |
371 | +<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/> |
372 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/> |
373 | +<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/> |
374 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/> |
375 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/> |
376 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/> |
377 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/> |
378 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/> |
379 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/> |
380 | +<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/> |
381 | +<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/> |
382 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/> |
383 | +<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/> |
384 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/> |
385 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/> |
386 | +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/> |
387 | +<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/> |
388 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/> |
389 | +<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/> |
390 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/> |
391 | +<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/> |
392 | +<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/> |
393 | +<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/> |
394 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/> |
395 | +<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/> |
396 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/> |
397 | +<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/> |
398 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/> |
399 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/> |
400 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/> |
401 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/> |
402 | +<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/> |
403 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/> |
404 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/> |
405 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/> |
406 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/> |
407 | +<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/> |
408 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/> |
409 | +<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/> |
410 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/> |
411 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/> |
412 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/> |
413 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/> |
414 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/> |
415 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> |
416 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/> |
417 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/> |
418 | +<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/> |
419 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/> |
420 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/> |
421 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/> |
422 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/> |
423 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/> |
424 | +<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.7"/> |
425 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/> |
426 | +<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/> |
427 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/> |
428 | +<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/> |
429 | +<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/> |
430 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/> |
431 | +<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/> |
432 | +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/> |
433 | +<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/> |
434 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/> |
435 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/> |
436 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/> |
437 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/> |
438 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/> |
439 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/> |
440 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/> |
441 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/> |
442 | +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/> |
443 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/> |
444 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/> |
445 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/> |
446 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/> |
447 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/> |
448 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> |
449 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/> |
450 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/> |
451 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/> |
452 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/> |
453 | +<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/> |
454 | +<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/> |
455 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/> |
456 | +<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/> |
457 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/> |
458 | +<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/> |
459 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/> |
460 | +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/> |
461 | +<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/> |
462 | +<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/> |
463 | +</profile> |
464 | +</profiles> |
465 | |
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 | final static Comparator<Accumulator> SORT_COMPARATOR = new Comparator<Accumulator>() { |
471 | |
472 | @Override |
473 | - public int compare(Accumulator a, Accumulator b) { |
474 | + public int compare(final Accumulator a, final Accumulator b) { |
475 | final String treeNameA = a.getTree() == null ? "" : a.getTree().getName(); |
476 | final String treeNameB = b.getTree() == null ? "" : b.getTree().getName(); |
477 | - int compare = treeNameA.compareTo(treeNameB); |
478 | + final int compare = treeNameA.compareTo(treeNameB); |
479 | if (compare != 0) { |
480 | return compare; |
481 | } else { |
482 | @@ -144,7 +144,7 @@ |
483 | * longer present in live TransactionStatus objects. This array has one |
484 | * element per TransactionIndexBucket. |
485 | */ |
486 | - private long[] _bucketValues; |
487 | + private final long[] _bucketValues; |
488 | |
489 | /* |
490 | * Object held on the accumulators list in {@link Persistit}. An |
491 | @@ -374,7 +374,7 @@ |
492 | } |
493 | |
494 | Accumulator takeCheckpointRef() { |
495 | - Accumulator result = _checkpointRef; |
496 | + final Accumulator result = _checkpointRef; |
497 | _checkpointRef = null; |
498 | return result; |
499 | } |
500 | @@ -551,7 +551,7 @@ |
501 | long getSnapshotValue(final long timestamp, final int step) throws PersistitInterruptedException { |
502 | try { |
503 | return _transactionIndex.getAccumulatorSnapshot(this, timestamp, step, _baseValue); |
504 | - } catch (InterruptedException ie) { |
505 | + } catch (final InterruptedException ie) { |
506 | throw new PersistitInterruptedException(ie); |
507 | } |
508 | } |
509 | @@ -588,6 +588,7 @@ |
510 | /** |
511 | * Update the Accumulator by contributing a value. The contribution is |
512 | * immediately accumulated into the live value, and it is also posted with a |
513 | + * |
514 | * @{link {@link Delta} instance to the supplied {@link Transaction}. |
515 | * |
516 | * @param value |
517 | @@ -636,8 +637,8 @@ |
518 | * values for this <code>Accumulator</code>. |
519 | */ |
520 | public String toString() { |
521 | - return String.format("Accumulator(tree=%s index=%d type=%s base=%,d live=%,d)", _tree == null ? "null" : _tree |
522 | - .getName(), _index, getType(), _baseValue, _liveValue.get()); |
523 | + return String.format("Accumulator(tree=%s index=%d type=%s base=%,d live=%,d)", |
524 | + _tree == null ? "null" : _tree.getName(), _index, getType(), _baseValue, _liveValue.get()); |
525 | } |
526 | |
527 | void store(final Value value) { |
528 | @@ -649,8 +650,8 @@ |
529 | |
530 | static AccumulatorState getAccumulatorState(final Tree tree, final int index) throws PersistitException { |
531 | final Exchange exchange = tree.getVolume().getStructure().directoryExchange(); |
532 | - exchange.clear().append(VolumeStructure.DIRECTORY_TREE_NAME).append(VolumeStructure.TREE_ACCUMULATOR).append( |
533 | - tree.getName()).append(index).fetch(); |
534 | + exchange.clear().append(VolumeStructure.DIRECTORY_TREE_NAME).append(VolumeStructure.TREE_ACCUMULATOR) |
535 | + .append(tree.getName()).append(index).fetch(); |
536 | if (exchange.getValue().isDefined()) { |
537 | return (AccumulatorState) exchange.getValue().get(); |
538 | } else { |
539 | |
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 | |
545 | package com.persistit; |
546 | |
547 | - |
548 | /** |
549 | * State of an accumulator recovered from a checkpoint. |
550 | * |
551 | @@ -48,19 +47,19 @@ |
552 | public String toString() { |
553 | return String.format("Accumulator(tree=%s index=%d type=%s value=%,d)", _treeName, _index, _type, _value); |
554 | } |
555 | - |
556 | + |
557 | public String getTreeName() { |
558 | return _treeName; |
559 | } |
560 | - |
561 | + |
562 | public int getIndex() { |
563 | return _index; |
564 | } |
565 | - |
566 | + |
567 | public Accumulator.Type getType() { |
568 | return _type; |
569 | } |
570 | - |
571 | + |
572 | public long getValue() { |
573 | return _value; |
574 | } |
575 | |
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 | */ |
581 | public class History { |
582 | private AlertLevel _level = AlertLevel.NORMAL; |
583 | - private List<Event> _eventList = new ArrayList<Event>(); |
584 | + private final List<Event> _eventList = new ArrayList<Event>(); |
585 | private volatile long _firstEventTime = Long.MAX_VALUE; |
586 | private volatile long _lastWarnLogTime = Long.MIN_VALUE; |
587 | private volatile long _lastErrorLogTime = Long.MIN_VALUE; |
588 | @@ -142,7 +142,7 @@ |
589 | public String getDetailedHistory() { |
590 | final StringBuilder sb = new StringBuilder(); |
591 | synchronized (AlertMonitor.this) { |
592 | - int size = _eventList.size(); |
593 | + final int size = _eventList.size(); |
594 | if (_count > 0) { |
595 | sb.append(String.format(EVENT_FORMAT, 1, format(_firstEvent))); |
596 | for (int index = _count > size ? 0 : 1; index < size; index++) { |
597 | @@ -250,7 +250,7 @@ |
598 | * does nothing unless the interval has elapsed. |
599 | */ |
600 | public void poll(final long now, final boolean force) { |
601 | - int count = getCount(); |
602 | + final int count = getCount(); |
603 | if (count > _reportedCount) { |
604 | switch (_level) { |
605 | case ERROR: |
606 | @@ -316,7 +316,7 @@ |
607 | * event was posted. |
608 | */ |
609 | public static class Event { |
610 | - private AlertLevel _level; |
611 | + private final AlertLevel _level; |
612 | private final LogItem _logItem; |
613 | private final Object[] _args; |
614 | private final long _time; |
615 | @@ -332,7 +332,7 @@ |
616 | * @param args |
617 | * arguments specific to the <code>LogItem</code> |
618 | */ |
619 | - public Event(AlertLevel level, LogItem logItem, Object... args) { |
620 | + public Event(final AlertLevel level, final LogItem logItem, final Object... args) { |
621 | this(level, System.currentTimeMillis(), logItem, args); |
622 | } |
623 | |
624 | @@ -349,7 +349,7 @@ |
625 | * @param args |
626 | * arguments specific to the <code>LogItem</code> |
627 | */ |
628 | - public Event(AlertLevel level, long time, LogItem logItem, Object... args) { |
629 | + public Event(final AlertLevel level, final long time, final LogItem logItem, final Object... args) { |
630 | _level = level; |
631 | _logItem = logItem; |
632 | _args = args; |
633 | @@ -492,7 +492,7 @@ |
634 | private volatile long _errorLogTimeInterval = DEFAULT_ERROR_INTERVAL; |
635 | private volatile int _historyLength = DEFAULT_HISTORY_LENGTH; |
636 | |
637 | - private AtomicLong _notificationSequence = new AtomicLong(); |
638 | + private final AtomicLong _notificationSequence = new AtomicLong(); |
639 | private volatile ObjectName _objectName; |
640 | |
641 | /** |
642 | @@ -533,7 +533,7 @@ |
643 | * A String describing the nature of the event. A separate |
644 | * event-history is maintained for each unique category. |
645 | */ |
646 | - public synchronized final void post(Event event, final String category) { |
647 | + public synchronized final void post(final Event event, final String category) { |
648 | History history = _historyMap.get(category); |
649 | if (history == null) { |
650 | history = new History(); |
651 | @@ -570,7 +570,7 @@ |
652 | * the interval in milliseconds |
653 | */ |
654 | @Override |
655 | - public void setWarnLogTimeInterval(long warnLogTimeInterval) { |
656 | + public void setWarnLogTimeInterval(final long warnLogTimeInterval) { |
657 | Util.rangeCheck(warnLogTimeInterval, MINIMUM_WARN_INTERVAL, MAXIMUM_WARN_INTERVAL); |
658 | _warnLogTimeInterval = warnLogTimeInterval; |
659 | } |
660 | @@ -592,7 +592,7 @@ |
661 | * the interval in milliseconds |
662 | */ |
663 | @Override |
664 | - public void setErrorLogTimeInterval(long errorLogTimeInterval) { |
665 | + public void setErrorLogTimeInterval(final long errorLogTimeInterval) { |
666 | Util.rangeCheck(errorLogTimeInterval, MINIMUM_ERROR_INTERVAL, MAXIMUM_ERROR_INTERVAL); |
667 | _errorLogTimeInterval = errorLogTimeInterval; |
668 | } |
669 | @@ -613,7 +613,7 @@ |
670 | * @return the <code>History</code> for that category or <code>null</code> |
671 | * if the specified category has no <code>History</code>. |
672 | */ |
673 | - public synchronized History getHistory(String name) { |
674 | + public synchronized History getHistory(final String name) { |
675 | return _historyMap.get(name); |
676 | } |
677 | |
678 | @@ -637,7 +637,7 @@ |
679 | * the historyLength to set |
680 | */ |
681 | @Override |
682 | - public synchronized void setHistoryLength(int historyLength) { |
683 | + public synchronized void setHistoryLength(final int historyLength) { |
684 | Util.rangeCheck(historyLength, MINIMUM_HISTORY_LENGTH, MAXIMUM_HISTORY_LENGTH); |
685 | _historyLength = historyLength; |
686 | for (final History history : _historyMap.values()) { |
687 | @@ -652,7 +652,7 @@ |
688 | * @return List of AlertRecord elements. |
689 | */ |
690 | public synchronized AlertRecord[] getAlertRecordArray() { |
691 | - List<AlertRecord> list = new ArrayList<AlertRecord>(); |
692 | + final List<AlertRecord> list = new ArrayList<AlertRecord>(); |
693 | for (final Map.Entry<String, History> entry : _historyMap.entrySet()) { |
694 | for (final Event event : entry.getValue().getEventList()) { |
695 | list.add(new AlertRecord(entry.getKey(), event)); |
696 | @@ -681,7 +681,7 @@ |
697 | */ |
698 | @Override |
699 | public synchronized String toString() { |
700 | - StringBuilder sb = new StringBuilder(); |
701 | + final StringBuilder sb = new StringBuilder(); |
702 | for (final Map.Entry<String, History> entry : _historyMap.entrySet()) { |
703 | sb.append(String.format("%12s: %s\n", entry.getKey(), entry.getValue())); |
704 | } |
705 | @@ -705,8 +705,8 @@ |
706 | */ |
707 | @Override |
708 | public synchronized String getDetailedHistory(final String select) { |
709 | - Pattern pattern = Util.pattern(select, true); |
710 | - StringBuilder sb = new StringBuilder(); |
711 | + final Pattern pattern = Util.pattern(select, true); |
712 | + final StringBuilder sb = new StringBuilder(); |
713 | for (final Map.Entry<String, History> entry : _historyMap.entrySet()) { |
714 | if (pattern.matcher(entry.getKey()).matches()) { |
715 | sb.append(String.format("%s:\n", entry.getKey())); |
716 | @@ -737,10 +737,10 @@ |
717 | */ |
718 | @Override |
719 | public MBeanNotificationInfo[] getNotificationInfo() { |
720 | - String[] types = new String[] { NOTIFICATION_TYPE }; |
721 | - String name = Notification.class.getName(); |
722 | - String description = "Alert raised by Akiban PersistIT"; |
723 | - MBeanNotificationInfo info = new MBeanNotificationInfo(types, name, description); |
724 | + final String[] types = new String[] { NOTIFICATION_TYPE }; |
725 | + final String name = Notification.class.getName(); |
726 | + final String description = "Alert raised by Akiban PersistIT"; |
727 | + final MBeanNotificationInfo info = new MBeanNotificationInfo(types, name, description); |
728 | return new MBeanNotificationInfo[] { info }; |
729 | } |
730 | |
731 | @@ -751,7 +751,7 @@ |
732 | * |
733 | * @param history |
734 | */ |
735 | - private void log(History history) { |
736 | + private void log(final History history) { |
737 | final Event event = history.getLastEvent(); |
738 | if (event != null && event.getLogItem().isEnabled()) { |
739 | if (history.getCount() == 1) { |
740 | @@ -767,13 +767,13 @@ |
741 | * |
742 | * @param history |
743 | */ |
744 | - private void sendNotification(History history) { |
745 | + private void sendNotification(final History history) { |
746 | final Event event = history.getLastEvent(); |
747 | if (event != null && event.getLogItem().isEnabled()) { |
748 | - final String description = LogBase.recurring(event.getLogItem().logMessage(event.getArgs()), history |
749 | - .getCount(), history.getDuration()); |
750 | - Notification notification = new Notification(NOTIFICATION_TYPE, getClass().getName(), _notificationSequence |
751 | - .incrementAndGet(), description); |
752 | + final String description = LogBase.recurring(event.getLogItem().logMessage(event.getArgs()), |
753 | + history.getCount(), history.getDuration()); |
754 | + final Notification notification = new Notification(NOTIFICATION_TYPE, getClass().getName(), |
755 | + _notificationSequence.incrementAndGet(), description); |
756 | sendNotification(notification); |
757 | } |
758 | } |
759 | @@ -796,7 +796,7 @@ |
760 | * @param event |
761 | * @return |
762 | */ |
763 | - private String format(Event event) { |
764 | + private String format(final Event event) { |
765 | return event == null ? "null" : event.toString(); |
766 | } |
767 | |
768 | |
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 | |
774 | package com.persistit; |
775 | |
776 | +import java.util.Arrays; |
777 | + |
778 | import com.persistit.exception.InvalidKeyException; |
779 | |
780 | -import java.util.Arrays; |
781 | - |
782 | /** |
783 | * Represents the end of a key range to be removed. Used in Transactions. |
784 | * |
785 | @@ -26,29 +26,29 @@ |
786 | * @version 1.1 |
787 | */ |
788 | class AntiValue { |
789 | - private int _elisionCount; |
790 | - private byte[] _bytes; |
791 | + private final int _elisionCount; |
792 | + private final byte[] _bytes; |
793 | |
794 | - AntiValue(int ec, byte[] bytes) { |
795 | + AntiValue(final int ec, final byte[] bytes) { |
796 | _elisionCount = ec; |
797 | _bytes = bytes; |
798 | } |
799 | |
800 | - static void putAntiValue(Value value, Key key1, Key key2) { |
801 | - int elisionCount = key1.firstUniqueByteIndex(key2); |
802 | - int size = key2.getEncodedSize() - elisionCount; |
803 | - byte[] bytes = new byte[size]; |
804 | + static void putAntiValue(final Value value, final Key key1, final Key key2) { |
805 | + final int elisionCount = key1.firstUniqueByteIndex(key2); |
806 | + final int size = key2.getEncodedSize() - elisionCount; |
807 | + final byte[] bytes = new byte[size]; |
808 | System.arraycopy(key2.getEncodedBytes(), elisionCount, bytes, 0, size); |
809 | value.putAntiValue((short) elisionCount, bytes); |
810 | } |
811 | |
812 | - static void fixUpKeys(Exchange exchange, int elisionCount, byte[] bytes, int offset, int length) |
813 | - throws InvalidKeyException { |
814 | - Key spareKey1 = exchange.getAuxiliaryKey1(); |
815 | - Key spareKey2 = exchange.getAuxiliaryKey2(); |
816 | + static void fixUpKeys(final Exchange exchange, final int elisionCount, final byte[] bytes, final int offset, |
817 | + final int length) throws InvalidKeyException { |
818 | + final Key spareKey1 = exchange.getAuxiliaryKey1(); |
819 | + final Key spareKey2 = exchange.getAuxiliaryKey2(); |
820 | spareKey1.copyTo(spareKey2); |
821 | - byte[] baseBytes = spareKey2.getEncodedBytes(); |
822 | - int baseSize = spareKey2.getEncodedSize(); |
823 | + final byte[] baseBytes = spareKey2.getEncodedBytes(); |
824 | + final int baseSize = spareKey2.getEncodedSize(); |
825 | if (baseSize < elisionCount || elisionCount + length > Key.MAX_KEY_LENGTH) { |
826 | throw new InvalidKeyException("Key encoding in transaction is invalid"); |
827 | } |
828 | |
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 | private volatile String _backupStatus; |
834 | |
835 | @Cmd("backup") |
836 | - static Task setupTask(@Arg("file|string|Archive file path") String file, |
837 | - @Arg("_flag|a|Start appendOnly mode") boolean start, @Arg("_flag|e|End appendOnly mode") boolean end, |
838 | - @Arg("_flag|c|Request checkpoint before backup") boolean checkpoint, |
839 | - @Arg("_flag|z|Compress output to ZIP format") boolean compressed, |
840 | - @Arg("_flag|f|Emit a list of files that need to be copied") boolean showFiles, |
841 | - @Arg("_flag|y|Copyback pages before starting") boolean copyback) throws Exception { |
842 | + static Task setupTask(@Arg("file|string|Archive file path") final String file, |
843 | + @Arg("_flag|a|Start appendOnly mode") final boolean start, |
844 | + @Arg("_flag|e|End appendOnly mode") final boolean end, |
845 | + @Arg("_flag|c|Request checkpoint before backup") final boolean checkpoint, |
846 | + @Arg("_flag|z|Compress output to ZIP format") final boolean compressed, |
847 | + @Arg("_flag|f|Emit a list of files that need to be copied") final boolean showFiles, |
848 | + @Arg("_flag|y|Copyback pages before starting") final boolean copyback) throws Exception { |
849 | final BackupTask task = new BackupTask(); |
850 | task._toFile = file; |
851 | task._start = start; |
852 | @@ -103,7 +104,7 @@ |
853 | protected void runTask() throws Exception { |
854 | validate(); |
855 | final Management management = _persistit.getManagement(); |
856 | - boolean wasAppendOnly = management.getJournalInfo().isAppendOnly(); |
857 | + final boolean wasAppendOnly = management.getJournalInfo().isAppendOnly(); |
858 | if (_checkpoint) { |
859 | postMessage("Waiting for checkpoint", 0); |
860 | final Checkpoint cp = _persistit.checkpoint(); |
861 | @@ -115,9 +116,9 @@ |
862 | } |
863 | if (_copyback && !wasAppendOnly) { |
864 | postMessage("Copying back pages from journal", 0); |
865 | - long start = _persistit.getJournalManager().getCopiedPageCount(); |
866 | + final long start = _persistit.getJournalManager().getCopiedPageCount(); |
867 | _persistit.copyBackPages(); |
868 | - long end = _persistit.getJournalManager().getCopiedPageCount(); |
869 | + final long end = _persistit.getJournalManager().getCopiedPageCount(); |
870 | postMessage((end - start) + " pages copied", 0); |
871 | } |
872 | try { |
873 | @@ -128,7 +129,7 @@ |
874 | doBackup(); |
875 | } |
876 | } |
877 | - } catch (Exception e) { |
878 | + } catch (final Exception e) { |
879 | _backupStatus = "Failed: " + e; |
880 | } finally { |
881 | management.setAppendOnly(_start ? true : _end ? false : wasAppendOnly); |
882 | @@ -136,7 +137,7 @@ |
883 | } |
884 | |
885 | @Override |
886 | - protected void postMessage(final String message, int level) { |
887 | + protected void postMessage(final String message, final int level) { |
888 | super.postMessage(message, level); |
889 | _backupStatus = message; |
890 | } |
891 | @@ -152,9 +153,9 @@ |
892 | final long baseAddress = info.getBaseAddress(); |
893 | final long currentAddress = info.getCurrentJournalAddress(); |
894 | final long blockSize = info.getBlockSize(); |
895 | - String path = JournalManager.fileToPath(new File(info.getCurrentJournalFile())); |
896 | + final String path = JournalManager.fileToPath(new File(info.getCurrentJournalFile())); |
897 | for (long generation = baseAddress / blockSize; generation <= currentAddress / blockSize; generation++) { |
898 | - File file = JournalManager.generationToFile(path, generation); |
899 | + final File file = JournalManager.generationToFile(path, generation); |
900 | _files.add(file.getAbsolutePath()); |
901 | } |
902 | final StringBuilder sb = new StringBuilder(); |
903 | |
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 | |
909 | abstract static class VerifyVisitor { |
910 | |
911 | - protected void visitPage(long timestamp, Volume volume, long page, int type, int bufferSize, int keyBlockStart, |
912 | - int keyBlockEnd, int alloc, int available, long rightSibling) throws PersistitException { |
913 | - } |
914 | - |
915 | - protected void visitIndexRecord(Key key, int foundAt, int tail, int kLength, long pointer) |
916 | - throws PersistitException { |
917 | - |
918 | - } |
919 | - |
920 | - protected void visitDataRecord(Key key, int foundAt, int tail, int klength, int offset, int length, byte[] bytes) |
921 | - throws PersistitException { |
922 | + protected void visitPage(final long timestamp, final Volume volume, final long page, final int type, |
923 | + final int bufferSize, final int keyBlockStart, final int keyBlockEnd, final int alloc, |
924 | + final int available, final long rightSibling) throws PersistitException { |
925 | + } |
926 | + |
927 | + protected void visitIndexRecord(final Key key, final int foundAt, final int tail, final int kLength, |
928 | + final long pointer) throws PersistitException { |
929 | + |
930 | + } |
931 | + |
932 | + protected void visitDataRecord(final Key key, final int foundAt, final int tail, final int klength, |
933 | + final int offset, final int length, final byte[] bytes) throws PersistitException { |
934 | } |
935 | } |
936 | |
937 | @@ -323,7 +324,7 @@ |
938 | * The bytes in this buffer. Note these bytes are also the backing store of |
939 | * _byteBuffer. |
940 | */ |
941 | - private byte[] _bytes; |
942 | + private final byte[] _bytes; |
943 | |
944 | /** |
945 | * FastIndex structure used for rapid page searching |
946 | @@ -382,7 +383,7 @@ |
947 | * @param size |
948 | * The buffer size, in bytes. |
949 | */ |
950 | - Buffer(int size, int index, BufferPool pool, Persistit persistit) { |
951 | + Buffer(int size, final int index, final BufferPool pool, final Persistit persistit) { |
952 | super(persistit); |
953 | boolean ok = false; |
954 | for (int s = MIN_BUFFER_SIZE; !ok && s <= MAX_BUFFER_SIZE; s *= 2) { |
955 | @@ -402,7 +403,7 @@ |
956 | _fastIndex = new FastIndex(this, 1 + (size - HEADER_SIZE) / MAX_KEY_RATIO); |
957 | } |
958 | |
959 | - Buffer(Buffer original) { |
960 | + Buffer(final Buffer original) { |
961 | this(original._bufferSize, original._poolIndex, original._pool, original._persistit); |
962 | setStatus(original); |
963 | _type = original._type; |
964 | @@ -421,7 +422,7 @@ |
965 | /** |
966 | * Initializes the buffer so that it contains no keys or data. |
967 | */ |
968 | - void init(int type) { |
969 | + void init(final int type) { |
970 | _type = type; |
971 | setKeyBlockEnd(KEY_BLOCK_START); |
972 | _tailHeaderSize = isIndexPage() ? TAILBLOCK_HDR_SIZE_INDEX : TAILBLOCK_HDR_SIZE_DATA; |
973 | @@ -449,7 +450,7 @@ |
974 | * @throws InUseException |
975 | * @throws PersistitInterruptedException |
976 | */ |
977 | - void load(Volume vol, long page) throws PersistitIOException, InvalidPageAddressException, |
978 | + void load(final Volume vol, final long page) throws PersistitIOException, InvalidPageAddressException, |
979 | InvalidPageStructureException, VolumeClosedException, InUseException, PersistitInterruptedException { |
980 | _vol = vol; |
981 | _page = page; |
982 | @@ -463,7 +464,7 @@ |
983 | _timestamp = getLong(TIMESTAMP_OFFSET); |
984 | |
985 | if (_page != 0) { |
986 | - int type = getByte(TYPE_OFFSET); |
987 | + final int type = getByte(TYPE_OFFSET); |
988 | if (type > PAGE_TYPE_MAX) { |
989 | throw new InvalidPageStructureException("Invalid type " + type); |
990 | } |
991 | @@ -519,6 +520,7 @@ |
992 | } |
993 | } |
994 | |
995 | + @Override |
996 | boolean clearDirty() { |
997 | if (super.clearDirty()) { |
998 | _pool.decrementDirtyPageCount(); |
999 | @@ -527,6 +529,7 @@ |
1000 | return false; |
1001 | } |
1002 | |
1003 | + @Override |
1004 | boolean setDirty() { |
1005 | throw new UnsupportedOperationException(); |
1006 | } |
1007 | @@ -543,12 +546,12 @@ |
1008 | } |
1009 | |
1010 | @Override |
1011 | - boolean claim(boolean writer) throws PersistitInterruptedException { |
1012 | + boolean claim(final boolean writer) throws PersistitInterruptedException { |
1013 | return claim(writer, DEFAULT_MAX_WAIT_TIME); |
1014 | } |
1015 | |
1016 | @Override |
1017 | - boolean claim(boolean writer, long timeout) throws PersistitInterruptedException { |
1018 | + boolean claim(final boolean writer, final long timeout) throws PersistitInterruptedException { |
1019 | if (super.claim(writer, timeout)) { |
1020 | if (!isDirty()) { |
1021 | _timestamp = _persistit.getCurrentTimestamp(); |
1022 | @@ -579,7 +582,7 @@ |
1023 | Util.clearBytes(_bytes, 0, _bufferSize); |
1024 | } |
1025 | |
1026 | - void clearBytes(int from, int to) { |
1027 | + void clearBytes(final int from, final int to) { |
1028 | Util.clearBytes(_bytes, from, to); |
1029 | } |
1030 | |
1031 | @@ -733,7 +736,7 @@ |
1032 | * @param pageAddress |
1033 | * the sibling's address |
1034 | */ |
1035 | - void setRightSibling(long pageAddress) { |
1036 | + void setRightSibling(final long pageAddress) { |
1037 | Debug.$assert0.t(isMine()); |
1038 | _rightSibling = pageAddress; |
1039 | } |
1040 | @@ -803,15 +806,15 @@ |
1041 | * it follows the last key in the page. |
1042 | * @throws PersistitInterruptedException |
1043 | */ |
1044 | - int findKey(Key key) throws PersistitInterruptedException { |
1045 | + int findKey(final Key key) throws PersistitInterruptedException { |
1046 | final FastIndex fastIndex = getFastIndex(); |
1047 | - byte[] kbytes = key.getEncodedBytes(); |
1048 | - int klength = key.getEncodedSize(); |
1049 | + final byte[] kbytes = key.getEncodedBytes(); |
1050 | + final int klength = key.getEncodedSize(); |
1051 | int depth = 0; |
1052 | int left = KEY_BLOCK_START; |
1053 | int right = _keyBlockEnd; |
1054 | - int start = left; |
1055 | - int tailHeaderSize = _tailHeaderSize; |
1056 | + final int start = left; |
1057 | + final int tailHeaderSize = _tailHeaderSize; |
1058 | |
1059 | for (int p = start; p < right;) { |
1060 | // |
1061 | @@ -820,7 +823,7 @@ |
1062 | int kbData = getInt(p); |
1063 | int index = (p - start) >> 2; |
1064 | int runCount = fastIndex.getRunCount(index); |
1065 | - int ebc = decodeKeyBlockEbc(kbData); |
1066 | + final int ebc = decodeKeyBlockEbc(kbData); |
1067 | |
1068 | if (depth < ebc) { |
1069 | // We know that depth < ebc for a bunch of KeyBlocks - we |
1070 | @@ -836,7 +839,7 @@ |
1071 | } |
1072 | |
1073 | else if (depth > ebc) { |
1074 | - int result = p | (depth << DEPTH_SHIFT); |
1075 | + final int result = p | (depth << DEPTH_SHIFT); |
1076 | return result; |
1077 | } |
1078 | |
1079 | @@ -847,7 +850,7 @@ |
1080 | int kb = kbytes[depth] & 0xFF; |
1081 | |
1082 | if (kb < db) { |
1083 | - int result = p | (depth << DEPTH_SHIFT); |
1084 | + final int result = p | (depth << DEPTH_SHIFT); |
1085 | return result; |
1086 | } |
1087 | if (kb > db) { |
1088 | @@ -858,13 +861,13 @@ |
1089 | // either do a linear search or perform a binary search |
1090 | // within the run. |
1091 | // |
1092 | - int p2 = p + (runCount * KEYBLOCK_LENGTH); |
1093 | + final int p2 = p + (runCount * KEYBLOCK_LENGTH); |
1094 | // |
1095 | // p2 now points to the last key block with the same |
1096 | // ebc in this run. |
1097 | // |
1098 | - int kbData2 = getInt(p2); |
1099 | - int db2 = decodeKeyBlockDb(kbData2); |
1100 | + final int kbData2 = getInt(p2); |
1101 | + final int db2 = decodeKeyBlockDb(kbData2); |
1102 | // |
1103 | // For the common case that runCount == 1, we avoid |
1104 | // setting up the binary search loop. Instead, the |
1105 | @@ -877,7 +880,7 @@ |
1106 | // This is right because we already know |
1107 | // that kb > db. |
1108 | // |
1109 | - int result = p2 | (depth << DEPTH_SHIFT); |
1110 | + final int result = p2 | (depth << DEPTH_SHIFT); |
1111 | return result; |
1112 | } else if (db2 < kb) { |
1113 | // |
1114 | @@ -888,7 +891,7 @@ |
1115 | // - |
1116 | // in that case we use the cross count to skip |
1117 | // all of them. |
1118 | - int runCount2 = fastIndex.getRunCount(index + runCount); |
1119 | + final int runCount2 = fastIndex.getRunCount(index + runCount); |
1120 | assert runCount2 <= 0; |
1121 | p = p2 + KEYBLOCK_LENGTH * (-runCount + 1); |
1122 | continue; |
1123 | @@ -921,8 +924,8 @@ |
1124 | // we are seeking. |
1125 | // |
1126 | if (runCount > BINARY_SEARCH_THRESHOLD) { |
1127 | - int distance = (right - left) >> 2; |
1128 | - int oldRight = right; |
1129 | + final int distance = (right - left) >> 2; |
1130 | + final int oldRight = right; |
1131 | if (distance > kb - db + 1) { |
1132 | right = left + ((kb - db + 1) << 2); |
1133 | } |
1134 | @@ -942,7 +945,7 @@ |
1135 | // that kb > db and less than db2, so the |
1136 | // final answer is know to be in right. |
1137 | // |
1138 | - int result = right | (depth << DEPTH_SHIFT); |
1139 | + final int result = right | (depth << DEPTH_SHIFT); |
1140 | return result; |
1141 | } |
1142 | // |
1143 | @@ -950,7 +953,7 @@ |
1144 | // mid-point and |
1145 | // adjust the ends depending on the comparison. |
1146 | // |
1147 | - int db1 = getDb(p); |
1148 | + final int db1 = getDb(p); |
1149 | |
1150 | if (db1 == kb) { |
1151 | db = db1; |
1152 | @@ -998,10 +1001,10 @@ |
1153 | // for each byte in the key. |
1154 | // |
1155 | kbData = getInt(p); |
1156 | - int tail = decodeKeyBlockTail(kbData); |
1157 | - int tbData = getInt(tail); |
1158 | - int tlength = decodeTailBlockKLength(tbData) + depth + 1; |
1159 | - int qlength = tlength < klength ? tlength : klength; |
1160 | + final int tail = decodeKeyBlockTail(kbData); |
1161 | + final int tbData = getInt(tail); |
1162 | + final int tlength = decodeTailBlockKLength(tbData) + depth + 1; |
1163 | + final int qlength = tlength < klength ? tlength : klength; |
1164 | // |
1165 | // Walk down the key, increasing depth |
1166 | // |
1167 | @@ -1025,7 +1028,7 @@ |
1168 | // Key is less than tail, so we return |
1169 | // this keyblock |
1170 | // |
1171 | - int result = p | (depth << DEPTH_SHIFT) | FIXUP_MASK; |
1172 | + final int result = p | (depth << DEPTH_SHIFT) | FIXUP_MASK; |
1173 | return result; |
1174 | } |
1175 | matched = false; |
1176 | @@ -1045,7 +1048,7 @@ |
1177 | // And the key lengths are equal so this is an |
1178 | // exact match. |
1179 | // |
1180 | - int result = p | (depth << DEPTH_SHIFT) | EXACT_MASK; |
1181 | + final int result = p | (depth << DEPTH_SHIFT) | EXACT_MASK; |
1182 | return result; |
1183 | } |
1184 | } else if (tlength > qlength) { |
1185 | @@ -1054,7 +1057,7 @@ |
1186 | // key is less than tail, so we return the |
1187 | // this keyblock since it is greater than the key |
1188 | // |
1189 | - int result = p | (depth << DEPTH_SHIFT) | FIXUP_MASK; |
1190 | + final int result = p | (depth << DEPTH_SHIFT) | FIXUP_MASK; |
1191 | return result; |
1192 | } |
1193 | // Otherwise, the key is longer, so we move to the next |
1194 | @@ -1066,7 +1069,7 @@ |
1195 | |
1196 | } |
1197 | |
1198 | - int result = right | (depth << DEPTH_SHIFT); |
1199 | + final int result = right | (depth << DEPTH_SHIFT); |
1200 | return result; |
1201 | } |
1202 | |
1203 | @@ -1074,13 +1077,13 @@ |
1204 | if (isDataPage()) { |
1205 | final int p = foundAt & P_MASK; |
1206 | if (p >= KEY_BLOCK_START && p < _keyBlockEnd) { |
1207 | - int kbData = getInt(p); |
1208 | - int tail = decodeKeyBlockTail(kbData); |
1209 | - int tbData = getInt(tail); |
1210 | - int klength = decodeTailBlockKLength(tbData); |
1211 | - int size = decodeTailBlockSize(tbData); |
1212 | - int offset = tail + _tailHeaderSize + klength; |
1213 | - int valueSize = size - klength - _tailHeaderSize; |
1214 | + final int kbData = getInt(p); |
1215 | + final int tail = decodeKeyBlockTail(kbData); |
1216 | + final int tbData = getInt(tail); |
1217 | + final int klength = decodeTailBlockKLength(tbData); |
1218 | + final int size = decodeTailBlockSize(tbData); |
1219 | + final int offset = tail + _tailHeaderSize + klength; |
1220 | + final int valueSize = size - klength - _tailHeaderSize; |
1221 | return valueSize == 1 && _bytes[offset] == MVV.TYPE_ANTIVALUE; |
1222 | } |
1223 | } |
1224 | @@ -1099,13 +1102,13 @@ |
1225 | if (isDataPage() || isIndexPage()) { |
1226 | final int p = foundAt & P_MASK; |
1227 | if (p >= KEY_BLOCK_START && p < _keyBlockEnd) { |
1228 | - int kbData = getInt(p); |
1229 | - int tail = decodeKeyBlockTail(kbData); |
1230 | - int tbData = getInt(tail); |
1231 | - int klength = decodeTailBlockKLength(tbData); |
1232 | - int size = decodeTailBlockSize(tbData); |
1233 | - int offset = tail + _tailHeaderSize + klength; |
1234 | - int valueSize = size - klength - _tailHeaderSize; |
1235 | + final int kbData = getInt(p); |
1236 | + final int tail = decodeKeyBlockTail(kbData); |
1237 | + final int tbData = getInt(tail); |
1238 | + final int klength = decodeTailBlockKLength(tbData); |
1239 | + final int size = decodeTailBlockSize(tbData); |
1240 | + final int offset = tail + _tailHeaderSize + klength; |
1241 | + final int valueSize = size - klength - _tailHeaderSize; |
1242 | return ((long) offset) << 32 | valueSize; |
1243 | } |
1244 | } |
1245 | @@ -1116,13 +1119,13 @@ |
1246 | Debug.$assert0.t(foundAt > 0 && foundAt < _keyBlockEnd); |
1247 | if (isDataPage() || isIndexPage()) { |
1248 | for (int p = KEY_BLOCK_START; p <= foundAt; p += KEYBLOCK_LENGTH) { |
1249 | - int kbData = getInt(p); |
1250 | - int tail = decodeKeyBlockTail(kbData); |
1251 | - int ebc = decodeKeyBlockEbc(kbData); |
1252 | - int db = decodeKeyBlockDb(kbData); |
1253 | - int tbData = getInt(tail); |
1254 | - int klength = decodeTailBlockKLength(tbData); |
1255 | - byte[] keyBytes = key.getEncodedBytes(); |
1256 | + final int kbData = getInt(p); |
1257 | + final int tail = decodeKeyBlockTail(kbData); |
1258 | + final int ebc = decodeKeyBlockEbc(kbData); |
1259 | + final int db = decodeKeyBlockDb(kbData); |
1260 | + final int tbData = getInt(tail); |
1261 | + final int klength = decodeTailBlockKLength(tbData); |
1262 | + final byte[] keyBytes = key.getEncodedBytes(); |
1263 | keyBytes[ebc] = (byte) db; |
1264 | System.arraycopy(_bytes, tail + _tailHeaderSize, keyBytes, ebc + 1, klength); |
1265 | key.setEncodedSize(ebc + klength + 1); |
1266 | @@ -1130,32 +1133,32 @@ |
1267 | } |
1268 | } |
1269 | |
1270 | - Value fetch(int foundAt, Value value) { |
1271 | + Value fetch(final int foundAt, final Value value) { |
1272 | if ((foundAt & EXACT_MASK) == 0) { |
1273 | value.clear(); |
1274 | } else { |
1275 | Debug.$assert0.t(foundAt > 0 && (foundAt & P_MASK) < _keyBlockEnd); |
1276 | - int kbData = getInt(foundAt & P_MASK); |
1277 | - int tail = decodeKeyBlockTail(kbData); |
1278 | - int tbData = getInt(tail); |
1279 | - int klength = decodeTailBlockKLength(tbData); |
1280 | - int size = decodeTailBlockSize(tbData); |
1281 | - int valueSize = size - klength - _tailHeaderSize; |
1282 | + final int kbData = getInt(foundAt & P_MASK); |
1283 | + final int tail = decodeKeyBlockTail(kbData); |
1284 | + final int tbData = getInt(tail); |
1285 | + final int klength = decodeTailBlockKLength(tbData); |
1286 | + final int size = decodeTailBlockSize(tbData); |
1287 | + final int valueSize = size - klength - _tailHeaderSize; |
1288 | value.putEncodedBytes(_bytes, tail + _tailHeaderSize + klength, valueSize); |
1289 | } |
1290 | return value; |
1291 | } |
1292 | |
1293 | - long fetchLongRecordPointer(int foundAt) { |
1294 | + long fetchLongRecordPointer(final int foundAt) { |
1295 | if (!isDataPage()) { |
1296 | return 0; |
1297 | } |
1298 | - int kbData = getInt(foundAt & P_MASK); |
1299 | - int tail = decodeKeyBlockTail(kbData); |
1300 | - int tbData = getInt(tail); |
1301 | - int klength = decodeTailBlockKLength(tbData); |
1302 | - int size = decodeTailBlockSize(tbData); |
1303 | - int valueSize = size - klength - _tailHeaderSize; |
1304 | + final int kbData = getInt(foundAt & P_MASK); |
1305 | + final int tail = decodeKeyBlockTail(kbData); |
1306 | + final int tbData = getInt(tail); |
1307 | + final int klength = decodeTailBlockKLength(tbData); |
1308 | + final int size = decodeTailBlockSize(tbData); |
1309 | + final int valueSize = size - klength - _tailHeaderSize; |
1310 | if (valueSize != LONGREC_SIZE) { |
1311 | return 0; |
1312 | } |
1313 | @@ -1163,16 +1166,16 @@ |
1314 | return 0; |
1315 | } |
1316 | |
1317 | - long pointer = getLong(tail + _tailHeaderSize + klength + LONGREC_PAGE_OFFSET); |
1318 | + final long pointer = getLong(tail + _tailHeaderSize + klength + LONGREC_PAGE_OFFSET); |
1319 | return pointer; |
1320 | } |
1321 | |
1322 | - long getPointer(int foundAt) throws PersistitException { |
1323 | + long getPointer(final int foundAt) throws PersistitException { |
1324 | if (!isIndexPage()) { |
1325 | throw new InvalidPageTypeException("type=" + _type); |
1326 | } |
1327 | - int kbData = getInt(foundAt & P_MASK); |
1328 | - int tail = decodeKeyBlockTail(kbData); |
1329 | + final int kbData = getInt(foundAt & P_MASK); |
1330 | + final int tail = decodeKeyBlockTail(kbData); |
1331 | return getInt(tail + 4); |
1332 | } |
1333 | |
1334 | @@ -1185,8 +1188,8 @@ |
1335 | * @param foundAt |
1336 | * @return |
1337 | */ |
1338 | - int traverse(Key key, Key.Direction mode, int foundAt) { |
1339 | - boolean exactMatch = (foundAt & EXACT_MASK) > 0; |
1340 | + int traverse(final Key key, final Key.Direction mode, final int foundAt) { |
1341 | + final boolean exactMatch = (foundAt & EXACT_MASK) > 0; |
1342 | if (mode == Key.EQ || exactMatch && (mode == Key.LTEQ || mode == Key.GTEQ)) { |
1343 | return foundAt; |
1344 | } |
1345 | @@ -1205,21 +1208,21 @@ |
1346 | * @param foundAt |
1347 | * @return |
1348 | */ |
1349 | - int previousKey(Key key, int foundAt) { |
1350 | + int previousKey(final Key key, final int foundAt) { |
1351 | int p = (foundAt & P_MASK) - KEYBLOCK_LENGTH; |
1352 | - int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; |
1353 | + final int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; |
1354 | |
1355 | if (p < KEY_BLOCK_START) |
1356 | return foundAt; |
1357 | |
1358 | - byte[] kbytes = key.getEncodedBytes(); |
1359 | + final byte[] kbytes = key.getEncodedBytes(); |
1360 | |
1361 | // Compute the count of prefix bytes in the supplied key that |
1362 | // are known to match. The leftmost knownGood bytes do not need |
1363 | // to be recovered by traversing keys in the page. |
1364 | // |
1365 | - int kbData2 = getInt(p + KEYBLOCK_LENGTH); |
1366 | - int ebc2 = decodeKeyBlockEbc(kbData2); |
1367 | + final int kbData2 = getInt(p + KEYBLOCK_LENGTH); |
1368 | + final int ebc2 = decodeKeyBlockEbc(kbData2); |
1369 | int kbData = getInt(p); |
1370 | int ebc = decodeKeyBlockEbc(kbData); |
1371 | int knownGood = ebc; |
1372 | @@ -1244,7 +1247,7 @@ |
1373 | int unknown = decodeTailBlockKLength(getInt(tail)) + ebc + 1; |
1374 | key.setEncodedSize(unknown); |
1375 | |
1376 | - int result = p | (unknown << DEPTH_SHIFT) | EXACT_MASK; |
1377 | + final int result = p | (unknown << DEPTH_SHIFT) | EXACT_MASK; |
1378 | // |
1379 | // Reconstruct the previous key. |
1380 | // |
1381 | @@ -1252,7 +1255,7 @@ |
1382 | if (ebc < unknown) { |
1383 | // move bytes from this keyblock into the result key. |
1384 | kbytes[ebc] = (byte) decodeKeyBlockDb(kbData); |
1385 | - int more = unknown - ebc - 1; |
1386 | + final int more = unknown - ebc - 1; |
1387 | if (more > 0) { |
1388 | System.arraycopy(_bytes, tail + _tailHeaderSize, kbytes, ebc + 1, more); |
1389 | } |
1390 | @@ -1278,7 +1281,7 @@ |
1391 | * @param foundAt |
1392 | * @return |
1393 | */ |
1394 | - int nextKey(Key key, int foundAt) { |
1395 | + int nextKey(final Key key, final int foundAt) { |
1396 | int p = foundAt & P_MASK; |
1397 | if ((foundAt & EXACT_MASK) != 0) |
1398 | p += KEYBLOCK_LENGTH; |
1399 | @@ -1286,16 +1289,16 @@ |
1400 | if (p >= _keyBlockEnd) |
1401 | return foundAt; |
1402 | |
1403 | - byte[] kbytes = key.getEncodedBytes(); |
1404 | - int kbData = getInt(p); |
1405 | - int ebc = decodeKeyBlockEbc(kbData); |
1406 | - int tail = decodeKeyBlockTail(kbData); |
1407 | - int tbData = getInt(tail); |
1408 | - int klength = decodeTailBlockKLength(tbData); |
1409 | - int keyLength = klength + ebc + 1; |
1410 | + final byte[] kbytes = key.getEncodedBytes(); |
1411 | + final int kbData = getInt(p); |
1412 | + final int ebc = decodeKeyBlockEbc(kbData); |
1413 | + final int tail = decodeKeyBlockTail(kbData); |
1414 | + final int tbData = getInt(tail); |
1415 | + final int klength = decodeTailBlockKLength(tbData); |
1416 | + final int keyLength = klength + ebc + 1; |
1417 | key.setEncodedSize(keyLength); |
1418 | |
1419 | - int result = p | (keyLength << DEPTH_SHIFT) | EXACT_MASK; |
1420 | + final int result = p | (keyLength << DEPTH_SHIFT) | EXACT_MASK; |
1421 | // |
1422 | // Note: the findKey method is guaranteed to return the offset of a |
1423 | // keyblock whose first ebc bytes match the supplied key. |
1424 | @@ -1313,15 +1316,15 @@ |
1425 | * @param foundAt |
1426 | * @return |
1427 | */ |
1428 | - int nextLongRecord(Value value, int foundAt) { |
1429 | + int nextLongRecord(final Value value, final int foundAt) { |
1430 | Debug.$assert0.t(isDataPage()); |
1431 | for (int p = foundAt & P_MASK; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { |
1432 | - int kbData = getInt(p); |
1433 | - int tail = decodeKeyBlockTail(kbData); |
1434 | - int tbData = getInt(tail); |
1435 | - int klength = decodeTailBlockKLength(tbData); |
1436 | - int size = decodeTailBlockSize(tbData); |
1437 | - int valueSize = size - klength - _tailHeaderSize; |
1438 | + final int kbData = getInt(p); |
1439 | + final int tail = decodeKeyBlockTail(kbData); |
1440 | + final int tbData = getInt(tail); |
1441 | + final int klength = decodeTailBlockKLength(tbData); |
1442 | + final int size = decodeTailBlockSize(tbData); |
1443 | + final int valueSize = size - klength - _tailHeaderSize; |
1444 | if ((valueSize > 0) && ((_bytes[tail + _tailHeaderSize + klength] & 0xFF) == LONGREC_TYPE)) { |
1445 | value.putEncodedBytes(_bytes, tail + _tailHeaderSize + klength, valueSize); |
1446 | return p; |
1447 | @@ -1330,15 +1333,15 @@ |
1448 | return -1; |
1449 | } |
1450 | |
1451 | - int previousKeyBlock(int foundAt) { |
1452 | - int p = (foundAt & P_MASK) - KEYBLOCK_LENGTH; |
1453 | + int previousKeyBlock(final int foundAt) { |
1454 | + final int p = (foundAt & P_MASK) - KEYBLOCK_LENGTH; |
1455 | if (p < KEY_BLOCK_START || p > _keyBlockEnd) |
1456 | return -1; |
1457 | return p; |
1458 | } |
1459 | |
1460 | - int nextKeyBlock(int foundAt) { |
1461 | - int p = (foundAt & P_MASK) + KEYBLOCK_LENGTH; |
1462 | + int nextKeyBlock(final int foundAt) { |
1463 | + final int p = (foundAt & P_MASK) + KEYBLOCK_LENGTH; |
1464 | if (p >= _keyBlockEnd || p < KEY_BLOCK_START) |
1465 | return -1; |
1466 | return p; |
1467 | @@ -1366,8 +1369,8 @@ |
1468 | * The value, converted to a byte array |
1469 | * @throws PersistitInterruptedException |
1470 | */ |
1471 | - int putValue(Key key, ValueHelper valueHelper) throws PersistitInterruptedException { |
1472 | - int p = findKey(key); |
1473 | + int putValue(final Key key, final ValueHelper valueHelper) throws PersistitInterruptedException { |
1474 | + final int p = findKey(key); |
1475 | return putValue(key, valueHelper, p, false); |
1476 | } |
1477 | |
1478 | @@ -1383,13 +1386,13 @@ |
1479 | * @param foundAt |
1480 | * The keyblock before which this record will be inserted |
1481 | */ |
1482 | - int putValue(Key key, ValueHelper valueHelper, int foundAt, boolean postSplit) { |
1483 | + int putValue(final Key key, final ValueHelper valueHelper, final int foundAt, final boolean postSplit) { |
1484 | if (Debug.ENABLED) { |
1485 | assertVerify(); |
1486 | } |
1487 | |
1488 | - boolean exactMatch = (foundAt & EXACT_MASK) > 0; |
1489 | - int p = foundAt & P_MASK; |
1490 | + final boolean exactMatch = (foundAt & EXACT_MASK) > 0; |
1491 | + final int p = foundAt & P_MASK; |
1492 | |
1493 | if (exactMatch) { |
1494 | return replaceValue(key, valueHelper, p); |
1495 | @@ -1401,9 +1404,9 @@ |
1496 | length = valueHelper.requiredLength(_bytes, 0, -1); |
1497 | } |
1498 | |
1499 | - int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; |
1500 | - boolean fixupSuccessor = (foundAt & FIXUP_MASK) > 0; |
1501 | - byte[] kbytes = key.getEncodedBytes(); |
1502 | + final int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; |
1503 | + final boolean fixupSuccessor = (foundAt & FIXUP_MASK) > 0; |
1504 | + final byte[] kbytes = key.getEncodedBytes(); |
1505 | |
1506 | int ebcNew; |
1507 | int ebcSuccessor; |
1508 | @@ -1429,8 +1432,8 @@ |
1509 | ebcSuccessor = 0; |
1510 | ebcNew = depth; |
1511 | } |
1512 | - int klength = key.getEncodedSize() - ebcNew - 1; |
1513 | - int newTailSize = klength + length + _tailHeaderSize; |
1514 | + final int klength = key.getEncodedSize() - ebcNew - 1; |
1515 | + final int newTailSize = klength + length + _tailHeaderSize; |
1516 | |
1517 | if (getKeyCount() >= _pool.getMaxKeys() || !willFit(newTailSize + KEYBLOCK_LENGTH - (free1 - free2))) { |
1518 | Debug.$assert0.t(!postSplit); |
1519 | @@ -1443,8 +1446,8 @@ |
1520 | // is correct. |
1521 | // |
1522 | if (fixupSuccessor && ebcNew != ebcSuccessor) { |
1523 | - int successorKeyLength = decodeTailBlockKLength(successorTailBlock); |
1524 | - int successorDb = getByte(successorTail + _tailHeaderSize + delta - 1); |
1525 | + final int successorKeyLength = decodeTailBlockKLength(successorTailBlock); |
1526 | + final int successorDb = getByte(successorTail + _tailHeaderSize + delta - 1); |
1527 | |
1528 | // Write updated successor tail block |
1529 | putInt(successorTail, encodeTailBlock(successorTailSize - delta, successorKeyLength - delta)); |
1530 | @@ -1460,7 +1463,7 @@ |
1531 | |
1532 | putInt(p, kbSuccessor); |
1533 | } |
1534 | - int dbNew = kbytes[ebcNew] & 0xFF; |
1535 | + final int dbNew = kbytes[ebcNew] & 0xFF; |
1536 | // |
1537 | // Allocate space for the new tail block |
1538 | // |
1539 | @@ -1481,7 +1484,7 @@ |
1540 | System.arraycopy(_bytes, p, _bytes, p + KEYBLOCK_LENGTH, _keyBlockEnd - p - KEYBLOCK_LENGTH); |
1541 | |
1542 | // Write new key block |
1543 | - int newKeyBlock = encodeKeyBlock(ebcNew, dbNew, newTail); |
1544 | + final int newKeyBlock = encodeKeyBlock(ebcNew, dbNew, newTail); |
1545 | putInt(p, newKeyBlock); |
1546 | |
1547 | // Write new tail block |
1548 | @@ -1493,12 +1496,12 @@ |
1549 | System.arraycopy(kbytes, ebcNew + 1, _bytes, newTail + _tailHeaderSize, klength); |
1550 | |
1551 | if (isIndexPage()) { |
1552 | - int pointer = (int) valueHelper.getPointerValue(); |
1553 | + final int pointer = (int) valueHelper.getPointerValue(); |
1554 | |
1555 | Debug.$assert0.t(p + KEYBLOCK_LENGTH < _keyBlockEnd ? pointer > 0 : true); |
1556 | putInt(newTail + TAILBLOCK_POINTER, pointer); |
1557 | } else { |
1558 | - int storedLength = valueHelper.storeVersion(_bytes, newTail + _tailHeaderSize + klength, -1, |
1559 | + final int storedLength = valueHelper.storeVersion(_bytes, newTail + _tailHeaderSize + klength, -1, |
1560 | _bytes.length); // TODO limit |
1561 | incCountIfMvv(_bytes, newTail + _tailHeaderSize + klength, storedLength & MVV.STORE_LENGTH_MASK); |
1562 | } |
1563 | @@ -1532,12 +1535,12 @@ |
1564 | */ |
1565 | private boolean adjacentKeyCheck(int p) { |
1566 | p &= P_MASK; |
1567 | - int kbData1 = getInt(p); |
1568 | - int kbData2 = getInt(p + KEYBLOCK_LENGTH); |
1569 | - int db1 = decodeKeyBlockDb(kbData1); |
1570 | - int ebc1 = decodeKeyBlockEbc(kbData1); |
1571 | - int db2 = decodeKeyBlockDb(kbData2); |
1572 | - int ebc2 = decodeKeyBlockEbc(kbData2); |
1573 | + final int kbData1 = getInt(p); |
1574 | + final int kbData2 = getInt(p + KEYBLOCK_LENGTH); |
1575 | + final int db1 = decodeKeyBlockDb(kbData1); |
1576 | + final int ebc1 = decodeKeyBlockEbc(kbData1); |
1577 | + final int db2 = decodeKeyBlockDb(kbData2); |
1578 | + final int ebc2 = decodeKeyBlockEbc(kbData2); |
1579 | |
1580 | if (db1 == 0 && p > KEY_BLOCK_START) { |
1581 | return false; // Can set breakpoint here |
1582 | @@ -1551,9 +1554,9 @@ |
1583 | if (ebc2 < ebc1) |
1584 | return true; |
1585 | if (ebc2 > ebc1) { |
1586 | - int tail1 = decodeKeyBlockTail(kbData1); |
1587 | - int tbData1 = getInt(tail1); |
1588 | - int klength1 = decodeTailBlockKLength(tbData1); |
1589 | + final int tail1 = decodeKeyBlockTail(kbData1); |
1590 | + final int tbData1 = getInt(tail1); |
1591 | + final int klength1 = decodeTailBlockKLength(tbData1); |
1592 | int db = -1; |
1593 | if (klength1 >= ebc2 - ebc1) { |
1594 | db = _bytes[tail1 + _tailHeaderSize + ebc2 - ebc1 - 1] & DB_MASK; |
1595 | @@ -1569,12 +1572,12 @@ |
1596 | return false; // Can set breakpoint here |
1597 | } |
1598 | |
1599 | - private int replaceValue(Key key, ValueHelper valueHelper, int p) { |
1600 | - int kbData = getInt(p); |
1601 | - int tail = decodeKeyBlockTail(kbData); |
1602 | - int tbData = getInt(tail); |
1603 | - int klength = decodeTailBlockKLength(tbData); |
1604 | - int oldTailSize = decodeTailBlockSize(tbData); |
1605 | + private int replaceValue(final Key key, final ValueHelper valueHelper, final int p) { |
1606 | + final int kbData = getInt(p); |
1607 | + final int tail = decodeKeyBlockTail(kbData); |
1608 | + final int tbData = getInt(tail); |
1609 | + final int klength = decodeTailBlockKLength(tbData); |
1610 | + final int oldTailSize = decodeTailBlockSize(tbData); |
1611 | boolean wasMVV = false; |
1612 | boolean isMVV = false; |
1613 | |
1614 | @@ -1587,9 +1590,9 @@ |
1615 | wasMVV = isValueMVV(_bytes, tail + _tailHeaderSize + klength, oldTailSize - _tailHeaderSize - klength); |
1616 | } |
1617 | |
1618 | - int newTailSize = klength + length + _tailHeaderSize; |
1619 | - int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1620 | - int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1621 | + final int newTailSize = klength + length + _tailHeaderSize; |
1622 | + final int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1623 | + final int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1624 | int newTail = tail; |
1625 | if (newNext < oldNext) { |
1626 | // Free the remainder of the old tail block |
1627 | @@ -1622,7 +1625,7 @@ |
1628 | } |
1629 | |
1630 | if (isIndexPage()) { |
1631 | - long pointer = valueHelper.getPointerValue(); |
1632 | + final long pointer = valueHelper.getPointerValue(); |
1633 | Debug.$assert0.t(p + KEYBLOCK_LENGTH < _keyBlockEnd ? pointer > 0 : pointer == -1); |
1634 | putInt(newTail + TAILBLOCK_POINTER, (int) pointer); |
1635 | } else { |
1636 | @@ -1658,11 +1661,11 @@ |
1637 | * @return <i>true</i> if the key was found and the value removed, else |
1638 | * <i>false</i> |
1639 | */ |
1640 | - boolean removeKeys(int foundAt1, int foundAt2, Key spareKey) { |
1641 | + boolean removeKeys(final int foundAt1, final int foundAt2, final Key spareKey) { |
1642 | if (Debug.ENABLED) { |
1643 | assertVerify(); |
1644 | } |
1645 | - int p1 = foundAt1 & P_MASK; |
1646 | + final int p1 = foundAt1 & P_MASK; |
1647 | int p2 = foundAt2 & P_MASK; |
1648 | if ((foundAt2 & EXACT_MASK) != 0) |
1649 | p2 += KEYBLOCK_LENGTH; |
1650 | @@ -1675,24 +1678,24 @@ |
1651 | |
1652 | int ebc = Integer.MAX_VALUE; |
1653 | |
1654 | - byte[] spareBytes = spareKey.getEncodedBytes(); |
1655 | + final byte[] spareBytes = spareKey.getEncodedBytes(); |
1656 | int keySize = 0; |
1657 | for (int p = p1; p < p2; p += KEYBLOCK_LENGTH) { |
1658 | - int kbData = getInt(p); |
1659 | - int ebcCandidate = decodeKeyBlockEbc(kbData); |
1660 | + final int kbData = getInt(p); |
1661 | + final int ebcCandidate = decodeKeyBlockEbc(kbData); |
1662 | if (ebcCandidate < ebc) { |
1663 | ebc = ebcCandidate; |
1664 | } |
1665 | - int db = decodeKeyBlockDb(kbData); |
1666 | - int tail = decodeKeyBlockTail(kbData); |
1667 | - int tbData = getInt(tail); |
1668 | - int klength = decodeTailBlockKLength(tbData); |
1669 | + final int db = decodeKeyBlockDb(kbData); |
1670 | + final int tail = decodeKeyBlockTail(kbData); |
1671 | + final int tbData = getInt(tail); |
1672 | + final int klength = decodeTailBlockKLength(tbData); |
1673 | spareBytes[ebcCandidate] = (byte) db; |
1674 | if (klength > 0) { |
1675 | System.arraycopy(_bytes, tail + _tailHeaderSize, spareBytes, ebcCandidate + 1, klength); |
1676 | } |
1677 | keySize = klength + ebcCandidate + 1; |
1678 | - int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1679 | + final int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1680 | deallocTail(tail, size); |
1681 | } |
1682 | spareKey.setEncodedSize(keySize); |
1683 | @@ -1711,22 +1714,22 @@ |
1684 | // |
1685 | if (p1 < _keyBlockEnd) { |
1686 | int kbNext = getInt(p1); |
1687 | - int ebcNext = decodeKeyBlockEbc(kbNext); |
1688 | + final int ebcNext = decodeKeyBlockEbc(kbNext); |
1689 | |
1690 | // |
1691 | // If ebcNext > ebc then the successor key will need to expand. |
1692 | // |
1693 | if (ebcNext > ebc) { |
1694 | int tailNext = decodeKeyBlockTail(kbNext); |
1695 | - int dbNext = decodeKeyBlockDb(kbNext); |
1696 | - int tbNext = getInt(tailNext); |
1697 | - int nextTailSize = decodeTailBlockSize(tbNext); |
1698 | - |
1699 | - int nextTailBlockSize = (nextTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1700 | - |
1701 | - int newNextTailBlockSize = (nextTailSize + ebcNext - ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1702 | - |
1703 | - int delta = newNextTailBlockSize - nextTailBlockSize; |
1704 | + final int dbNext = decodeKeyBlockDb(kbNext); |
1705 | + final int tbNext = getInt(tailNext); |
1706 | + final int nextTailSize = decodeTailBlockSize(tbNext); |
1707 | + |
1708 | + final int nextTailBlockSize = (nextTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1709 | + |
1710 | + final int newNextTailBlockSize = (nextTailSize + ebcNext - ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1711 | + |
1712 | + final int delta = newNextTailBlockSize - nextTailBlockSize; |
1713 | boolean freeNextTailBlock = false; |
1714 | int newNextTail = tailNext; |
1715 | if (delta > 0) { |
1716 | @@ -1786,17 +1789,17 @@ |
1717 | // |
1718 | // Now construct the new tail block |
1719 | // |
1720 | - int newNextKLength = decodeTailBlockKLength(tbNext) + ebcNext - ebc; |
1721 | - int newNextTailSize = nextTailSize + ebcNext - ebc; |
1722 | + final int newNextKLength = decodeTailBlockKLength(tbNext) + ebcNext - ebc; |
1723 | + final int newNextTailSize = nextTailSize + ebcNext - ebc; |
1724 | putInt(newNextTail, encodeTailBlock(newNextTailSize, newNextKLength)); |
1725 | if (freeNextTailBlock) { |
1726 | - int toFree = (nextTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1727 | + final int toFree = (nextTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1728 | deallocTail(tailNext, toFree); |
1729 | } |
1730 | // |
1731 | // Fix up the successor key block |
1732 | // |
1733 | - int kbNewNext = encodeKeyBlock(ebc, spareBytes[ebc], newNextTail); |
1734 | + final int kbNewNext = encodeKeyBlock(ebc, spareBytes[ebc], newNextTail); |
1735 | putInt(p1, kbNewNext); |
1736 | } |
1737 | } |
1738 | @@ -1820,7 +1823,7 @@ |
1739 | * The amount by which that block is to be expanded. |
1740 | * @return int Offset of the expanded tail block, or -1 if it does not fit. |
1741 | */ |
1742 | - private int wedgeTail(int tail, int delta) { |
1743 | + private int wedgeTail(final int tail, int delta) { |
1744 | delta = (delta + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1745 | if (delta == 0) { |
1746 | return tail; |
1747 | @@ -1836,8 +1839,8 @@ |
1748 | _alloc -= delta; |
1749 | |
1750 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { |
1751 | - int kbData = getInt(p); |
1752 | - int oldTail = decodeKeyBlockTail(kbData); |
1753 | + final int kbData = getInt(p); |
1754 | + final int oldTail = decodeKeyBlockTail(kbData); |
1755 | if (oldTail < tail) { |
1756 | putInt(p, encodeKeyBlockTail(kbData, oldTail - delta)); |
1757 | } |
1758 | @@ -1869,8 +1872,8 @@ |
1759 | * the right sibling Buffer. |
1760 | * @throws PersistitException |
1761 | */ |
1762 | - final int split(Buffer rightSibling, Key key, ValueHelper valueHelper, int foundAt, Key indexKey, |
1763 | - Sequence sequence, SplitPolicy policy) throws PersistitException { |
1764 | + final int split(final Buffer rightSibling, final Key key, final ValueHelper valueHelper, int foundAt, |
1765 | + final Key indexKey, final Sequence sequence, final SplitPolicy policy) throws PersistitException { |
1766 | // Make sure the right sibling page is empty. |
1767 | |
1768 | Debug.$assert0.t(rightSibling._keyBlockEnd == KEY_BLOCK_START); |
1769 | @@ -1888,10 +1891,10 @@ |
1770 | // |
1771 | int currentSize = _bufferSize - _alloc - _slack + _keyBlockEnd - KEY_BLOCK_START; |
1772 | |
1773 | - int foundAtPosition = foundAt & P_MASK; |
1774 | - boolean exact = (foundAt & EXACT_MASK) != 0; |
1775 | + final int foundAtPosition = foundAt & P_MASK; |
1776 | + final boolean exact = (foundAt & EXACT_MASK) != 0; |
1777 | int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; |
1778 | - boolean fixupSuccessor = (foundAt & FIXUP_MASK) > 0; |
1779 | + final boolean fixupSuccessor = (foundAt & FIXUP_MASK) > 0; |
1780 | |
1781 | int ebcNew; |
1782 | int ebcSuccessor; |
1783 | @@ -1899,18 +1902,18 @@ |
1784 | int deltaSuccessorEbc = 0; |
1785 | |
1786 | if (fixupSuccessor) { |
1787 | - int kbSuccessor = getInt(foundAtPosition); |
1788 | - int tbSuccessor = getInt(decodeKeyBlockTail(kbSuccessor)); |
1789 | + final int kbSuccessor = getInt(foundAtPosition); |
1790 | + final int tbSuccessor = getInt(decodeKeyBlockTail(kbSuccessor)); |
1791 | ebcNew = decodeKeyBlockEbc(kbSuccessor); |
1792 | ebcSuccessor = depth; |
1793 | - int tbSize = decodeTailBlockSize(tbSuccessor); |
1794 | + final int tbSize = decodeTailBlockSize(tbSuccessor); |
1795 | |
1796 | // This is the number of bytes by which the successor key |
1797 | // can have its elided byte count increased. |
1798 | deltaSuccessorEbc = ebcSuccessor - ebcNew; |
1799 | |
1800 | - int oldSize = (tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1801 | - int newSize = (tbSize - deltaSuccessorEbc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1802 | + final int oldSize = (tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1803 | + final int newSize = (tbSize - deltaSuccessorEbc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1804 | |
1805 | // This is the number of bytes by which the successor tail block |
1806 | // can be reduced (because its elision count has increased.) |
1807 | @@ -1924,11 +1927,11 @@ |
1808 | int newTailBlockSize; |
1809 | int newValueSize; |
1810 | if (exact) { |
1811 | - int kbData = getInt(foundAtPosition); |
1812 | - int tail = decodeKeyBlockTail(kbData); |
1813 | - int tbData = getInt(tail); |
1814 | - int tbSize = decodeTailBlockSize(tbData); |
1815 | - int klength = decodeTailBlockKLength(tbData); |
1816 | + final int kbData = getInt(foundAtPosition); |
1817 | + final int tail = decodeKeyBlockTail(kbData); |
1818 | + final int tbData = getInt(tail); |
1819 | + final int tbSize = decodeTailBlockSize(tbData); |
1820 | + final int klength = decodeTailBlockKLength(tbData); |
1821 | oldTailBlockSize = (tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1822 | keyBlockSizeDelta = 0; |
1823 | ebcNew = decodeKeyBlockEbc(kbData); |
1824 | @@ -1940,7 +1943,7 @@ |
1825 | newTailBlockSize = ((isIndexPage() ? 0 : newValueSize) + _tailHeaderSize + key.getEncodedSize() - ebcNew - 1 + ~TAILBLOCK_MASK) |
1826 | & TAILBLOCK_MASK; |
1827 | |
1828 | - int virtualSize = currentSize + newTailBlockSize - oldTailBlockSize + keyBlockSizeDelta |
1829 | + final int virtualSize = currentSize + newTailBlockSize - oldTailBlockSize + keyBlockSizeDelta |
1830 | - deltaSuccessorTailSize; |
1831 | |
1832 | int splitBest = 0; // Maximal fitness measure |
1833 | @@ -1951,7 +1954,7 @@ |
1834 | boolean armed = true; |
1835 | int whereInserted = -1; |
1836 | |
1837 | - int rightKeyBlock = _keyBlockEnd - KEYBLOCK_LENGTH; |
1838 | + final int rightKeyBlock = _keyBlockEnd - KEYBLOCK_LENGTH; |
1839 | for (int p = KEY_BLOCK_START; p < rightKeyBlock;) { |
1840 | int splitCandidate = 0; |
1841 | if (p == foundAtPosition && armed) { |
1842 | @@ -1968,18 +1971,18 @@ |
1843 | // Compute the number of bytes by which the successor tailblock |
1844 | // will grow due to its elision count becoming zero. |
1845 | // |
1846 | - int kbData = getInt(p); |
1847 | - int tbData = getInt(decodeKeyBlockTail(kbData)); |
1848 | - int ebc = decodeKeyBlockEbc(kbData); |
1849 | - int tbSize = decodeTailBlockSize(tbData); |
1850 | - int tbSizeDelta = ((tbSize + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
1851 | + final int kbData = getInt(p); |
1852 | + final int tbData = getInt(decodeKeyBlockTail(kbData)); |
1853 | + final int ebc = decodeKeyBlockEbc(kbData); |
1854 | + final int tbSize = decodeTailBlockSize(tbData); |
1855 | + final int tbSizeDelta = ((tbSize + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
1856 | - ((tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); |
1857 | |
1858 | - int edgeTailBlockSize = (decodeTailBlockKLength(tbData) - deltaSuccessorEbc + _tailHeaderSize + ~TAILBLOCK_MASK) |
1859 | + final int edgeTailBlockSize = (decodeTailBlockKLength(tbData) - deltaSuccessorEbc + _tailHeaderSize + ~TAILBLOCK_MASK) |
1860 | & TAILBLOCK_MASK; |
1861 | |
1862 | if (p < rightKeyBlock) { |
1863 | - int rightSize = virtualSize - leftSize + tbSizeDelta; |
1864 | + final int rightSize = virtualSize - leftSize + tbSizeDelta; |
1865 | |
1866 | splitCandidate = policy.splitFit(this, p, foundAtPosition, exact, leftSize + KEYBLOCK_LENGTH |
1867 | + edgeTailBlockSize, rightSize, currentSize, virtualSize, _bufferSize - KEY_BLOCK_START, |
1868 | @@ -1996,7 +1999,7 @@ |
1869 | int kbData = getInt(p); |
1870 | int tbData = getInt(decodeKeyBlockTail(kbData)); |
1871 | int tbSizeDelta; |
1872 | - int tailBlockSize = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1873 | + final int tailBlockSize = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1874 | leftSize += tailBlockSize + KEYBLOCK_LENGTH; |
1875 | |
1876 | p += KEYBLOCK_LENGTH; |
1877 | @@ -2011,8 +2014,8 @@ |
1878 | } else { |
1879 | kbData = getInt(p); |
1880 | tbData = getInt(decodeKeyBlockTail(kbData)); |
1881 | - int ebc = decodeKeyBlockEbc(kbData); |
1882 | - int tbSize = decodeTailBlockSize(tbData); |
1883 | + final int ebc = decodeKeyBlockEbc(kbData); |
1884 | + final int tbSize = decodeTailBlockSize(tbData); |
1885 | |
1886 | tbSizeDelta = ((tbSize + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
1887 | - ((tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); |
1888 | @@ -2022,7 +2025,7 @@ |
1889 | } |
1890 | |
1891 | if (p < rightKeyBlock) { |
1892 | - int rightSize = virtualSize - leftSize + tbSizeDelta; |
1893 | + final int rightSize = virtualSize - leftSize + tbSizeDelta; |
1894 | |
1895 | splitCandidate = policy.splitFit(this, p, foundAtPosition, exact, leftSize + KEYBLOCK_LENGTH |
1896 | + edgeTailBlockSize, rightSize, currentSize, virtualSize, _bufferSize - KEY_BLOCK_START, |
1897 | @@ -2048,11 +2051,11 @@ |
1898 | // |
1899 | // Now move the keys and records. |
1900 | // |
1901 | - byte[] indexKeyBytes = indexKey.getEncodedBytes(); |
1902 | - int splitAtPosition = splitAt & P_MASK; |
1903 | + final byte[] indexKeyBytes = indexKey.getEncodedBytes(); |
1904 | + final int splitAtPosition = splitAt & P_MASK; |
1905 | |
1906 | - boolean lastLeft = (splitAt & EXACT_MASK) != 0; |
1907 | - boolean firstRight = !lastLeft && splitAtPosition == foundAtPosition; |
1908 | + final boolean lastLeft = (splitAt & EXACT_MASK) != 0; |
1909 | + final boolean firstRight = !lastLeft && splitAtPosition == foundAtPosition; |
1910 | int indexKeyDepth = 0; |
1911 | // |
1912 | // First we need to compute the full key in the right sibling page. |
1913 | @@ -2074,18 +2077,18 @@ |
1914 | // |
1915 | if (!firstRight) { |
1916 | for (int p = scanStart; p <= splitAtPosition; p += KEYBLOCK_LENGTH) { |
1917 | - int kbData = getInt(p); |
1918 | - int ebc = decodeKeyBlockEbc(kbData); |
1919 | - int db = decodeKeyBlockDb(kbData); |
1920 | - int tail = decodeKeyBlockTail(kbData); |
1921 | + final int kbData = getInt(p); |
1922 | + final int ebc = decodeKeyBlockEbc(kbData); |
1923 | + final int db = decodeKeyBlockDb(kbData); |
1924 | + final int tail = decodeKeyBlockTail(kbData); |
1925 | if (ebc > indexKeyDepth) { |
1926 | throw new InvalidPageStructureException("ebc at " + p + " ebc=" + ebc + " > indexKeyDepth=" |
1927 | + indexKeyDepth); |
1928 | } |
1929 | indexKeyDepth = ebc; |
1930 | indexKeyBytes[indexKeyDepth++] = (byte) db; |
1931 | - int tbData = getInt(tail); |
1932 | - int klength = decodeTailBlockKLength(tbData); |
1933 | + final int tbData = getInt(tail); |
1934 | + final int klength = decodeTailBlockKLength(tbData); |
1935 | |
1936 | System.arraycopy(_bytes, tail + _tailHeaderSize, indexKeyBytes, indexKeyDepth, klength); |
1937 | indexKeyDepth += klength; |
1938 | @@ -2202,7 +2205,7 @@ |
1939 | if (isDataPage()) { |
1940 | currentSize = (tailBlockSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1941 | |
1942 | - int newSize = (tailBlockSize - dataSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1943 | + final int newSize = (tailBlockSize - dataSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
1944 | if (newSize != currentSize) { |
1945 | deallocTail(tail + newSize, currentSize - newSize); |
1946 | } |
1947 | @@ -2217,9 +2220,9 @@ |
1948 | // |
1949 | // Fix up the right edge key in the left page. |
1950 | // |
1951 | - int kbData = getInt(splitAtPosition); |
1952 | + final int kbData = getInt(splitAtPosition); |
1953 | int edgeTail = decodeKeyBlockTail(kbData); |
1954 | - int ebc = decodeKeyBlockEbc(kbData); |
1955 | + final int ebc = decodeKeyBlockEbc(kbData); |
1956 | depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; |
1957 | |
1958 | if (firstRight && !exact) { |
1959 | @@ -2230,10 +2233,10 @@ |
1960 | if (fixupSuccessor) { |
1961 | depth = ebc; |
1962 | } |
1963 | - int db = indexKeyBytes[depth]; |
1964 | + final int db = indexKeyBytes[depth]; |
1965 | |
1966 | - int edgeKeyLength = indexKey.getEncodedSize() - depth - 1; |
1967 | - int edgeTailBlockSize = edgeKeyLength + _tailHeaderSize; |
1968 | + final int edgeKeyLength = indexKey.getEncodedSize() - depth - 1; |
1969 | + final int edgeTailBlockSize = edgeKeyLength + _tailHeaderSize; |
1970 | edgeTail = allocTail(edgeTailBlockSize); |
1971 | if (edgeTail == -1) { |
1972 | setKeyBlockEnd(splitAtPosition); |
1973 | @@ -2367,8 +2370,8 @@ |
1974 | * in the rare case where no rearrangement of the records is |
1975 | * possible. |
1976 | */ |
1977 | - final boolean join(Buffer buffer, int foundAt1, int foundAt2, Key indexKey, Key spareKey, JoinPolicy policy) |
1978 | - throws RebalanceException { |
1979 | + final boolean join(final Buffer buffer, int foundAt1, int foundAt2, final Key indexKey, final Key spareKey, |
1980 | + final JoinPolicy policy) throws RebalanceException { |
1981 | foundAt1 &= P_MASK; |
1982 | foundAt2 &= P_MASK; |
1983 | |
1984 | @@ -2401,17 +2404,17 @@ |
1985 | // |
1986 | buffer.keyAt(foundAt2, spareKey); |
1987 | |
1988 | - long measureLeft = joinMeasure(foundAt1, _keyBlockEnd); |
1989 | - long measureRight = buffer.joinMeasure(KEY_BLOCK_START, foundAt2); |
1990 | + final long measureLeft = joinMeasure(foundAt1, _keyBlockEnd); |
1991 | + final long measureRight = buffer.joinMeasure(KEY_BLOCK_START, foundAt2); |
1992 | kbData = buffer.getInt(foundAt2); |
1993 | - int oldEbc = decodeKeyBlockEbc(kbData); |
1994 | - int newEbc = Math.min(oldEbc, Math.min((int) (measureLeft >>> 32), (int) (measureRight >>> 32))); |
1995 | + final int oldEbc = decodeKeyBlockEbc(kbData); |
1996 | + final int newEbc = Math.min(oldEbc, Math.min((int) (measureLeft >>> 32), (int) (measureRight >>> 32))); |
1997 | tail = decodeKeyBlockTail(kbData); |
1998 | tbData = buffer.getInt(tail); |
1999 | |
2000 | - int oldSize = decodeTailBlockSize(tbData); |
2001 | - int newSize = oldSize + (oldEbc - newEbc); |
2002 | - int adjustmentForNewEbc = ((newSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
2003 | + final int oldSize = decodeTailBlockSize(tbData); |
2004 | + final int newSize = oldSize + (oldEbc - newEbc); |
2005 | + final int adjustmentForNewEbc = ((newSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
2006 | - ((oldSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); |
2007 | |
2008 | /* |
2009 | @@ -2424,7 +2427,7 @@ |
2010 | final int virtualKeyCount = ((foundAt1 - KEY_BLOCK_START) + (buffer.getKeyBlockEnd() - foundAt2)) |
2011 | / KEYBLOCK_LENGTH; |
2012 | |
2013 | - boolean okayToRejoin = virtualKeyCount < _pool.getMaxKeys() && policy.acceptJoin(this, virtualSize); |
2014 | + final boolean okayToRejoin = virtualKeyCount < _pool.getMaxKeys() && policy.acceptJoin(this, virtualSize); |
2015 | |
2016 | boolean result; |
2017 | |
2018 | @@ -2473,7 +2476,7 @@ |
2019 | /* |
2020 | * unsplice the right buffer from the right sibling chain. |
2021 | */ |
2022 | - long rightSibling = buffer.getRightSibling(); |
2023 | + final long rightSibling = buffer.getRightSibling(); |
2024 | setRightSibling(rightSibling); |
2025 | if (hasMVV) { |
2026 | _mvvCount = Integer.MAX_VALUE; |
2027 | @@ -2520,7 +2523,7 @@ |
2028 | buffer.joinDeallocateTails(KEY_BLOCK_START, foundAt2); |
2029 | buffer.clearBytes(KEY_BLOCK_START, foundAt2); |
2030 | buffer.reduceEbc(foundAt2, newEbc, spareKeyBytes); |
2031 | - int rightSize = buffer._keyBlockEnd - joinOffset; |
2032 | + final int rightSize = buffer._keyBlockEnd - joinOffset; |
2033 | |
2034 | moveRecords(buffer, foundAt2, joinOffset, _keyBlockEnd, true); |
2035 | |
2036 | @@ -2540,7 +2543,7 @@ |
2037 | |
2038 | buffer.joinDeallocateTails(KEY_BLOCK_START, foundAt2); |
2039 | |
2040 | - int rightSize = buffer._keyBlockEnd - foundAt2; |
2041 | + final int rightSize = buffer._keyBlockEnd - foundAt2; |
2042 | System.arraycopy(buffer._bytes, foundAt2, buffer._bytes, KEY_BLOCK_START, rightSize); |
2043 | buffer.clearBytes(KEY_BLOCK_START + rightSize, buffer._keyBlockEnd); |
2044 | buffer.setKeyBlockEnd(KEY_BLOCK_START + rightSize); |
2045 | @@ -2629,18 +2632,18 @@ |
2046 | * @return long encoding the size being deleted and the minimum ebc |
2047 | * |
2048 | */ |
2049 | - long joinMeasure(int from, int to) { |
2050 | + long joinMeasure(final int from, final int to) { |
2051 | int minimumEbc = Integer.MAX_VALUE; |
2052 | int totalDeallocatedSize = 0; |
2053 | for (int index = from; index < to; index += KEYBLOCK_LENGTH) { |
2054 | - int kbData = getInt(index); |
2055 | - int ebc = decodeKeyBlockEbc(kbData); |
2056 | + final int kbData = getInt(index); |
2057 | + final int ebc = decodeKeyBlockEbc(kbData); |
2058 | if (index != KEY_BLOCK_START && ebc < minimumEbc) { |
2059 | minimumEbc = ebc; |
2060 | } |
2061 | - int tail = decodeKeyBlockTail(kbData); |
2062 | - int tbData = getInt(tail); |
2063 | - int size = decodeTailBlockSize(tbData); |
2064 | + final int tail = decodeKeyBlockTail(kbData); |
2065 | + final int tbData = getInt(tail); |
2066 | + final int size = decodeTailBlockSize(tbData); |
2067 | totalDeallocatedSize += ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) + KEYBLOCK_LENGTH; |
2068 | } |
2069 | return (((long) minimumEbc) << 32) | totalDeallocatedSize; |
2070 | @@ -2660,12 +2663,12 @@ |
2071 | * @param to |
2072 | * offset of the next key block not being deleted |
2073 | */ |
2074 | - void joinDeallocateTails(int from, int to) { |
2075 | + void joinDeallocateTails(final int from, final int to) { |
2076 | for (int index = from; index < to; index += KEYBLOCK_LENGTH) { |
2077 | - int kbData = getInt(index); |
2078 | - int tail = decodeKeyBlockTail(kbData); |
2079 | - int tbData = getInt(tail); |
2080 | - int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2081 | + final int kbData = getInt(index); |
2082 | + final int tail = decodeKeyBlockTail(kbData); |
2083 | + final int tbData = getInt(tail); |
2084 | + final int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2085 | deallocTail(tail, size); |
2086 | } |
2087 | } |
2088 | @@ -2739,23 +2742,24 @@ |
2089 | // |
2090 | for (int p = KEY_BLOCK_START; p < foundAt1; p += KEYBLOCK_LENGTH) { |
2091 | kbData = getInt(p); |
2092 | - int ebc = decodeKeyBlockEbc(kbData); |
2093 | + final int ebc = decodeKeyBlockEbc(kbData); |
2094 | tail = decodeKeyBlockTail(kbData); |
2095 | tbData = getInt(tail); |
2096 | - int size = decodeTailBlockSize(tbData); |
2097 | + final int size = decodeTailBlockSize(tbData); |
2098 | klength = decodeTailBlockKLength(tbData); |
2099 | |
2100 | - int delta = ((size + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); |
2101 | - |
2102 | - int candidateRightSize = virtualSize - leftSize + delta; |
2103 | - |
2104 | - int candidateLeftSize = leftSize + KEYBLOCK_LENGTH + ((klength + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
2105 | + final int delta = ((size + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
2106 | + - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); |
2107 | + |
2108 | + final int candidateRightSize = virtualSize - leftSize + delta; |
2109 | + |
2110 | + final int candidateLeftSize = leftSize + KEYBLOCK_LENGTH + ((klength + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
2111 | + _tailHeaderSize; |
2112 | |
2113 | - int rightKeyCount = ((buffer.getKeyBlockEnd() - foundAt2) + (foundAt1 - p)) / KEYBLOCK_LENGTH; |
2114 | + final int rightKeyCount = ((buffer.getKeyBlockEnd() - foundAt2) + (foundAt1 - p)) / KEYBLOCK_LENGTH; |
2115 | |
2116 | - int joinFit = policy.rebalanceFit(this, buffer, p, foundAt1, foundAt2, virtualSize, candidateLeftSize, |
2117 | - candidateRightSize, _bufferSize - KEY_BLOCK_START); |
2118 | + final int joinFit = policy.rebalanceFit(this, buffer, p, foundAt1, foundAt2, virtualSize, |
2119 | + candidateLeftSize, candidateRightSize, _bufferSize - KEY_BLOCK_START); |
2120 | |
2121 | if (joinFit > joinBest && rightKeyCount < _pool.getMaxKeys()) { |
2122 | joinBest = joinFit; |
2123 | @@ -2770,10 +2774,10 @@ |
2124 | */ |
2125 | for (int p = foundAt2; p < buffer._keyBlockEnd; p += KEYBLOCK_LENGTH) { |
2126 | kbData = buffer.getInt(p); |
2127 | - int ebc = decodeKeyBlockEbc(kbData); |
2128 | + final int ebc = decodeKeyBlockEbc(kbData); |
2129 | tail = decodeKeyBlockTail(kbData); |
2130 | tbData = buffer.getInt(tail); |
2131 | - int size = decodeTailBlockSize(tbData); |
2132 | + final int size = decodeTailBlockSize(tbData); |
2133 | klength = decodeTailBlockKLength(tbData); |
2134 | |
2135 | /* |
2136 | @@ -2781,23 +2785,24 @@ |
2137 | * rebalance key would have to grow if it became the first key on |
2138 | * the right page and its ebc became zero. |
2139 | */ |
2140 | - int delta = ((size + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); |
2141 | + final int delta = ((size + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
2142 | + - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); |
2143 | |
2144 | /* |
2145 | * Amount by which the current tail block needs to grow to |
2146 | * accommodate reduced ebc. |
2147 | */ |
2148 | - int adjustment = (p == foundAt2) ? adjustmentForNewEbc : 0; |
2149 | - |
2150 | - int candidateRightSize = virtualSize - leftSize + delta; |
2151 | - |
2152 | - int candidateLeftSize = leftSize + ((klength + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) + adjustment |
2153 | + final int adjustment = (p == foundAt2) ? adjustmentForNewEbc : 0; |
2154 | + |
2155 | + final int candidateRightSize = virtualSize - leftSize + delta; |
2156 | + |
2157 | + final int candidateLeftSize = leftSize + ((klength + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) + adjustment |
2158 | + _tailHeaderSize + KEYBLOCK_LENGTH; |
2159 | |
2160 | - int leftKeyCount = ((foundAt1 - KEY_BLOCK_START) + (p - foundAt2)) / KEYBLOCK_LENGTH; |
2161 | + final int leftKeyCount = ((foundAt1 - KEY_BLOCK_START) + (p - foundAt2)) / KEYBLOCK_LENGTH; |
2162 | |
2163 | - int joinFit = policy.rebalanceFit(this, buffer, p, foundAt1, foundAt2, virtualSize, candidateLeftSize, |
2164 | - candidateRightSize, _bufferSize - KEY_BLOCK_START); |
2165 | + final int joinFit = policy.rebalanceFit(this, buffer, p, foundAt1, foundAt2, virtualSize, |
2166 | + candidateLeftSize, candidateRightSize, _bufferSize - KEY_BLOCK_START); |
2167 | |
2168 | if (joinFit > joinBest && leftKeyCount < _pool.getMaxKeys()) { |
2169 | joinBest = joinFit; |
2170 | @@ -2821,12 +2826,12 @@ |
2171 | return _fastIndex; |
2172 | } |
2173 | |
2174 | - private void reduceEbc(int p, int newEbc, byte[] indexKeyBytes) { |
2175 | + private void reduceEbc(final int p, final int newEbc, final byte[] indexKeyBytes) { |
2176 | int kbData = getInt(p); |
2177 | - int oldDb = decodeKeyBlockDb(kbData); |
2178 | - int oldEbc = decodeKeyBlockEbc(kbData); |
2179 | + final int oldDb = decodeKeyBlockDb(kbData); |
2180 | + final int oldEbc = decodeKeyBlockEbc(kbData); |
2181 | int tail = decodeKeyBlockTail(kbData); |
2182 | - int tbData = getInt(tail); |
2183 | + final int tbData = getInt(tail); |
2184 | int size = decodeTailBlockSize(tbData); |
2185 | int klength = decodeTailBlockKLength(tbData); |
2186 | |
2187 | @@ -2836,7 +2841,7 @@ |
2188 | throw new IllegalArgumentException("newEbc=" + newEbc + " must be less than oldEbc=" + oldEbc); |
2189 | } |
2190 | |
2191 | - int delta = ((size + oldEbc - newEbc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
2192 | + final int delta = ((size + oldEbc - newEbc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) |
2193 | - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); |
2194 | int newTail; |
2195 | boolean wedged = false; |
2196 | @@ -2881,7 +2886,7 @@ |
2197 | |
2198 | size += oldEbc - newEbc; |
2199 | klength += oldEbc - newEbc; |
2200 | - int newDb = indexKeyBytes[newEbc] & 0xFF; |
2201 | + final int newDb = indexKeyBytes[newEbc] & 0xFF; |
2202 | |
2203 | putInt(newTail, encodeTailBlock(size, klength)); |
2204 | |
2205 | @@ -2897,7 +2902,7 @@ |
2206 | * @param insertAt |
2207 | * @param includesRightEdge |
2208 | */ |
2209 | - void moveRecords(Buffer buffer, int p1, int p2, int insertAt, boolean includesRightEdge) { |
2210 | + void moveRecords(final Buffer buffer, final int p1, final int p2, int insertAt, final boolean includesRightEdge) { |
2211 | if (p2 - p1 + _keyBlockEnd > _alloc) { |
2212 | repack(); |
2213 | } |
2214 | @@ -2912,15 +2917,15 @@ |
2215 | setKeyBlockEnd(getKeyBlockEnd() + KEYBLOCK_LENGTH); |
2216 | |
2217 | for (int p = p1; p < p2 || includesRightEdge && p == p2; p += KEYBLOCK_LENGTH) { |
2218 | - int kbData = buffer.getInt(p); |
2219 | - int ebc = decodeKeyBlockEbc(kbData); |
2220 | - int db = decodeKeyBlockDb(kbData); |
2221 | - int tail = decodeKeyBlockTail(kbData); |
2222 | - int tbData = buffer.getInt(tail); |
2223 | - int size = decodeTailBlockSize(tbData); |
2224 | - int klength = decodeTailBlockKLength(tbData); |
2225 | + final int kbData = buffer.getInt(p); |
2226 | + final int ebc = decodeKeyBlockEbc(kbData); |
2227 | + final int db = decodeKeyBlockDb(kbData); |
2228 | + final int tail = decodeKeyBlockTail(kbData); |
2229 | + final int tbData = buffer.getInt(tail); |
2230 | + final int size = decodeTailBlockSize(tbData); |
2231 | + final int klength = decodeTailBlockKLength(tbData); |
2232 | int newSize = size; |
2233 | - boolean edgeCase = includesRightEdge && p == p2; |
2234 | + final boolean edgeCase = includesRightEdge && p == p2; |
2235 | if (edgeCase) { |
2236 | // this is just for the right edge key of the left page |
2237 | newSize = _tailHeaderSize + klength; |
2238 | @@ -2972,7 +2977,7 @@ |
2239 | */ |
2240 | private int allocTail(int size) { |
2241 | size = (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2242 | - int alloc = _alloc - size; |
2243 | + final int alloc = _alloc - size; |
2244 | if (alloc >= _keyBlockEnd) { |
2245 | _alloc = alloc; |
2246 | return alloc; |
2247 | @@ -2981,7 +2986,7 @@ |
2248 | } |
2249 | } |
2250 | |
2251 | - private void deallocTail(int tail, int size) { |
2252 | + private void deallocTail(final int tail, int size) { |
2253 | size = (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2254 | |
2255 | Debug.$assert0.t((size > 0 && size <= _bufferSize - _alloc) && (tail >= _alloc && tail < _bufferSize) |
2256 | @@ -2993,9 +2998,9 @@ |
2257 | // any free space above this block. |
2258 | // |
2259 | while (tail + size < _bufferSize) { |
2260 | - int kbNext = getInt(tail + size); |
2261 | + final int kbNext = getInt(tail + size); |
2262 | if ((kbNext & TAILBLOCK_INUSE_MASK) == 0) { |
2263 | - int sizeNext = decodeTailBlockSize(kbNext); |
2264 | + final int sizeNext = decodeTailBlockSize(kbNext); |
2265 | Debug.$assert0.t((sizeNext & ~TAILBLOCK_MASK) == 0 && sizeNext != 0); |
2266 | _slack -= sizeNext; |
2267 | putInt(tail + size, 0); |
2268 | @@ -3018,7 +3023,7 @@ |
2269 | private void repack() { |
2270 | Debug.$assert0.t(isMine()); |
2271 | |
2272 | - int[] plan = getRepackPlanBuffer(); |
2273 | + final int[] plan = getRepackPlanBuffer(); |
2274 | // |
2275 | // Phase 1: |
2276 | // For each allocated tail block, post the offset of its |
2277 | @@ -3028,9 +3033,9 @@ |
2278 | int free = 0; |
2279 | int back = 0; |
2280 | for (int tail = _alloc; tail < _bufferSize;) { |
2281 | - int tbData = getInt(tail); |
2282 | + final int tbData = getInt(tail); |
2283 | |
2284 | - int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2285 | + final int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2286 | if (size <= 0) { |
2287 | _persistit.fatal("Buffer has invalid tailblock length " + size + " at " + tail + " in " + this, null); |
2288 | } |
2289 | @@ -3058,9 +3063,9 @@ |
2290 | if (free > 0) |
2291 | moveSize += alloc - tail - free; |
2292 | alloc = tail + free; |
2293 | - int planData = plan[tail / TAILBLOCK_FACTOR]; |
2294 | + final int planData = plan[tail / TAILBLOCK_FACTOR]; |
2295 | plan[tail / TAILBLOCK_FACTOR] = free + tail; |
2296 | - int deltaFree = planData & 0xFFFF; |
2297 | + final int deltaFree = planData & 0xFFFF; |
2298 | if (deltaFree > 0 && moveSize > 0 && free > 0) { |
2299 | System.arraycopy(_bytes, moveFrom, _bytes, moveFrom + free, moveSize); |
2300 | moveSize = 0; |
2301 | @@ -3080,14 +3085,14 @@ |
2302 | // |
2303 | if (free > 0) { |
2304 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { |
2305 | - int kbData = getInt(p); |
2306 | + final int kbData = getInt(p); |
2307 | // |
2308 | // For certain remove operations, we may have invalid keyblocks |
2309 | // in range. We can safely ignore them here. |
2310 | // |
2311 | if (kbData != 0) { |
2312 | - int tail = decodeKeyBlockTail(kbData); |
2313 | - int newTail = plan[tail / KEYBLOCK_LENGTH]; |
2314 | + final int tail = decodeKeyBlockTail(kbData); |
2315 | + final int newTail = plan[tail / KEYBLOCK_LENGTH]; |
2316 | |
2317 | if (newTail != tail) { |
2318 | putInt(p, encodeKeyBlockTail(kbData, newTail)); |
2319 | @@ -3105,7 +3110,7 @@ |
2320 | * The size required by the proposed new tailblock. |
2321 | * @return boolean <i>true</i> if it will fit, else <i>false</i>. |
2322 | */ |
2323 | - private boolean willFit(int needed) { |
2324 | + private boolean willFit(final int needed) { |
2325 | return needed <= (_alloc - _keyBlockEnd + _slack); |
2326 | } |
2327 | |
2328 | @@ -3116,8 +3121,8 @@ |
2329 | * @param foundAt |
2330 | * The keyblock index |
2331 | */ |
2332 | - boolean isAfterRightEdge(int foundAt) { |
2333 | - int p = foundAt & P_MASK; |
2334 | + boolean isAfterRightEdge(final int foundAt) { |
2335 | + final int p = foundAt & P_MASK; |
2336 | return (p >= _keyBlockEnd) || ((p == _keyBlockEnd - KEYBLOCK_LENGTH && (foundAt & EXACT_MASK) != 0)); |
2337 | } |
2338 | |
2339 | @@ -3127,7 +3132,7 @@ |
2340 | * |
2341 | * @param foundAt |
2342 | */ |
2343 | - boolean isBeforeLeftEdge(int foundAt) { |
2344 | + boolean isBeforeLeftEdge(final int foundAt) { |
2345 | return (((foundAt & EXACT_MASK) == 0 && (foundAt & P_MASK) <= KEY_BLOCK_START) || (foundAt & P_MASK) < KEY_BLOCK_START); |
2346 | } |
2347 | |
2348 | @@ -3136,11 +3141,11 @@ |
2349 | return _bytes; |
2350 | } |
2351 | |
2352 | - int getByte(int index) { |
2353 | + int getByte(final int index) { |
2354 | return (_bytes[index] & 0xFF); |
2355 | } |
2356 | |
2357 | - int getChar(int index) { |
2358 | + int getChar(final int index) { |
2359 | if (Persistit.BIG_ENDIAN) { |
2360 | return (_bytes[index + 1] & 0xFF) | (_bytes[index] & 0xFF) << 8; |
2361 | } else { |
2362 | @@ -3148,7 +3153,7 @@ |
2363 | } |
2364 | } |
2365 | |
2366 | - int getInt(int index) { |
2367 | + int getInt(final int index) { |
2368 | if (Persistit.BIG_ENDIAN) { |
2369 | return (_bytes[index + 3] & 0xFF) | (_bytes[index + 2] & 0xFF) << 8 | (_bytes[index + 1] & 0xFF) << 16 |
2370 | | (_bytes[index] & 0xFF) << 24; |
2371 | @@ -3158,21 +3163,21 @@ |
2372 | } |
2373 | } |
2374 | |
2375 | - long getLong(int index) { |
2376 | + long getLong(final int index) { |
2377 | if (Persistit.BIG_ENDIAN) { |
2378 | - return (long) (_bytes[index + 7] & 0xFF) | (long) (_bytes[index + 6] & 0xFF) << 8 |
2379 | + return _bytes[index + 7] & 0xFF | (long) (_bytes[index + 6] & 0xFF) << 8 |
2380 | | (long) (_bytes[index + 5] & 0xFF) << 16 | (long) (_bytes[index + 4] & 0xFF) << 24 |
2381 | | (long) (_bytes[index + 3] & 0xFF) << 32 | (long) (_bytes[index + 2] & 0xFF) << 40 |
2382 | | (long) (_bytes[index + 1] & 0xFF) << 48 | (long) (_bytes[index] & 0xFF) << 56; |
2383 | } else { |
2384 | - return (long) (_bytes[index] & 0xFF) | (long) (_bytes[index + 1] & 0xFF) << 8 |
2385 | + return _bytes[index] & 0xFF | (long) (_bytes[index + 1] & 0xFF) << 8 |
2386 | | (long) (_bytes[index + 2] & 0xFF) << 16 | (long) (_bytes[index + 3] & 0xFF) << 24 |
2387 | | (long) (_bytes[index + 4] & 0xFF) << 32 | (long) (_bytes[index + 5] & 0xFF) << 40 |
2388 | | (long) (_bytes[index + 6] & 0xFF) << 48 | (long) (_bytes[index + 7] & 0xFF) << 56; |
2389 | } |
2390 | } |
2391 | |
2392 | - int getDb(int index) { |
2393 | + int getDb(final int index) { |
2394 | if (Persistit.BIG_ENDIAN) { |
2395 | return _bytes[index + 3] & 0xFF; |
2396 | } else { |
2397 | @@ -3180,12 +3185,12 @@ |
2398 | } |
2399 | } |
2400 | |
2401 | - void putByte(int index, int value) { |
2402 | + void putByte(final int index, final int value) { |
2403 | Debug.$assert0.t(index >= 0 && index + 1 <= _bytes.length); |
2404 | _bytes[index] = (byte) (value); |
2405 | } |
2406 | |
2407 | - void putChar(int index, int value) { |
2408 | + void putChar(final int index, final int value) { |
2409 | Debug.$assert0.t(index >= 0 && index + 2 <= _bytes.length); |
2410 | if (Persistit.BIG_ENDIAN) { |
2411 | _bytes[index + 1] = (byte) (value); |
2412 | @@ -3196,7 +3201,7 @@ |
2413 | } |
2414 | } |
2415 | |
2416 | - void putInt(int index, int value) { |
2417 | + void putInt(final int index, final int value) { |
2418 | Debug.$assert0.t(index >= 0 && index + 4 <= _bytes.length); |
2419 | if (Persistit.BIG_ENDIAN) { |
2420 | _bytes[index + 3] = (byte) (value); |
2421 | @@ -3211,7 +3216,7 @@ |
2422 | } |
2423 | } |
2424 | |
2425 | - void putLong(int index, long value) { |
2426 | + void putLong(final int index, final long value) { |
2427 | Debug.$assert0.t(index >= 0 && index + 8 <= _bytes.length); |
2428 | |
2429 | if (Persistit.BIG_ENDIAN) { |
2430 | @@ -3235,7 +3240,7 @@ |
2431 | } |
2432 | } |
2433 | |
2434 | - static void writeLongRecordDescriptor(byte[] bytes, int size, long pageAddr) { |
2435 | + static void writeLongRecordDescriptor(final byte[] bytes, final int size, final long pageAddr) { |
2436 | if (bytes.length != LONGREC_SIZE) { |
2437 | throw new IllegalArgumentException("Bad LONG_RECORD descriptor size: " + size); |
2438 | } |
2439 | @@ -3246,7 +3251,7 @@ |
2440 | Util.putLong(bytes, LONGREC_PAGE_OFFSET, pageAddr); |
2441 | } |
2442 | |
2443 | - static int decodeLongRecordDescriptorSize(byte[] bytes, int offset) { |
2444 | + static int decodeLongRecordDescriptorSize(final byte[] bytes, final int offset) { |
2445 | int type; |
2446 | if ((type = (bytes[offset] & 0xFF)) != LONGREC_TYPE) { |
2447 | throw new IllegalArgumentException("Bad LONG_RECORD descriptor type: " + type); |
2448 | @@ -3254,7 +3259,7 @@ |
2449 | return (int) Util.getLong(bytes, offset + LONGREC_SIZE_OFFSET); |
2450 | } |
2451 | |
2452 | - static long decodeLongRecordDescriptorPointer(byte[] bytes, int offset) { |
2453 | + static long decodeLongRecordDescriptorPointer(final byte[] bytes, final int offset) { |
2454 | int type; |
2455 | if ((type = (bytes[offset] & 0xFF)) != LONGREC_TYPE) { |
2456 | throw new IllegalArgumentException("Bad LONG_RECORD descriptor type: " + type); |
2457 | @@ -3263,7 +3268,7 @@ |
2458 | } |
2459 | |
2460 | static int bufferSizeWithOverhead(final int bufferSize) { |
2461 | - int fastIndexSize = ((bufferSize - HEADER_SIZE) / MAX_KEY_RATIO) * FastIndex.BYTES_PER_ENTRY; |
2462 | + final int fastIndexSize = ((bufferSize - HEADER_SIZE) / MAX_KEY_RATIO) * FastIndex.BYTES_PER_ENTRY; |
2463 | return bufferSize + fastIndexSize + ESTIMATED_FIXED_BUFFER_OVERHEAD; |
2464 | } |
2465 | |
2466 | @@ -3314,16 +3319,16 @@ |
2467 | return (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2468 | } |
2469 | |
2470 | - static int encodeKeyBlock(int ebc, int db, int tail) { |
2471 | + static int encodeKeyBlock(final int ebc, final int db, final int tail) { |
2472 | return ((ebc << EBC_SHIFT) & EBC_MASK) | ((db /* << DB_SHIFT */) & DB_MASK) |
2473 | | ((tail << TAIL_SHIFT) & TAIL_MASK); |
2474 | } |
2475 | |
2476 | - static int encodeKeyBlockTail(int kbData, int tail) { |
2477 | + static int encodeKeyBlockTail(final int kbData, final int tail) { |
2478 | return (kbData & ~TAIL_MASK) | ((tail << TAIL_SHIFT) & TAIL_MASK); |
2479 | } |
2480 | |
2481 | - static int encodeTailBlock(int size, int klength) { |
2482 | + static int encodeTailBlock(final int size, final int klength) { |
2483 | return ((klength << TAILBLOCK_KLENGTH_SHIFT) & TAILBLOCK_KLENGTH_MASK) | ((size /* |
2484 | * << |
2485 | * TAILBLOCK_SIZE_SHIFT |
2486 | @@ -3331,35 +3336,35 @@ |
2487 | | TAILBLOCK_INUSE_MASK; |
2488 | } |
2489 | |
2490 | - static int encodeFreeBlock(int size) { |
2491 | + static int encodeFreeBlock(final int size) { |
2492 | return ((size /* << TAILBLOCK_SIZE_SHIFT */) & TAILBLOCK_SIZE_MASK); |
2493 | } |
2494 | |
2495 | - static int decodeKeyBlockEbc(int kbData) { |
2496 | + static int decodeKeyBlockEbc(final int kbData) { |
2497 | return (kbData & EBC_MASK) >>> EBC_SHIFT; |
2498 | } |
2499 | |
2500 | - static int decodeKeyBlockDb(int kbData) { |
2501 | + static int decodeKeyBlockDb(final int kbData) { |
2502 | return (kbData & DB_MASK) /* >>> DB_SHIFT */; |
2503 | } |
2504 | |
2505 | - static int decodeKeyBlockTail(int kbData) { |
2506 | + static int decodeKeyBlockTail(final int kbData) { |
2507 | return (kbData & TAIL_MASK) >>> TAIL_SHIFT; |
2508 | } |
2509 | |
2510 | - static int decodeTailBlockSize(int tbData) { |
2511 | + static int decodeTailBlockSize(final int tbData) { |
2512 | return (tbData & TAILBLOCK_SIZE_MASK) /* >>> TAILBLOCK_SIZE_SHIFT */; |
2513 | } |
2514 | |
2515 | - static int decodeTailBlockKLength(int tbData) { |
2516 | + static int decodeTailBlockKLength(final int tbData) { |
2517 | return (tbData & TAILBLOCK_KLENGTH_MASK) >>> TAILBLOCK_KLENGTH_SHIFT; |
2518 | } |
2519 | |
2520 | - static boolean decodeTailBlockInUse(int tbData) { |
2521 | + static boolean decodeTailBlockInUse(final int tbData) { |
2522 | return (tbData & TAILBLOCK_INUSE_MASK) != 0; |
2523 | } |
2524 | |
2525 | - static int decodeDepth(int foundAt) { |
2526 | + static int decodeDepth(final int foundAt) { |
2527 | return (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT; |
2528 | } |
2529 | |
2530 | @@ -3367,7 +3372,7 @@ |
2531 | return _persistit.getThreadLocalIntArray(MAX_BUFFER_SIZE / TAILBLOCK_FACTOR); |
2532 | } |
2533 | |
2534 | - PersistitException verify(Key key, VerifyVisitor visitor) { |
2535 | + PersistitException verify(Key key, final VerifyVisitor visitor) { |
2536 | try { |
2537 | if (_page == 0) { |
2538 | return new InvalidPageStructureException("head page is neither a data page nor an index page"); |
2539 | @@ -3380,8 +3385,8 @@ |
2540 | key = new Key(_persistit); |
2541 | } |
2542 | |
2543 | - byte[] kb = key.getEncodedBytes(); |
2544 | - int[] plan = getRepackPlanBuffer(); |
2545 | + final byte[] kb = key.getEncodedBytes(); |
2546 | + final int[] plan = getRepackPlanBuffer(); |
2547 | for (int index = 0; index < plan.length; index++) { |
2548 | plan[index] = 0; |
2549 | } |
2550 | @@ -3392,10 +3397,10 @@ |
2551 | } |
2552 | |
2553 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { |
2554 | - int kbData = getInt(p); |
2555 | - int db = decodeKeyBlockDb(kbData); |
2556 | - int ebc = decodeKeyBlockEbc(kbData); |
2557 | - int tail = decodeKeyBlockTail(kbData); |
2558 | + final int kbData = getInt(p); |
2559 | + final int db = decodeKeyBlockDb(kbData); |
2560 | + final int ebc = decodeKeyBlockEbc(kbData); |
2561 | + final int tail = decodeKeyBlockTail(kbData); |
2562 | |
2563 | if (p == KEY_BLOCK_START && ebc != 0) { |
2564 | return new InvalidPageStructureException("invalid initial ebc " + ebc + " for keyblock at " + p |
2565 | @@ -3407,8 +3412,8 @@ |
2566 | return new InvalidPageStructureException("invalid tail block offset " + tail + " for keyblock at " |
2567 | + p + " --[" + summarize() + "]"); |
2568 | } |
2569 | - int tbData = getInt(tail); |
2570 | - int klength = decodeTailBlockKLength(tbData); |
2571 | + final int tbData = getInt(tail); |
2572 | + final int klength = decodeTailBlockKLength(tbData); |
2573 | if ((tbData & TAILBLOCK_INUSE_MASK) == 0) { |
2574 | return new InvalidPageStructureException("not in-use tail block offset " + tail |
2575 | + " for keyblock at " + p + " --[" + summarize() + "]"); |
2576 | @@ -3426,14 +3431,14 @@ |
2577 | compare = (kb[index] & 0xFF) - (_bytes[tail + _tailHeaderSize + index - 1] & 0xFF); |
2578 | } |
2579 | if (compare != 0) { |
2580 | - String s = compare < 0 ? "too big" : "too small"; |
2581 | + final String s = compare < 0 ? "too big" : "too small"; |
2582 | return new InvalidPageStructureException("initial key " + s + " at offset " + index |
2583 | + " for keyblock at " + p + " --[" + summarize() + "]"); |
2584 | } |
2585 | } |
2586 | // Verify that successor keys follow in sequence. |
2587 | if (p > KEY_BLOCK_START && ebc < key.getEncodedSize()) { |
2588 | - int dbPrev = kb[ebc] & 0xFF; |
2589 | + final int dbPrev = kb[ebc] & 0xFF; |
2590 | if (db < dbPrev) { |
2591 | return new InvalidPageStructureException("db not greater: db=" + db + " dbPrev=" + dbPrev |
2592 | + " for keyblock at " + p + " --[" + summarize() + "]"); |
2593 | @@ -3444,7 +3449,7 @@ |
2594 | // redundant |
2595 | // |
2596 | if (isIndexPage()) { |
2597 | - int pointer = getInt(tail + 4); |
2598 | + final int pointer = getInt(tail + 4); |
2599 | if (visitor != null) { |
2600 | visitor.visitIndexRecord(key, p, tail, klength, pointer); |
2601 | } |
2602 | @@ -3455,9 +3460,9 @@ |
2603 | } |
2604 | } |
2605 | } else if (isDataPage()) { |
2606 | - int size = decodeTailBlockSize(tbData); |
2607 | - int offset = tail + _tailHeaderSize + klength; |
2608 | - int length = size - klength - _tailHeaderSize; |
2609 | + final int size = decodeTailBlockSize(tbData); |
2610 | + final int offset = tail + _tailHeaderSize + klength; |
2611 | + final int length = size - klength - _tailHeaderSize; |
2612 | if (visitor != null) { |
2613 | visitor.visitDataRecord(key, p, tail, klength, offset, length, getBytes()); |
2614 | } |
2615 | @@ -3477,13 +3482,13 @@ |
2616 | |
2617 | // Now check the free blocks |
2618 | |
2619 | - int formerBlock = _alloc; |
2620 | + final int formerBlock = _alloc; |
2621 | for (int tail = _alloc; tail < _bufferSize;) { |
2622 | if ((tail & ~TAILBLOCK_MASK) != 0 || tail < 0 || tail > _bufferSize) { |
2623 | return new InvalidPageStructureException("Tail block at " + formerBlock + " is invalid"); |
2624 | } |
2625 | - int tbData = getInt(tail); |
2626 | - int size = decodeTailBlockSize(tbData); |
2627 | + final int tbData = getInt(tail); |
2628 | + final int size = decodeTailBlockSize(tbData); |
2629 | if (size <= ~TAILBLOCK_MASK || size >= _bufferSize - _keyBlockEnd) { |
2630 | return new InvalidPageStructureException("Tailblock at " + tail + " has invalid size=" + size); |
2631 | } |
2632 | @@ -3492,7 +3497,7 @@ |
2633 | return new InvalidPageStructureException("Tailblock at " + tail + " is in use, but no key " |
2634 | + " block points to it."); |
2635 | } |
2636 | - int klength = decodeTailBlockKLength(tbData); |
2637 | + final int klength = decodeTailBlockKLength(tbData); |
2638 | { |
2639 | if (klength + _tailHeaderSize > size) { |
2640 | return new InvalidPageStructureException("Tailblock at " + tail + " has klength=" + klength |
2641 | @@ -3508,7 +3513,7 @@ |
2642 | tail += ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK); |
2643 | } |
2644 | return null; |
2645 | - } catch (PersistitException pe) { |
2646 | + } catch (final PersistitException pe) { |
2647 | return pe; |
2648 | } |
2649 | |
2650 | @@ -3528,7 +3533,7 @@ |
2651 | * @return |
2652 | * @throws PersistitException |
2653 | */ |
2654 | - boolean pruneMvvValues(final Tree tree, boolean pruneLongMVVs) throws PersistitException { |
2655 | + boolean pruneMvvValues(final Tree tree, final boolean pruneLongMVVs) throws PersistitException { |
2656 | |
2657 | boolean changed = false; |
2658 | try { |
2659 | @@ -3541,7 +3546,7 @@ |
2660 | final long timestamp = _persistit.getTimestampAllocator().updateTimestamp(); |
2661 | _mvvCount = 0; |
2662 | writePageOnCheckpoint(timestamp); |
2663 | - List<PrunedVersion> prunedVersions = new ArrayList<PrunedVersion>(); |
2664 | + final List<PrunedVersion> prunedVersions = new ArrayList<PrunedVersion>(); |
2665 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { |
2666 | final int kbData = getInt(p); |
2667 | final int tail = decodeKeyBlockTail(kbData); |
2668 | @@ -3567,9 +3572,9 @@ |
2669 | true, prunedVersions); |
2670 | if (newSize != oldSize) { |
2671 | changed = true; |
2672 | - int newTailSize = klength + newSize + _tailHeaderSize; |
2673 | - int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2674 | - int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2675 | + final int newTailSize = klength + newSize + _tailHeaderSize; |
2676 | + final int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2677 | + final int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2678 | if (newNext < oldNext) { |
2679 | // Free the remainder of the old tail block |
2680 | deallocTail(newNext, oldNext - newNext); |
2681 | @@ -3600,11 +3605,11 @@ |
2682 | prunedVersions.clear(); |
2683 | |
2684 | if (pruneLongMVVs && hasLongMvvRecords) { |
2685 | - List<PersistitException> deferredExceptions = new ArrayList<PersistitException>(); |
2686 | - List<Long> oldChainsToDeallocate = new ArrayList<Long>(); |
2687 | + final List<PersistitException> deferredExceptions = new ArrayList<PersistitException>(); |
2688 | + final List<Long> oldChainsToDeallocate = new ArrayList<Long>(); |
2689 | |
2690 | - Buffer copy = new Buffer(this); |
2691 | - boolean copyChanged = copy.pruneLongMvvValues(tree, prunedVersions, deferredExceptions, |
2692 | + final Buffer copy = new Buffer(this); |
2693 | + final boolean copyChanged = copy.pruneLongMvvValues(tree, prunedVersions, deferredExceptions, |
2694 | oldChainsToDeallocate); |
2695 | if (copyChanged) { |
2696 | changed = true; |
2697 | @@ -3666,17 +3671,17 @@ |
2698 | boolean pruned = false; |
2699 | try { |
2700 | pruned = pruneLongMvv(_bytes, offset, oldSize, value, prunedVersions, toDeallocate); |
2701 | - } catch (PersistitException pe) { |
2702 | + } catch (final PersistitException pe) { |
2703 | deferredExceptions.add(pe); |
2704 | } |
2705 | if (pruned) { |
2706 | changed = true; |
2707 | - int newSize = value.getEncodedSize(); |
2708 | + final int newSize = value.getEncodedSize(); |
2709 | assert newSize <= oldSize : "Pruned long value overflow"; |
2710 | System.arraycopy(value.getEncodedBytes(), 0, _bytes, offset, newSize); |
2711 | - int newTailSize = klength + newSize + _tailHeaderSize; |
2712 | - int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2713 | - int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2714 | + final int newTailSize = klength + newSize + _tailHeaderSize; |
2715 | + final int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2716 | + final int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
2717 | if (newNext < oldNext) { |
2718 | // Free the remainder of the old tail block |
2719 | deallocTail(newNext, oldNext - newNext); |
2720 | @@ -3709,8 +3714,7 @@ |
2721 | if (!_enqueuedForAntiValuePruning) { |
2722 | final int treeHandle = tree.getHandle(); |
2723 | assert treeHandle != 0 : "MVV found in a temporary tree " + tree; |
2724 | - if (_persistit.getCleanupManager().offer( |
2725 | - new CleanupAntiValue(treeHandle, getPageAddress()))) { |
2726 | + if (_persistit.getCleanupManager().offer(new CleanupAntiValue(treeHandle, getPageAddress()))) { |
2727 | _enqueuedForAntiValuePruning = true; |
2728 | } |
2729 | } |
2730 | @@ -3731,19 +3735,19 @@ |
2731 | private boolean pruneLongMvv(final byte[] bytes, final int offset, final int oldSize, final Value value, |
2732 | final List<PrunedVersion> prunedVersions, final List<Long> toDeallocate) throws PersistitException { |
2733 | assert isLongMVV(bytes, offset, oldSize) : "Not a long MVV"; |
2734 | - long oldLongRecordChain = decodeLongRecordDescriptorPointer(bytes, offset); |
2735 | + final long oldLongRecordChain = decodeLongRecordDescriptorPointer(bytes, offset); |
2736 | value.changeLongRecordMode(false); |
2737 | value.ensureFit(oldSize); |
2738 | System.arraycopy(bytes, offset, value.getEncodedBytes(), 0, oldSize); |
2739 | value.setEncodedSize(oldSize); |
2740 | final LongRecordHelper helper = new LongRecordHelper(_persistit, _vol); |
2741 | helper.fetchLongRecord(value, Integer.MAX_VALUE); |
2742 | - byte[] rawBytes = value.getEncodedBytes(); |
2743 | - int oldLongSize = value.getEncodedSize(); |
2744 | + final byte[] rawBytes = value.getEncodedBytes(); |
2745 | + final int oldLongSize = value.getEncodedSize(); |
2746 | // TODO - perhaps remove. Done as a precaution for now. |
2747 | MVV.verify(rawBytes, 0, oldLongSize); |
2748 | - List<PrunedVersion> provisionalPrunedVersions = new ArrayList<PrunedVersion>(); |
2749 | - int newLongSize = MVV.prune(rawBytes, 0, oldLongSize, _persistit.getTransactionIndex(), true, |
2750 | + final List<PrunedVersion> provisionalPrunedVersions = new ArrayList<PrunedVersion>(); |
2751 | + final int newLongSize = MVV.prune(rawBytes, 0, oldLongSize, _persistit.getTransactionIndex(), true, |
2752 | provisionalPrunedVersions); |
2753 | if (newLongSize == oldLongSize) { |
2754 | // No pruning done. |
2755 | @@ -3771,6 +3775,7 @@ |
2756 | getTimestamp(), getGeneration()); |
2757 | } |
2758 | |
2759 | + @Override |
2760 | public String toString() { |
2761 | if (_toStringDebug) { |
2762 | return toStringDetail(); |
2763 | @@ -3818,7 +3823,7 @@ |
2764 | } |
2765 | boolean elision = false; |
2766 | for (int index = 0; index < records.length; index++) { |
2767 | - RecordInfo r = records[index]; |
2768 | + final RecordInfo r = records[index]; |
2769 | r.getKeyState().copyTo(key); |
2770 | String mark = " "; |
2771 | boolean selected = all | index < contextLines || index >= records.length - contextLines; |
2772 | @@ -3843,16 +3848,16 @@ |
2773 | r.getValueState().getEncodedBytes().length, Util.abridge(value.toString(), |
2774 | maxValueDisplayLength))); |
2775 | } else { |
2776 | - sb.append(String.format("\n%s %5d: db=%3d ebc=%3d tb=%,5d [%,d]%s->%,d", mark, r |
2777 | - .getKbOffset(), r.getDb(), r.getEbc(), r.getTbOffset(), r.getKLength(), Util |
2778 | - .abridge(key.toString(), maxKeyDisplayLength), r.getPointerValue())); |
2779 | + sb.append(String.format("\n%s %5d: db=%3d ebc=%3d tb=%,5d [%,d]%s->%,d", mark, |
2780 | + r.getKbOffset(), r.getDb(), r.getEbc(), r.getTbOffset(), r.getKLength(), |
2781 | + Util.abridge(key.toString(), maxKeyDisplayLength), r.getPointerValue())); |
2782 | } |
2783 | } else { |
2784 | elision = true; |
2785 | } |
2786 | |
2787 | } |
2788 | - } catch (Exception e) { |
2789 | + } catch (final Exception e) { |
2790 | sb.append(" - " + e); |
2791 | } |
2792 | } else if (isHeadPage()) { |
2793 | @@ -3876,7 +3881,7 @@ |
2794 | } |
2795 | |
2796 | String foundAtString(int p) { |
2797 | - StringBuilder sb = new StringBuilder("<"); |
2798 | + final StringBuilder sb = new StringBuilder("<"); |
2799 | sb.append(p & P_MASK); |
2800 | if ((p & EXACT_MASK) != 0) |
2801 | sb.append(":exact"); |
2802 | @@ -3892,7 +3897,7 @@ |
2803 | else if (p + KEYBLOCK_LENGTH == _keyBlockEnd) |
2804 | sb.append(":end"); |
2805 | else { |
2806 | - int kbData = getInt(p); |
2807 | + final int kbData = getInt(p); |
2808 | sb.append(":ebc=" + decodeKeyBlockEbc(kbData)); |
2809 | sb.append(":db=" + decodeKeyBlockDb(kbData)); |
2810 | sb.append(":tail=" + decodeKeyBlockTail(kbData)); |
2811 | @@ -3908,23 +3913,23 @@ |
2812 | ManagementImpl.RecordInfo[] result = null; |
2813 | |
2814 | if (isIndexPage() || isDataPage()) { |
2815 | - Key key = new Key(_persistit); |
2816 | - Value value = new Value(_persistit); |
2817 | + final Key key = new Key(_persistit); |
2818 | + final Value value = new Value(_persistit); |
2819 | |
2820 | - int count = (_keyBlockEnd - KEY_BLOCK_START) / KEYBLOCK_LENGTH; |
2821 | + final int count = (_keyBlockEnd - KEY_BLOCK_START) / KEYBLOCK_LENGTH; |
2822 | result = new ManagementImpl.RecordInfo[count]; |
2823 | int n = 0; |
2824 | for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) { |
2825 | - int kbData = getInt(p); |
2826 | - int db = decodeKeyBlockDb(kbData); |
2827 | - int ebc = decodeKeyBlockEbc(kbData); |
2828 | - int tail = decodeKeyBlockTail(kbData); |
2829 | - int tbData = tail != 0 ? getInt(tail) : 0; |
2830 | - int size = decodeTailBlockSize(tbData); |
2831 | - int klength = decodeTailBlockKLength(tbData); |
2832 | - boolean inUse = decodeTailBlockInUse(tbData); |
2833 | + final int kbData = getInt(p); |
2834 | + final int db = decodeKeyBlockDb(kbData); |
2835 | + final int ebc = decodeKeyBlockEbc(kbData); |
2836 | + final int tail = decodeKeyBlockTail(kbData); |
2837 | + final int tbData = tail != 0 ? getInt(tail) : 0; |
2838 | + final int size = decodeTailBlockSize(tbData); |
2839 | + final int klength = decodeTailBlockKLength(tbData); |
2840 | + final boolean inUse = decodeTailBlockInUse(tbData); |
2841 | |
2842 | - ManagementImpl.RecordInfo rec = new ManagementImpl.RecordInfo(); |
2843 | + final ManagementImpl.RecordInfo rec = new ManagementImpl.RecordInfo(); |
2844 | rec._kbOffset = p; |
2845 | rec._tbOffset = tail; |
2846 | rec._ebc = ebc; |
2847 | @@ -3933,7 +3938,7 @@ |
2848 | rec._size = size; |
2849 | rec._inUse = inUse; |
2850 | |
2851 | - byte[] kbytes = key.getEncodedBytes(); |
2852 | + final byte[] kbytes = key.getEncodedBytes(); |
2853 | kbytes[ebc] = (byte) db; |
2854 | System.arraycopy(_bytes, tail + _tailHeaderSize, kbytes, ebc + 1, klength); |
2855 | key.setEncodedSize(ebc + 1 + klength); |
2856 | @@ -3956,11 +3961,11 @@ |
2857 | result[n++] = rec; |
2858 | } |
2859 | } else if (isGarbagePage()) { |
2860 | - int count = (_bufferSize - _alloc) / GARBAGE_BLOCK_SIZE; |
2861 | + final int count = (_bufferSize - _alloc) / GARBAGE_BLOCK_SIZE; |
2862 | result = new ManagementImpl.RecordInfo[count]; |
2863 | int n = 0; |
2864 | for (int p = _alloc; p < _bufferSize; p += GARBAGE_BLOCK_SIZE) { |
2865 | - ManagementImpl.RecordInfo rec = new ManagementImpl.RecordInfo(); |
2866 | + final ManagementImpl.RecordInfo rec = new ManagementImpl.RecordInfo(); |
2867 | rec._tbOffset = p; |
2868 | rec._garbageStatus = getInt(p + GARBAGE_BLOCK_STATUS); |
2869 | rec._garbageLeftPage = getLong(p + GARBAGE_BLOCK_LEFT_PAGE); |
2870 | @@ -3973,12 +3978,12 @@ |
2871 | |
2872 | void assertVerify() { |
2873 | if (Debug.VERIFY_PAGES) { |
2874 | - Exception verifyException = verify(null, null); |
2875 | + final Exception verifyException = verify(null, null); |
2876 | Debug.$assert1.t(verifyException == null); |
2877 | } |
2878 | } |
2879 | |
2880 | - boolean addGarbageChain(long left, long right, long expectedCount) { |
2881 | + boolean addGarbageChain(final long left, final long right, final long expectedCount) { |
2882 | Debug.$assert0.t(left > 0 && left <= MAX_VALID_PAGE_ADDR && left != _page && right != _page && isGarbagePage()); |
2883 | |
2884 | if (_alloc - GARBAGE_BLOCK_SIZE < _keyBlockEnd) { |
2885 | @@ -4006,7 +4011,7 @@ |
2886 | Debug.$assert0.t(isGarbagePage()); |
2887 | if (_alloc + GARBAGE_BLOCK_SIZE > _bufferSize) |
2888 | return -1; |
2889 | - long page = getLong(_alloc + GARBAGE_BLOCK_LEFT_PAGE); |
2890 | + final long page = getLong(_alloc + GARBAGE_BLOCK_LEFT_PAGE); |
2891 | Debug.$assert0.t(page > 0 && page <= MAX_VALID_PAGE_ADDR && page != _page); |
2892 | return page; |
2893 | } |
2894 | @@ -4019,13 +4024,13 @@ |
2895 | return getLong(_alloc + GARBAGE_BLOCK_RIGHT_PAGE); |
2896 | } |
2897 | |
2898 | - long getGarbageChainLeftPage(int p) { |
2899 | - long page = getLong(p + GARBAGE_BLOCK_LEFT_PAGE); |
2900 | + long getGarbageChainLeftPage(final int p) { |
2901 | + final long page = getLong(p + GARBAGE_BLOCK_LEFT_PAGE); |
2902 | Debug.$assert1.t(page > 0 && page <= MAX_VALID_PAGE_ADDR && page != _page); |
2903 | return page; |
2904 | } |
2905 | |
2906 | - long getGarbageChainRightPage(int p) { |
2907 | + long getGarbageChainRightPage(final int p) { |
2908 | return getLong(p + GARBAGE_BLOCK_RIGHT_PAGE); |
2909 | } |
2910 | |
2911 | @@ -4036,18 +4041,18 @@ |
2912 | bumpGeneration(); |
2913 | } |
2914 | |
2915 | - void setGarbageLeftPage(long left) { |
2916 | + void setGarbageLeftPage(final long left) { |
2917 | Debug.$assert1.t(isMine() && isGarbagePage() && left > 0 && left <= MAX_VALID_PAGE_ADDR && left != _page |
2918 | && _alloc + GARBAGE_BLOCK_SIZE <= _bufferSize && _alloc >= _keyBlockEnd); |
2919 | putLong(_alloc + GARBAGE_BLOCK_LEFT_PAGE, left); |
2920 | bumpGeneration(); |
2921 | } |
2922 | |
2923 | - void populateInfo(ManagementImpl.BufferInfo info) { |
2924 | + void populateInfo(final ManagementImpl.BufferInfo info) { |
2925 | info.poolIndex = _poolIndex; |
2926 | info.pageAddress = _page; |
2927 | info.rightSiblingAddress = _rightSibling; |
2928 | - Volume vol = _vol; |
2929 | + final Volume vol = _vol; |
2930 | if (vol != null) { |
2931 | info.volumeName = vol.getPath(); |
2932 | } else { |
2933 | @@ -4064,7 +4069,7 @@ |
2934 | info.timestamp = _timestamp; |
2935 | info.status = getStatus(); |
2936 | info.statusName = getStatusCode(); |
2937 | - Thread writerThread = getWriterThread(); |
2938 | + final Thread writerThread = getWriterThread(); |
2939 | if (writerThread != null) { |
2940 | info.writerThreadName = writerThread.getName(); |
2941 | } else { |
2942 | @@ -4075,10 +4080,10 @@ |
2943 | |
2944 | void enqueuePruningAction(final int treeHandle) { |
2945 | if (_mvvCount > 0) { |
2946 | - long delay = _persistit.getCleanupManager().getMinimumPruningDelay(); |
2947 | + final long delay = _persistit.getCleanupManager().getMinimumPruningDelay(); |
2948 | if (delay > 0) { |
2949 | - long last = _lastPrunedTime; |
2950 | - long now = System.currentTimeMillis(); |
2951 | + final long last = _lastPrunedTime; |
2952 | + final long now = System.currentTimeMillis(); |
2953 | if (now - last > delay) { |
2954 | _lastPrunedTime = now; |
2955 | _persistit.getCleanupManager().offer( |
2956 | @@ -4105,9 +4110,9 @@ |
2957 | * writes an IV record. |
2958 | * @throws Exception |
2959 | */ |
2960 | - void dump(final ByteBuffer bb, final boolean secure, boolean verbose, final Set<Volume> identifiedVolumes) |
2961 | + void dump(final ByteBuffer bb, final boolean secure, final boolean verbose, final Set<Volume> identifiedVolumes) |
2962 | throws Exception { |
2963 | - byte[] bytes = new byte[_bufferSize]; |
2964 | + final byte[] bytes = new byte[_bufferSize]; |
2965 | int type; |
2966 | int keyBlockEnd; |
2967 | int alloc; |
2968 | @@ -4120,7 +4125,7 @@ |
2969 | /* |
2970 | * Copy all the information needed quickly and then release the buffer. |
2971 | */ |
2972 | - boolean claimed = claim(false, Persistit.SHORT_DELAY); |
2973 | + final boolean claimed = claim(false, Persistit.SHORT_DELAY); |
2974 | try { |
2975 | bufferSize = _bufferSize; |
2976 | type = _type; |
2977 | @@ -4138,12 +4143,12 @@ |
2978 | } |
2979 | } |
2980 | |
2981 | - String toString = toString(); |
2982 | + final String toString = toString(); |
2983 | if (verbose) { |
2984 | System.out.println(toString); |
2985 | } |
2986 | |
2987 | - int volumeHandle = volume == null ? 0 : volume.getHandle(); |
2988 | + final int volumeHandle = volume == null ? 0 : volume.getHandle(); |
2989 | if (volume != null && !identifiedVolumes.contains(volume)) { |
2990 | IV.putType(bb); |
2991 | IV.putHandle(bb, volumeHandle); |
2992 | @@ -4154,9 +4159,9 @@ |
2993 | identifiedVolumes.add(volume); |
2994 | } |
2995 | |
2996 | - boolean isDataPage = type == PAGE_TYPE_DATA; |
2997 | - boolean isIndexPage = type >= PAGE_TYPE_INDEX_MIN && type <= PAGE_TYPE_INDEX_MAX; |
2998 | - boolean isLongRecordPage = type == PAGE_TYPE_LONG_RECORD; |
2999 | + final boolean isDataPage = type == PAGE_TYPE_DATA; |
3000 | + final boolean isIndexPage = type >= PAGE_TYPE_INDEX_MIN && type <= PAGE_TYPE_INDEX_MAX; |
3001 | + final boolean isLongRecordPage = type == PAGE_TYPE_LONG_RECORD; |
3002 | |
3003 | /* |
3004 | * Following is equivalent to the save method, except written to the |
3005 | @@ -4187,7 +4192,7 @@ |
3006 | } else if (secure && isLongRecordPage) { |
3007 | left = KEY_BLOCK_START; |
3008 | } |
3009 | - int recordSize = PA.OVERHEAD + left + right; |
3010 | + final int recordSize = PA.OVERHEAD + left + right; |
3011 | PA.putLength(bb, recordSize); |
3012 | PA.putType(bb); |
3013 | PA.putVolumeHandle(bb, volumeHandle); |
3014 | @@ -4207,7 +4212,7 @@ |
3015 | * @param bytes |
3016 | * buffer image |
3017 | */ |
3018 | - private void dumpSecureOverwriteValues(byte[] bytes) { |
3019 | + private void dumpSecureOverwriteValues(final byte[] bytes) { |
3020 | if (bytes[0] != PAGE_TYPE_DATA) { |
3021 | return; |
3022 | } |
3023 | @@ -4216,12 +4221,12 @@ |
3024 | * overwrite values. |
3025 | */ |
3026 | for (int p = KEY_BLOCK_START; p < Util.getInt(bytes, KEY_BLOCK_END_OFFSET); p += KEYBLOCK_LENGTH) { |
3027 | - int kbData = Util.getInt(bytes, p); |
3028 | - int db = decodeKeyBlockDb(kbData); |
3029 | + final int kbData = Util.getInt(bytes, p); |
3030 | + final int db = decodeKeyBlockDb(kbData); |
3031 | if (db == 0 && p == KEY_BLOCK_START) { |
3032 | continue; |
3033 | } else if (db == Key.TYPE_STRING) { |
3034 | - int tail = decodeKeyBlockTail(kbData); |
3035 | + final int tail = decodeKeyBlockTail(kbData); |
3036 | if (bytes[tail + TAILBLOCK_HDR_SIZE_DATA] == '_') { |
3037 | // Probably a system key - don't overwrite values |
3038 | return; |
3039 | @@ -4235,9 +4240,9 @@ |
3040 | |
3041 | int tail = Util.getChar(bytes, FREE_OFFSET); |
3042 | for (; tail < bytes.length;) { |
3043 | - int tbData = Util.getInt(bytes, tail); |
3044 | - int tbSize = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
3045 | - int tbKLength = decodeTailBlockKLength(tbData); |
3046 | + final int tbData = Util.getInt(bytes, tail); |
3047 | + final int tbSize = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK; |
3048 | + final int tbKLength = decodeTailBlockKLength(tbData); |
3049 | // |
3050 | // If the tbSize field is corrupt then just dump the |
3051 | // remainder of the buffer |
3052 | @@ -4250,7 +4255,7 @@ |
3053 | // Otherwise, dump just the portion of the tailblock we |
3054 | // need for analysis and fill the rest with 'x's. |
3055 | // |
3056 | - boolean tbInUse = decodeTailBlockInUse(tbData); |
3057 | + final boolean tbInUse = decodeTailBlockInUse(tbData); |
3058 | // Number of bytes we need to dump |
3059 | int keep; |
3060 | if (tbInUse) { |
3061 | @@ -4272,7 +4277,8 @@ |
3062 | } |
3063 | } |
3064 | |
3065 | - static void deallocatePrunedVersions(Persistit persistit, Volume volume, List<PrunedVersion> prunedVersions) { |
3066 | + static void deallocatePrunedVersions(final Persistit persistit, final Volume volume, |
3067 | + final List<PrunedVersion> prunedVersions) { |
3068 | for (final PrunedVersion pv : prunedVersions) { |
3069 | final TransactionStatus ts = persistit.getTransactionIndex().getStatus(pv.getTs()); |
3070 | if (ts != null && ts.getTc() == TransactionStatus.ABORTED) { |
3071 | @@ -4281,7 +4287,7 @@ |
3072 | if (pv.getLongRecordPage() != 0) { |
3073 | try { |
3074 | volume.getStructure().deallocateGarbageChain(pv.getLongRecordPage(), 0); |
3075 | - } catch (PersistitException e) { |
3076 | + } catch (final PersistitException e) { |
3077 | persistit.getLogBase().pruneException.log(e, ts); |
3078 | } |
3079 | } |
3080 | @@ -4289,20 +4295,20 @@ |
3081 | prunedVersions.clear(); |
3082 | } |
3083 | |
3084 | - static boolean isLongRecord(byte[] bytes, int offset, int length) { |
3085 | + static boolean isLongRecord(final byte[] bytes, final int offset, final int length) { |
3086 | return (length > 0) && ((bytes[offset] & 0xFF) == LONGREC_TYPE); |
3087 | } |
3088 | |
3089 | - static boolean isLongMVV(byte[] bytes, int offset, int length) { |
3090 | + static boolean isLongMVV(final byte[] bytes, final int offset, final int length) { |
3091 | return isLongRecord(bytes, offset, length) && (length > LONGREC_PREFIX_OFFSET) |
3092 | && MVV.isArrayMVV(bytes, offset + LONGREC_PREFIX_OFFSET, length - LONGREC_PREFIX_OFFSET); |
3093 | } |
3094 | |
3095 | - static boolean isValueMVV(byte[] bytes, int offset, int length) { |
3096 | + static boolean isValueMVV(final byte[] bytes, final int offset, final int length) { |
3097 | return MVV.isArrayMVV(bytes, offset, length) || isLongMVV(bytes, offset, length); |
3098 | } |
3099 | |
3100 | - private void incCountIfMvv(byte[] bytes, int offset, int length) { |
3101 | + private void incCountIfMvv(final byte[] bytes, final int offset, final int length) { |
3102 | if (isValueMVV(bytes, offset, length)) { |
3103 | ++_mvvCount; |
3104 | } |
3105 | |
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 | |
3111 | package com.persistit; |
3112 | |
3113 | +import java.io.BufferedReader; |
3114 | +import java.io.BufferedWriter; |
3115 | import java.io.DataOutputStream; |
3116 | +import java.io.File; |
3117 | +import java.io.FileReader; |
3118 | +import java.io.FileWriter; |
3119 | +import java.io.IOException; |
3120 | import java.nio.ByteBuffer; |
3121 | import java.util.Arrays; |
3122 | import java.util.HashSet; |
3123 | @@ -36,7 +42,6 @@ |
3124 | import com.persistit.exception.VolumeClosedException; |
3125 | import com.persistit.util.Debug; |
3126 | import com.persistit.util.Util; |
3127 | -import java.io.*; |
3128 | |
3129 | /** |
3130 | * A pool of {@link Buffer} objects, maintained on various lists that permit |
3131 | @@ -52,7 +57,7 @@ |
3132 | private final static long DEFAULT_WRITER_POLL_INTERVAL = 5000; |
3133 | |
3134 | private final static int PAGE_WRITER_TRANCHE_SIZE = 5000; |
3135 | - |
3136 | + |
3137 | /** |
3138 | * Sleep time when buffers are exhausted |
3139 | */ |
3140 | @@ -148,7 +153,7 @@ |
3141 | /** |
3142 | * Count of newly created pages |
3143 | */ |
3144 | - private AtomicLong _newCounter = new AtomicLong(); |
3145 | + private final AtomicLong _newCounter = new AtomicLong(); |
3146 | |
3147 | /** |
3148 | * Count of valid buffers evicted to make room for another page. |
3149 | @@ -188,7 +193,7 @@ |
3150 | * Timestamp to which all dirty pages should be written. PAGE_WRITER writes |
3151 | * any page with a lower update timestamp regardless of urgency. |
3152 | */ |
3153 | - private AtomicLong _flushTimestamp = new AtomicLong(); |
3154 | + private final AtomicLong _flushTimestamp = new AtomicLong(); |
3155 | |
3156 | /** |
3157 | * Polling interval for PageWriter |
3158 | @@ -196,24 +201,24 @@ |
3159 | private volatile long _writerPollInterval = DEFAULT_WRITER_POLL_INTERVAL; |
3160 | |
3161 | private volatile int _pageWriterTrancheSize = PAGE_WRITER_TRANCHE_SIZE; |
3162 | - |
3163 | + |
3164 | /** |
3165 | * Polling interval for PageCacher |
3166 | */ |
3167 | private volatile long _cacherPollInterval; |
3168 | - |
3169 | + |
3170 | /** |
3171 | * The PAGE_WRITER IOTaskRunnable |
3172 | */ |
3173 | private PageWriter _writer; |
3174 | - |
3175 | + |
3176 | /** |
3177 | * The PAGE_CACHER IOTaskRunnable |
3178 | */ |
3179 | private PageCacher _cacher; |
3180 | - |
3181 | + |
3182 | private String _defaultLogPath; |
3183 | - |
3184 | + |
3185 | /** |
3186 | * Construct a BufferPool with the specified count of <code>Buffer</code>s |
3187 | * of the specified size. |
3188 | @@ -223,7 +228,7 @@ |
3189 | * @param size |
3190 | * The size (in bytes) of each buffer |
3191 | */ |
3192 | - BufferPool(int count, int size, Persistit persistit) { |
3193 | + BufferPool(final int count, final int size, final Persistit persistit) { |
3194 | _persistit = persistit; |
3195 | if (count < MINIMUM_POOL_COUNT) { |
3196 | throw new IllegalArgumentException("Buffer pool count too small: " + count); |
3197 | @@ -250,7 +255,7 @@ |
3198 | _hashTable = new Buffer[_bufferCount * HASH_MULTIPLE]; |
3199 | _hashLocks = new ReentrantLock[HASH_LOCKS]; |
3200 | _maxKeys = (_bufferSize - Buffer.HEADER_SIZE) / Buffer.MAX_KEY_RATIO; |
3201 | - |
3202 | + |
3203 | for (int index = 0; index < HASH_LOCKS; index++) { |
3204 | _hashLocks[index] = new ReentrantLock(); |
3205 | } |
3206 | @@ -263,11 +268,11 @@ |
3207 | byte[] reserve = new byte[1024 * 1024]; |
3208 | try { |
3209 | for (int index = 0; index < _bufferCount; index++) { |
3210 | - Buffer buffer = new Buffer(size, index, this, _persistit); |
3211 | + final Buffer buffer = new Buffer(size, index, this, _persistit); |
3212 | _buffers[index] = buffer; |
3213 | buffers++; |
3214 | } |
3215 | - } catch (OutOfMemoryError e) { |
3216 | + } catch (final OutOfMemoryError e) { |
3217 | // |
3218 | // Note: written this way to try to avoid another OOME. |
3219 | // Do not use String.format here. |
3220 | @@ -286,34 +291,33 @@ |
3221 | _writer = new PageWriter(); |
3222 | _cacher = new PageCacher(); |
3223 | } |
3224 | - |
3225 | - void warmupBufferPool(String pathName, String fname) throws PersistitException { |
3226 | - File file = new File(pathName, fname + ".log"); |
3227 | + |
3228 | + void warmupBufferPool(final String pathName, final String fname) throws PersistitException { |
3229 | + final File file = new File(pathName, fname + ".log"); |
3230 | _defaultLogPath = file.getAbsolutePath(); |
3231 | - |
3232 | + |
3233 | try { |
3234 | if (!file.exists()) { |
3235 | - file.createNewFile(); |
3236 | + file.createNewFile(); |
3237 | } |
3238 | - |
3239 | - BufferedReader reader = new BufferedReader(new FileReader(file)); |
3240 | + |
3241 | + final BufferedReader reader = new BufferedReader(new FileReader(file)); |
3242 | String currLine; |
3243 | while ((currLine = reader.readLine()) != null) { |
3244 | - String[] info = currLine.split(" "); |
3245 | + final String[] info = currLine.split(" "); |
3246 | if (info.length == 2) { |
3247 | - Volume vol = _persistit.getVolume(info[1]); |
3248 | + final Volume vol = _persistit.getVolume(info[1]); |
3249 | if (vol != null) { |
3250 | - long page = Long.parseLong(info[0]); |
3251 | - Buffer buff = get(vol, page, false, true); |
3252 | - buff.release(); |
3253 | + final long page = Long.parseLong(info[0]); |
3254 | + final Buffer buff = get(vol, page, false, true); |
3255 | + buff.release(); |
3256 | } |
3257 | } |
3258 | } |
3259 | reader.close(); |
3260 | _cacherPollInterval = _persistit.getConfiguration().getBufferInventoryPollingInterval(); |
3261 | _cacher.start(); |
3262 | - } |
3263 | - catch (IOException e) { |
3264 | + } catch (final IOException e) { |
3265 | throw new PersistitException(e); |
3266 | } |
3267 | } |
3268 | @@ -331,8 +335,8 @@ |
3269 | } |
3270 | |
3271 | /** |
3272 | - * Abruptly stop (using {@link Thread#stop()}) the writer, cacher, and collector |
3273 | - * threads. This method should be used only by tests. |
3274 | + * Abruptly stop (using {@link Thread#stop()}) the writer, cacher, and |
3275 | + * collector threads. This method should be used only by tests. |
3276 | */ |
3277 | void crash() { |
3278 | IOTaskRunnable.crash(_writer); |
3279 | @@ -351,14 +355,14 @@ |
3280 | return _flushTimestamp.get() != 0; |
3281 | } |
3282 | |
3283 | - int hashIndex(Volume vol, long page) { |
3284 | + int hashIndex(final Volume vol, final long page) { |
3285 | return (int) (((page ^ vol.hashCode()) & Integer.MAX_VALUE) % _hashTable.length); |
3286 | } |
3287 | |
3288 | - int countInUse(Volume vol, boolean writer) { |
3289 | + int countInUse(final Volume vol, final boolean writer) { |
3290 | int count = 0; |
3291 | for (int i = 0; i < _bufferCount; i++) { |
3292 | - Buffer buffer = _buffers[i]; |
3293 | + final Buffer buffer = _buffers[i]; |
3294 | if ((vol == null || buffer.getVolume() == vol) |
3295 | && ((buffer.getStatus() & SharedResource.CLAIMED_MASK) != 0 && (!writer || (buffer.getStatus() & SharedResource.WRITER_MASK) != 0))) { |
3296 | count++; |
3297 | @@ -367,7 +371,7 @@ |
3298 | return count; |
3299 | } |
3300 | |
3301 | - void populateBufferPoolInfo(ManagementImpl.BufferPoolInfo info) { |
3302 | + void populateBufferPoolInfo(final ManagementImpl.BufferPoolInfo info) { |
3303 | info.bufferCount = _bufferCount; |
3304 | info.bufferSize = _bufferSize; |
3305 | info.missCount = _missCounter.get(); |
3306 | @@ -383,8 +387,8 @@ |
3307 | int writerClaimedPages = 0; |
3308 | |
3309 | for (int index = 0; index < _bufferCount; index++) { |
3310 | - Buffer buffer = _buffers[index]; |
3311 | - int status = buffer.getStatus(); |
3312 | + final Buffer buffer = _buffers[index]; |
3313 | + final int status = buffer.getStatus(); |
3314 | if ((status & SharedResource.VALID_MASK) != 0) |
3315 | validPages++; |
3316 | if ((status & SharedResource.WRITER_MASK) != 0) |
3317 | @@ -400,12 +404,13 @@ |
3318 | info.updateAcquisitonTime(); |
3319 | } |
3320 | |
3321 | - int populateInfo(ManagementImpl.BufferInfo[] array, int traveralType, int includeMask, int excludeMask) { |
3322 | + int populateInfo(final ManagementImpl.BufferInfo[] array, final int traveralType, final int includeMask, |
3323 | + final int excludeMask) { |
3324 | int index = 0; |
3325 | switch (traveralType) { |
3326 | case 0: |
3327 | for (int i = 0; i < _bufferCount; i++) { |
3328 | - Buffer buffer = _buffers[i]; |
3329 | + final Buffer buffer = _buffers[i]; |
3330 | if (selected(buffer, includeMask, excludeMask)) { |
3331 | populateInfo1(array, index, buffer); |
3332 | index++; |
3333 | @@ -420,31 +425,31 @@ |
3334 | return index; |
3335 | } |
3336 | |
3337 | - private static void populateInfo1(ManagementImpl.BufferInfo[] array, int index, Buffer buffer) { |
3338 | + private static void populateInfo1(final ManagementImpl.BufferInfo[] array, final int index, final Buffer buffer) { |
3339 | if (index < array.length) { |
3340 | if (array[index] == null) |
3341 | array[index] = new ManagementImpl.BufferInfo(); |
3342 | buffer.populateInfo(array[index]); |
3343 | } |
3344 | } |
3345 | - |
3346 | + |
3347 | private void populateWarmupFile() throws PersistitException { |
3348 | - File file = new File(_defaultLogPath); |
3349 | - |
3350 | + final File file = new File(_defaultLogPath); |
3351 | + |
3352 | try { |
3353 | - BufferedWriter writer = new BufferedWriter(new FileWriter(file)); |
3354 | + final BufferedWriter writer = new BufferedWriter(new FileWriter(file)); |
3355 | for (int i = 0; i < _buffers.length; ++i) { |
3356 | - Buffer b = _buffers[i]; |
3357 | + final Buffer b = _buffers[i]; |
3358 | if (b != null && b.isValid() && !b.isDirty()) { |
3359 | - long page = b.getPageAddress(); |
3360 | - Volume volume = b.getVolume(); |
3361 | - long page2 = b.getPageAddress(); |
3362 | - Volume volume2 = b.getVolume(); |
3363 | - |
3364 | + final long page = b.getPageAddress(); |
3365 | + final Volume volume = b.getVolume(); |
3366 | + final long page2 = b.getPageAddress(); |
3367 | + final Volume volume2 = b.getVolume(); |
3368 | + |
3369 | // Check if buffer has changed while reading |
3370 | if (page == page2 && volume == volume2 && volume != null) { |
3371 | - String addr = Long.toString(page); |
3372 | - String vol = volume.getName(); |
3373 | + final String addr = Long.toString(page); |
3374 | + final String vol = volume.getName(); |
3375 | writer.append(addr + " " + vol); |
3376 | writer.newLine(); |
3377 | writer.flush(); |
3378 | @@ -452,12 +457,12 @@ |
3379 | } |
3380 | } |
3381 | writer.close(); |
3382 | - } catch (IOException e) { |
3383 | + } catch (final IOException e) { |
3384 | throw new PersistitException(e); |
3385 | } |
3386 | } |
3387 | |
3388 | - private boolean selected(Buffer buffer, int includeMask, int excludeMask) { |
3389 | + private boolean selected(final Buffer buffer, final int includeMask, final int excludeMask) { |
3390 | return ((includeMask == 0) || (buffer.getStatus() & includeMask) != 0) |
3391 | && (buffer.getStatus() & excludeMask) == 0; |
3392 | } |
3393 | @@ -599,7 +604,7 @@ |
3394 | * The volume |
3395 | * @throws PersistitInterruptedException |
3396 | */ |
3397 | - boolean invalidate(Volume volume) throws PersistitInterruptedException { |
3398 | + boolean invalidate(final Volume volume) throws PersistitInterruptedException { |
3399 | final float ratio = (float) volume.getStorage().getNextAvailablePage() / (float) _bufferCount; |
3400 | if (ratio < SMALL_VOLUME_RATIO) { |
3401 | return invalidateSmallVolume(volume); |
3402 | @@ -612,7 +617,7 @@ |
3403 | boolean result = true; |
3404 | int markedAvailable = 0; |
3405 | for (long page = 1; page < volume.getStorage().getNextAvailablePage(); page++) { |
3406 | - int hashIndex = hashIndex(volume, page); |
3407 | + final int hashIndex = hashIndex(volume, page); |
3408 | _hashLocks[hashIndex % HASH_LOCKS].lock(); |
3409 | try { |
3410 | for (Buffer buffer = _hashTable[hashIndex]; buffer != null; buffer = buffer.getNext()) { |
3411 | @@ -630,9 +635,9 @@ |
3412 | buffer.release(); |
3413 | } |
3414 | if (invalidated) { |
3415 | - int q = buffer.getIndex() / 64; |
3416 | - int p = buffer.getIndex() % 64; |
3417 | - long bits = _availablePagesBits.get(q); |
3418 | + final int q = buffer.getIndex() / 64; |
3419 | + final int p = buffer.getIndex() % 64; |
3420 | + final long bits = _availablePagesBits.get(q); |
3421 | if (_availablePagesBits.compareAndSet(q, bits, bits | (1L << p))) { |
3422 | markedAvailable++; |
3423 | } |
3424 | @@ -657,7 +662,7 @@ |
3425 | boolean result = true; |
3426 | int markedAvailable = 0; |
3427 | for (int index = 0; index < _bufferCount; index++) { |
3428 | - Buffer buffer = _buffers[index]; |
3429 | + final Buffer buffer = _buffers[index]; |
3430 | if ((buffer.getVolume() == volume || volume == null) && !buffer.isFixed() && buffer.isValid()) { |
3431 | if (buffer.claim(true, 0)) { |
3432 | // re-check after claim |
3433 | @@ -671,9 +676,9 @@ |
3434 | buffer.release(); |
3435 | } |
3436 | if (invalidated) { |
3437 | - int q = buffer.getIndex() / 64; |
3438 | - int p = buffer.getIndex() % 64; |
3439 | - long bits = _availablePagesBits.get(q); |
3440 | + final int q = buffer.getIndex() / 64; |
3441 | + final int p = buffer.getIndex() % 64; |
3442 | + final long bits = _availablePagesBits.get(q); |
3443 | if (_availablePagesBits.compareAndSet(q, bits, bits | (1L << p))) { |
3444 | markedAvailable++; |
3445 | } |
3446 | @@ -689,29 +694,33 @@ |
3447 | return result; |
3448 | } |
3449 | |
3450 | - private void invalidate(Buffer buffer) { |
3451 | + private void invalidate(final Buffer buffer) { |
3452 | Debug.$assert0.t(buffer.isValid() && buffer.isMine()); |
3453 | |
3454 | while (!detach(buffer)) { |
3455 | // |
3456 | - // Spin until detach succeeds. Note: this method must not throw an Exception |
3457 | - // because it is called in at at critical time when cleanup must be done. |
3458 | - // It is not possible to lock the hash bucket here due to possible deadlock. |
3459 | - // However, the likelihood of a lengthy live-lock is infinitesimal so polling |
3460 | + // Spin until detach succeeds. Note: this method must not throw an |
3461 | + // Exception |
3462 | + // because it is called in at at critical time when cleanup must be |
3463 | + // done. |
3464 | + // It is not possible to lock the hash bucket here due to possible |
3465 | + // deadlock. |
3466 | + // However, the likelihood of a lengthy live-lock is infinitesimal |
3467 | + // so polling |
3468 | // is acceptable. |
3469 | // |
3470 | - try { |
3471 | - Thread.sleep(1); |
3472 | - } catch (InterruptedException ie) { |
3473 | - // ignore |
3474 | - } |
3475 | + try { |
3476 | + Thread.sleep(1); |
3477 | + } catch (final InterruptedException ie) { |
3478 | + // ignore |
3479 | + } |
3480 | } |
3481 | buffer.clearValid(); |
3482 | buffer.clearDirty(); |
3483 | buffer.setPageAddressAndVolume(0, null); |
3484 | } |
3485 | |
3486 | - private boolean detach(Buffer buffer) { |
3487 | + private boolean detach(final Buffer buffer) { |
3488 | final int hash = hashIndex(buffer.getVolume(), buffer.getPageAddress()); |
3489 | if (!_hashLocks[hash % HASH_LOCKS].tryLock()) { |
3490 | return false; |
3491 | @@ -756,8 +765,9 @@ |
3492 | * @return Buffer The Buffer describing the buffer containing the page. |
3493 | * @throws InUseException |
3494 | */ |
3495 | - Buffer get(Volume vol, long page, boolean writer, boolean wantRead) throws PersistitException { |
3496 | - int hash = hashIndex(vol, page); |
3497 | + Buffer get(final Volume vol, final long page, final boolean writer, final boolean wantRead) |
3498 | + throws PersistitException { |
3499 | + final int hash = hashIndex(vol, page); |
3500 | Buffer buffer = null; |
3501 | |
3502 | for (;;) { |
3503 | @@ -904,10 +914,10 @@ |
3504 | * @throws RetryException |
3505 | * @throws IOException |
3506 | */ |
3507 | - public Buffer getBufferCopy(Volume vol, long page) throws InvalidPageAddressException, |
3508 | + public Buffer getBufferCopy(final Volume vol, final long page) throws InvalidPageAddressException, |
3509 | InvalidPageStructureException, VolumeClosedException, InUseException, PersistitIOException, |
3510 | PersistitInterruptedException { |
3511 | - int hash = hashIndex(vol, page); |
3512 | + final int hash = hashIndex(vol, page); |
3513 | Buffer buffer = null; |
3514 | _hashLocks[hash % HASH_LOCKS].lock(); |
3515 | try { |
3516 | @@ -934,7 +944,7 @@ |
3517 | // Didn't find it in the pool, so we'll read a copy. |
3518 | // |
3519 | buffer = new Buffer(_bufferSize, -1, this, _persistit); |
3520 | - boolean acquired = buffer.claim(true); |
3521 | + final boolean acquired = buffer.claim(true); |
3522 | assert acquired : "buffer not unavailable"; |
3523 | buffer.load(vol, page); |
3524 | buffer.setValid(); |
3525 | @@ -968,7 +978,7 @@ |
3526 | // since no valid page will need to be evicted. |
3527 | // |
3528 | if (_availablePages.get()) { |
3529 | - int start = (_clock.get() / 64) * 64; |
3530 | + final int start = (_clock.get() / 64) * 64; |
3531 | for (int q = start;;) { |
3532 | q += 64; |
3533 | if (q >= _bufferCount) { |
3534 | @@ -1007,12 +1017,12 @@ |
3535 | // Look for a page to evict. |
3536 | // |
3537 | for (int retry = 0; retry < _bufferCount * 2;) { |
3538 | - int clock = _clock.get(); |
3539 | + final int clock = _clock.get(); |
3540 | assert clock < _bufferCount; |
3541 | if (!_clock.compareAndSet(clock, (clock + 1) % _bufferCount)) { |
3542 | continue; |
3543 | } |
3544 | - Buffer buffer = _buffers[clock]; |
3545 | + final Buffer buffer = _buffers[clock]; |
3546 | if (buffer.isTouched()) { |
3547 | buffer.clearTouched(); |
3548 | } else { |
3549 | @@ -1081,7 +1091,7 @@ |
3550 | |
3551 | void setFlushTimestamp(final long timestamp) { |
3552 | while (true) { |
3553 | - long current = _flushTimestamp.get(); |
3554 | + final long current = _flushTimestamp.get(); |
3555 | if (timestamp > current) { |
3556 | if (_flushTimestamp.compareAndSet(current, timestamp)) { |
3557 | break; |
3558 | @@ -1099,7 +1109,7 @@ |
3559 | * polling cycle |
3560 | */ |
3561 | boolean shouldWritePages() { |
3562 | - int cleanCount = _bufferCount - _dirtyPageCount.get(); |
3563 | + final int cleanCount = _bufferCount - _dirtyPageCount.get(); |
3564 | if (getEarliestDirtyTimestamp() < _flushTimestamp.get()) { |
3565 | return true; |
3566 | } |
3567 | @@ -1116,7 +1126,7 @@ |
3568 | } |
3569 | |
3570 | void writeDirtyBuffers(final int[] priorities, final BufferHolder[] selectedBuffers) throws PersistitException { |
3571 | - int count = selectDirtyBuffers(priorities, selectedBuffers); |
3572 | + final int count = selectDirtyBuffers(priorities, selectedBuffers); |
3573 | if (count > 0) { |
3574 | Arrays.sort(selectedBuffers, 0, count); |
3575 | for (int index = 0; index < count; index++) { |
3576 | @@ -1144,7 +1154,7 @@ |
3577 | final long currentTimestamp = _persistit.getCurrentTimestamp(); |
3578 | |
3579 | long earliestDirtyTimestamp = currentTimestamp; |
3580 | - long flushTimestamp = _flushTimestamp.get(); |
3581 | + final long flushTimestamp = _flushTimestamp.get(); |
3582 | |
3583 | boolean flushed = true; |
3584 | for (int index = clock; index < clock + _bufferCount; index++) { |
3585 | @@ -1202,8 +1212,9 @@ |
3586 | } |
3587 | return count; |
3588 | } |
3589 | - |
3590 | - int addSelectedBufferByPriority(final Buffer buffer, final int priority, final int[] priorities, final BufferHolder[] holders, final int initialCount) { |
3591 | + |
3592 | + int addSelectedBufferByPriority(final Buffer buffer, final int priority, final int[] priorities, |
3593 | + final BufferHolder[] holders, final int initialCount) { |
3594 | int count = initialCount; |
3595 | if (priority > 0) { |
3596 | if (count == 0 || priorities[count - 1] > priority) { |
3597 | @@ -1214,13 +1225,13 @@ |
3598 | } |
3599 | } else { |
3600 | count = Math.min(count, priorities.length - 1); |
3601 | - int where = count; |
3602 | + int where = count; |
3603 | while (where > 0 && priorities[where - 1] < priority) { |
3604 | where--; |
3605 | } |
3606 | - int move = count - where ; |
3607 | + final int move = count - where; |
3608 | if (move > 0) { |
3609 | - BufferHolder lastHolder = holders[count]; |
3610 | + final BufferHolder lastHolder = holders[count]; |
3611 | System.arraycopy(priorities, where, priorities, where + 1, move); |
3612 | System.arraycopy(holders, where, holders, where + 1, move); |
3613 | holders[where] = lastHolder; |
3614 | @@ -1240,8 +1251,8 @@ |
3615 | * |
3616 | * @return priority |
3617 | */ |
3618 | - int writePriority(final Buffer buffer, int clock, long checkpointTimestamp, final long currentTimestamp) { |
3619 | - int status = buffer.getStatus(); |
3620 | + int writePriority(final Buffer buffer, final int clock, final long checkpointTimestamp, final long currentTimestamp) { |
3621 | + final int status = buffer.getStatus(); |
3622 | if ((status & Buffer.VALID_MASK) == 0 || (status & Buffer.DIRTY_MASK) == 0) { |
3623 | // ineligible |
3624 | return 0; |
3625 | @@ -1336,7 +1347,7 @@ |
3626 | * address order. |
3627 | */ |
3628 | @Override |
3629 | - public int compareTo(BufferHolder buffer) { |
3630 | + public int compareTo(final BufferHolder buffer) { |
3631 | return _volumeId > buffer._volumeId ? 1 : _volumeId < buffer._volumeId ? -1 : _page > buffer._page ? 1 |
3632 | : _page < buffer._page ? -1 : 0; |
3633 | |
3634 | @@ -1367,7 +1378,7 @@ |
3635 | |
3636 | @Override |
3637 | public void runTask() throws PersistitException { |
3638 | - int size = _pageWriterTrancheSize; |
3639 | + final int size = _pageWriterTrancheSize; |
3640 | if (size != _priorities.length) { |
3641 | _priorities = new int[size]; |
3642 | _selectedBuffers = new BufferHolder[size]; |
3643 | @@ -1391,16 +1402,16 @@ |
3644 | return isFlushing() ? 0 : _writerPollInterval; |
3645 | } |
3646 | } |
3647 | - |
3648 | + |
3649 | /** |
3650 | * Implementation of PAGE_CACHER thread |
3651 | */ |
3652 | class PageCacher extends IOTaskRunnable { |
3653 | - |
3654 | + |
3655 | PageCacher() { |
3656 | super(BufferPool.this._persistit); |
3657 | } |
3658 | - |
3659 | + |
3660 | void start() { |
3661 | start("PAGE_CACHER:" + _bufferSize, _cacherPollInterval); |
3662 | } |
3663 | @@ -1409,12 +1420,12 @@ |
3664 | public void runTask() throws Exception { |
3665 | populateWarmupFile(); |
3666 | } |
3667 | - |
3668 | + |
3669 | @Override |
3670 | protected boolean shouldStop() { |
3671 | return _closed.get() && !isFlushing(); |
3672 | } |
3673 | - |
3674 | + |
3675 | @Override |
3676 | protected long pollInterval() { |
3677 | return isFlushing() ? 0 : _cacherPollInterval; |
3678 | @@ -1431,7 +1442,7 @@ |
3679 | * @param detail |
3680 | * @return toString value for buffer at index <code>i</code>. |
3681 | */ |
3682 | - String toString(int i, boolean detail) { |
3683 | + String toString(final int i, final boolean detail) { |
3684 | if (detail) { |
3685 | return _buffers[i].toStringDetail(); |
3686 | } else { |
3687 | |
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 | |
3693 | /** |
3694 | * MXBean that exposes information about a {@link BufferPool}. |
3695 | + * |
3696 | * @author peter |
3697 | - * |
3698 | + * |
3699 | */ |
3700 | class BufferPoolMXBeanImpl implements BufferPoolMXBean { |
3701 | |
3702 | @@ -47,16 +48,16 @@ |
3703 | } |
3704 | |
3705 | private BufferPoolInfo recent() { |
3706 | - long now = System.currentTimeMillis(); |
3707 | + final long now = System.currentTimeMillis(); |
3708 | if (_recent.getAcquisitionTime() < now - MAX_STALE) { |
3709 | try { |
3710 | - BufferPoolInfo[] array = _persistit.getManagement().getBufferPoolInfoArray(); |
3711 | - for (BufferPoolInfo info : array) { |
3712 | + final BufferPoolInfo[] array = _persistit.getManagement().getBufferPoolInfoArray(); |
3713 | + for (final BufferPoolInfo info : array) { |
3714 | if (info.getBufferSize() == _bufferSize) { |
3715 | _recent = info; |
3716 | } |
3717 | } |
3718 | - } catch (RemoteException e) { |
3719 | + } catch (final RemoteException e) { |
3720 | // TODO Auto-generated catch block |
3721 | e.printStackTrace(); |
3722 | } |
3723 | |
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 | public static void registerCommands(final Class<?> clazz) { |
3729 | for (final Method method : clazz.getDeclaredMethods()) { |
3730 | if (method.isAnnotationPresent(Cmd.class)) { |
3731 | - String name = method.getAnnotation(Cmd.class).value(); |
3732 | - Annotation[][] parameters = method.getParameterAnnotations(); |
3733 | - String[] argTemplate = new String[parameters.length]; |
3734 | + final String name = method.getAnnotation(Cmd.class).value(); |
3735 | + final Annotation[][] parameters = method.getParameterAnnotations(); |
3736 | + final String[] argTemplate = new String[parameters.length]; |
3737 | int index = 0; |
3738 | - for (Annotation[] annotations : parameters) { |
3739 | - Arg argAnnotation = (Arg) annotations[0]; |
3740 | + for (final Annotation[] annotations : parameters) { |
3741 | + final Arg argAnnotation = (Arg) annotations[0]; |
3742 | argTemplate[index++] = argAnnotation.value(); |
3743 | } |
3744 | COMMANDS.put(name, new Command(name, argTemplate, method)); |
3745 | @@ -228,7 +228,7 @@ |
3746 | int port = -1; |
3747 | String host = null; |
3748 | |
3749 | - String[] hostPieces = args[0].split(":"); |
3750 | + final String[] hostPieces = args[0].split(":"); |
3751 | switch (hostPieces.length) { |
3752 | case 1: |
3753 | port = Integer.parseInt(hostPieces[0]); |
3754 | @@ -275,7 +275,7 @@ |
3755 | */ |
3756 | public static void runScript(final Persistit persistit, final BufferedReader reader, final PrintWriter writer) |
3757 | throws Exception { |
3758 | - CLI cli = new CLI(persistit, reader, writer); |
3759 | + final CLI cli = new CLI(persistit, reader, writer); |
3760 | cli.commandLoop(); |
3761 | cli.close(false); |
3762 | writer.println(); |
3763 | @@ -307,7 +307,7 @@ |
3764 | |
3765 | boolean quoted = false; |
3766 | for (int index = 0; index < commandLine.length(); index++) { |
3767 | - char c = commandLine.charAt(index); |
3768 | + final char c = commandLine.charAt(index); |
3769 | if (index == 0 && !Character.isLetter(c)) { |
3770 | commandDelimiter = c; |
3771 | continue; |
3772 | @@ -342,17 +342,17 @@ |
3773 | } |
3774 | |
3775 | static Task parseTask(final Persistit persistit, final String line) throws Exception { |
3776 | - List<String> pieces = pieces(line); |
3777 | + final List<String> pieces = pieces(line); |
3778 | if (pieces.isEmpty()) { |
3779 | return null; |
3780 | } |
3781 | final String commandName = pieces.remove(0); |
3782 | - Command command = COMMANDS.get(commandName); |
3783 | + final Command command = COMMANDS.get(commandName); |
3784 | if (command == null) { |
3785 | return null; |
3786 | } |
3787 | - Task task = command.createTask(persistit, new ArgParser(commandName, pieces.toArray(new String[pieces.size()]), |
3788 | - command.argTemplate).strict()); |
3789 | + final Task task = command.createTask(persistit, |
3790 | + new ArgParser(commandName, pieces.toArray(new String[pieces.size()]), command.argTemplate).strict()); |
3791 | if (task != null) { |
3792 | task.setPersistit(persistit); |
3793 | } |
3794 | @@ -433,14 +433,14 @@ |
3795 | private final BufferedReader _reader; |
3796 | private final PrintWriter _writer; |
3797 | |
3798 | - private ScriptReader(final BufferedReader reader, PrintWriter writer) { |
3799 | + private ScriptReader(final BufferedReader reader, final PrintWriter writer) { |
3800 | _reader = reader; |
3801 | _writer = writer; |
3802 | } |
3803 | |
3804 | @Override |
3805 | public String readLine() throws IOException { |
3806 | - String line = _reader.readLine(); |
3807 | + final String line = _reader.readLine(); |
3808 | if (line != null) { |
3809 | _writer.println(); |
3810 | _writer.println(">> " + line); |
3811 | @@ -476,10 +476,10 @@ |
3812 | private String execute(final CLI cli, final ArgParser ap) throws Exception { |
3813 | final Object[] args = invocationArgs(ap); |
3814 | if (method.getReturnType() == String.class) { |
3815 | - String result = (String) method.invoke(cli, args); |
3816 | + final String result = (String) method.invoke(cli, args); |
3817 | return result; |
3818 | } else if (Task.class.isAssignableFrom(method.getReturnType())) { |
3819 | - Task task = (Task) method.invoke(cli, args); |
3820 | + final Task task = (Task) method.invoke(cli, args); |
3821 | task.setPersistit(cli._persistit); |
3822 | task.setMaximumTime(-1); |
3823 | task.setMessageWriter(cli._writer); |
3824 | @@ -493,9 +493,9 @@ |
3825 | |
3826 | private Task createTask(final Persistit persistit, final ArgParser ap) throws Exception { |
3827 | if (Task.class.isAssignableFrom(method.getReturnType())) { |
3828 | - CLI cli = persistit.getSessionCLI(); |
3829 | + final CLI cli = persistit.getSessionCLI(); |
3830 | final Object[] args = invocationArgs(ap); |
3831 | - Task task = (Task) method.invoke(cli, args); |
3832 | + final Task task = (Task) method.invoke(cli, args); |
3833 | return task; |
3834 | } else { |
3835 | return null; |
3836 | @@ -503,10 +503,10 @@ |
3837 | } |
3838 | |
3839 | private Object[] invocationArgs(final ArgParser ap) { |
3840 | - Class<?>[] types = method.getParameterTypes(); |
3841 | + final Class<?>[] types = method.getParameterTypes(); |
3842 | final Object[] args = new Object[types.length]; |
3843 | for (int index = 0; index < types.length; index++) { |
3844 | - Class<?> type = types[index]; |
3845 | + final Class<?> type = types[index]; |
3846 | if (String.class.equals(type)) { |
3847 | args[index] = ap.stringValue(index); |
3848 | } else if (int.class.equals(type)) { |
3849 | @@ -525,7 +525,7 @@ |
3850 | |
3851 | @Override |
3852 | public String toString() { |
3853 | - StringBuilder sb = new StringBuilder(name); |
3854 | + final StringBuilder sb = new StringBuilder(name); |
3855 | sb.append(Util.NEW_LINE); |
3856 | sb.append(new ArgParser(name, new String[0], argTemplate).strict()); |
3857 | return sb.toString(); |
3858 | @@ -540,7 +540,7 @@ |
3859 | |
3860 | private LineReader _lineReader; |
3861 | PrintWriter _writer = new PrintWriter(System.out); |
3862 | - private Stack<BufferedReader> _sourceStack = new Stack<BufferedReader>(); |
3863 | + private final Stack<BufferedReader> _sourceStack = new Stack<BufferedReader>(); |
3864 | private Persistit _persistit; |
3865 | private boolean _stop = false; |
3866 | private Volume _currentVolume; |
3867 | @@ -635,19 +635,19 @@ |
3868 | final String[] args = list.toArray(new String[list.size()]); |
3869 | final ArgParser ap = new ArgParser(commandName, args, command.argTemplate).strict(); |
3870 | if (!ap.isUsageOnly()) { |
3871 | - String result = command.execute(this, ap); |
3872 | + final String result = command.execute(this, ap); |
3873 | if (result != null) { |
3874 | _writer.println(result); |
3875 | } |
3876 | _lastStatus += " - done"; |
3877 | } |
3878 | - } catch (InvocationTargetException e) { |
3879 | + } catch (final InvocationTargetException e) { |
3880 | _lastStatus += e.getTargetException(); |
3881 | _writer.println(e.getTargetException()); |
3882 | - } catch (RuntimeException e) { |
3883 | + } catch (final RuntimeException e) { |
3884 | _lastStatus += e; |
3885 | e.printStackTrace(_writer); |
3886 | - } catch (Exception e) { |
3887 | + } catch (final Exception e) { |
3888 | _lastStatus += e; |
3889 | _writer.println(e); |
3890 | } |
3891 | @@ -680,28 +680,28 @@ |
3892 | * @throws Exception |
3893 | */ |
3894 | @Cmd("open") |
3895 | - String open(@Arg("datapath|string|Data path") String datapath, |
3896 | - @Arg("journalpath|string|Journal path") String journalpath, |
3897 | - @Arg("volumepath|string|Volume file") String volumepath, |
3898 | - @Arg("rmiport|int:1099:0:99999|RMI Management port") int rmiport, |
3899 | - @Arg("_flag|y|Recover committed transactions") boolean y) throws Exception { |
3900 | + String open(@Arg("datapath|string|Data path") final String datapath, |
3901 | + @Arg("journalpath|string|Journal path") final String journalpath, |
3902 | + @Arg("volumepath|string|Volume file") final String volumepath, |
3903 | + @Arg("rmiport|int:1099:0:99999|RMI Management port") final int rmiport, |
3904 | + @Arg("_flag|y|Recover committed transactions") final boolean y) throws Exception { |
3905 | |
3906 | if (_live) { |
3907 | return "Cannot open another Persistit instance within a live system"; |
3908 | } |
3909 | close(false); |
3910 | |
3911 | - String jpath = journalPath(filesOnPath(journalpath.isEmpty() ? datapath : journalpath)); |
3912 | - List<VolumeSpecification> volumeSpecifications = volumeSpecifications( |
3913 | + final String jpath = journalPath(filesOnPath(journalpath.isEmpty() ? datapath : journalpath)); |
3914 | + final List<VolumeSpecification> volumeSpecifications = volumeSpecifications( |
3915 | filesOnPath(volumepath.isEmpty() ? datapath : volumepath), Long.MAX_VALUE); |
3916 | - Set<Integer> bufferSizes = new HashSet<Integer>(); |
3917 | + final Set<Integer> bufferSizes = new HashSet<Integer>(); |
3918 | for (final VolumeSpecification vs : volumeSpecifications) { |
3919 | bufferSizes.add(vs.getPageSize()); |
3920 | } |
3921 | final Properties properties = new Properties(); |
3922 | - long bpoolMemory = availableMemory() / 2; |
3923 | + final long bpoolMemory = availableMemory() / 2; |
3924 | for (final Integer size : bufferSizes) { |
3925 | - int alloc = (int) (size * 1.25); |
3926 | + final int alloc = (int) (size * 1.25); |
3927 | final int count = (int) ((bpoolMemory / bufferSizes.size()) / alloc); |
3928 | properties.put(Persistit.BUFFERS_PROPERTY_NAME + size, Integer.toString(count)); |
3929 | } |
3930 | @@ -755,7 +755,7 @@ |
3931 | } |
3932 | |
3933 | @Cmd("close") |
3934 | - String close(@Arg("_flag|f|Flush modifications to disk") boolean flush) throws Exception { |
3935 | + String close(@Arg("_flag|f|Flush modifications to disk") final boolean flush) throws Exception { |
3936 | if (_persistit != null) { |
3937 | try { |
3938 | if (_live) { |
3939 | @@ -764,7 +764,7 @@ |
3940 | _persistit.shutdownGUI(); |
3941 | _persistit.close(flush); |
3942 | } |
3943 | - } catch (Exception e) { |
3944 | + } catch (final Exception e) { |
3945 | return e.toString(); |
3946 | } finally { |
3947 | _persistit = null; |
3948 | @@ -832,6 +832,7 @@ |
3949 | public void runTask() throws Exception { |
3950 | final JournalTool jt = new JournalTool(_persistit); |
3951 | jt.setAction(jt.new SimpleDumpAction() { |
3952 | + @Override |
3953 | protected void write(final String msg) { |
3954 | postMessage(msg, LOG_NORMAL); |
3955 | } |
3956 | @@ -923,7 +924,7 @@ |
3957 | return; |
3958 | } |
3959 | |
3960 | - List<Object> selected = new ArrayList<Object>(); |
3961 | + final List<Object> selected = new ArrayList<Object>(); |
3962 | final TreeSelector selector = TreeSelector.parseSelector(tstring, r, '\\'); |
3963 | |
3964 | for (final Volume volume : _persistit.getVolumes()) { |
3965 | @@ -988,10 +989,10 @@ |
3966 | if (!keyString.isEmpty()) { |
3967 | new KeyParser(keyString).parseKey(exchange.getKey()); |
3968 | } |
3969 | - StringBuilder sb = new StringBuilder(); |
3970 | - int depth = _currentTree.getDepth(); |
3971 | + final StringBuilder sb = new StringBuilder(); |
3972 | + final int depth = _currentTree.getDepth(); |
3973 | for (int level = depth; --level >= 0;) { |
3974 | - Buffer copy = exchange.fetchBufferCopy(level); |
3975 | + final Buffer copy = exchange.fetchBufferCopy(level); |
3976 | if (sb.length() > 0) { |
3977 | sb.append(Util.NEW_LINE); |
3978 | } |
3979 | @@ -1051,7 +1052,7 @@ |
3980 | return; |
3981 | } |
3982 | if (index >= 0) { |
3983 | - BufferPool pool = _persistit.getBufferPool(pageSize); |
3984 | + final BufferPool pool = _persistit.getBufferPool(pageSize); |
3985 | buffer = pool.getBufferCopy(index); |
3986 | } else if (journalAddress >= 0) { |
3987 | buffer = _persistit.getJournalManager().readPageBuffer(journalAddress); |
3988 | @@ -1088,12 +1089,13 @@ |
3989 | } |
3990 | } |
3991 | |
3992 | + @Override |
3993 | public String getStatus() { |
3994 | return ""; |
3995 | } |
3996 | }; |
3997 | } |
3998 | - |
3999 | + |
4000 | @Cmd("pviewchain") |
4001 | Task pviewchain(final @Arg("page|long:0:0:99999999999999999|Starting page address") long pageAddress, |
4002 | final @Arg("find|long:-1:0:99999999999999999|Optional page pointer to find") long findPointer, |
4003 | @@ -1102,7 +1104,7 @@ |
4004 | final @Arg("maxvalue|int:42:4:100000|Maximum displayed value length") int maxvalue, |
4005 | final @Arg("context|int:3:0:100000|Context lines") int context, |
4006 | final @Arg("_flag|a|All lines") boolean allLines, final @Arg("_flag|s|Summary only") boolean summary) { |
4007 | - |
4008 | + |
4009 | return new Task() { |
4010 | |
4011 | @Override |
4012 | @@ -1121,15 +1123,15 @@ |
4013 | postMessage(buffer.toStringDetail(findPointer, maxkey, maxvalue, context, allLines), LOG_NORMAL); |
4014 | } |
4015 | currentPage = buffer.getRightSibling(); |
4016 | - } |
4017 | + } |
4018 | } |
4019 | |
4020 | @Override |
4021 | public String getStatus() { |
4022 | return ""; |
4023 | } |
4024 | - |
4025 | - }; |
4026 | + |
4027 | + }; |
4028 | } |
4029 | |
4030 | @Cmd("jquery") |
4031 | @@ -1140,6 +1142,7 @@ |
4032 | final @Arg("_flag|V|Show volume handle map") boolean showTreeMap, |
4033 | final @Arg("_flag|T|Show tree handle map") boolean showVolumeMap) { |
4034 | return new Task() { |
4035 | + @Override |
4036 | public void runTask() throws Exception { |
4037 | if (!showVolumeMap && !showTreeMap && pageAddress == -1 && ts == -1) { |
4038 | postMessage("No items requested", LOG_NORMAL); |
4039 | @@ -1147,20 +1150,20 @@ |
4040 | } |
4041 | if (showVolumeMap) { |
4042 | postMessage("Volume Handle Map", LOG_NORMAL); |
4043 | - Map<Integer, Volume> map = _persistit.getJournalManager().queryVolumeMap(); |
4044 | + final Map<Integer, Volume> map = _persistit.getJournalManager().queryVolumeMap(); |
4045 | for (final Map.Entry<Integer, Volume> entry : map.entrySet()) { |
4046 | postMessage(String.format("%,5d -> %s", entry.getKey(), entry.getValue()), LOG_NORMAL); |
4047 | } |
4048 | } |
4049 | if (showVolumeMap) { |
4050 | postMessage("Tree Handle Map", LOG_NORMAL); |
4051 | - Map<Integer, TreeDescriptor> map = _persistit.getJournalManager().queryTreeMap(); |
4052 | + final Map<Integer, TreeDescriptor> map = _persistit.getJournalManager().queryTreeMap(); |
4053 | for (final Map.Entry<Integer, TreeDescriptor> entry : map.entrySet()) { |
4054 | postMessage(String.format("%,5d -> %s", entry.getKey(), entry.getValue()), LOG_NORMAL); |
4055 | } |
4056 | } |
4057 | if (ts != -1) { |
4058 | - TransactionMapItem item = _persistit.getJournalManager().queryTransactionMap(ts); |
4059 | + final TransactionMapItem item = _persistit.getJournalManager().queryTransactionMap(ts); |
4060 | postMessage(String.format("TransactionMapItem for ts=%,d -> %s", ts, item), LOG_NORMAL); |
4061 | } |
4062 | if (pageAddress != -1) { |
4063 | @@ -1168,7 +1171,7 @@ |
4064 | if (volumeHandle != -1) { |
4065 | queryPageNode(volumeHandle, pageAddress, verbose); |
4066 | } else { |
4067 | - Map<Integer, Volume> volumeMap = _persistit.getJournalManager().queryVolumeMap(); |
4068 | + final Map<Integer, Volume> volumeMap = _persistit.getJournalManager().queryVolumeMap(); |
4069 | for (final int handle : volumeMap.keySet()) { |
4070 | queryPageNode(handle, pageAddress, verbose); |
4071 | } |
4072 | @@ -1202,6 +1205,7 @@ |
4073 | final @Arg("_flag|v|Verbose") boolean verbose) throws Exception { |
4074 | |
4075 | return new Task() { |
4076 | + @Override |
4077 | public void runTask() throws Exception { |
4078 | final File target = new File(file); |
4079 | if (target.exists() && !ovewrite) { |
4080 | @@ -1255,12 +1259,12 @@ |
4081 | zos.closeEntry(); |
4082 | bb.clear(); |
4083 | |
4084 | - PrintWriter writer = new PrintWriter(zos); |
4085 | + final PrintWriter writer = new PrintWriter(zos); |
4086 | ze = new ZipEntry(basePath + ".txt"); |
4087 | ze.setSize(Integer.MAX_VALUE); |
4088 | ze.setTime(baseTime); |
4089 | zos.putNextEntry(ze); |
4090 | - List<Volume> volumes = _persistit.getVolumes(); |
4091 | + final List<Volume> volumes = _persistit.getVolumes(); |
4092 | |
4093 | writer.printf("@volumes=%d\n", volumes.size()); |
4094 | for (final Volume volume : volumes) { |
4095 | @@ -1314,7 +1318,7 @@ |
4096 | |
4097 | @Cmd("cliserver") |
4098 | static Task cliserver(final @Arg("port|int:9999:1024:99999999") int port) throws Exception { |
4099 | - Task task = new Task() { |
4100 | + final Task task = new Task() { |
4101 | CLI _cli; |
4102 | |
4103 | @Override |
4104 | @@ -1325,9 +1329,9 @@ |
4105 | |
4106 | @Override |
4107 | public String getStatus() { |
4108 | - CLI cli = _cli; |
4109 | + final CLI cli = _cli; |
4110 | if (cli != null) { |
4111 | - String status = cli._lastStatus; |
4112 | + final String status = cli._lastStatus; |
4113 | if (status != null) { |
4114 | return status; |
4115 | } |
4116 | @@ -1339,12 +1343,12 @@ |
4117 | return task; |
4118 | } |
4119 | |
4120 | - private static String journalPath(List<String> files) { |
4121 | + private static String journalPath(final List<String> files) { |
4122 | String journalPath = null; |
4123 | for (final String file : files) { |
4124 | - Matcher matcher = JournalManager.PATH_PATTERN.matcher(file); |
4125 | + final Matcher matcher = JournalManager.PATH_PATTERN.matcher(file); |
4126 | if (matcher.matches()) { |
4127 | - String path = matcher.group(1); |
4128 | + final String path = matcher.group(1); |
4129 | if (journalPath == null) { |
4130 | journalPath = path; |
4131 | } else if (!journalPath.equals(path)) { |
4132 | @@ -1355,7 +1359,7 @@ |
4133 | return journalPath; |
4134 | } |
4135 | |
4136 | - private static List<VolumeSpecification> volumeSpecifications(List<String> files, long systemTimestamp) { |
4137 | + private static List<VolumeSpecification> volumeSpecifications(final List<String> files, final long systemTimestamp) { |
4138 | final List<VolumeSpecification> list = new ArrayList<VolumeSpecification>(); |
4139 | for (final String path : files) { |
4140 | if (JournalManager.PATH_PATTERN.matcher(path).matches()) { |
4141 | @@ -1366,7 +1370,7 @@ |
4142 | if (VolumeHeader.verifyVolumeHeader(specification, systemTimestamp)) { |
4143 | list.add(specification); |
4144 | } |
4145 | - } catch (PersistitException e) { |
4146 | + } catch (final PersistitException e) { |
4147 | // ignore this file |
4148 | } |
4149 | } |
4150 | |
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 | private final long _systemTime; |
4156 | |
4157 | private volatile boolean _completed = false; |
4158 | - |
4159 | + |
4160 | Checkpoint(final long timestamp, final long systemTime) { |
4161 | _timestamp = timestamp; |
4162 | _systemTime = systemTime; |
4163 | @@ -72,8 +72,8 @@ |
4164 | |
4165 | @Override |
4166 | public String toString() { |
4167 | - return String.format("Checkpoint %,d%s @ %s", _timestamp, isCompleted() ? "c" : "u", SDF.format(new Date( |
4168 | - _systemTime))); |
4169 | + return String.format("Checkpoint %,d%s @ %s", _timestamp, isCompleted() ? "c" : "u", |
4170 | + SDF.format(new Date(_systemTime))); |
4171 | } |
4172 | |
4173 | @Override |
4174 | @@ -81,7 +81,7 @@ |
4175 | if (!(object instanceof Checkpoint)) { |
4176 | return false; |
4177 | } |
4178 | - Checkpoint cp = (Checkpoint) object; |
4179 | + final Checkpoint cp = (Checkpoint) object; |
4180 | return cp._systemTime == _systemTime && cp._timestamp == _timestamp; |
4181 | } |
4182 | } |
4183 | @@ -92,9 +92,9 @@ |
4184 | * Default interval in nanoseconds between checkpoints - two minutes. |
4185 | */ |
4186 | private final static long DEFAULT_CHECKPOINT_INTERVAL = 120; |
4187 | - |
4188 | + |
4189 | private final static long MINIMUM_CHECKPOINT_INTERVAL = 10; |
4190 | - |
4191 | + |
4192 | private final static long MAXIMUM_CHECKPOINT_INTERVAL = 1800; |
4193 | |
4194 | private final static Checkpoint UNAVALABLE_CHECKPOINT = new Checkpoint(0, 0); |
4195 | @@ -110,13 +110,12 @@ |
4196 | private final static long FLUSH_CHECKPOINT_INTERVAL = 5000; |
4197 | |
4198 | private volatile Checkpoint _currentCheckpoint = new Checkpoint(0, 0, true); |
4199 | - |
4200 | - private List<Checkpoint> _outstandingCheckpoints = new ArrayList<Checkpoint>(); |
4201 | - |
4202 | - |
4203 | - private AtomicBoolean _closed = new AtomicBoolean(); |
4204 | - |
4205 | - private AtomicBoolean _fastClose = new AtomicBoolean(); |
4206 | + |
4207 | + private final List<Checkpoint> _outstandingCheckpoints = new ArrayList<Checkpoint>(); |
4208 | + |
4209 | + private final AtomicBoolean _closed = new AtomicBoolean(); |
4210 | + |
4211 | + private final AtomicBoolean _fastClose = new AtomicBoolean(); |
4212 | |
4213 | CheckpointManager(final Persistit persistit) { |
4214 | super(persistit); |
4215 | @@ -139,12 +138,12 @@ |
4216 | Checkpoint getCurrentCheckpoint() { |
4217 | return _currentCheckpoint; |
4218 | } |
4219 | - |
4220 | + |
4221 | long getCheckpointIntervalNanos() { |
4222 | return _checkpointIntervalNanos; |
4223 | } |
4224 | |
4225 | - void setCheckpointIntervalNanos(long interval) { |
4226 | + void setCheckpointIntervalNanos(final long interval) { |
4227 | _checkpointIntervalNanos = interval; |
4228 | } |
4229 | |
4230 | @@ -159,19 +158,19 @@ |
4231 | } |
4232 | |
4233 | @Override |
4234 | - public void setCheckpointInterval(long interval) { |
4235 | + public void setCheckpointInterval(final long interval) { |
4236 | Util.rangeCheck(interval, MINIMUM_CHECKPOINT_INTERVAL, MAXIMUM_CHECKPOINT_INTERVAL); |
4237 | _checkpointIntervalNanos = interval * NS_PER_S; |
4238 | } |
4239 | - |
4240 | + |
4241 | @Override |
4242 | - public synchronized int getOutstandingCheckpointCount() { |
4243 | + public synchronized int getOutstandingCheckpointCount() { |
4244 | return _outstandingCheckpoints.size(); |
4245 | } |
4246 | - |
4247 | + |
4248 | @Override |
4249 | public synchronized String outstandingCheckpointReport() { |
4250 | - StringBuilder sb = new StringBuilder(); |
4251 | + final StringBuilder sb = new StringBuilder(); |
4252 | for (final Checkpoint cp : _outstandingCheckpoints) { |
4253 | sb.append(cp); |
4254 | sb.append(Util.NEW_LINE); |
4255 | @@ -180,7 +179,7 @@ |
4256 | } |
4257 | |
4258 | Checkpoint checkpoint() throws PersistitException { |
4259 | - Checkpoint checkpoint = createCheckpoint(); |
4260 | + final Checkpoint checkpoint = createCheckpoint(); |
4261 | _persistit.flushBuffers(checkpoint.getTimestamp()); |
4262 | |
4263 | while (true) { |
4264 | @@ -239,14 +238,14 @@ |
4265 | final SessionId saveSessionId = _persistit.getSessionId(); |
4266 | try { |
4267 | _persistit.setSessionId(_checkpointTxnSessionId); |
4268 | - Transaction txn = _persistit.getTransaction(); |
4269 | + final Transaction txn = _persistit.getTransaction(); |
4270 | |
4271 | _lastCheckpointNanos = System.nanoTime(); |
4272 | |
4273 | txn.beginCheckpoint(); |
4274 | try { |
4275 | _persistit.flushTransactions(txn.getStartTimestamp()); |
4276 | - List<Accumulator> accumulators = _persistit.getCheckpointAccumulators(); |
4277 | + final List<Accumulator> accumulators = _persistit.getCheckpointAccumulators(); |
4278 | _persistit.getTransactionIndex().checkpointAccumulatorSnapshots(txn.getStartTimestamp(), accumulators); |
4279 | Accumulator.saveAccumulatorCheckpointValues(accumulators); |
4280 | txn.commit(CommitPolicy.HARD); |
4281 | @@ -254,7 +253,7 @@ |
4282 | _outstandingCheckpoints.add(_currentCheckpoint); |
4283 | _persistit.getLogBase().checkpointProposed.log(_currentCheckpoint); |
4284 | return _currentCheckpoint; |
4285 | - } catch (InterruptedException ie) { |
4286 | + } catch (final InterruptedException ie) { |
4287 | throw new PersistitInterruptedException(ie); |
4288 | } finally { |
4289 | txn.end(); |
4290 | @@ -272,9 +271,9 @@ |
4291 | void pollFlushCheckpoint() { |
4292 | final long earliestDirtyTimestamp = _persistit.earliestDirtyTimestamp(); |
4293 | Checkpoint checkpoint = null; |
4294 | - synchronized(this) { |
4295 | + synchronized (this) { |
4296 | while (!_outstandingCheckpoints.isEmpty()) { |
4297 | - Checkpoint cp = _outstandingCheckpoints.get(0); |
4298 | + final Checkpoint cp = _outstandingCheckpoints.get(0); |
4299 | if (cp.getTimestamp() <= earliestDirtyTimestamp) { |
4300 | checkpoint = cp; |
4301 | _outstandingCheckpoints.remove(0); |
4302 | @@ -286,7 +285,7 @@ |
4303 | if (checkpoint != null) { |
4304 | try { |
4305 | _persistit.getJournalManager().writeCheckpointToJournal(checkpoint); |
4306 | - } catch (PersistitException e) { |
4307 | + } catch (final PersistitException e) { |
4308 | _persistit.getLogBase().exception.log(e); |
4309 | } |
4310 | } |
4311 | |
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 | INITIAL_CAPACITY); |
4317 | |
4318 | private int _testIdFloor = Integer.MIN_VALUE; |
4319 | - private AtomicInteger _cacheMisses = new AtomicInteger(); |
4320 | - private AtomicInteger _discardedDuplicates = new AtomicInteger(); |
4321 | + private final AtomicInteger _cacheMisses = new AtomicInteger(); |
4322 | + private final AtomicInteger _discardedDuplicates = new AtomicInteger(); |
4323 | |
4324 | /** |
4325 | * A structure holding a ClassInfo, plus links to other related |
4326 | @@ -82,7 +82,7 @@ |
4327 | final ClassInfoEntry _next; |
4328 | final ClassInfo _classInfo; |
4329 | |
4330 | - ClassInfoEntry(ClassInfo ci, ClassInfoEntry next) { |
4331 | + ClassInfoEntry(final ClassInfo ci, final ClassInfoEntry next) { |
4332 | _classInfo = ci; |
4333 | _next = next; |
4334 | } |
4335 | @@ -95,7 +95,7 @@ |
4336 | * @param persistit |
4337 | * Owning Persistit instance. |
4338 | */ |
4339 | - ClassIndex(Persistit persistit) { |
4340 | + ClassIndex(final Persistit persistit) { |
4341 | _persistit = persistit; |
4342 | } |
4343 | |
4344 | @@ -117,8 +117,8 @@ |
4345 | * The handle |
4346 | * @return The associated ClassInfo, or <i>null</i> if there is none. |
4347 | */ |
4348 | - public ClassInfo lookupByHandle(int handle) { |
4349 | - AtomicReferenceArray<ClassInfoEntry> hashTable = _hashTable; |
4350 | + public ClassInfo lookupByHandle(final int handle) { |
4351 | + final AtomicReferenceArray<ClassInfoEntry> hashTable = _hashTable; |
4352 | ClassInfoEntry cie = hashTable.get(handle % hashTable.length()); |
4353 | while (cie != null) { |
4354 | if (cie._classInfo.getHandle() == handle) |
4355 | @@ -138,43 +138,44 @@ |
4356 | try { |
4357 | ex.clear().append(BY_HANDLE).append(handle).fetch(); |
4358 | txn.commit(); |
4359 | - } catch (Exception e) { |
4360 | + } catch (final Exception e) { |
4361 | _persistit.getLogBase().exception.log(e); |
4362 | throw new ConversionException(e); |
4363 | } finally { |
4364 | txn.end(); |
4365 | } |
4366 | - Value value = ex.getValue(); |
4367 | + final Value value = ex.getValue(); |
4368 | if (value.isDefined()) { |
4369 | value.setStreamMode(true); |
4370 | - int storedId = value.getInt(); |
4371 | - String storedName = value.getString(); |
4372 | - long storedSuid = value.getLong(); |
4373 | + final int storedId = value.getInt(); |
4374 | + final String storedName = value.getString(); |
4375 | + final long storedSuid = value.getLong(); |
4376 | if (storedId != handle) { |
4377 | throw new IllegalStateException("ClassInfo stored for handle=" + handle |
4378 | + " has invalid stored handle=" + storedId); |
4379 | } |
4380 | - Class<?> cl = Class.forName(storedName, false, Thread.currentThread().getContextClassLoader()); |
4381 | + final Class<?> cl = Class |
4382 | + .forName(storedName, false, Thread.currentThread().getContextClassLoader()); |
4383 | |
4384 | long suid = 0; |
4385 | - ObjectStreamClass osc = ObjectStreamClass.lookupAny(cl); |
4386 | + final ObjectStreamClass osc = ObjectStreamClass.lookupAny(cl); |
4387 | if (osc != null) |
4388 | suid = osc.getSerialVersionUID(); |
4389 | if (storedSuid != suid) { |
4390 | throw new ConversionException("Class " + cl.getName() + " persistent SUID=" + storedSuid |
4391 | + " does not match current class SUID=" + suid); |
4392 | } |
4393 | - ClassInfo ci = new ClassInfo(cl, suid, handle, osc); |
4394 | + final ClassInfo ci = new ClassInfo(cl, suid, handle, osc); |
4395 | hashClassInfo(ci); |
4396 | return ci; |
4397 | } else { |
4398 | - ClassInfo ci = new ClassInfo(null, 0, handle, null); |
4399 | + final ClassInfo ci = new ClassInfo(null, 0, handle, null); |
4400 | hashClassInfo(ci); |
4401 | return ci; |
4402 | } |
4403 | - } catch (ClassNotFoundException cnfe) { |
4404 | + } catch (final ClassNotFoundException cnfe) { |
4405 | throw new ConversionException(cnfe); |
4406 | - } catch (PersistitException pe) { |
4407 | + } catch (final PersistitException pe) { |
4408 | throw new ConversionException(pe); |
4409 | } finally { |
4410 | if (ex != null) |
4411 | @@ -191,13 +192,13 @@ |
4412 | * The <code>Class</code> |
4413 | * @return The ClassInfo for the specified Class. |
4414 | */ |
4415 | - public ClassInfo lookupByClass(Class<?> clazz) { |
4416 | - AtomicReferenceArray<ClassInfoEntry> hashTable = _hashTable; |
4417 | + public ClassInfo lookupByClass(final Class<?> clazz) { |
4418 | + final AtomicReferenceArray<ClassInfoEntry> hashTable = _hashTable; |
4419 | |
4420 | ObjectStreamClass osc = null; |
4421 | long suid = 0; |
4422 | |
4423 | - int nh = clazz.getName().hashCode() & 0x7FFFFFFF; |
4424 | + final int nh = clazz.getName().hashCode() & 0x7FFFFFFF; |
4425 | ClassInfoEntry cie = hashTable.get(nh % hashTable.length()); |
4426 | |
4427 | while (cie != null) { |
4428 | @@ -260,14 +261,14 @@ |
4429 | final int handle; |
4430 | txn.begin(); |
4431 | ex.clear().append(BY_NAME).append(clazz.getName()).append(suid).fetch(); |
4432 | - Value value = ex.getValue(); |
4433 | + final Value value = ex.getValue(); |
4434 | try { |
4435 | if (value.isDefined()) { |
4436 | value.setStreamMode(true); |
4437 | |
4438 | handle = value.getInt(); |
4439 | - String storedName = value.getString(); |
4440 | - long storedSuid = value.getLong(); |
4441 | + final String storedName = value.getString(); |
4442 | + final long storedSuid = value.getLong(); |
4443 | |
4444 | if (storedSuid != suid || !clazz.getName().equals(storedName)) { |
4445 | throw new ConversionException("Class " + clazz.getName() + " persistent SUID=" + storedSuid |
4446 | @@ -301,7 +302,7 @@ |
4447 | } finally { |
4448 | txn.end(); |
4449 | } |
4450 | - } catch (PersistitException pe) { |
4451 | + } catch (final PersistitException pe) { |
4452 | throw new ConversionException(pe); |
4453 | } finally { |
4454 | if (ex != null) { |
4455 | @@ -322,16 +323,16 @@ |
4456 | * @param clazz |
4457 | * Class instance to register. |
4458 | */ |
4459 | - public void registerClass(Class<?> clazz) { |
4460 | + public void registerClass(final Class<?> clazz) { |
4461 | lookupByClass(clazz); |
4462 | } |
4463 | |
4464 | - private void hashClassInfo(ClassInfo ci) { |
4465 | - int size = _size.get(); |
4466 | + private void hashClassInfo(final ClassInfo ci) { |
4467 | + final int size = _size.get(); |
4468 | if (size * EXTRA_FACTOR > _hashTable.length()) { |
4469 | - int discarded = _discardedDuplicates.get(); |
4470 | - AtomicReferenceArray<ClassInfoEntry> newHashTable = new AtomicReferenceArray<ClassInfoEntry>(EXTRA_FACTOR |
4471 | - * 2 * size); |
4472 | + final int discarded = _discardedDuplicates.get(); |
4473 | + final AtomicReferenceArray<ClassInfoEntry> newHashTable = new AtomicReferenceArray<ClassInfoEntry>( |
4474 | + EXTRA_FACTOR * 2 * size); |
4475 | for (int i = 0; i < _hashTable.length(); i++) { |
4476 | ClassInfoEntry cie = _hashTable.get(i); |
4477 | while (cie != null) { |
4478 | @@ -345,7 +346,7 @@ |
4479 | addHashEntry(_hashTable, ci); |
4480 | } |
4481 | |
4482 | - private void addHashEntry(final AtomicReferenceArray<ClassInfoEntry> hashTable, ClassInfo ci) { |
4483 | + private void addHashEntry(final AtomicReferenceArray<ClassInfoEntry> hashTable, final ClassInfo ci) { |
4484 | final int hh = ci.getHandle() % hashTable.length(); |
4485 | final int nh = ci.getDescribedClass() == null ? -1 |
4486 | : ((ci.getDescribedClass().getName().hashCode() & 0x7FFFFFFF) % hashTable.length()); |
4487 | @@ -358,7 +359,8 @@ |
4488 | } |
4489 | } |
4490 | |
4491 | - private boolean addHashEntry(final AtomicReferenceArray<ClassInfoEntry> hashTable, ClassInfo ci, final int hash) { |
4492 | + private boolean addHashEntry(final AtomicReferenceArray<ClassInfoEntry> hashTable, final ClassInfo ci, |
4493 | + final int hash) { |
4494 | ClassInfoEntry cie = hashTable.get(hash); |
4495 | while (cie != null) { |
4496 | if (ci.equals(cie._classInfo)) { |
4497 | @@ -367,7 +369,7 @@ |
4498 | cie = cie._next; |
4499 | } |
4500 | cie = hashTable.get(hash); |
4501 | - ClassInfoEntry newCie = new ClassInfoEntry(ci, cie); |
4502 | + final ClassInfoEntry newCie = new ClassInfoEntry(ci, cie); |
4503 | hashTable.set(hash, newCie); |
4504 | _size.incrementAndGet(); |
4505 | return true; |
4506 | @@ -375,14 +377,14 @@ |
4507 | |
4508 | private Exchange getExchange() throws PersistitException { |
4509 | try { |
4510 | - Volume volume = _persistit.getSystemVolume(); |
4511 | + final Volume volume = _persistit.getSystemVolume(); |
4512 | return _persistit.getExchange(volume, CLASS_INDEX_TREE_NAME, true); |
4513 | - } catch (PersistitException pe) { |
4514 | + } catch (final PersistitException pe) { |
4515 | throw new ConversionException(pe); |
4516 | } |
4517 | } |
4518 | |
4519 | - private void releaseExchange(Exchange ex) { |
4520 | + private void releaseExchange(final Exchange ex) { |
4521 | _persistit.releaseExchange(ex); |
4522 | } |
4523 | |
4524 | |
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 | */ |
4530 | |
4531 | class ClassInfo { |
4532 | - private Class<?> _class; |
4533 | - private long _suid; |
4534 | - private int _handle; |
4535 | - private ObjectStreamClass _osc; |
4536 | + private final Class<?> _class; |
4537 | + private final long _suid; |
4538 | + private final int _handle; |
4539 | + private final ObjectStreamClass _osc; |
4540 | |
4541 | - ClassInfo(Class<?> cl, long suid, int handle, ObjectStreamClass osc) { |
4542 | + ClassInfo(final Class<?> cl, final long suid, final int handle, final ObjectStreamClass osc) { |
4543 | _class = cl; |
4544 | _suid = suid; |
4545 | _handle = handle; |
4546 | _osc = osc; |
4547 | } |
4548 | |
4549 | + @Override |
4550 | public boolean equals(final Object object) { |
4551 | if (object instanceof ClassInfo) { |
4552 | - ClassInfo ci = (ClassInfo) object; |
4553 | + final ClassInfo ci = (ClassInfo) object; |
4554 | if (equals(_class, ci._class) && _handle == ci._handle && _suid == ci._suid) { |
4555 | return true; |
4556 | } |
4557 | @@ -46,6 +47,7 @@ |
4558 | return false; |
4559 | } |
4560 | |
4561 | + @Override |
4562 | public int hashCode() { |
4563 | return _class.hashCode() ^ _handle ^ (int) _suid; |
4564 | } |
4565 | @@ -86,9 +88,8 @@ |
4566 | public ObjectStreamClass getClassDescriptor() { |
4567 | return _osc; |
4568 | } |
4569 | - |
4570 | - private boolean equals(Class<?> a, Class<?> b) { |
4571 | + |
4572 | + private boolean equals(final Class<?> a, final Class<?> b) { |
4573 | return a == null ? b == null : a.equals(b); |
4574 | } |
4575 | } |
4576 | - |
4577 | |
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 | |
4583 | final Queue<CleanupAction> _cleanupActionQueue = new ArrayBlockingQueue<CleanupAction>(DEFAULT_QUEUE_SIZE); |
4584 | |
4585 | - private AtomicBoolean _closed = new AtomicBoolean(); |
4586 | - |
4587 | - private AtomicLong _accepted = new AtomicLong(); |
4588 | - |
4589 | - private AtomicLong _refused = new AtomicLong(); |
4590 | - |
4591 | - private AtomicLong _performed = new AtomicLong(); |
4592 | - |
4593 | - private AtomicLong _errors = new AtomicLong(); |
4594 | - |
4595 | - private AtomicLong _minimumPruningDelay = new AtomicLong(DEFAULT_MINIMUM_PRUNING_DELAY); |
4596 | + private final AtomicBoolean _closed = new AtomicBoolean(); |
4597 | + |
4598 | + private final AtomicLong _accepted = new AtomicLong(); |
4599 | + |
4600 | + private final AtomicLong _refused = new AtomicLong(); |
4601 | + |
4602 | + private final AtomicLong _performed = new AtomicLong(); |
4603 | + |
4604 | + private final AtomicLong _errors = new AtomicLong(); |
4605 | + |
4606 | + private final AtomicLong _minimumPruningDelay = new AtomicLong(DEFAULT_MINIMUM_PRUNING_DELAY); |
4607 | |
4608 | CleanupManager(final Persistit persistit) { |
4609 | super(persistit); |
4610 | @@ -81,8 +81,8 @@ |
4611 | return _closed.get(); |
4612 | } |
4613 | |
4614 | - synchronized boolean offer(CleanupAction action) { |
4615 | - boolean accepted = _cleanupActionQueue.offer(action); |
4616 | + synchronized boolean offer(final CleanupAction action) { |
4617 | + final boolean accepted = _cleanupActionQueue.offer(action); |
4618 | if (accepted) { |
4619 | _accepted.incrementAndGet(); |
4620 | } else { |
4621 | @@ -148,9 +148,10 @@ |
4622 | try { |
4623 | action.performAction(_persistit); |
4624 | _performed.incrementAndGet(); |
4625 | - } catch (PersistitException e) { |
4626 | + } catch (final PersistitException e) { |
4627 | lastException(e); |
4628 | - _persistit.getAlertMonitor().post(new Event(AlertLevel.ERROR, _persistit.getLogBase().cleanupException, e, action), |
4629 | + _persistit.getAlertMonitor().post( |
4630 | + new Event(AlertLevel.ERROR, _persistit.getLogBase().cleanupException, e, action), |
4631 | AlertMonitor.CLEANUP_CATEGORY); |
4632 | _errors.incrementAndGet(); |
4633 | } |
4634 | @@ -164,7 +165,7 @@ |
4635 | |
4636 | @Override |
4637 | public synchronized String toString() { |
4638 | - StringBuilder sb = new StringBuilder("["); |
4639 | + final StringBuilder sb = new StringBuilder("["); |
4640 | for (final CleanupAction a : _cleanupActionQueue) { |
4641 | if (sb.length() > 1) { |
4642 | sb.append(",\n "); |
4643 | @@ -188,9 +189,9 @@ |
4644 | } |
4645 | |
4646 | @Override |
4647 | - public boolean equals(Object other) { |
4648 | + public boolean equals(final Object other) { |
4649 | if (other instanceof CleanupTreePage) { |
4650 | - CleanupTreePage a = (CleanupTreePage) other; |
4651 | + final CleanupTreePage a = (CleanupTreePage) other; |
4652 | return a._page == _page && a._treeHandle == _treeHandle && getClass().equals(a.getClass()); |
4653 | } else { |
4654 | return false; |
4655 | @@ -199,10 +200,10 @@ |
4656 | } |
4657 | |
4658 | @Override |
4659 | - public int compareTo(CleanupAction other) { |
4660 | + public int compareTo(final CleanupAction other) { |
4661 | if (other instanceof CleanupTreePage) { |
4662 | - CleanupTreePage a = (CleanupTreePage) other; |
4663 | - int d = _treeHandle - a._treeHandle; |
4664 | + final CleanupTreePage a = (CleanupTreePage) other; |
4665 | + final int d = _treeHandle - a._treeHandle; |
4666 | if (d != 0) { |
4667 | return d; |
4668 | } |
4669 | @@ -222,15 +223,15 @@ |
4670 | if (tree == null) { |
4671 | return null; |
4672 | } |
4673 | - WeakReference<Exchange> ref = _exchangeThreadLocal.get(); |
4674 | + final WeakReference<Exchange> ref = _exchangeThreadLocal.get(); |
4675 | if (ref != null) { |
4676 | - Exchange exchange = ref.get(); |
4677 | + final Exchange exchange = ref.get(); |
4678 | if (exchange != null) { |
4679 | exchange.init(tree); |
4680 | return exchange; |
4681 | } |
4682 | } |
4683 | - Exchange exchange = new Exchange(tree); |
4684 | + final Exchange exchange = new Exchange(tree); |
4685 | _exchangeThreadLocal.set(new WeakReference<Exchange>(exchange)); |
4686 | return exchange; |
4687 | } |
4688 | @@ -253,7 +254,7 @@ |
4689 | |
4690 | static class CleanupPruneAction extends CleanupTreePage { |
4691 | |
4692 | - CleanupPruneAction(int treeHandle, long page) { |
4693 | + CleanupPruneAction(final int treeHandle, final long page) { |
4694 | super(treeHandle, page); |
4695 | } |
4696 | |
4697 | @@ -269,7 +270,7 @@ |
4698 | static class CleanupIndexHole extends CleanupTreePage { |
4699 | int _level; |
4700 | |
4701 | - CleanupIndexHole(int treeHandle, long page, int level) { |
4702 | + CleanupIndexHole(final int treeHandle, final long page, final int level) { |
4703 | super(treeHandle, page); |
4704 | _level = level; |
4705 | } |
4706 | |
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 | * Property name for the "append only" property. |
4712 | */ |
4713 | public final static String APPEND_ONLY_PROPERTY = "appendonly"; |
4714 | - |
4715 | + |
4716 | /** |
4717 | * Property name for the "ignore missing volumes" property. |
4718 | */ |
4719 | public final static String IGNORE_MISSING_VOLUMES_PROPERTY = "ignoremissingvolumes"; |
4720 | - |
4721 | + |
4722 | /** |
4723 | * Property name to specify the default {@link SplitPolicy}. |
4724 | */ |
4725 | public final static String SPLIT_POLICY_PROPERTY_NAME = "splitpolicy"; |
4726 | - |
4727 | + |
4728 | /** |
4729 | * Property name to specify the"buffer inventory" property name. |
4730 | */ |
4731 | public final static String BUFFER_INVENTORY_PROPERTY_NAME = "bufferinventory"; |
4732 | - |
4733 | + |
4734 | public final static String BUFFER_POLLING_INTERVAL_PROPERTY = "bufferpollinginterval"; |
4735 | |
4736 | /** |
4737 | @@ -392,7 +392,7 @@ |
4738 | * @param minimumCount |
4739 | * the minimumCount to set |
4740 | */ |
4741 | - public void setMinimumCount(int minimumCount) { |
4742 | + public void setMinimumCount(final int minimumCount) { |
4743 | this.minimumCount = minimumCount; |
4744 | } |
4745 | |
4746 | @@ -407,7 +407,7 @@ |
4747 | * @param maximumCount |
4748 | * the maximumCount to set |
4749 | */ |
4750 | - public void setMaximumCount(int maximumCount) { |
4751 | + public void setMaximumCount(final int maximumCount) { |
4752 | this.maximumCount = maximumCount; |
4753 | } |
4754 | |
4755 | @@ -416,7 +416,7 @@ |
4756 | * |
4757 | * @param count |
4758 | */ |
4759 | - public void setCount(int count) { |
4760 | + public void setCount(final int count) { |
4761 | setMinimumCount(count); |
4762 | setMaximumCount(count); |
4763 | } |
4764 | @@ -432,7 +432,7 @@ |
4765 | * @param minimumMemory |
4766 | * the minimumMemory to set |
4767 | */ |
4768 | - public void setMinimumMemory(long minimumMemory) { |
4769 | + public void setMinimumMemory(final long minimumMemory) { |
4770 | this.minimumMemory = minimumMemory; |
4771 | } |
4772 | |
4773 | @@ -447,7 +447,7 @@ |
4774 | * @param maximumMemory |
4775 | * the maximumMemory to set |
4776 | */ |
4777 | - public void setMaximumMemory(long maximumMemory) { |
4778 | + public void setMaximumMemory(final long maximumMemory) { |
4779 | this.maximumMemory = maximumMemory; |
4780 | } |
4781 | |
4782 | @@ -462,7 +462,7 @@ |
4783 | * @param reservedMemory |
4784 | * the reservedMemory to set |
4785 | */ |
4786 | - public void setReservedMemory(long reservedMemory) { |
4787 | + public void setReservedMemory(final long reservedMemory) { |
4788 | this.reservedMemory = reservedMemory; |
4789 | } |
4790 | |
4791 | @@ -477,7 +477,7 @@ |
4792 | * @param fraction |
4793 | * the fraction to set |
4794 | */ |
4795 | - public void setFraction(float fraction) { |
4796 | + public void setFraction(final float fraction) { |
4797 | this.fraction = fraction; |
4798 | } |
4799 | |
4800 | @@ -496,10 +496,11 @@ |
4801 | if (maximumCount == 0) { |
4802 | return 0; |
4803 | } |
4804 | - long maximumAvailable = (long) ((availableHeapMemory - reservedMemory) * fraction); |
4805 | - long allocation = Math.min(maximumAvailable, maximumMemory); |
4806 | - int bufferSizeWithOverhead = Buffer.bufferSizeWithOverhead(bufferSize); |
4807 | - int buffers = Math.max(minimumCount, Math.min(maximumCount, (int) (allocation / bufferSizeWithOverhead))); |
4808 | + final long maximumAvailable = (long) ((availableHeapMemory - reservedMemory) * fraction); |
4809 | + final long allocation = Math.min(maximumAvailable, maximumMemory); |
4810 | + final int bufferSizeWithOverhead = Buffer.bufferSizeWithOverhead(bufferSize); |
4811 | + final int buffers = Math.max(minimumCount, |
4812 | + Math.min(maximumCount, (int) (allocation / bufferSizeWithOverhead))); |
4813 | if (buffers < BufferPool.MINIMUM_POOL_COUNT || buffers > BufferPool.MAXIMUM_POOL_COUNT |
4814 | || (long) buffers * (long) bufferSizeWithOverhead > maximumAvailable |
4815 | || (long) (buffers + 1) * (long) bufferSizeWithOverhead < minimumMemory) { |
4816 | @@ -510,8 +511,9 @@ |
4817 | return buffers; |
4818 | } |
4819 | |
4820 | + @Override |
4821 | public String toString() { |
4822 | - StringBuilder sb = new StringBuilder("BufferPoolConfiguration("); |
4823 | + final StringBuilder sb = new StringBuilder("BufferPoolConfiguration("); |
4824 | sb.append(String.format("size=%d", bufferSize)); |
4825 | if (minimumCount == maximumCount) { |
4826 | sb.append(String.format(",count=%d", minimumCount)); |
4827 | @@ -545,7 +547,7 @@ |
4828 | */ |
4829 | public void parseBufferCount(final int bufferSize, final String propertyName, final String propertyValue) { |
4830 | reset(); |
4831 | - int count = (int) parseLongProperty(propertyName, propertyValue); |
4832 | + final int count = (int) parseLongProperty(propertyName, propertyValue); |
4833 | Util.rangeCheck(count, BufferPool.MINIMUM_POOL_COUNT, BufferPool.MAXIMUM_POOL_COUNT); |
4834 | setMaximumCount(count); |
4835 | setMinimumCount(count); |
4836 | @@ -633,7 +635,8 @@ |
4837 | private boolean jmx = true; |
4838 | private boolean appendOnly; |
4839 | private String bufferInventoryPathName; |
4840 | - private long bufferInventoryPollInterval = 3000000; // default five minute polling |
4841 | + private long bufferInventoryPollInterval = 3000000; // default five minute |
4842 | + // polling |
4843 | private boolean ignoreMissingVolumes; |
4844 | private String tmpVolDir; |
4845 | private int tmpVolPageSize; |
4846 | @@ -644,8 +647,8 @@ |
4847 | * passed to the {@link Persistit#initialize(Configuration)} method. |
4848 | */ |
4849 | public Configuration() { |
4850 | - Map<Integer, BufferPoolConfiguration> map = new TreeMap<Integer, BufferPoolConfiguration>(); |
4851 | - for (int bufferSize : BUFFER_SIZES) { |
4852 | + final Map<Integer, BufferPoolConfiguration> map = new TreeMap<Integer, BufferPoolConfiguration>(); |
4853 | + for (final int bufferSize : BUFFER_SIZES) { |
4854 | map.put(bufferSize, new BufferPoolConfiguration(bufferSize)); |
4855 | } |
4856 | bufferPoolMap = Collections.unmodifiableMap(map); |
4857 | @@ -673,22 +676,22 @@ |
4858 | } |
4859 | |
4860 | void readPropertiesFile(final String propertiesFileName) throws PersistitException { |
4861 | - Properties properties = new Properties(); |
4862 | + final Properties properties = new Properties(); |
4863 | try { |
4864 | if (propertiesFileName.contains(DEFAULT_PROPERTIES_FILE_SUFFIX) |
4865 | || propertiesFileName.contains(File.separator)) { |
4866 | properties.load(new FileInputStream(propertiesFileName)); |
4867 | } else { |
4868 | - ResourceBundle bundle = ResourceBundle.getBundle(propertiesFileName); |
4869 | - for (Enumeration<String> e = bundle.getKeys(); e.hasMoreElements();) { |
4870 | + final ResourceBundle bundle = ResourceBundle.getBundle(propertiesFileName); |
4871 | + for (final Enumeration<String> e = bundle.getKeys(); e.hasMoreElements();) { |
4872 | final String key = e.nextElement(); |
4873 | properties.put(key, bundle.getString(key)); |
4874 | } |
4875 | } |
4876 | - } catch (FileNotFoundException fnfe) { |
4877 | + } catch (final FileNotFoundException fnfe) { |
4878 | // A friendlier exception when the properties file is not found. |
4879 | throw new PropertiesNotFoundException(fnfe.getMessage()); |
4880 | - } catch (IOException ioe) { |
4881 | + } catch (final IOException ioe) { |
4882 | throw new PersistitIOException(ioe); |
4883 | } |
4884 | merge(properties); |
4885 | @@ -696,7 +699,7 @@ |
4886 | } |
4887 | |
4888 | final static void checkBufferSize(final int bufferSize) { |
4889 | - for (int size : BUFFER_SIZES) { |
4890 | + for (final int size : BUFFER_SIZES) { |
4891 | if (size == bufferSize) { |
4892 | return; |
4893 | } |
4894 | @@ -741,13 +744,13 @@ |
4895 | |
4896 | void loadPropertiesBufferSpecifications() { |
4897 | for (int index = 0; index < BUFFER_SIZES.length; index++) { |
4898 | - int size = BUFFER_SIZES[index]; |
4899 | + final int size = BUFFER_SIZES[index]; |
4900 | |
4901 | final String countPropertyName = BUFFERS_PROPERTY_NAME + size; |
4902 | final String memPropertyName = BUFFER_MEM_PROPERTY_NAME + size; |
4903 | |
4904 | - String countSpec = getProperty(countPropertyName); |
4905 | - String memSpec = getProperty(memPropertyName); |
4906 | + final String countSpec = getProperty(countPropertyName); |
4907 | + final String memSpec = getProperty(memPropertyName); |
4908 | int count = 0; |
4909 | final BufferPoolConfiguration bpc = bufferPoolMap.get(size); |
4910 | |
4911 | @@ -770,13 +773,13 @@ |
4912 | } |
4913 | |
4914 | void loadPropertiesVolumeSpecifications() throws InvalidVolumeSpecificationException { |
4915 | - for (Enumeration<?> enumeration = _properties.propertyNames(); enumeration.hasMoreElements();) { |
4916 | - String key = (String) enumeration.nextElement(); |
4917 | + for (final Enumeration<?> enumeration = _properties.propertyNames(); enumeration.hasMoreElements();) { |
4918 | + final String key = (String) enumeration.nextElement(); |
4919 | if (key.startsWith(VOLUME_PROPERTY_PREFIX)) { |
4920 | boolean isOne = true; |
4921 | try { |
4922 | Integer.parseInt(key.substring(VOLUME_PROPERTY_PREFIX.length())); |
4923 | - } catch (NumberFormatException nfe) { |
4924 | + } catch (final NumberFormatException nfe) { |
4925 | isOne = false; |
4926 | } |
4927 | if (isOne) { |
4928 | @@ -789,12 +792,12 @@ |
4929 | |
4930 | final static int bufferSizeFromPropertyName(final String propertyName) { |
4931 | if (propertyName.startsWith(BUFFERS_PROPERTY_NAME) || propertyName.startsWith(BUFFER_MEM_PROPERTY_NAME)) { |
4932 | - String[] s = propertyName.split("\\."); |
4933 | + final String[] s = propertyName.split("\\."); |
4934 | try { |
4935 | - int size = Integer.parseInt(s[2]); |
4936 | + final int size = Integer.parseInt(s[2]); |
4937 | checkBufferSize(size); |
4938 | return size; |
4939 | - } catch (Exception e) { |
4940 | + } catch (final Exception e) { |
4941 | // default to -1 |
4942 | } |
4943 | } |
4944 | @@ -812,7 +815,7 @@ |
4945 | * Properties containing substitution values |
4946 | * @return text with substituted property values |
4947 | */ |
4948 | - public String substituteProperties(String text, Properties properties) { |
4949 | + public String substituteProperties(final String text, final Properties properties) { |
4950 | return substituteProperties(text, properties, 0); |
4951 | } |
4952 | |
4953 | @@ -828,13 +831,13 @@ |
4954 | * Count of recursive calls - maximum depth is 20. |
4955 | * @return |
4956 | */ |
4957 | - String substituteProperties(String text, Properties properties, int depth) { |
4958 | + String substituteProperties(String text, final Properties properties, final int depth) { |
4959 | int p = text.indexOf("${"); |
4960 | while (p >= 0 && p < text.length()) { |
4961 | p += 2; |
4962 | - int q = text.indexOf("}", p); |
4963 | + final int q = text.indexOf("}", p); |
4964 | if (q > 0) { |
4965 | - String propertyName = text.substring(p, q); |
4966 | + final String propertyName = text.substring(p, q); |
4967 | if (Util.isValidName(propertyName)) { |
4968 | // sanity check to prevent stack overflow |
4969 | // due to infinite loop |
4970 | @@ -898,7 +901,7 @@ |
4971 | * The property name |
4972 | * @return The resulting string |
4973 | */ |
4974 | - public String getProperty(String propertyName) { |
4975 | + public String getProperty(final String propertyName) { |
4976 | return getProperty(propertyName, null); |
4977 | } |
4978 | |
4979 | @@ -937,12 +940,12 @@ |
4980 | * The default value |
4981 | * @return The resulting string |
4982 | */ |
4983 | - public String getProperty(String propertyName, String defaultValue) { |
4984 | - String value = getProperty(propertyName, 0, _properties); |
4985 | + public String getProperty(final String propertyName, final String defaultValue) { |
4986 | + final String value = getProperty(propertyName, 0, _properties); |
4987 | return value == null ? defaultValue : value; |
4988 | } |
4989 | |
4990 | - private String getProperty(String propertyName, int depth, Properties properties) { |
4991 | + private String getProperty(final String propertyName, final int depth, final Properties properties) { |
4992 | String value = null; |
4993 | |
4994 | value = getSystemProperty(SYSTEM_PROPERTY_PREFIX + propertyName); |
4995 | @@ -983,14 +986,15 @@ |
4996 | |
4997 | private String getSystemProperty(final String propertyName) { |
4998 | return (String) AccessController.doPrivileged(new PrivilegedAction() { |
4999 | + @Override |
5000 | 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.