Merge lp:~pbeaman/akiban-persistit/buffer-pool-warmup-sorted into lp:akiban-persistit

Proposed by Peter Beaman
Status: Superseded
Proposed branch: lp:~pbeaman/akiban-persistit/buffer-pool-warmup-sorted
Merge into: lp:akiban-persistit
Prerequisite: lp:~pbeaman/akiban-persistit/eclipse-canonical-format
Diff against target: 39118 lines (+7109/-5984)
317 files modified
doc/Configuration.rst (+13/-1)
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 (+215/-169)
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 (+28/-28)
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 (+152/-144)
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 (+147/-119)
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 (+54/-53)
src/main/java/com/persistit/Persistit.java (+134/-120)
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 (+12/-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 (+17/-14)
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 (+16/-13)
src/test/java/com/persistit/TestShim.java (+6/-5)
src/test/java/com/persistit/TrackingFileChannel.java (+175/-0)
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 (+89/-33)
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/PreloadMixtureTxn1.java (+82/-0)
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 (+11/-10)
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/UnitTestProperties.java (+0/-1)
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/buffer-pool-warmup-sorted
Reviewer Review Type Date Requested Status
Akiban Technologies Pending
Review via email: mp+121188@code.launchpad.net

This proposal supersedes a proposal from 2012-08-23.

This proposal has been superseded by a proposal from 2012-08-25.

Description of the change

This proposal is a re-work of the original buffer pool warm-up code. Instead of creating a text file, this version stores the inventory in the system volume. It also loads pages in file-address order to reduce I/O time. There is a new stress test that pushes this into a medium-sized buffer pool (25K pages) but we still need to test it with a 1M page pool in TPCC or some other big test.

There are two config options, one to turn on inventory recording and the other to enable pre-loading pages. They are separate so that a server can start up without waiting for the pre-load but still be set to perform the inventory function.

Other changes include Configuration, Configuration.rst (documentation), etc.

To post a comment you must log in.
383. By Peter Beaman

Merge from release-notes-3.16

Revision history for this message
Nathan Williams (nwilliams) wrote :

This has a pre-req of the reformatting, but it doesn't look to have kicked in.

Could you try resubmitting? If that doesn't work then I'll do the diff manually for review.

384. By Peter Beaman

Fix failures in WarmupTest

385. By Peter Beaman

Fix WarmupTest (again)

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'doc/Configuration.rst'
--- doc/Configuration.rst 2012-06-11 21:25:37 +0000
+++ doc/Configuration.rst 2012-08-24 18:21:19 +0000
@@ -221,7 +221,7 @@
221 ``serialOverride``, ``constructorOverride``: (``com.persistit.Configuration#setSerialOverride`` ``com.persistit.Configuration#setConstructorOverride``) 221 ``serialOverride``, ``constructorOverride``: (``com.persistit.Configuration#setSerialOverride`` ``com.persistit.Configuration#setConstructorOverride``)
222 Control aspects of object serialization. See :ref:`Serialization`.222 Control aspects of object serialization. See :ref:`Serialization`.
223223
224 ``showgui``: (``com.persistit.Configuration#setShowGUI``), True of False. 224 ``showgui``: (``com.persistit.Configuration#setShowGUI``), True or False (default).
225 If true, Persistit attempts to create and display an instance of the AdminUI utility panel within the current JVM. 225 If true, Persistit attempts to create and display an instance of the AdminUI utility panel within the current JVM.
226 Alternatively, AdminUI uses RMI and can be launched and run remotely if ``rmiport`` or ``rmihost`` has been 226 Alternatively, AdminUI uses RMI and can be launched and run remotely if ``rmiport`` or ``rmihost`` has been
227 specified.227 specified.
@@ -231,6 +231,18 @@
231 install a logging adapter to reroute messages through Log4J, SLF4J or other logger. The ``logfile`` property is used 231 install a logging adapter to reroute messages through Log4J, SLF4J or other logger. The ``logfile`` property is used
232 only when no adapter has been installed.232 only when no adapter has been installed.
233233
234 ``bufferinventory``: (``com.persistit.Configuration#setBufferInventoryEnabled``), True or False (default).
235 If true, Persistit periodically records an inventory of all the buffes in the buffers pools to the System Volume. The inventory
236 enables Persistit to preload the buffer pools then next time it starts up with approximately the same pages that were present
237 before shutdown. To enable buffer preloading, the bufferpreload property must also be true.
238
239 ``bufferpreload``: (``com.persistit.Configuration#setBufferPreloadEnabled``), True or False (default).
240 If true, and if a buffer pool inventory was previously recorded, Persistit attempts to "warm up" the buffer pool
241 by preloading pages that were present in the buffer pool when Persistit last shut down. This may allow a freshly started
242 Persistit instance to begin service a workload similar to what it had previously been processing without incurring the
243 cost of many random disk reads to load pages.
244
245
234For all integer-valued properties, the suffix “K” may be used to represent kilo, “M” for mega, “G” for giga and “T” for tera. For example, “2M” represents the value 2,097,152.246For all integer-valued properties, the suffix “K” may be used to represent kilo, “M” for mega, “G” for giga and “T” for tera. For example, “2M” represents the value 2,097,152.
235247
236A Configuration Example248A Configuration Example
237249
=== modified file 'doc/ReleaseNotes.rst'
--- doc/ReleaseNotes.rst 2012-08-06 14:43:42 +0000
+++ doc/ReleaseNotes.rst 2012-08-24 18:21:19 +0000
@@ -44,6 +44,26 @@
44|44|
45|45|
4646
47
48************************************
493.1.6
50************************************
51
52Release Date
53============
54August 24, 2012
55
56Overview
57========
58This version of Persistit fixes one bug.
59
60Fixed Issues
61============
62
63https://bugs.launchpad.net/akiban-persistit/+bug/1036422
64
65With CommitPolicy HARD we observed a CPU-soaking loop in the commit logic.
66
47************************************67************************************
483.1.5683.1.5
49************************************69************************************
5070
=== modified file 'pom.xml'
--- pom.xml 2012-08-07 21:11:28 +0000
+++ pom.xml 2012-08-24 18:21:19 +0000
@@ -82,6 +82,14 @@
82 </dependency>82 </dependency>
83 </dependencies>83 </dependencies>
8484
85 <pluginRepositories>
86 <pluginRepository>
87 <id>maven-java-formatter-plugin</id>
88 <name>Maven2 Java Formatter Plugin repository</name>
89 <url>https://raw.github.com/benalexau/maven-java-formatter-plugin/master/releases/</url>
90 </pluginRepository>
91 </pluginRepositories>
92
85 <build>93 <build>
86 <finalName>${project.artifactId}-${project.version}${BZR_REVISION}</finalName>94 <finalName>${project.artifactId}-${project.version}${BZR_REVISION}</finalName>
87 <resources>95 <resources>
@@ -256,6 +264,7 @@
256 <exclude>.project</exclude>264 <exclude>.project</exclude>
257 <exclude>.classpath</exclude>265 <exclude>.classpath</exclude>
258 <exclude>.bzrignore</exclude>266 <exclude>.bzrignore</exclude>
267 <exclude>src/etc/eclipse*.xml</exclude>
259 <!-- Other -->268 <!-- Other -->
260 <exclude>LICENSE.txt</exclude>269 <exclude>LICENSE.txt</exclude>
261 </excludes>270 </excludes>
@@ -273,6 +282,21 @@
273 <artifactId>maven-eclipse-plugin</artifactId>282 <artifactId>maven-eclipse-plugin</artifactId>
274 <version>2.6</version>283 <version>2.6</version>
275 </plugin>284 </plugin>
285 <plugin>
286 <groupId>com.googlecode.maven-java-formatter-plugin</groupId>
287 <artifactId>maven-java-formatter-plugin</artifactId>
288 <version>0.4.0.e371sr1</version>
289 <configuration>
290 <configFile>${project.basedir}/src/etc/eclipse-format-config.xml</configFile>
291 </configuration>
292 <executions>
293 <execution>
294 <goals>
295 <goal>format</goal>
296 </goals>
297 </execution>
298 </executions>
299 </plugin>
276 </plugins>300 </plugins>
277 <pluginManagement>301 <pluginManagement>
278 <plugins>302 <plugins>
@@ -324,6 +348,19 @@
324 <ignore />348 <ignore />
325 </action>349 </action>
326 </pluginExecution>350 </pluginExecution>
351 <pluginExecution>
352 <pluginExecutionFilter>
353 <groupId>com.googlecode.maven-java-formatter-plugin</groupId>
354 <artifactId>maven-java-formatter-plugin</artifactId>
355 <versionRange>[0.4.0.e371sr1,)</versionRange>
356 <goals>
357 <goal>format</goal>
358 </goals>
359 </pluginExecutionFilter>
360 <action>
361 <ignore></ignore>
362 </action>
363 </pluginExecution>
327 </pluginExecutions>364 </pluginExecutions>
328 </lifecycleMappingMetadata>365 </lifecycleMappingMetadata>
329 </configuration>366 </configuration>
@@ -331,7 +368,6 @@
331 </plugins>368 </plugins>
332 </pluginManagement>369 </pluginManagement>
333 </build>370 </build>
334
335 <reporting>371 <reporting>
336 <plugins>372 <plugins>
337 <plugin>373 <plugin>
338374
=== added file 'src/etc/eclipse-cleanup-config.xml'
--- src/etc/eclipse-cleanup-config.xml 1970-01-01 00:00:00 +0000
+++ src/etc/eclipse-cleanup-config.xml 2012-08-24 18:21:19 +0000
@@ -0,0 +1,56 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<profiles version="2">
3<profile kind="CleanUpProfile" name="Akiban-Persistit" version="2">
4<setting id="cleanup.format_source_code" value="true"/>
5<setting id="cleanup.add_missing_annotations" value="true"/>
6<setting id="cleanup.use_this_for_non_static_method_access_only_if_necessary" value="true"/>
7<setting id="cleanup.remove_unused_private_types" value="true"/>
8<setting id="cleanup.qualify_static_member_accesses_through_instances_with_declaring_class" value="true"/>
9<setting id="cleanup.qualify_static_method_accesses_with_declaring_class" value="false"/>
10<setting id="cleanup.add_generated_serial_version_id" value="false"/>
11<setting id="cleanup.make_variable_declarations_final" value="true"/>
12<setting id="cleanup.add_missing_methods" value="false"/>
13<setting id="cleanup.always_use_this_for_non_static_field_access" value="false"/>
14<setting id="cleanup.remove_trailing_whitespaces_ignore_empty" value="false"/>
15<setting id="cleanup.correct_indentation" value="true"/>
16<setting id="cleanup.never_use_parentheses_in_expressions" value="true"/>
17<setting id="cleanup.add_serial_version_id" value="false"/>
18<setting id="cleanup.remove_unused_private_methods" value="true"/>
19<setting id="cleanup.use_this_for_non_static_field_access" value="false"/>
20<setting id="cleanup.use_blocks_only_for_return_and_throw" value="false"/>
21<setting id="cleanup.remove_unused_private_members" value="false"/>
22<setting id="cleanup.add_missing_override_annotations_interface_methods" value="true"/>
23<setting id="cleanup.remove_trailing_whitespaces_all" value="true"/>
24<setting id="cleanup.make_type_abstract_if_missing_method" value="false"/>
25<setting id="cleanup.always_use_this_for_non_static_method_access" value="false"/>
26<setting id="cleanup.remove_unnecessary_nls_tags" value="true"/>
27<setting id="cleanup.format_source_code_changes_only" value="false"/>
28<setting id="cleanup.qualify_static_field_accesses_with_declaring_class" value="false"/>
29<setting id="cleanup.add_missing_nls_tags" value="false"/>
30<setting id="cleanup.use_this_for_non_static_field_access_only_if_necessary" value="true"/>
31<setting id="cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class" value="false"/>
32<setting id="cleanup.remove_unnecessary_casts" value="true"/>
33<setting id="cleanup.qualify_static_member_accesses_with_declaring_class" value="true"/>
34<setting id="cleanup.use_parentheses_in_expressions" value="false"/>
35<setting id="cleanup.remove_unused_private_fields" value="true"/>
36<setting id="cleanup.make_parameters_final" value="true"/>
37<setting id="cleanup.remove_trailing_whitespaces" value="true"/>
38<setting id="cleanup.remove_unused_imports" value="true"/>
39<setting id="cleanup.organize_imports" value="true"/>
40<setting id="cleanup.sort_members" value="false"/>
41<setting id="cleanup.remove_private_constructors" value="true"/>
42<setting id="cleanup.convert_to_enhanced_for_loop" value="false"/>
43<setting id="cleanup.always_use_blocks" value="true"/>
44<setting id="cleanup.never_use_blocks" value="false"/>
45<setting id="cleanup.always_use_parentheses_in_expressions" value="false"/>
46<setting id="cleanup.use_this_for_non_static_method_access" value="false"/>
47<setting id="cleanup.remove_unused_local_variables" value="false"/>
48<setting id="cleanup.make_private_fields_final" value="true"/>
49<setting id="cleanup.add_missing_deprecated_annotations" value="true"/>
50<setting id="cleanup.add_default_serial_version_id" value="true"/>
51<setting id="cleanup.sort_members_all" value="false"/>
52<setting id="cleanup.use_blocks" value="false"/>
53<setting id="cleanup.add_missing_override_annotations" value="true"/>
54<setting id="cleanup.make_local_variable_final" value="true"/>
55</profile>
56</profiles>
057
=== added file 'src/etc/eclipse-format-config.xml'
--- src/etc/eclipse-format-config.xml 1970-01-01 00:00:00 +0000
+++ src/etc/eclipse-format-config.xml 2012-08-24 18:21:19 +0000
@@ -0,0 +1,291 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<profiles version="12">
3<profile kind="CodeFormatterProfile" name="Akiban-code-format" version="12">
4<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
5<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
6<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
7<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
8<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
9<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
10<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
11<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
12<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
13<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
14<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
15<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
16<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
17<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
18<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
19<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
20<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
21<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
22<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
23<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
24<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
25<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/>
26<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
27<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
28<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
29<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
30<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
31<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
32<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
33<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
34<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
35<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
36<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
37<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
38<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
39<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
40<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
41<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
42<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
43<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
44<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
45<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
46<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
47<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
48<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
49<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
50<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
51<setting id="org.eclipse.jdt.core.compiler.source" value="1.7"/>
52<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
53<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
54<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
55<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
56<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
57<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
58<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
59<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
60<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
61<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
62<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
63<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
64<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
65<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
66<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
67<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
68<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
69<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
70<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
71<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
72<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
73<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
74<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
75<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
76<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
77<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
78<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
79<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
80<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
81<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
82<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
83<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
84<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
85<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
86<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
87<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
88<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
89<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
90<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
91<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
92<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
93<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
94<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
95<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
96<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
97<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
98<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
99<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
100<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
101<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
102<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
103<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
104<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
105<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
106<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
107<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
108<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
109<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
110<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
111<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
112<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
113<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
114<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
115<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
116<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
117<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
118<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
119<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
120<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
121<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
122<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
123<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
124<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
125<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
126<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
127<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
128<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
129<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
130<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
131<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
132<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
133<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
134<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
135<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
136<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
137<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
138<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
139<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
140<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
141<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
142<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
143<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
144<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
145<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
146<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
147<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
148<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
149<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
150<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
151<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
152<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
153<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
154<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
155<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
156<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
157<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
158<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
159<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
160<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
161<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
162<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
163<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
164<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
165<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
166<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
167<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
168<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
169<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
170<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
171<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
172<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
173<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
174<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
175<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.7"/>
176<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
177<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
178<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
179<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
180<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
181<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
182<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
183<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
184<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
185<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
186<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
187<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
188<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
189<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
190<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
191<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
192<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
193<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
194<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
195<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
196<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
197<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
198<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
199<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
200<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
201<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
202<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
203<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
204<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
205<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
206<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
207<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
208<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
209<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
210<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
211<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
212<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
213<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
214<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
215<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
216<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
217<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
218<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
219<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
220<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
221<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
222<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
223<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
224<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
225<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
226<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
227<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
228<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
229<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
230<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
231<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
232<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
233<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
234<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
235<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
236<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
237<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
238<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
239<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
240<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
241<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
242<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
243<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
244<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
245<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
246<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
247<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
248<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
249<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
250<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
251<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.7"/>
252<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
253<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
254<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
255<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
256<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
257<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
258<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
259<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
260<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
261<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
262<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
263<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
264<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
265<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
266<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
267<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
268<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
269<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
270<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
271<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
272<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
273<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
274<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
275<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
276<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
277<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
278<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
279<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
280<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
281<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
282<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
283<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
284<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
285<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
286<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
287<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
288<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
289<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
290</profile>
291</profiles>
0292
=== modified file 'src/main/java/com/persistit/Accumulator.java'
--- src/main/java/com/persistit/Accumulator.java 2012-08-02 04:45:28 +0000
+++ src/main/java/com/persistit/Accumulator.java 2012-08-24 18:21:19 +0000
@@ -97,10 +97,10 @@
97 final static Comparator<Accumulator> SORT_COMPARATOR = new Comparator<Accumulator>() {97 final static Comparator<Accumulator> SORT_COMPARATOR = new Comparator<Accumulator>() {
9898
99 @Override99 @Override
100 public int compare(Accumulator a, Accumulator b) {100 public int compare(final Accumulator a, final Accumulator b) {
101 final String treeNameA = a.getTree() == null ? "" : a.getTree().getName();101 final String treeNameA = a.getTree() == null ? "" : a.getTree().getName();
102 final String treeNameB = b.getTree() == null ? "" : b.getTree().getName();102 final String treeNameB = b.getTree() == null ? "" : b.getTree().getName();
103 int compare = treeNameA.compareTo(treeNameB);103 final int compare = treeNameA.compareTo(treeNameB);
104 if (compare != 0) {104 if (compare != 0) {
105 return compare;105 return compare;
106 } else {106 } else {
@@ -144,7 +144,7 @@
144 * longer present in live TransactionStatus objects. This array has one144 * longer present in live TransactionStatus objects. This array has one
145 * element per TransactionIndexBucket.145 * element per TransactionIndexBucket.
146 */146 */
147 private long[] _bucketValues;147 private final long[] _bucketValues;
148148
149 /*149 /*
150 * Object held on the accumulators list in {@link Persistit}. An150 * Object held on the accumulators list in {@link Persistit}. An
@@ -374,7 +374,7 @@
374 }374 }
375375
376 Accumulator takeCheckpointRef() {376 Accumulator takeCheckpointRef() {
377 Accumulator result = _checkpointRef;377 final Accumulator result = _checkpointRef;
378 _checkpointRef = null;378 _checkpointRef = null;
379 return result;379 return result;
380 }380 }
@@ -551,7 +551,7 @@
551 long getSnapshotValue(final long timestamp, final int step) throws PersistitInterruptedException {551 long getSnapshotValue(final long timestamp, final int step) throws PersistitInterruptedException {
552 try {552 try {
553 return _transactionIndex.getAccumulatorSnapshot(this, timestamp, step, _baseValue);553 return _transactionIndex.getAccumulatorSnapshot(this, timestamp, step, _baseValue);
554 } catch (InterruptedException ie) {554 } catch (final InterruptedException ie) {
555 throw new PersistitInterruptedException(ie);555 throw new PersistitInterruptedException(ie);
556 }556 }
557 }557 }
@@ -588,6 +588,7 @@
588 /**588 /**
589 * Update the Accumulator by contributing a value. The contribution is589 * Update the Accumulator by contributing a value. The contribution is
590 * immediately accumulated into the live value, and it is also posted with a590 * immediately accumulated into the live value, and it is also posted with a
591 *
591 * @{link {@link Delta} instance to the supplied {@link Transaction}.592 * @{link {@link Delta} instance to the supplied {@link Transaction}.
592 * 593 *
593 * @param value594 * @param value
@@ -636,8 +637,8 @@
636 * values for this <code>Accumulator</code>.637 * values for this <code>Accumulator</code>.
637 */638 */
638 public String toString() {639 public String toString() {
639 return String.format("Accumulator(tree=%s index=%d type=%s base=%,d live=%,d)", _tree == null ? "null" : _tree640 return String.format("Accumulator(tree=%s index=%d type=%s base=%,d live=%,d)",
640 .getName(), _index, getType(), _baseValue, _liveValue.get());641 _tree == null ? "null" : _tree.getName(), _index, getType(), _baseValue, _liveValue.get());
641 }642 }
642643
643 void store(final Value value) {644 void store(final Value value) {
@@ -649,8 +650,8 @@
649650
650 static AccumulatorState getAccumulatorState(final Tree tree, final int index) throws PersistitException {651 static AccumulatorState getAccumulatorState(final Tree tree, final int index) throws PersistitException {
651 final Exchange exchange = tree.getVolume().getStructure().directoryExchange();652 final Exchange exchange = tree.getVolume().getStructure().directoryExchange();
652 exchange.clear().append(VolumeStructure.DIRECTORY_TREE_NAME).append(VolumeStructure.TREE_ACCUMULATOR).append(653 exchange.clear().append(VolumeStructure.DIRECTORY_TREE_NAME).append(VolumeStructure.TREE_ACCUMULATOR)
653 tree.getName()).append(index).fetch();654 .append(tree.getName()).append(index).fetch();
654 if (exchange.getValue().isDefined()) {655 if (exchange.getValue().isDefined()) {
655 return (AccumulatorState) exchange.getValue().get();656 return (AccumulatorState) exchange.getValue().get();
656 } else {657 } else {
657658
=== modified file 'src/main/java/com/persistit/AccumulatorState.java'
--- src/main/java/com/persistit/AccumulatorState.java 2012-08-02 04:45:28 +0000
+++ src/main/java/com/persistit/AccumulatorState.java 2012-08-24 18:21:19 +0000
@@ -15,7 +15,6 @@
1515
16package com.persistit;16package com.persistit;
1717
18
19/**18/**
20 * State of an accumulator recovered from a checkpoint.19 * State of an accumulator recovered from a checkpoint.
21 * 20 *
@@ -48,19 +47,19 @@
48 public String toString() {47 public String toString() {
49 return String.format("Accumulator(tree=%s index=%d type=%s value=%,d)", _treeName, _index, _type, _value);48 return String.format("Accumulator(tree=%s index=%d type=%s value=%,d)", _treeName, _index, _type, _value);
50 }49 }
51 50
52 public String getTreeName() {51 public String getTreeName() {
53 return _treeName;52 return _treeName;
54 }53 }
55 54
56 public int getIndex() {55 public int getIndex() {
57 return _index;56 return _index;
58 }57 }
59 58
60 public Accumulator.Type getType() {59 public Accumulator.Type getType() {
61 return _type;60 return _type;
62 }61 }
63 62
64 public long getValue() {63 public long getValue() {
65 return _value;64 return _value;
66 }65 }
6766
=== modified file 'src/main/java/com/persistit/AlertMonitor.java'
--- src/main/java/com/persistit/AlertMonitor.java 2012-08-02 04:45:28 +0000
+++ src/main/java/com/persistit/AlertMonitor.java 2012-08-24 18:21:19 +0000
@@ -113,7 +113,7 @@
113 */113 */
114 public class History {114 public class History {
115 private AlertLevel _level = AlertLevel.NORMAL;115 private AlertLevel _level = AlertLevel.NORMAL;
116 private List<Event> _eventList = new ArrayList<Event>();116 private final List<Event> _eventList = new ArrayList<Event>();
117 private volatile long _firstEventTime = Long.MAX_VALUE;117 private volatile long _firstEventTime = Long.MAX_VALUE;
118 private volatile long _lastWarnLogTime = Long.MIN_VALUE;118 private volatile long _lastWarnLogTime = Long.MIN_VALUE;
119 private volatile long _lastErrorLogTime = Long.MIN_VALUE;119 private volatile long _lastErrorLogTime = Long.MIN_VALUE;
@@ -142,7 +142,7 @@
142 public String getDetailedHistory() {142 public String getDetailedHistory() {
143 final StringBuilder sb = new StringBuilder();143 final StringBuilder sb = new StringBuilder();
144 synchronized (AlertMonitor.this) {144 synchronized (AlertMonitor.this) {
145 int size = _eventList.size();145 final int size = _eventList.size();
146 if (_count > 0) {146 if (_count > 0) {
147 sb.append(String.format(EVENT_FORMAT, 1, format(_firstEvent)));147 sb.append(String.format(EVENT_FORMAT, 1, format(_firstEvent)));
148 for (int index = _count > size ? 0 : 1; index < size; index++) {148 for (int index = _count > size ? 0 : 1; index < size; index++) {
@@ -250,7 +250,7 @@
250 * does nothing unless the interval has elapsed.250 * does nothing unless the interval has elapsed.
251 */251 */
252 public void poll(final long now, final boolean force) {252 public void poll(final long now, final boolean force) {
253 int count = getCount();253 final int count = getCount();
254 if (count > _reportedCount) {254 if (count > _reportedCount) {
255 switch (_level) {255 switch (_level) {
256 case ERROR:256 case ERROR:
@@ -316,7 +316,7 @@
316 * event was posted.316 * event was posted.
317 */317 */
318 public static class Event {318 public static class Event {
319 private AlertLevel _level;319 private final AlertLevel _level;
320 private final LogItem _logItem;320 private final LogItem _logItem;
321 private final Object[] _args;321 private final Object[] _args;
322 private final long _time;322 private final long _time;
@@ -332,7 +332,7 @@
332 * @param args332 * @param args
333 * arguments specific to the <code>LogItem</code>333 * arguments specific to the <code>LogItem</code>
334 */334 */
335 public Event(AlertLevel level, LogItem logItem, Object... args) {335 public Event(final AlertLevel level, final LogItem logItem, final Object... args) {
336 this(level, System.currentTimeMillis(), logItem, args);336 this(level, System.currentTimeMillis(), logItem, args);
337 }337 }
338338
@@ -349,7 +349,7 @@
349 * @param args349 * @param args
350 * arguments specific to the <code>LogItem</code>350 * arguments specific to the <code>LogItem</code>
351 */351 */
352 public Event(AlertLevel level, long time, LogItem logItem, Object... args) {352 public Event(final AlertLevel level, final long time, final LogItem logItem, final Object... args) {
353 _level = level;353 _level = level;
354 _logItem = logItem;354 _logItem = logItem;
355 _args = args;355 _args = args;
@@ -492,7 +492,7 @@
492 private volatile long _errorLogTimeInterval = DEFAULT_ERROR_INTERVAL;492 private volatile long _errorLogTimeInterval = DEFAULT_ERROR_INTERVAL;
493 private volatile int _historyLength = DEFAULT_HISTORY_LENGTH;493 private volatile int _historyLength = DEFAULT_HISTORY_LENGTH;
494494
495 private AtomicLong _notificationSequence = new AtomicLong();495 private final AtomicLong _notificationSequence = new AtomicLong();
496 private volatile ObjectName _objectName;496 private volatile ObjectName _objectName;
497497
498 /**498 /**
@@ -533,7 +533,7 @@
533 * A String describing the nature of the event. A separate533 * A String describing the nature of the event. A separate
534 * event-history is maintained for each unique category.534 * event-history is maintained for each unique category.
535 */535 */
536 public synchronized final void post(Event event, final String category) {536 public synchronized final void post(final Event event, final String category) {
537 History history = _historyMap.get(category);537 History history = _historyMap.get(category);
538 if (history == null) {538 if (history == null) {
539 history = new History();539 history = new History();
@@ -570,7 +570,7 @@
570 * the interval in milliseconds570 * the interval in milliseconds
571 */571 */
572 @Override572 @Override
573 public void setWarnLogTimeInterval(long warnLogTimeInterval) {573 public void setWarnLogTimeInterval(final long warnLogTimeInterval) {
574 Util.rangeCheck(warnLogTimeInterval, MINIMUM_WARN_INTERVAL, MAXIMUM_WARN_INTERVAL);574 Util.rangeCheck(warnLogTimeInterval, MINIMUM_WARN_INTERVAL, MAXIMUM_WARN_INTERVAL);
575 _warnLogTimeInterval = warnLogTimeInterval;575 _warnLogTimeInterval = warnLogTimeInterval;
576 }576 }
@@ -592,7 +592,7 @@
592 * the interval in milliseconds592 * the interval in milliseconds
593 */593 */
594 @Override594 @Override
595 public void setErrorLogTimeInterval(long errorLogTimeInterval) {595 public void setErrorLogTimeInterval(final long errorLogTimeInterval) {
596 Util.rangeCheck(errorLogTimeInterval, MINIMUM_ERROR_INTERVAL, MAXIMUM_ERROR_INTERVAL);596 Util.rangeCheck(errorLogTimeInterval, MINIMUM_ERROR_INTERVAL, MAXIMUM_ERROR_INTERVAL);
597 _errorLogTimeInterval = errorLogTimeInterval;597 _errorLogTimeInterval = errorLogTimeInterval;
598 }598 }
@@ -613,7 +613,7 @@
613 * @return the <code>History</code> for that category or <code>null</code>613 * @return the <code>History</code> for that category or <code>null</code>
614 * if the specified category has no <code>History</code>.614 * if the specified category has no <code>History</code>.
615 */615 */
616 public synchronized History getHistory(String name) {616 public synchronized History getHistory(final String name) {
617 return _historyMap.get(name);617 return _historyMap.get(name);
618 }618 }
619619
@@ -637,7 +637,7 @@
637 * the historyLength to set637 * the historyLength to set
638 */638 */
639 @Override639 @Override
640 public synchronized void setHistoryLength(int historyLength) {640 public synchronized void setHistoryLength(final int historyLength) {
641 Util.rangeCheck(historyLength, MINIMUM_HISTORY_LENGTH, MAXIMUM_HISTORY_LENGTH);641 Util.rangeCheck(historyLength, MINIMUM_HISTORY_LENGTH, MAXIMUM_HISTORY_LENGTH);
642 _historyLength = historyLength;642 _historyLength = historyLength;
643 for (final History history : _historyMap.values()) {643 for (final History history : _historyMap.values()) {
@@ -652,7 +652,7 @@
652 * @return List of AlertRecord elements.652 * @return List of AlertRecord elements.
653 */653 */
654 public synchronized AlertRecord[] getAlertRecordArray() {654 public synchronized AlertRecord[] getAlertRecordArray() {
655 List<AlertRecord> list = new ArrayList<AlertRecord>();655 final List<AlertRecord> list = new ArrayList<AlertRecord>();
656 for (final Map.Entry<String, History> entry : _historyMap.entrySet()) {656 for (final Map.Entry<String, History> entry : _historyMap.entrySet()) {
657 for (final Event event : entry.getValue().getEventList()) {657 for (final Event event : entry.getValue().getEventList()) {
658 list.add(new AlertRecord(entry.getKey(), event));658 list.add(new AlertRecord(entry.getKey(), event));
@@ -681,7 +681,7 @@
681 */681 */
682 @Override682 @Override
683 public synchronized String toString() {683 public synchronized String toString() {
684 StringBuilder sb = new StringBuilder();684 final StringBuilder sb = new StringBuilder();
685 for (final Map.Entry<String, History> entry : _historyMap.entrySet()) {685 for (final Map.Entry<String, History> entry : _historyMap.entrySet()) {
686 sb.append(String.format("%12s: %s\n", entry.getKey(), entry.getValue()));686 sb.append(String.format("%12s: %s\n", entry.getKey(), entry.getValue()));
687 }687 }
@@ -705,8 +705,8 @@
705 */705 */
706 @Override706 @Override
707 public synchronized String getDetailedHistory(final String select) {707 public synchronized String getDetailedHistory(final String select) {
708 Pattern pattern = Util.pattern(select, true);708 final Pattern pattern = Util.pattern(select, true);
709 StringBuilder sb = new StringBuilder();709 final StringBuilder sb = new StringBuilder();
710 for (final Map.Entry<String, History> entry : _historyMap.entrySet()) {710 for (final Map.Entry<String, History> entry : _historyMap.entrySet()) {
711 if (pattern.matcher(entry.getKey()).matches()) {711 if (pattern.matcher(entry.getKey()).matches()) {
712 sb.append(String.format("%s:\n", entry.getKey()));712 sb.append(String.format("%s:\n", entry.getKey()));
@@ -737,10 +737,10 @@
737 */737 */
738 @Override738 @Override
739 public MBeanNotificationInfo[] getNotificationInfo() {739 public MBeanNotificationInfo[] getNotificationInfo() {
740 String[] types = new String[] { NOTIFICATION_TYPE };740 final String[] types = new String[] { NOTIFICATION_TYPE };
741 String name = Notification.class.getName();741 final String name = Notification.class.getName();
742 String description = "Alert raised by Akiban PersistIT";742 final String description = "Alert raised by Akiban PersistIT";
743 MBeanNotificationInfo info = new MBeanNotificationInfo(types, name, description);743 final MBeanNotificationInfo info = new MBeanNotificationInfo(types, name, description);
744 return new MBeanNotificationInfo[] { info };744 return new MBeanNotificationInfo[] { info };
745 }745 }
746746
@@ -751,7 +751,7 @@
751 * 751 *
752 * @param history752 * @param history
753 */753 */
754 private void log(History history) {754 private void log(final History history) {
755 final Event event = history.getLastEvent();755 final Event event = history.getLastEvent();
756 if (event != null && event.getLogItem().isEnabled()) {756 if (event != null && event.getLogItem().isEnabled()) {
757 if (history.getCount() == 1) {757 if (history.getCount() == 1) {
@@ -767,13 +767,13 @@
767 * 767 *
768 * @param history768 * @param history
769 */769 */
770 private void sendNotification(History history) {770 private void sendNotification(final History history) {
771 final Event event = history.getLastEvent();771 final Event event = history.getLastEvent();
772 if (event != null && event.getLogItem().isEnabled()) {772 if (event != null && event.getLogItem().isEnabled()) {
773 final String description = LogBase.recurring(event.getLogItem().logMessage(event.getArgs()), history773 final String description = LogBase.recurring(event.getLogItem().logMessage(event.getArgs()),
774 .getCount(), history.getDuration());774 history.getCount(), history.getDuration());
775 Notification notification = new Notification(NOTIFICATION_TYPE, getClass().getName(), _notificationSequence775 final Notification notification = new Notification(NOTIFICATION_TYPE, getClass().getName(),
776 .incrementAndGet(), description);776 _notificationSequence.incrementAndGet(), description);
777 sendNotification(notification);777 sendNotification(notification);
778 }778 }
779 }779 }
@@ -796,7 +796,7 @@
796 * @param event796 * @param event
797 * @return797 * @return
798 */798 */
799 private String format(Event event) {799 private String format(final Event event) {
800 return event == null ? "null" : event.toString();800 return event == null ? "null" : event.toString();
801 }801 }
802802
803803
=== modified file 'src/main/java/com/persistit/AntiValue.java'
--- src/main/java/com/persistit/AntiValue.java 2012-08-02 04:45:28 +0000
+++ src/main/java/com/persistit/AntiValue.java 2012-08-24 18:21:19 +0000
@@ -15,10 +15,10 @@
1515
16package com.persistit;16package com.persistit;
1717
18import java.util.Arrays;
19
18import com.persistit.exception.InvalidKeyException;20import com.persistit.exception.InvalidKeyException;
1921
20import java.util.Arrays;
21
22/**22/**
23 * Represents the end of a key range to be removed. Used in Transactions.23 * Represents the end of a key range to be removed. Used in Transactions.
24 * 24 *
@@ -26,29 +26,29 @@
26 * @version 1.126 * @version 1.1
27 */27 */
28class AntiValue {28class AntiValue {
29 private int _elisionCount;29 private final int _elisionCount;
30 private byte[] _bytes;30 private final byte[] _bytes;
3131
32 AntiValue(int ec, byte[] bytes) {32 AntiValue(final int ec, final byte[] bytes) {
33 _elisionCount = ec;33 _elisionCount = ec;
34 _bytes = bytes;34 _bytes = bytes;
35 }35 }
3636
37 static void putAntiValue(Value value, Key key1, Key key2) {37 static void putAntiValue(final Value value, final Key key1, final Key key2) {
38 int elisionCount = key1.firstUniqueByteIndex(key2);38 final int elisionCount = key1.firstUniqueByteIndex(key2);
39 int size = key2.getEncodedSize() - elisionCount;39 final int size = key2.getEncodedSize() - elisionCount;
40 byte[] bytes = new byte[size];40 final byte[] bytes = new byte[size];
41 System.arraycopy(key2.getEncodedBytes(), elisionCount, bytes, 0, size);41 System.arraycopy(key2.getEncodedBytes(), elisionCount, bytes, 0, size);
42 value.putAntiValue((short) elisionCount, bytes);42 value.putAntiValue((short) elisionCount, bytes);
43 }43 }
4444
45 static void fixUpKeys(Exchange exchange, int elisionCount, byte[] bytes, int offset, int length)45 static void fixUpKeys(final Exchange exchange, final int elisionCount, final byte[] bytes, final int offset,
46 throws InvalidKeyException {46 final int length) throws InvalidKeyException {
47 Key spareKey1 = exchange.getAuxiliaryKey1();47 final Key spareKey1 = exchange.getAuxiliaryKey1();
48 Key spareKey2 = exchange.getAuxiliaryKey2();48 final Key spareKey2 = exchange.getAuxiliaryKey2();
49 spareKey1.copyTo(spareKey2);49 spareKey1.copyTo(spareKey2);
50 byte[] baseBytes = spareKey2.getEncodedBytes();50 final byte[] baseBytes = spareKey2.getEncodedBytes();
51 int baseSize = spareKey2.getEncodedSize();51 final int baseSize = spareKey2.getEncodedSize();
52 if (baseSize < elisionCount || elisionCount + length > Key.MAX_KEY_LENGTH) {52 if (baseSize < elisionCount || elisionCount + length > Key.MAX_KEY_LENGTH) {
53 throw new InvalidKeyException("Key encoding in transaction is invalid");53 throw new InvalidKeyException("Key encoding in transaction is invalid");
54 }54 }
5555
=== modified file 'src/main/java/com/persistit/BackupTask.java'
--- src/main/java/com/persistit/BackupTask.java 2012-08-02 04:45:28 +0000
+++ src/main/java/com/persistit/BackupTask.java 2012-08-24 18:21:19 +0000
@@ -76,12 +76,13 @@
76 private volatile String _backupStatus;76 private volatile String _backupStatus;
7777
78 @Cmd("backup")78 @Cmd("backup")
79 static Task setupTask(@Arg("file|string|Archive file path") String file,79 static Task setupTask(@Arg("file|string|Archive file path") final String file,
80 @Arg("_flag|a|Start appendOnly mode") boolean start, @Arg("_flag|e|End appendOnly mode") boolean end,80 @Arg("_flag|a|Start appendOnly mode") final boolean start,
81 @Arg("_flag|c|Request checkpoint before backup") boolean checkpoint,81 @Arg("_flag|e|End appendOnly mode") final boolean end,
82 @Arg("_flag|z|Compress output to ZIP format") boolean compressed,82 @Arg("_flag|c|Request checkpoint before backup") final boolean checkpoint,
83 @Arg("_flag|f|Emit a list of files that need to be copied") boolean showFiles,83 @Arg("_flag|z|Compress output to ZIP format") final boolean compressed,
84 @Arg("_flag|y|Copyback pages before starting") boolean copyback) throws Exception {84 @Arg("_flag|f|Emit a list of files that need to be copied") final boolean showFiles,
85 @Arg("_flag|y|Copyback pages before starting") final boolean copyback) throws Exception {
85 final BackupTask task = new BackupTask();86 final BackupTask task = new BackupTask();
86 task._toFile = file;87 task._toFile = file;
87 task._start = start;88 task._start = start;
@@ -103,7 +104,7 @@
103 protected void runTask() throws Exception {104 protected void runTask() throws Exception {
104 validate();105 validate();
105 final Management management = _persistit.getManagement();106 final Management management = _persistit.getManagement();
106 boolean wasAppendOnly = management.getJournalInfo().isAppendOnly();107 final boolean wasAppendOnly = management.getJournalInfo().isAppendOnly();
107 if (_checkpoint) {108 if (_checkpoint) {
108 postMessage("Waiting for checkpoint", 0);109 postMessage("Waiting for checkpoint", 0);
109 final Checkpoint cp = _persistit.checkpoint();110 final Checkpoint cp = _persistit.checkpoint();
@@ -115,9 +116,9 @@
115 }116 }
116 if (_copyback && !wasAppendOnly) {117 if (_copyback && !wasAppendOnly) {
117 postMessage("Copying back pages from journal", 0);118 postMessage("Copying back pages from journal", 0);
118 long start = _persistit.getJournalManager().getCopiedPageCount();119 final long start = _persistit.getJournalManager().getCopiedPageCount();
119 _persistit.copyBackPages();120 _persistit.copyBackPages();
120 long end = _persistit.getJournalManager().getCopiedPageCount();121 final long end = _persistit.getJournalManager().getCopiedPageCount();
121 postMessage((end - start) + " pages copied", 0);122 postMessage((end - start) + " pages copied", 0);
122 }123 }
123 try {124 try {
@@ -128,7 +129,7 @@
128 doBackup();129 doBackup();
129 }130 }
130 }131 }
131 } catch (Exception e) {132 } catch (final Exception e) {
132 _backupStatus = "Failed: " + e;133 _backupStatus = "Failed: " + e;
133 } finally {134 } finally {
134 management.setAppendOnly(_start ? true : _end ? false : wasAppendOnly);135 management.setAppendOnly(_start ? true : _end ? false : wasAppendOnly);
@@ -136,7 +137,7 @@
136 }137 }
137138
138 @Override139 @Override
139 protected void postMessage(final String message, int level) {140 protected void postMessage(final String message, final int level) {
140 super.postMessage(message, level);141 super.postMessage(message, level);
141 _backupStatus = message;142 _backupStatus = message;
142 }143 }
@@ -152,9 +153,9 @@
152 final long baseAddress = info.getBaseAddress();153 final long baseAddress = info.getBaseAddress();
153 final long currentAddress = info.getCurrentJournalAddress();154 final long currentAddress = info.getCurrentJournalAddress();
154 final long blockSize = info.getBlockSize();155 final long blockSize = info.getBlockSize();
155 String path = JournalManager.fileToPath(new File(info.getCurrentJournalFile()));156 final String path = JournalManager.fileToPath(new File(info.getCurrentJournalFile()));
156 for (long generation = baseAddress / blockSize; generation <= currentAddress / blockSize; generation++) {157 for (long generation = baseAddress / blockSize; generation <= currentAddress / blockSize; generation++) {
157 File file = JournalManager.generationToFile(path, generation);158 final File file = JournalManager.generationToFile(path, generation);
158 _files.add(file.getAbsolutePath());159 _files.add(file.getAbsolutePath());
159 }160 }
160 final StringBuilder sb = new StringBuilder();161 final StringBuilder sb = new StringBuilder();
161162
=== modified file 'src/main/java/com/persistit/Buffer.java'
--- src/main/java/com/persistit/Buffer.java 2012-08-02 04:45:28 +0000
+++ src/main/java/com/persistit/Buffer.java 2012-08-24 18:21:19 +0000
@@ -266,17 +266,18 @@
266266
267 abstract static class VerifyVisitor {267 abstract static class VerifyVisitor {
268268
269 protected void visitPage(long timestamp, Volume volume, long page, int type, int bufferSize, int keyBlockStart,269 protected void visitPage(final long timestamp, final Volume volume, final long page, final int type,
270 int keyBlockEnd, int alloc, int available, long rightSibling) throws PersistitException {270 final int bufferSize, final int keyBlockStart, final int keyBlockEnd, final int alloc,
271 }271 final int available, final long rightSibling) throws PersistitException {
272272 }
273 protected void visitIndexRecord(Key key, int foundAt, int tail, int kLength, long pointer)273
274 throws PersistitException {274 protected void visitIndexRecord(final Key key, final int foundAt, final int tail, final int kLength,
275275 final long pointer) throws PersistitException {
276 }276
277277 }
278 protected void visitDataRecord(Key key, int foundAt, int tail, int klength, int offset, int length, byte[] bytes)278
279 throws PersistitException {279 protected void visitDataRecord(final Key key, final int foundAt, final int tail, final int klength,
280 final int offset, final int length, final byte[] bytes) throws PersistitException {
280 }281 }
281 }282 }
282283
@@ -323,7 +324,7 @@
323 * The bytes in this buffer. Note these bytes are also the backing store of324 * The bytes in this buffer. Note these bytes are also the backing store of
324 * _byteBuffer.325 * _byteBuffer.
325 */326 */
326 private byte[] _bytes;327 private final byte[] _bytes;
327328
328 /**329 /**
329 * FastIndex structure used for rapid page searching330 * FastIndex structure used for rapid page searching
@@ -382,7 +383,7 @@
382 * @param size383 * @param size
383 * The buffer size, in bytes.384 * The buffer size, in bytes.
384 */385 */
385 Buffer(int size, int index, BufferPool pool, Persistit persistit) {386 Buffer(int size, final int index, final BufferPool pool, final Persistit persistit) {
386 super(persistit);387 super(persistit);
387 boolean ok = false;388 boolean ok = false;
388 for (int s = MIN_BUFFER_SIZE; !ok && s <= MAX_BUFFER_SIZE; s *= 2) {389 for (int s = MIN_BUFFER_SIZE; !ok && s <= MAX_BUFFER_SIZE; s *= 2) {
@@ -402,7 +403,7 @@
402 _fastIndex = new FastIndex(this, 1 + (size - HEADER_SIZE) / MAX_KEY_RATIO);403 _fastIndex = new FastIndex(this, 1 + (size - HEADER_SIZE) / MAX_KEY_RATIO);
403 }404 }
404405
405 Buffer(Buffer original) {406 Buffer(final Buffer original) {
406 this(original._bufferSize, original._poolIndex, original._pool, original._persistit);407 this(original._bufferSize, original._poolIndex, original._pool, original._persistit);
407 setStatus(original);408 setStatus(original);
408 _type = original._type;409 _type = original._type;
@@ -421,7 +422,7 @@
421 /**422 /**
422 * Initializes the buffer so that it contains no keys or data.423 * Initializes the buffer so that it contains no keys or data.
423 */424 */
424 void init(int type) {425 void init(final int type) {
425 _type = type;426 _type = type;
426 setKeyBlockEnd(KEY_BLOCK_START);427 setKeyBlockEnd(KEY_BLOCK_START);
427 _tailHeaderSize = isIndexPage() ? TAILBLOCK_HDR_SIZE_INDEX : TAILBLOCK_HDR_SIZE_DATA;428 _tailHeaderSize = isIndexPage() ? TAILBLOCK_HDR_SIZE_INDEX : TAILBLOCK_HDR_SIZE_DATA;
@@ -449,7 +450,7 @@
449 * @throws InUseException450 * @throws InUseException
450 * @throws PersistitInterruptedException451 * @throws PersistitInterruptedException
451 */452 */
452 void load(Volume vol, long page) throws PersistitIOException, InvalidPageAddressException,453 void load(final Volume vol, final long page) throws PersistitIOException, InvalidPageAddressException,
453 InvalidPageStructureException, VolumeClosedException, InUseException, PersistitInterruptedException {454 InvalidPageStructureException, VolumeClosedException, InUseException, PersistitInterruptedException {
454 _vol = vol;455 _vol = vol;
455 _page = page;456 _page = page;
@@ -463,7 +464,7 @@
463 _timestamp = getLong(TIMESTAMP_OFFSET);464 _timestamp = getLong(TIMESTAMP_OFFSET);
464465
465 if (_page != 0) {466 if (_page != 0) {
466 int type = getByte(TYPE_OFFSET);467 final int type = getByte(TYPE_OFFSET);
467 if (type > PAGE_TYPE_MAX) {468 if (type > PAGE_TYPE_MAX) {
468 throw new InvalidPageStructureException("Invalid type " + type);469 throw new InvalidPageStructureException("Invalid type " + type);
469 }470 }
@@ -519,6 +520,7 @@
519 }520 }
520 }521 }
521522
523 @Override
522 boolean clearDirty() {524 boolean clearDirty() {
523 if (super.clearDirty()) {525 if (super.clearDirty()) {
524 _pool.decrementDirtyPageCount();526 _pool.decrementDirtyPageCount();
@@ -527,6 +529,7 @@
527 return false;529 return false;
528 }530 }
529531
532 @Override
530 boolean setDirty() {533 boolean setDirty() {
531 throw new UnsupportedOperationException();534 throw new UnsupportedOperationException();
532 }535 }
@@ -543,12 +546,12 @@
543 }546 }
544547
545 @Override548 @Override
546 boolean claim(boolean writer) throws PersistitInterruptedException {549 boolean claim(final boolean writer) throws PersistitInterruptedException {
547 return claim(writer, DEFAULT_MAX_WAIT_TIME);550 return claim(writer, DEFAULT_MAX_WAIT_TIME);
548 }551 }
549552
550 @Override553 @Override
551 boolean claim(boolean writer, long timeout) throws PersistitInterruptedException {554 boolean claim(final boolean writer, final long timeout) throws PersistitInterruptedException {
552 if (super.claim(writer, timeout)) {555 if (super.claim(writer, timeout)) {
553 if (!isDirty()) {556 if (!isDirty()) {
554 _timestamp = _persistit.getCurrentTimestamp();557 _timestamp = _persistit.getCurrentTimestamp();
@@ -579,7 +582,7 @@
579 Util.clearBytes(_bytes, 0, _bufferSize);582 Util.clearBytes(_bytes, 0, _bufferSize);
580 }583 }
581584
582 void clearBytes(int from, int to) {585 void clearBytes(final int from, final int to) {
583 Util.clearBytes(_bytes, from, to);586 Util.clearBytes(_bytes, from, to);
584 }587 }
585588
@@ -733,7 +736,7 @@
733 * @param pageAddress736 * @param pageAddress
734 * the sibling's address737 * the sibling's address
735 */738 */
736 void setRightSibling(long pageAddress) {739 void setRightSibling(final long pageAddress) {
737 Debug.$assert0.t(isMine());740 Debug.$assert0.t(isMine());
738 _rightSibling = pageAddress;741 _rightSibling = pageAddress;
739 }742 }
@@ -803,15 +806,15 @@
803 * it follows the last key in the page.806 * it follows the last key in the page.
804 * @throws PersistitInterruptedException807 * @throws PersistitInterruptedException
805 */808 */
806 int findKey(Key key) throws PersistitInterruptedException {809 int findKey(final Key key) throws PersistitInterruptedException {
807 final FastIndex fastIndex = getFastIndex();810 final FastIndex fastIndex = getFastIndex();
808 byte[] kbytes = key.getEncodedBytes();811 final byte[] kbytes = key.getEncodedBytes();
809 int klength = key.getEncodedSize();812 final int klength = key.getEncodedSize();
810 int depth = 0;813 int depth = 0;
811 int left = KEY_BLOCK_START;814 int left = KEY_BLOCK_START;
812 int right = _keyBlockEnd;815 int right = _keyBlockEnd;
813 int start = left;816 final int start = left;
814 int tailHeaderSize = _tailHeaderSize;817 final int tailHeaderSize = _tailHeaderSize;
815818
816 for (int p = start; p < right;) {819 for (int p = start; p < right;) {
817 //820 //
@@ -820,7 +823,7 @@
820 int kbData = getInt(p);823 int kbData = getInt(p);
821 int index = (p - start) >> 2;824 int index = (p - start) >> 2;
822 int runCount = fastIndex.getRunCount(index);825 int runCount = fastIndex.getRunCount(index);
823 int ebc = decodeKeyBlockEbc(kbData);826 final int ebc = decodeKeyBlockEbc(kbData);
824827
825 if (depth < ebc) {828 if (depth < ebc) {
826 // We know that depth < ebc for a bunch of KeyBlocks - we829 // We know that depth < ebc for a bunch of KeyBlocks - we
@@ -836,7 +839,7 @@
836 }839 }
837840
838 else if (depth > ebc) {841 else if (depth > ebc) {
839 int result = p | (depth << DEPTH_SHIFT);842 final int result = p | (depth << DEPTH_SHIFT);
840 return result;843 return result;
841 }844 }
842845
@@ -847,7 +850,7 @@
847 int kb = kbytes[depth] & 0xFF;850 int kb = kbytes[depth] & 0xFF;
848851
849 if (kb < db) {852 if (kb < db) {
850 int result = p | (depth << DEPTH_SHIFT);853 final int result = p | (depth << DEPTH_SHIFT);
851 return result;854 return result;
852 }855 }
853 if (kb > db) {856 if (kb > db) {
@@ -858,13 +861,13 @@
858 // either do a linear search or perform a binary search861 // either do a linear search or perform a binary search
859 // within the run.862 // within the run.
860 //863 //
861 int p2 = p + (runCount * KEYBLOCK_LENGTH);864 final int p2 = p + (runCount * KEYBLOCK_LENGTH);
862 //865 //
863 // p2 now points to the last key block with the same866 // p2 now points to the last key block with the same
864 // ebc in this run.867 // ebc in this run.
865 //868 //
866 int kbData2 = getInt(p2);869 final int kbData2 = getInt(p2);
867 int db2 = decodeKeyBlockDb(kbData2);870 final int db2 = decodeKeyBlockDb(kbData2);
868 //871 //
869 // For the common case that runCount == 1, we avoid872 // For the common case that runCount == 1, we avoid
870 // setting up the binary search loop. Instead, the873 // setting up the binary search loop. Instead, the
@@ -877,7 +880,7 @@
877 // This is right because we already know880 // This is right because we already know
878 // that kb > db.881 // that kb > db.
879 //882 //
880 int result = p2 | (depth << DEPTH_SHIFT);883 final int result = p2 | (depth << DEPTH_SHIFT);
881 return result;884 return result;
882 } else if (db2 < kb) {885 } else if (db2 < kb) {
883 //886 //
@@ -888,7 +891,7 @@
888 // -891 // -
889 // in that case we use the cross count to skip892 // in that case we use the cross count to skip
890 // all of them.893 // all of them.
891 int runCount2 = fastIndex.getRunCount(index + runCount);894 final int runCount2 = fastIndex.getRunCount(index + runCount);
892 assert runCount2 <= 0;895 assert runCount2 <= 0;
893 p = p2 + KEYBLOCK_LENGTH * (-runCount + 1);896 p = p2 + KEYBLOCK_LENGTH * (-runCount + 1);
894 continue;897 continue;
@@ -921,8 +924,8 @@
921 // we are seeking.924 // we are seeking.
922 //925 //
923 if (runCount > BINARY_SEARCH_THRESHOLD) {926 if (runCount > BINARY_SEARCH_THRESHOLD) {
924 int distance = (right - left) >> 2;927 final int distance = (right - left) >> 2;
925 int oldRight = right;928 final int oldRight = right;
926 if (distance > kb - db + 1) {929 if (distance > kb - db + 1) {
927 right = left + ((kb - db + 1) << 2);930 right = left + ((kb - db + 1) << 2);
928 }931 }
@@ -942,7 +945,7 @@
942 // that kb > db and less than db2, so the945 // that kb > db and less than db2, so the
943 // final answer is know to be in right.946 // final answer is know to be in right.
944 //947 //
945 int result = right | (depth << DEPTH_SHIFT);948 final int result = right | (depth << DEPTH_SHIFT);
946 return result;949 return result;
947 }950 }
948 //951 //
@@ -950,7 +953,7 @@
950 // mid-point and953 // mid-point and
951 // adjust the ends depending on the comparison.954 // adjust the ends depending on the comparison.
952 //955 //
953 int db1 = getDb(p);956 final int db1 = getDb(p);
954957
955 if (db1 == kb) {958 if (db1 == kb) {
956 db = db1;959 db = db1;
@@ -998,10 +1001,10 @@
998 // for each byte in the key.1001 // for each byte in the key.
999 //1002 //
1000 kbData = getInt(p);1003 kbData = getInt(p);
1001 int tail = decodeKeyBlockTail(kbData);1004 final int tail = decodeKeyBlockTail(kbData);
1002 int tbData = getInt(tail);1005 final int tbData = getInt(tail);
1003 int tlength = decodeTailBlockKLength(tbData) + depth + 1;1006 final int tlength = decodeTailBlockKLength(tbData) + depth + 1;
1004 int qlength = tlength < klength ? tlength : klength;1007 final int qlength = tlength < klength ? tlength : klength;
1005 //1008 //
1006 // Walk down the key, increasing depth1009 // Walk down the key, increasing depth
1007 //1010 //
@@ -1025,7 +1028,7 @@
1025 // Key is less than tail, so we return1028 // Key is less than tail, so we return
1026 // this keyblock1029 // this keyblock
1027 //1030 //
1028 int result = p | (depth << DEPTH_SHIFT) | FIXUP_MASK;1031 final int result = p | (depth << DEPTH_SHIFT) | FIXUP_MASK;
1029 return result;1032 return result;
1030 }1033 }
1031 matched = false;1034 matched = false;
@@ -1045,7 +1048,7 @@
1045 // And the key lengths are equal so this is an1048 // And the key lengths are equal so this is an
1046 // exact match.1049 // exact match.
1047 //1050 //
1048 int result = p | (depth << DEPTH_SHIFT) | EXACT_MASK;1051 final int result = p | (depth << DEPTH_SHIFT) | EXACT_MASK;
1049 return result;1052 return result;
1050 }1053 }
1051 } else if (tlength > qlength) {1054 } else if (tlength > qlength) {
@@ -1054,7 +1057,7 @@
1054 // key is less than tail, so we return the1057 // key is less than tail, so we return the
1055 // this keyblock since it is greater than the key1058 // this keyblock since it is greater than the key
1056 //1059 //
1057 int result = p | (depth << DEPTH_SHIFT) | FIXUP_MASK;1060 final int result = p | (depth << DEPTH_SHIFT) | FIXUP_MASK;
1058 return result;1061 return result;
1059 }1062 }
1060 // Otherwise, the key is longer, so we move to the next1063 // Otherwise, the key is longer, so we move to the next
@@ -1066,7 +1069,7 @@
10661069
1067 }1070 }
10681071
1069 int result = right | (depth << DEPTH_SHIFT);1072 final int result = right | (depth << DEPTH_SHIFT);
1070 return result;1073 return result;
1071 }1074 }
10721075
@@ -1074,13 +1077,13 @@
1074 if (isDataPage()) {1077 if (isDataPage()) {
1075 final int p = foundAt & P_MASK;1078 final int p = foundAt & P_MASK;
1076 if (p >= KEY_BLOCK_START && p < _keyBlockEnd) {1079 if (p >= KEY_BLOCK_START && p < _keyBlockEnd) {
1077 int kbData = getInt(p);1080 final int kbData = getInt(p);
1078 int tail = decodeKeyBlockTail(kbData);1081 final int tail = decodeKeyBlockTail(kbData);
1079 int tbData = getInt(tail);1082 final int tbData = getInt(tail);
1080 int klength = decodeTailBlockKLength(tbData);1083 final int klength = decodeTailBlockKLength(tbData);
1081 int size = decodeTailBlockSize(tbData);1084 final int size = decodeTailBlockSize(tbData);
1082 int offset = tail + _tailHeaderSize + klength;1085 final int offset = tail + _tailHeaderSize + klength;
1083 int valueSize = size - klength - _tailHeaderSize;1086 final int valueSize = size - klength - _tailHeaderSize;
1084 return valueSize == 1 && _bytes[offset] == MVV.TYPE_ANTIVALUE;1087 return valueSize == 1 && _bytes[offset] == MVV.TYPE_ANTIVALUE;
1085 }1088 }
1086 }1089 }
@@ -1099,13 +1102,13 @@
1099 if (isDataPage() || isIndexPage()) {1102 if (isDataPage() || isIndexPage()) {
1100 final int p = foundAt & P_MASK;1103 final int p = foundAt & P_MASK;
1101 if (p >= KEY_BLOCK_START && p < _keyBlockEnd) {1104 if (p >= KEY_BLOCK_START && p < _keyBlockEnd) {
1102 int kbData = getInt(p);1105 final int kbData = getInt(p);
1103 int tail = decodeKeyBlockTail(kbData);1106 final int tail = decodeKeyBlockTail(kbData);
1104 int tbData = getInt(tail);1107 final int tbData = getInt(tail);
1105 int klength = decodeTailBlockKLength(tbData);1108 final int klength = decodeTailBlockKLength(tbData);
1106 int size = decodeTailBlockSize(tbData);1109 final int size = decodeTailBlockSize(tbData);
1107 int offset = tail + _tailHeaderSize + klength;1110 final int offset = tail + _tailHeaderSize + klength;
1108 int valueSize = size - klength - _tailHeaderSize;1111 final int valueSize = size - klength - _tailHeaderSize;
1109 return ((long) offset) << 32 | valueSize;1112 return ((long) offset) << 32 | valueSize;
1110 }1113 }
1111 }1114 }
@@ -1116,13 +1119,13 @@
1116 Debug.$assert0.t(foundAt > 0 && foundAt < _keyBlockEnd);1119 Debug.$assert0.t(foundAt > 0 && foundAt < _keyBlockEnd);
1117 if (isDataPage() || isIndexPage()) {1120 if (isDataPage() || isIndexPage()) {
1118 for (int p = KEY_BLOCK_START; p <= foundAt; p += KEYBLOCK_LENGTH) {1121 for (int p = KEY_BLOCK_START; p <= foundAt; p += KEYBLOCK_LENGTH) {
1119 int kbData = getInt(p);1122 final int kbData = getInt(p);
1120 int tail = decodeKeyBlockTail(kbData);1123 final int tail = decodeKeyBlockTail(kbData);
1121 int ebc = decodeKeyBlockEbc(kbData);1124 final int ebc = decodeKeyBlockEbc(kbData);
1122 int db = decodeKeyBlockDb(kbData);1125 final int db = decodeKeyBlockDb(kbData);
1123 int tbData = getInt(tail);1126 final int tbData = getInt(tail);
1124 int klength = decodeTailBlockKLength(tbData);1127 final int klength = decodeTailBlockKLength(tbData);
1125 byte[] keyBytes = key.getEncodedBytes();1128 final byte[] keyBytes = key.getEncodedBytes();
1126 keyBytes[ebc] = (byte) db;1129 keyBytes[ebc] = (byte) db;
1127 System.arraycopy(_bytes, tail + _tailHeaderSize, keyBytes, ebc + 1, klength);1130 System.arraycopy(_bytes, tail + _tailHeaderSize, keyBytes, ebc + 1, klength);
1128 key.setEncodedSize(ebc + klength + 1);1131 key.setEncodedSize(ebc + klength + 1);
@@ -1130,32 +1133,32 @@
1130 }1133 }
1131 }1134 }
11321135
1133 Value fetch(int foundAt, Value value) {1136 Value fetch(final int foundAt, final Value value) {
1134 if ((foundAt & EXACT_MASK) == 0) {1137 if ((foundAt & EXACT_MASK) == 0) {
1135 value.clear();1138 value.clear();
1136 } else {1139 } else {
1137 Debug.$assert0.t(foundAt > 0 && (foundAt & P_MASK) < _keyBlockEnd);1140 Debug.$assert0.t(foundAt > 0 && (foundAt & P_MASK) < _keyBlockEnd);
1138 int kbData = getInt(foundAt & P_MASK);1141 final int kbData = getInt(foundAt & P_MASK);
1139 int tail = decodeKeyBlockTail(kbData);1142 final int tail = decodeKeyBlockTail(kbData);
1140 int tbData = getInt(tail);1143 final int tbData = getInt(tail);
1141 int klength = decodeTailBlockKLength(tbData);1144 final int klength = decodeTailBlockKLength(tbData);
1142 int size = decodeTailBlockSize(tbData);1145 final int size = decodeTailBlockSize(tbData);
1143 int valueSize = size - klength - _tailHeaderSize;1146 final int valueSize = size - klength - _tailHeaderSize;
1144 value.putEncodedBytes(_bytes, tail + _tailHeaderSize + klength, valueSize);1147 value.putEncodedBytes(_bytes, tail + _tailHeaderSize + klength, valueSize);
1145 }1148 }
1146 return value;1149 return value;
1147 }1150 }
11481151
1149 long fetchLongRecordPointer(int foundAt) {1152 long fetchLongRecordPointer(final int foundAt) {
1150 if (!isDataPage()) {1153 if (!isDataPage()) {
1151 return 0;1154 return 0;
1152 }1155 }
1153 int kbData = getInt(foundAt & P_MASK);1156 final int kbData = getInt(foundAt & P_MASK);
1154 int tail = decodeKeyBlockTail(kbData);1157 final int tail = decodeKeyBlockTail(kbData);
1155 int tbData = getInt(tail);1158 final int tbData = getInt(tail);
1156 int klength = decodeTailBlockKLength(tbData);1159 final int klength = decodeTailBlockKLength(tbData);
1157 int size = decodeTailBlockSize(tbData);1160 final int size = decodeTailBlockSize(tbData);
1158 int valueSize = size - klength - _tailHeaderSize;1161 final int valueSize = size - klength - _tailHeaderSize;
1159 if (valueSize != LONGREC_SIZE) {1162 if (valueSize != LONGREC_SIZE) {
1160 return 0;1163 return 0;
1161 }1164 }
@@ -1163,16 +1166,16 @@
1163 return 0;1166 return 0;
1164 }1167 }
11651168
1166 long pointer = getLong(tail + _tailHeaderSize + klength + LONGREC_PAGE_OFFSET);1169 final long pointer = getLong(tail + _tailHeaderSize + klength + LONGREC_PAGE_OFFSET);
1167 return pointer;1170 return pointer;
1168 }1171 }
11691172
1170 long getPointer(int foundAt) throws PersistitException {1173 long getPointer(final int foundAt) throws PersistitException {
1171 if (!isIndexPage()) {1174 if (!isIndexPage()) {
1172 throw new InvalidPageTypeException("type=" + _type);1175 throw new InvalidPageTypeException("type=" + _type);
1173 }1176 }
1174 int kbData = getInt(foundAt & P_MASK);1177 final int kbData = getInt(foundAt & P_MASK);
1175 int tail = decodeKeyBlockTail(kbData);1178 final int tail = decodeKeyBlockTail(kbData);
1176 return getInt(tail + 4);1179 return getInt(tail + 4);
1177 }1180 }
11781181
@@ -1185,8 +1188,8 @@
1185 * @param foundAt1188 * @param foundAt
1186 * @return1189 * @return
1187 */1190 */
1188 int traverse(Key key, Key.Direction mode, int foundAt) {1191 int traverse(final Key key, final Key.Direction mode, final int foundAt) {
1189 boolean exactMatch = (foundAt & EXACT_MASK) > 0;1192 final boolean exactMatch = (foundAt & EXACT_MASK) > 0;
1190 if (mode == Key.EQ || exactMatch && (mode == Key.LTEQ || mode == Key.GTEQ)) {1193 if (mode == Key.EQ || exactMatch && (mode == Key.LTEQ || mode == Key.GTEQ)) {
1191 return foundAt;1194 return foundAt;
1192 }1195 }
@@ -1205,21 +1208,21 @@
1205 * @param foundAt1208 * @param foundAt
1206 * @return1209 * @return
1207 */1210 */
1208 int previousKey(Key key, int foundAt) {1211 int previousKey(final Key key, final int foundAt) {
1209 int p = (foundAt & P_MASK) - KEYBLOCK_LENGTH;1212 int p = (foundAt & P_MASK) - KEYBLOCK_LENGTH;
1210 int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT;1213 final int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT;
12111214
1212 if (p < KEY_BLOCK_START)1215 if (p < KEY_BLOCK_START)
1213 return foundAt;1216 return foundAt;
12141217
1215 byte[] kbytes = key.getEncodedBytes();1218 final byte[] kbytes = key.getEncodedBytes();
12161219
1217 // Compute the count of prefix bytes in the supplied key that1220 // Compute the count of prefix bytes in the supplied key that
1218 // are known to match. The leftmost knownGood bytes do not need1221 // are known to match. The leftmost knownGood bytes do not need
1219 // to be recovered by traversing keys in the page.1222 // to be recovered by traversing keys in the page.
1220 //1223 //
1221 int kbData2 = getInt(p + KEYBLOCK_LENGTH);1224 final int kbData2 = getInt(p + KEYBLOCK_LENGTH);
1222 int ebc2 = decodeKeyBlockEbc(kbData2);1225 final int ebc2 = decodeKeyBlockEbc(kbData2);
1223 int kbData = getInt(p);1226 int kbData = getInt(p);
1224 int ebc = decodeKeyBlockEbc(kbData);1227 int ebc = decodeKeyBlockEbc(kbData);
1225 int knownGood = ebc;1228 int knownGood = ebc;
@@ -1244,7 +1247,7 @@
1244 int unknown = decodeTailBlockKLength(getInt(tail)) + ebc + 1;1247 int unknown = decodeTailBlockKLength(getInt(tail)) + ebc + 1;
1245 key.setEncodedSize(unknown);1248 key.setEncodedSize(unknown);
12461249
1247 int result = p | (unknown << DEPTH_SHIFT) | EXACT_MASK;1250 final int result = p | (unknown << DEPTH_SHIFT) | EXACT_MASK;
1248 //1251 //
1249 // Reconstruct the previous key.1252 // Reconstruct the previous key.
1250 //1253 //
@@ -1252,7 +1255,7 @@
1252 if (ebc < unknown) {1255 if (ebc < unknown) {
1253 // move bytes from this keyblock into the result key.1256 // move bytes from this keyblock into the result key.
1254 kbytes[ebc] = (byte) decodeKeyBlockDb(kbData);1257 kbytes[ebc] = (byte) decodeKeyBlockDb(kbData);
1255 int more = unknown - ebc - 1;1258 final int more = unknown - ebc - 1;
1256 if (more > 0) {1259 if (more > 0) {
1257 System.arraycopy(_bytes, tail + _tailHeaderSize, kbytes, ebc + 1, more);1260 System.arraycopy(_bytes, tail + _tailHeaderSize, kbytes, ebc + 1, more);
1258 }1261 }
@@ -1278,7 +1281,7 @@
1278 * @param foundAt1281 * @param foundAt
1279 * @return1282 * @return
1280 */1283 */
1281 int nextKey(Key key, int foundAt) {1284 int nextKey(final Key key, final int foundAt) {
1282 int p = foundAt & P_MASK;1285 int p = foundAt & P_MASK;
1283 if ((foundAt & EXACT_MASK) != 0)1286 if ((foundAt & EXACT_MASK) != 0)
1284 p += KEYBLOCK_LENGTH;1287 p += KEYBLOCK_LENGTH;
@@ -1286,16 +1289,16 @@
1286 if (p >= _keyBlockEnd)1289 if (p >= _keyBlockEnd)
1287 return foundAt;1290 return foundAt;
12881291
1289 byte[] kbytes = key.getEncodedBytes();1292 final byte[] kbytes = key.getEncodedBytes();
1290 int kbData = getInt(p);1293 final int kbData = getInt(p);
1291 int ebc = decodeKeyBlockEbc(kbData);1294 final int ebc = decodeKeyBlockEbc(kbData);
1292 int tail = decodeKeyBlockTail(kbData);1295 final int tail = decodeKeyBlockTail(kbData);
1293 int tbData = getInt(tail);1296 final int tbData = getInt(tail);
1294 int klength = decodeTailBlockKLength(tbData);1297 final int klength = decodeTailBlockKLength(tbData);
1295 int keyLength = klength + ebc + 1;1298 final int keyLength = klength + ebc + 1;
1296 key.setEncodedSize(keyLength);1299 key.setEncodedSize(keyLength);
12971300
1298 int result = p | (keyLength << DEPTH_SHIFT) | EXACT_MASK;1301 final int result = p | (keyLength << DEPTH_SHIFT) | EXACT_MASK;
1299 //1302 //
1300 // Note: the findKey method is guaranteed to return the offset of a1303 // Note: the findKey method is guaranteed to return the offset of a
1301 // keyblock whose first ebc bytes match the supplied key.1304 // keyblock whose first ebc bytes match the supplied key.
@@ -1313,15 +1316,15 @@
1313 * @param foundAt1316 * @param foundAt
1314 * @return1317 * @return
1315 */1318 */
1316 int nextLongRecord(Value value, int foundAt) {1319 int nextLongRecord(final Value value, final int foundAt) {
1317 Debug.$assert0.t(isDataPage());1320 Debug.$assert0.t(isDataPage());
1318 for (int p = foundAt & P_MASK; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) {1321 for (int p = foundAt & P_MASK; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) {
1319 int kbData = getInt(p);1322 final int kbData = getInt(p);
1320 int tail = decodeKeyBlockTail(kbData);1323 final int tail = decodeKeyBlockTail(kbData);
1321 int tbData = getInt(tail);1324 final int tbData = getInt(tail);
1322 int klength = decodeTailBlockKLength(tbData);1325 final int klength = decodeTailBlockKLength(tbData);
1323 int size = decodeTailBlockSize(tbData);1326 final int size = decodeTailBlockSize(tbData);
1324 int valueSize = size - klength - _tailHeaderSize;1327 final int valueSize = size - klength - _tailHeaderSize;
1325 if ((valueSize > 0) && ((_bytes[tail + _tailHeaderSize + klength] & 0xFF) == LONGREC_TYPE)) {1328 if ((valueSize > 0) && ((_bytes[tail + _tailHeaderSize + klength] & 0xFF) == LONGREC_TYPE)) {
1326 value.putEncodedBytes(_bytes, tail + _tailHeaderSize + klength, valueSize);1329 value.putEncodedBytes(_bytes, tail + _tailHeaderSize + klength, valueSize);
1327 return p;1330 return p;
@@ -1330,15 +1333,15 @@
1330 return -1;1333 return -1;
1331 }1334 }
13321335
1333 int previousKeyBlock(int foundAt) {1336 int previousKeyBlock(final int foundAt) {
1334 int p = (foundAt & P_MASK) - KEYBLOCK_LENGTH;1337 final int p = (foundAt & P_MASK) - KEYBLOCK_LENGTH;
1335 if (p < KEY_BLOCK_START || p > _keyBlockEnd)1338 if (p < KEY_BLOCK_START || p > _keyBlockEnd)
1336 return -1;1339 return -1;
1337 return p;1340 return p;
1338 }1341 }
13391342
1340 int nextKeyBlock(int foundAt) {1343 int nextKeyBlock(final int foundAt) {
1341 int p = (foundAt & P_MASK) + KEYBLOCK_LENGTH;1344 final int p = (foundAt & P_MASK) + KEYBLOCK_LENGTH;
1342 if (p >= _keyBlockEnd || p < KEY_BLOCK_START)1345 if (p >= _keyBlockEnd || p < KEY_BLOCK_START)
1343 return -1;1346 return -1;
1344 return p;1347 return p;
@@ -1366,8 +1369,8 @@
1366 * The value, converted to a byte array1369 * The value, converted to a byte array
1367 * @throws PersistitInterruptedException1370 * @throws PersistitInterruptedException
1368 */1371 */
1369 int putValue(Key key, ValueHelper valueHelper) throws PersistitInterruptedException {1372 int putValue(final Key key, final ValueHelper valueHelper) throws PersistitInterruptedException {
1370 int p = findKey(key);1373 final int p = findKey(key);
1371 return putValue(key, valueHelper, p, false);1374 return putValue(key, valueHelper, p, false);
1372 }1375 }
13731376
@@ -1383,13 +1386,13 @@
1383 * @param foundAt1386 * @param foundAt
1384 * The keyblock before which this record will be inserted1387 * The keyblock before which this record will be inserted
1385 */1388 */
1386 int putValue(Key key, ValueHelper valueHelper, int foundAt, boolean postSplit) {1389 int putValue(final Key key, final ValueHelper valueHelper, final int foundAt, final boolean postSplit) {
1387 if (Debug.ENABLED) {1390 if (Debug.ENABLED) {
1388 assertVerify();1391 assertVerify();
1389 }1392 }
13901393
1391 boolean exactMatch = (foundAt & EXACT_MASK) > 0;1394 final boolean exactMatch = (foundAt & EXACT_MASK) > 0;
1392 int p = foundAt & P_MASK;1395 final int p = foundAt & P_MASK;
13931396
1394 if (exactMatch) {1397 if (exactMatch) {
1395 return replaceValue(key, valueHelper, p);1398 return replaceValue(key, valueHelper, p);
@@ -1401,9 +1404,9 @@
1401 length = valueHelper.requiredLength(_bytes, 0, -1);1404 length = valueHelper.requiredLength(_bytes, 0, -1);
1402 }1405 }
14031406
1404 int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT;1407 final int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT;
1405 boolean fixupSuccessor = (foundAt & FIXUP_MASK) > 0;1408 final boolean fixupSuccessor = (foundAt & FIXUP_MASK) > 0;
1406 byte[] kbytes = key.getEncodedBytes();1409 final byte[] kbytes = key.getEncodedBytes();
14071410
1408 int ebcNew;1411 int ebcNew;
1409 int ebcSuccessor;1412 int ebcSuccessor;
@@ -1429,8 +1432,8 @@
1429 ebcSuccessor = 0;1432 ebcSuccessor = 0;
1430 ebcNew = depth;1433 ebcNew = depth;
1431 }1434 }
1432 int klength = key.getEncodedSize() - ebcNew - 1;1435 final int klength = key.getEncodedSize() - ebcNew - 1;
1433 int newTailSize = klength + length + _tailHeaderSize;1436 final int newTailSize = klength + length + _tailHeaderSize;
14341437
1435 if (getKeyCount() >= _pool.getMaxKeys() || !willFit(newTailSize + KEYBLOCK_LENGTH - (free1 - free2))) {1438 if (getKeyCount() >= _pool.getMaxKeys() || !willFit(newTailSize + KEYBLOCK_LENGTH - (free1 - free2))) {
1436 Debug.$assert0.t(!postSplit);1439 Debug.$assert0.t(!postSplit);
@@ -1443,8 +1446,8 @@
1443 // is correct.1446 // is correct.
1444 //1447 //
1445 if (fixupSuccessor && ebcNew != ebcSuccessor) {1448 if (fixupSuccessor && ebcNew != ebcSuccessor) {
1446 int successorKeyLength = decodeTailBlockKLength(successorTailBlock);1449 final int successorKeyLength = decodeTailBlockKLength(successorTailBlock);
1447 int successorDb = getByte(successorTail + _tailHeaderSize + delta - 1);1450 final int successorDb = getByte(successorTail + _tailHeaderSize + delta - 1);
14481451
1449 // Write updated successor tail block1452 // Write updated successor tail block
1450 putInt(successorTail, encodeTailBlock(successorTailSize - delta, successorKeyLength - delta));1453 putInt(successorTail, encodeTailBlock(successorTailSize - delta, successorKeyLength - delta));
@@ -1460,7 +1463,7 @@
14601463
1461 putInt(p, kbSuccessor);1464 putInt(p, kbSuccessor);
1462 }1465 }
1463 int dbNew = kbytes[ebcNew] & 0xFF;1466 final int dbNew = kbytes[ebcNew] & 0xFF;
1464 //1467 //
1465 // Allocate space for the new tail block1468 // Allocate space for the new tail block
1466 //1469 //
@@ -1481,7 +1484,7 @@
1481 System.arraycopy(_bytes, p, _bytes, p + KEYBLOCK_LENGTH, _keyBlockEnd - p - KEYBLOCK_LENGTH);1484 System.arraycopy(_bytes, p, _bytes, p + KEYBLOCK_LENGTH, _keyBlockEnd - p - KEYBLOCK_LENGTH);
14821485
1483 // Write new key block1486 // Write new key block
1484 int newKeyBlock = encodeKeyBlock(ebcNew, dbNew, newTail);1487 final int newKeyBlock = encodeKeyBlock(ebcNew, dbNew, newTail);
1485 putInt(p, newKeyBlock);1488 putInt(p, newKeyBlock);
14861489
1487 // Write new tail block1490 // Write new tail block
@@ -1493,12 +1496,12 @@
1493 System.arraycopy(kbytes, ebcNew + 1, _bytes, newTail + _tailHeaderSize, klength);1496 System.arraycopy(kbytes, ebcNew + 1, _bytes, newTail + _tailHeaderSize, klength);
14941497
1495 if (isIndexPage()) {1498 if (isIndexPage()) {
1496 int pointer = (int) valueHelper.getPointerValue();1499 final int pointer = (int) valueHelper.getPointerValue();
14971500
1498 Debug.$assert0.t(p + KEYBLOCK_LENGTH < _keyBlockEnd ? pointer > 0 : true);1501 Debug.$assert0.t(p + KEYBLOCK_LENGTH < _keyBlockEnd ? pointer > 0 : true);
1499 putInt(newTail + TAILBLOCK_POINTER, pointer);1502 putInt(newTail + TAILBLOCK_POINTER, pointer);
1500 } else {1503 } else {
1501 int storedLength = valueHelper.storeVersion(_bytes, newTail + _tailHeaderSize + klength, -1,1504 final int storedLength = valueHelper.storeVersion(_bytes, newTail + _tailHeaderSize + klength, -1,
1502 _bytes.length); // TODO limit1505 _bytes.length); // TODO limit
1503 incCountIfMvv(_bytes, newTail + _tailHeaderSize + klength, storedLength & MVV.STORE_LENGTH_MASK);1506 incCountIfMvv(_bytes, newTail + _tailHeaderSize + klength, storedLength & MVV.STORE_LENGTH_MASK);
1504 }1507 }
@@ -1532,12 +1535,12 @@
1532 */1535 */
1533 private boolean adjacentKeyCheck(int p) {1536 private boolean adjacentKeyCheck(int p) {
1534 p &= P_MASK;1537 p &= P_MASK;
1535 int kbData1 = getInt(p);1538 final int kbData1 = getInt(p);
1536 int kbData2 = getInt(p + KEYBLOCK_LENGTH);1539 final int kbData2 = getInt(p + KEYBLOCK_LENGTH);
1537 int db1 = decodeKeyBlockDb(kbData1);1540 final int db1 = decodeKeyBlockDb(kbData1);
1538 int ebc1 = decodeKeyBlockEbc(kbData1);1541 final int ebc1 = decodeKeyBlockEbc(kbData1);
1539 int db2 = decodeKeyBlockDb(kbData2);1542 final int db2 = decodeKeyBlockDb(kbData2);
1540 int ebc2 = decodeKeyBlockEbc(kbData2);1543 final int ebc2 = decodeKeyBlockEbc(kbData2);
15411544
1542 if (db1 == 0 && p > KEY_BLOCK_START) {1545 if (db1 == 0 && p > KEY_BLOCK_START) {
1543 return false; // Can set breakpoint here1546 return false; // Can set breakpoint here
@@ -1551,9 +1554,9 @@
1551 if (ebc2 < ebc1)1554 if (ebc2 < ebc1)
1552 return true;1555 return true;
1553 if (ebc2 > ebc1) {1556 if (ebc2 > ebc1) {
1554 int tail1 = decodeKeyBlockTail(kbData1);1557 final int tail1 = decodeKeyBlockTail(kbData1);
1555 int tbData1 = getInt(tail1);1558 final int tbData1 = getInt(tail1);
1556 int klength1 = decodeTailBlockKLength(tbData1);1559 final int klength1 = decodeTailBlockKLength(tbData1);
1557 int db = -1;1560 int db = -1;
1558 if (klength1 >= ebc2 - ebc1) {1561 if (klength1 >= ebc2 - ebc1) {
1559 db = _bytes[tail1 + _tailHeaderSize + ebc2 - ebc1 - 1] & DB_MASK;1562 db = _bytes[tail1 + _tailHeaderSize + ebc2 - ebc1 - 1] & DB_MASK;
@@ -1569,12 +1572,12 @@
1569 return false; // Can set breakpoint here1572 return false; // Can set breakpoint here
1570 }1573 }
15711574
1572 private int replaceValue(Key key, ValueHelper valueHelper, int p) {1575 private int replaceValue(final Key key, final ValueHelper valueHelper, final int p) {
1573 int kbData = getInt(p);1576 final int kbData = getInt(p);
1574 int tail = decodeKeyBlockTail(kbData);1577 final int tail = decodeKeyBlockTail(kbData);
1575 int tbData = getInt(tail);1578 final int tbData = getInt(tail);
1576 int klength = decodeTailBlockKLength(tbData);1579 final int klength = decodeTailBlockKLength(tbData);
1577 int oldTailSize = decodeTailBlockSize(tbData);1580 final int oldTailSize = decodeTailBlockSize(tbData);
1578 boolean wasMVV = false;1581 boolean wasMVV = false;
1579 boolean isMVV = false;1582 boolean isMVV = false;
15801583
@@ -1587,9 +1590,9 @@
1587 wasMVV = isValueMVV(_bytes, tail + _tailHeaderSize + klength, oldTailSize - _tailHeaderSize - klength);1590 wasMVV = isValueMVV(_bytes, tail + _tailHeaderSize + klength, oldTailSize - _tailHeaderSize - klength);
1588 }1591 }
15891592
1590 int newTailSize = klength + length + _tailHeaderSize;1593 final int newTailSize = klength + length + _tailHeaderSize;
1591 int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;1594 final int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
1592 int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;1595 final int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
1593 int newTail = tail;1596 int newTail = tail;
1594 if (newNext < oldNext) {1597 if (newNext < oldNext) {
1595 // Free the remainder of the old tail block1598 // Free the remainder of the old tail block
@@ -1622,7 +1625,7 @@
1622 }1625 }
16231626
1624 if (isIndexPage()) {1627 if (isIndexPage()) {
1625 long pointer = valueHelper.getPointerValue();1628 final long pointer = valueHelper.getPointerValue();
1626 Debug.$assert0.t(p + KEYBLOCK_LENGTH < _keyBlockEnd ? pointer > 0 : pointer == -1);1629 Debug.$assert0.t(p + KEYBLOCK_LENGTH < _keyBlockEnd ? pointer > 0 : pointer == -1);
1627 putInt(newTail + TAILBLOCK_POINTER, (int) pointer);1630 putInt(newTail + TAILBLOCK_POINTER, (int) pointer);
1628 } else {1631 } else {
@@ -1658,11 +1661,11 @@
1658 * @return <i>true</i> if the key was found and the value removed, else1661 * @return <i>true</i> if the key was found and the value removed, else
1659 * <i>false</i>1662 * <i>false</i>
1660 */1663 */
1661 boolean removeKeys(int foundAt1, int foundAt2, Key spareKey) {1664 boolean removeKeys(final int foundAt1, final int foundAt2, final Key spareKey) {
1662 if (Debug.ENABLED) {1665 if (Debug.ENABLED) {
1663 assertVerify();1666 assertVerify();
1664 }1667 }
1665 int p1 = foundAt1 & P_MASK;1668 final int p1 = foundAt1 & P_MASK;
1666 int p2 = foundAt2 & P_MASK;1669 int p2 = foundAt2 & P_MASK;
1667 if ((foundAt2 & EXACT_MASK) != 0)1670 if ((foundAt2 & EXACT_MASK) != 0)
1668 p2 += KEYBLOCK_LENGTH;1671 p2 += KEYBLOCK_LENGTH;
@@ -1675,24 +1678,24 @@
16751678
1676 int ebc = Integer.MAX_VALUE;1679 int ebc = Integer.MAX_VALUE;
16771680
1678 byte[] spareBytes = spareKey.getEncodedBytes();1681 final byte[] spareBytes = spareKey.getEncodedBytes();
1679 int keySize = 0;1682 int keySize = 0;
1680 for (int p = p1; p < p2; p += KEYBLOCK_LENGTH) {1683 for (int p = p1; p < p2; p += KEYBLOCK_LENGTH) {
1681 int kbData = getInt(p);1684 final int kbData = getInt(p);
1682 int ebcCandidate = decodeKeyBlockEbc(kbData);1685 final int ebcCandidate = decodeKeyBlockEbc(kbData);
1683 if (ebcCandidate < ebc) {1686 if (ebcCandidate < ebc) {
1684 ebc = ebcCandidate;1687 ebc = ebcCandidate;
1685 }1688 }
1686 int db = decodeKeyBlockDb(kbData);1689 final int db = decodeKeyBlockDb(kbData);
1687 int tail = decodeKeyBlockTail(kbData);1690 final int tail = decodeKeyBlockTail(kbData);
1688 int tbData = getInt(tail);1691 final int tbData = getInt(tail);
1689 int klength = decodeTailBlockKLength(tbData);1692 final int klength = decodeTailBlockKLength(tbData);
1690 spareBytes[ebcCandidate] = (byte) db;1693 spareBytes[ebcCandidate] = (byte) db;
1691 if (klength > 0) {1694 if (klength > 0) {
1692 System.arraycopy(_bytes, tail + _tailHeaderSize, spareBytes, ebcCandidate + 1, klength);1695 System.arraycopy(_bytes, tail + _tailHeaderSize, spareBytes, ebcCandidate + 1, klength);
1693 }1696 }
1694 keySize = klength + ebcCandidate + 1;1697 keySize = klength + ebcCandidate + 1;
1695 int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;1698 final int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
1696 deallocTail(tail, size);1699 deallocTail(tail, size);
1697 }1700 }
1698 spareKey.setEncodedSize(keySize);1701 spareKey.setEncodedSize(keySize);
@@ -1711,22 +1714,22 @@
1711 //1714 //
1712 if (p1 < _keyBlockEnd) {1715 if (p1 < _keyBlockEnd) {
1713 int kbNext = getInt(p1);1716 int kbNext = getInt(p1);
1714 int ebcNext = decodeKeyBlockEbc(kbNext);1717 final int ebcNext = decodeKeyBlockEbc(kbNext);
17151718
1716 //1719 //
1717 // If ebcNext > ebc then the successor key will need to expand.1720 // If ebcNext > ebc then the successor key will need to expand.
1718 //1721 //
1719 if (ebcNext > ebc) {1722 if (ebcNext > ebc) {
1720 int tailNext = decodeKeyBlockTail(kbNext);1723 int tailNext = decodeKeyBlockTail(kbNext);
1721 int dbNext = decodeKeyBlockDb(kbNext);1724 final int dbNext = decodeKeyBlockDb(kbNext);
1722 int tbNext = getInt(tailNext);1725 final int tbNext = getInt(tailNext);
1723 int nextTailSize = decodeTailBlockSize(tbNext);1726 final int nextTailSize = decodeTailBlockSize(tbNext);
17241727
1725 int nextTailBlockSize = (nextTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;1728 final int nextTailBlockSize = (nextTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
17261729
1727 int newNextTailBlockSize = (nextTailSize + ebcNext - ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;1730 final int newNextTailBlockSize = (nextTailSize + ebcNext - ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
17281731
1729 int delta = newNextTailBlockSize - nextTailBlockSize;1732 final int delta = newNextTailBlockSize - nextTailBlockSize;
1730 boolean freeNextTailBlock = false;1733 boolean freeNextTailBlock = false;
1731 int newNextTail = tailNext;1734 int newNextTail = tailNext;
1732 if (delta > 0) {1735 if (delta > 0) {
@@ -1786,17 +1789,17 @@
1786 //1789 //
1787 // Now construct the new tail block1790 // Now construct the new tail block
1788 //1791 //
1789 int newNextKLength = decodeTailBlockKLength(tbNext) + ebcNext - ebc;1792 final int newNextKLength = decodeTailBlockKLength(tbNext) + ebcNext - ebc;
1790 int newNextTailSize = nextTailSize + ebcNext - ebc;1793 final int newNextTailSize = nextTailSize + ebcNext - ebc;
1791 putInt(newNextTail, encodeTailBlock(newNextTailSize, newNextKLength));1794 putInt(newNextTail, encodeTailBlock(newNextTailSize, newNextKLength));
1792 if (freeNextTailBlock) {1795 if (freeNextTailBlock) {
1793 int toFree = (nextTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;1796 final int toFree = (nextTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
1794 deallocTail(tailNext, toFree);1797 deallocTail(tailNext, toFree);
1795 }1798 }
1796 //1799 //
1797 // Fix up the successor key block1800 // Fix up the successor key block
1798 //1801 //
1799 int kbNewNext = encodeKeyBlock(ebc, spareBytes[ebc], newNextTail);1802 final int kbNewNext = encodeKeyBlock(ebc, spareBytes[ebc], newNextTail);
1800 putInt(p1, kbNewNext);1803 putInt(p1, kbNewNext);
1801 }1804 }
1802 }1805 }
@@ -1820,7 +1823,7 @@
1820 * The amount by which that block is to be expanded.1823 * The amount by which that block is to be expanded.
1821 * @return int Offset of the expanded tail block, or -1 if it does not fit.1824 * @return int Offset of the expanded tail block, or -1 if it does not fit.
1822 */1825 */
1823 private int wedgeTail(int tail, int delta) {1826 private int wedgeTail(final int tail, int delta) {
1824 delta = (delta + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;1827 delta = (delta + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
1825 if (delta == 0) {1828 if (delta == 0) {
1826 return tail;1829 return tail;
@@ -1836,8 +1839,8 @@
1836 _alloc -= delta;1839 _alloc -= delta;
18371840
1838 for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) {1841 for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) {
1839 int kbData = getInt(p);1842 final int kbData = getInt(p);
1840 int oldTail = decodeKeyBlockTail(kbData);1843 final int oldTail = decodeKeyBlockTail(kbData);
1841 if (oldTail < tail) {1844 if (oldTail < tail) {
1842 putInt(p, encodeKeyBlockTail(kbData, oldTail - delta));1845 putInt(p, encodeKeyBlockTail(kbData, oldTail - delta));
1843 }1846 }
@@ -1869,8 +1872,8 @@
1869 * the right sibling Buffer.1872 * the right sibling Buffer.
1870 * @throws PersistitException1873 * @throws PersistitException
1871 */1874 */
1872 final int split(Buffer rightSibling, Key key, ValueHelper valueHelper, int foundAt, Key indexKey,1875 final int split(final Buffer rightSibling, final Key key, final ValueHelper valueHelper, int foundAt,
1873 Sequence sequence, SplitPolicy policy) throws PersistitException {1876 final Key indexKey, final Sequence sequence, final SplitPolicy policy) throws PersistitException {
1874 // Make sure the right sibling page is empty.1877 // Make sure the right sibling page is empty.
18751878
1876 Debug.$assert0.t(rightSibling._keyBlockEnd == KEY_BLOCK_START);1879 Debug.$assert0.t(rightSibling._keyBlockEnd == KEY_BLOCK_START);
@@ -1888,10 +1891,10 @@
1888 //1891 //
1889 int currentSize = _bufferSize - _alloc - _slack + _keyBlockEnd - KEY_BLOCK_START;1892 int currentSize = _bufferSize - _alloc - _slack + _keyBlockEnd - KEY_BLOCK_START;
18901893
1891 int foundAtPosition = foundAt & P_MASK;1894 final int foundAtPosition = foundAt & P_MASK;
1892 boolean exact = (foundAt & EXACT_MASK) != 0;1895 final boolean exact = (foundAt & EXACT_MASK) != 0;
1893 int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT;1896 int depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT;
1894 boolean fixupSuccessor = (foundAt & FIXUP_MASK) > 0;1897 final boolean fixupSuccessor = (foundAt & FIXUP_MASK) > 0;
18951898
1896 int ebcNew;1899 int ebcNew;
1897 int ebcSuccessor;1900 int ebcSuccessor;
@@ -1899,18 +1902,18 @@
1899 int deltaSuccessorEbc = 0;1902 int deltaSuccessorEbc = 0;
19001903
1901 if (fixupSuccessor) {1904 if (fixupSuccessor) {
1902 int kbSuccessor = getInt(foundAtPosition);1905 final int kbSuccessor = getInt(foundAtPosition);
1903 int tbSuccessor = getInt(decodeKeyBlockTail(kbSuccessor));1906 final int tbSuccessor = getInt(decodeKeyBlockTail(kbSuccessor));
1904 ebcNew = decodeKeyBlockEbc(kbSuccessor);1907 ebcNew = decodeKeyBlockEbc(kbSuccessor);
1905 ebcSuccessor = depth;1908 ebcSuccessor = depth;
1906 int tbSize = decodeTailBlockSize(tbSuccessor);1909 final int tbSize = decodeTailBlockSize(tbSuccessor);
19071910
1908 // This is the number of bytes by which the successor key1911 // This is the number of bytes by which the successor key
1909 // can have its elided byte count increased.1912 // can have its elided byte count increased.
1910 deltaSuccessorEbc = ebcSuccessor - ebcNew;1913 deltaSuccessorEbc = ebcSuccessor - ebcNew;
19111914
1912 int oldSize = (tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;1915 final int oldSize = (tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
1913 int newSize = (tbSize - deltaSuccessorEbc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;1916 final int newSize = (tbSize - deltaSuccessorEbc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
19141917
1915 // This is the number of bytes by which the successor tail block1918 // This is the number of bytes by which the successor tail block
1916 // can be reduced (because its elision count has increased.)1919 // can be reduced (because its elision count has increased.)
@@ -1924,11 +1927,11 @@
1924 int newTailBlockSize;1927 int newTailBlockSize;
1925 int newValueSize;1928 int newValueSize;
1926 if (exact) {1929 if (exact) {
1927 int kbData = getInt(foundAtPosition);1930 final int kbData = getInt(foundAtPosition);
1928 int tail = decodeKeyBlockTail(kbData);1931 final int tail = decodeKeyBlockTail(kbData);
1929 int tbData = getInt(tail);1932 final int tbData = getInt(tail);
1930 int tbSize = decodeTailBlockSize(tbData);1933 final int tbSize = decodeTailBlockSize(tbData);
1931 int klength = decodeTailBlockKLength(tbData);1934 final int klength = decodeTailBlockKLength(tbData);
1932 oldTailBlockSize = (tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;1935 oldTailBlockSize = (tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
1933 keyBlockSizeDelta = 0;1936 keyBlockSizeDelta = 0;
1934 ebcNew = decodeKeyBlockEbc(kbData);1937 ebcNew = decodeKeyBlockEbc(kbData);
@@ -1940,7 +1943,7 @@
1940 newTailBlockSize = ((isIndexPage() ? 0 : newValueSize) + _tailHeaderSize + key.getEncodedSize() - ebcNew - 1 + ~TAILBLOCK_MASK)1943 newTailBlockSize = ((isIndexPage() ? 0 : newValueSize) + _tailHeaderSize + key.getEncodedSize() - ebcNew - 1 + ~TAILBLOCK_MASK)
1941 & TAILBLOCK_MASK;1944 & TAILBLOCK_MASK;
19421945
1943 int virtualSize = currentSize + newTailBlockSize - oldTailBlockSize + keyBlockSizeDelta1946 final int virtualSize = currentSize + newTailBlockSize - oldTailBlockSize + keyBlockSizeDelta
1944 - deltaSuccessorTailSize;1947 - deltaSuccessorTailSize;
19451948
1946 int splitBest = 0; // Maximal fitness measure1949 int splitBest = 0; // Maximal fitness measure
@@ -1951,7 +1954,7 @@
1951 boolean armed = true;1954 boolean armed = true;
1952 int whereInserted = -1;1955 int whereInserted = -1;
19531956
1954 int rightKeyBlock = _keyBlockEnd - KEYBLOCK_LENGTH;1957 final int rightKeyBlock = _keyBlockEnd - KEYBLOCK_LENGTH;
1955 for (int p = KEY_BLOCK_START; p < rightKeyBlock;) {1958 for (int p = KEY_BLOCK_START; p < rightKeyBlock;) {
1956 int splitCandidate = 0;1959 int splitCandidate = 0;
1957 if (p == foundAtPosition && armed) {1960 if (p == foundAtPosition && armed) {
@@ -1968,18 +1971,18 @@
1968 // Compute the number of bytes by which the successor tailblock1971 // Compute the number of bytes by which the successor tailblock
1969 // will grow due to its elision count becoming zero.1972 // will grow due to its elision count becoming zero.
1970 //1973 //
1971 int kbData = getInt(p);1974 final int kbData = getInt(p);
1972 int tbData = getInt(decodeKeyBlockTail(kbData));1975 final int tbData = getInt(decodeKeyBlockTail(kbData));
1973 int ebc = decodeKeyBlockEbc(kbData);1976 final int ebc = decodeKeyBlockEbc(kbData);
1974 int tbSize = decodeTailBlockSize(tbData);1977 final int tbSize = decodeTailBlockSize(tbData);
1975 int tbSizeDelta = ((tbSize + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK)1978 final int tbSizeDelta = ((tbSize + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK)
1976 - ((tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK);1979 - ((tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK);
19771980
1978 int edgeTailBlockSize = (decodeTailBlockKLength(tbData) - deltaSuccessorEbc + _tailHeaderSize + ~TAILBLOCK_MASK)1981 final int edgeTailBlockSize = (decodeTailBlockKLength(tbData) - deltaSuccessorEbc + _tailHeaderSize + ~TAILBLOCK_MASK)
1979 & TAILBLOCK_MASK;1982 & TAILBLOCK_MASK;
19801983
1981 if (p < rightKeyBlock) {1984 if (p < rightKeyBlock) {
1982 int rightSize = virtualSize - leftSize + tbSizeDelta;1985 final int rightSize = virtualSize - leftSize + tbSizeDelta;
19831986
1984 splitCandidate = policy.splitFit(this, p, foundAtPosition, exact, leftSize + KEYBLOCK_LENGTH1987 splitCandidate = policy.splitFit(this, p, foundAtPosition, exact, leftSize + KEYBLOCK_LENGTH
1985 + edgeTailBlockSize, rightSize, currentSize, virtualSize, _bufferSize - KEY_BLOCK_START,1988 + edgeTailBlockSize, rightSize, currentSize, virtualSize, _bufferSize - KEY_BLOCK_START,
@@ -1996,7 +1999,7 @@
1996 int kbData = getInt(p);1999 int kbData = getInt(p);
1997 int tbData = getInt(decodeKeyBlockTail(kbData));2000 int tbData = getInt(decodeKeyBlockTail(kbData));
1998 int tbSizeDelta;2001 int tbSizeDelta;
1999 int tailBlockSize = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;2002 final int tailBlockSize = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
2000 leftSize += tailBlockSize + KEYBLOCK_LENGTH;2003 leftSize += tailBlockSize + KEYBLOCK_LENGTH;
20012004
2002 p += KEYBLOCK_LENGTH;2005 p += KEYBLOCK_LENGTH;
@@ -2011,8 +2014,8 @@
2011 } else {2014 } else {
2012 kbData = getInt(p);2015 kbData = getInt(p);
2013 tbData = getInt(decodeKeyBlockTail(kbData));2016 tbData = getInt(decodeKeyBlockTail(kbData));
2014 int ebc = decodeKeyBlockEbc(kbData);2017 final int ebc = decodeKeyBlockEbc(kbData);
2015 int tbSize = decodeTailBlockSize(tbData);2018 final int tbSize = decodeTailBlockSize(tbData);
20162019
2017 tbSizeDelta = ((tbSize + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK)2020 tbSizeDelta = ((tbSize + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK)
2018 - ((tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK);2021 - ((tbSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK);
@@ -2022,7 +2025,7 @@
2022 }2025 }
20232026
2024 if (p < rightKeyBlock) {2027 if (p < rightKeyBlock) {
2025 int rightSize = virtualSize - leftSize + tbSizeDelta;2028 final int rightSize = virtualSize - leftSize + tbSizeDelta;
20262029
2027 splitCandidate = policy.splitFit(this, p, foundAtPosition, exact, leftSize + KEYBLOCK_LENGTH2030 splitCandidate = policy.splitFit(this, p, foundAtPosition, exact, leftSize + KEYBLOCK_LENGTH
2028 + edgeTailBlockSize, rightSize, currentSize, virtualSize, _bufferSize - KEY_BLOCK_START,2031 + edgeTailBlockSize, rightSize, currentSize, virtualSize, _bufferSize - KEY_BLOCK_START,
@@ -2048,11 +2051,11 @@
2048 //2051 //
2049 // Now move the keys and records.2052 // Now move the keys and records.
2050 //2053 //
2051 byte[] indexKeyBytes = indexKey.getEncodedBytes();2054 final byte[] indexKeyBytes = indexKey.getEncodedBytes();
2052 int splitAtPosition = splitAt & P_MASK;2055 final int splitAtPosition = splitAt & P_MASK;
20532056
2054 boolean lastLeft = (splitAt & EXACT_MASK) != 0;2057 final boolean lastLeft = (splitAt & EXACT_MASK) != 0;
2055 boolean firstRight = !lastLeft && splitAtPosition == foundAtPosition;2058 final boolean firstRight = !lastLeft && splitAtPosition == foundAtPosition;
2056 int indexKeyDepth = 0;2059 int indexKeyDepth = 0;
2057 //2060 //
2058 // First we need to compute the full key in the right sibling page.2061 // First we need to compute the full key in the right sibling page.
@@ -2074,18 +2077,18 @@
2074 //2077 //
2075 if (!firstRight) {2078 if (!firstRight) {
2076 for (int p = scanStart; p <= splitAtPosition; p += KEYBLOCK_LENGTH) {2079 for (int p = scanStart; p <= splitAtPosition; p += KEYBLOCK_LENGTH) {
2077 int kbData = getInt(p);2080 final int kbData = getInt(p);
2078 int ebc = decodeKeyBlockEbc(kbData);2081 final int ebc = decodeKeyBlockEbc(kbData);
2079 int db = decodeKeyBlockDb(kbData);2082 final int db = decodeKeyBlockDb(kbData);
2080 int tail = decodeKeyBlockTail(kbData);2083 final int tail = decodeKeyBlockTail(kbData);
2081 if (ebc > indexKeyDepth) {2084 if (ebc > indexKeyDepth) {
2082 throw new InvalidPageStructureException("ebc at " + p + " ebc=" + ebc + " > indexKeyDepth="2085 throw new InvalidPageStructureException("ebc at " + p + " ebc=" + ebc + " > indexKeyDepth="
2083 + indexKeyDepth);2086 + indexKeyDepth);
2084 }2087 }
2085 indexKeyDepth = ebc;2088 indexKeyDepth = ebc;
2086 indexKeyBytes[indexKeyDepth++] = (byte) db;2089 indexKeyBytes[indexKeyDepth++] = (byte) db;
2087 int tbData = getInt(tail);2090 final int tbData = getInt(tail);
2088 int klength = decodeTailBlockKLength(tbData);2091 final int klength = decodeTailBlockKLength(tbData);
20892092
2090 System.arraycopy(_bytes, tail + _tailHeaderSize, indexKeyBytes, indexKeyDepth, klength);2093 System.arraycopy(_bytes, tail + _tailHeaderSize, indexKeyBytes, indexKeyDepth, klength);
2091 indexKeyDepth += klength;2094 indexKeyDepth += klength;
@@ -2202,7 +2205,7 @@
2202 if (isDataPage()) {2205 if (isDataPage()) {
2203 currentSize = (tailBlockSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;2206 currentSize = (tailBlockSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
22042207
2205 int newSize = (tailBlockSize - dataSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;2208 final int newSize = (tailBlockSize - dataSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
2206 if (newSize != currentSize) {2209 if (newSize != currentSize) {
2207 deallocTail(tail + newSize, currentSize - newSize);2210 deallocTail(tail + newSize, currentSize - newSize);
2208 }2211 }
@@ -2217,9 +2220,9 @@
2217 //2220 //
2218 // Fix up the right edge key in the left page.2221 // Fix up the right edge key in the left page.
2219 //2222 //
2220 int kbData = getInt(splitAtPosition);2223 final int kbData = getInt(splitAtPosition);
2221 int edgeTail = decodeKeyBlockTail(kbData);2224 int edgeTail = decodeKeyBlockTail(kbData);
2222 int ebc = decodeKeyBlockEbc(kbData);2225 final int ebc = decodeKeyBlockEbc(kbData);
2223 depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT;2226 depth = (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT;
22242227
2225 if (firstRight && !exact) {2228 if (firstRight && !exact) {
@@ -2230,10 +2233,10 @@
2230 if (fixupSuccessor) {2233 if (fixupSuccessor) {
2231 depth = ebc;2234 depth = ebc;
2232 }2235 }
2233 int db = indexKeyBytes[depth];2236 final int db = indexKeyBytes[depth];
22342237
2235 int edgeKeyLength = indexKey.getEncodedSize() - depth - 1;2238 final int edgeKeyLength = indexKey.getEncodedSize() - depth - 1;
2236 int edgeTailBlockSize = edgeKeyLength + _tailHeaderSize;2239 final int edgeTailBlockSize = edgeKeyLength + _tailHeaderSize;
2237 edgeTail = allocTail(edgeTailBlockSize);2240 edgeTail = allocTail(edgeTailBlockSize);
2238 if (edgeTail == -1) {2241 if (edgeTail == -1) {
2239 setKeyBlockEnd(splitAtPosition);2242 setKeyBlockEnd(splitAtPosition);
@@ -2367,8 +2370,8 @@
2367 * in the rare case where no rearrangement of the records is2370 * in the rare case where no rearrangement of the records is
2368 * possible.2371 * possible.
2369 */2372 */
2370 final boolean join(Buffer buffer, int foundAt1, int foundAt2, Key indexKey, Key spareKey, JoinPolicy policy)2373 final boolean join(final Buffer buffer, int foundAt1, int foundAt2, final Key indexKey, final Key spareKey,
2371 throws RebalanceException {2374 final JoinPolicy policy) throws RebalanceException {
2372 foundAt1 &= P_MASK;2375 foundAt1 &= P_MASK;
2373 foundAt2 &= P_MASK;2376 foundAt2 &= P_MASK;
23742377
@@ -2401,17 +2404,17 @@
2401 //2404 //
2402 buffer.keyAt(foundAt2, spareKey);2405 buffer.keyAt(foundAt2, spareKey);
24032406
2404 long measureLeft = joinMeasure(foundAt1, _keyBlockEnd);2407 final long measureLeft = joinMeasure(foundAt1, _keyBlockEnd);
2405 long measureRight = buffer.joinMeasure(KEY_BLOCK_START, foundAt2);2408 final long measureRight = buffer.joinMeasure(KEY_BLOCK_START, foundAt2);
2406 kbData = buffer.getInt(foundAt2);2409 kbData = buffer.getInt(foundAt2);
2407 int oldEbc = decodeKeyBlockEbc(kbData);2410 final int oldEbc = decodeKeyBlockEbc(kbData);
2408 int newEbc = Math.min(oldEbc, Math.min((int) (measureLeft >>> 32), (int) (measureRight >>> 32)));2411 final int newEbc = Math.min(oldEbc, Math.min((int) (measureLeft >>> 32), (int) (measureRight >>> 32)));
2409 tail = decodeKeyBlockTail(kbData);2412 tail = decodeKeyBlockTail(kbData);
2410 tbData = buffer.getInt(tail);2413 tbData = buffer.getInt(tail);
24112414
2412 int oldSize = decodeTailBlockSize(tbData);2415 final int oldSize = decodeTailBlockSize(tbData);
2413 int newSize = oldSize + (oldEbc - newEbc);2416 final int newSize = oldSize + (oldEbc - newEbc);
2414 int adjustmentForNewEbc = ((newSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK)2417 final int adjustmentForNewEbc = ((newSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK)
2415 - ((oldSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK);2418 - ((oldSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK);
24162419
2417 /*2420 /*
@@ -2424,7 +2427,7 @@
2424 final int virtualKeyCount = ((foundAt1 - KEY_BLOCK_START) + (buffer.getKeyBlockEnd() - foundAt2))2427 final int virtualKeyCount = ((foundAt1 - KEY_BLOCK_START) + (buffer.getKeyBlockEnd() - foundAt2))
2425 / KEYBLOCK_LENGTH;2428 / KEYBLOCK_LENGTH;
24262429
2427 boolean okayToRejoin = virtualKeyCount < _pool.getMaxKeys() && policy.acceptJoin(this, virtualSize);2430 final boolean okayToRejoin = virtualKeyCount < _pool.getMaxKeys() && policy.acceptJoin(this, virtualSize);
24282431
2429 boolean result;2432 boolean result;
24302433
@@ -2473,7 +2476,7 @@
2473 /*2476 /*
2474 * unsplice the right buffer from the right sibling chain.2477 * unsplice the right buffer from the right sibling chain.
2475 */2478 */
2476 long rightSibling = buffer.getRightSibling();2479 final long rightSibling = buffer.getRightSibling();
2477 setRightSibling(rightSibling);2480 setRightSibling(rightSibling);
2478 if (hasMVV) {2481 if (hasMVV) {
2479 _mvvCount = Integer.MAX_VALUE;2482 _mvvCount = Integer.MAX_VALUE;
@@ -2520,7 +2523,7 @@
2520 buffer.joinDeallocateTails(KEY_BLOCK_START, foundAt2);2523 buffer.joinDeallocateTails(KEY_BLOCK_START, foundAt2);
2521 buffer.clearBytes(KEY_BLOCK_START, foundAt2);2524 buffer.clearBytes(KEY_BLOCK_START, foundAt2);
2522 buffer.reduceEbc(foundAt2, newEbc, spareKeyBytes);2525 buffer.reduceEbc(foundAt2, newEbc, spareKeyBytes);
2523 int rightSize = buffer._keyBlockEnd - joinOffset;2526 final int rightSize = buffer._keyBlockEnd - joinOffset;
25242527
2525 moveRecords(buffer, foundAt2, joinOffset, _keyBlockEnd, true);2528 moveRecords(buffer, foundAt2, joinOffset, _keyBlockEnd, true);
25262529
@@ -2540,7 +2543,7 @@
25402543
2541 buffer.joinDeallocateTails(KEY_BLOCK_START, foundAt2);2544 buffer.joinDeallocateTails(KEY_BLOCK_START, foundAt2);
25422545
2543 int rightSize = buffer._keyBlockEnd - foundAt2;2546 final int rightSize = buffer._keyBlockEnd - foundAt2;
2544 System.arraycopy(buffer._bytes, foundAt2, buffer._bytes, KEY_BLOCK_START, rightSize);2547 System.arraycopy(buffer._bytes, foundAt2, buffer._bytes, KEY_BLOCK_START, rightSize);
2545 buffer.clearBytes(KEY_BLOCK_START + rightSize, buffer._keyBlockEnd);2548 buffer.clearBytes(KEY_BLOCK_START + rightSize, buffer._keyBlockEnd);
2546 buffer.setKeyBlockEnd(KEY_BLOCK_START + rightSize);2549 buffer.setKeyBlockEnd(KEY_BLOCK_START + rightSize);
@@ -2629,18 +2632,18 @@
2629 * @return long encoding the size being deleted and the minimum ebc2632 * @return long encoding the size being deleted and the minimum ebc
2630 * 2633 *
2631 */2634 */
2632 long joinMeasure(int from, int to) {2635 long joinMeasure(final int from, final int to) {
2633 int minimumEbc = Integer.MAX_VALUE;2636 int minimumEbc = Integer.MAX_VALUE;
2634 int totalDeallocatedSize = 0;2637 int totalDeallocatedSize = 0;
2635 for (int index = from; index < to; index += KEYBLOCK_LENGTH) {2638 for (int index = from; index < to; index += KEYBLOCK_LENGTH) {
2636 int kbData = getInt(index);2639 final int kbData = getInt(index);
2637 int ebc = decodeKeyBlockEbc(kbData);2640 final int ebc = decodeKeyBlockEbc(kbData);
2638 if (index != KEY_BLOCK_START && ebc < minimumEbc) {2641 if (index != KEY_BLOCK_START && ebc < minimumEbc) {
2639 minimumEbc = ebc;2642 minimumEbc = ebc;
2640 }2643 }
2641 int tail = decodeKeyBlockTail(kbData);2644 final int tail = decodeKeyBlockTail(kbData);
2642 int tbData = getInt(tail);2645 final int tbData = getInt(tail);
2643 int size = decodeTailBlockSize(tbData);2646 final int size = decodeTailBlockSize(tbData);
2644 totalDeallocatedSize += ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) + KEYBLOCK_LENGTH;2647 totalDeallocatedSize += ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) + KEYBLOCK_LENGTH;
2645 }2648 }
2646 return (((long) minimumEbc) << 32) | totalDeallocatedSize;2649 return (((long) minimumEbc) << 32) | totalDeallocatedSize;
@@ -2660,12 +2663,12 @@
2660 * @param to2663 * @param to
2661 * offset of the next key block not being deleted2664 * offset of the next key block not being deleted
2662 */2665 */
2663 void joinDeallocateTails(int from, int to) {2666 void joinDeallocateTails(final int from, final int to) {
2664 for (int index = from; index < to; index += KEYBLOCK_LENGTH) {2667 for (int index = from; index < to; index += KEYBLOCK_LENGTH) {
2665 int kbData = getInt(index);2668 final int kbData = getInt(index);
2666 int tail = decodeKeyBlockTail(kbData);2669 final int tail = decodeKeyBlockTail(kbData);
2667 int tbData = getInt(tail);2670 final int tbData = getInt(tail);
2668 int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;2671 final int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
2669 deallocTail(tail, size);2672 deallocTail(tail, size);
2670 }2673 }
2671 }2674 }
@@ -2739,23 +2742,24 @@
2739 //2742 //
2740 for (int p = KEY_BLOCK_START; p < foundAt1; p += KEYBLOCK_LENGTH) {2743 for (int p = KEY_BLOCK_START; p < foundAt1; p += KEYBLOCK_LENGTH) {
2741 kbData = getInt(p);2744 kbData = getInt(p);
2742 int ebc = decodeKeyBlockEbc(kbData);2745 final int ebc = decodeKeyBlockEbc(kbData);
2743 tail = decodeKeyBlockTail(kbData);2746 tail = decodeKeyBlockTail(kbData);
2744 tbData = getInt(tail);2747 tbData = getInt(tail);
2745 int size = decodeTailBlockSize(tbData);2748 final int size = decodeTailBlockSize(tbData);
2746 klength = decodeTailBlockKLength(tbData);2749 klength = decodeTailBlockKLength(tbData);
27472750
2748 int delta = ((size + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK);2751 final int delta = ((size + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK)
27492752 - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK);
2750 int candidateRightSize = virtualSize - leftSize + delta;2753
27512754 final int candidateRightSize = virtualSize - leftSize + delta;
2752 int candidateLeftSize = leftSize + KEYBLOCK_LENGTH + ((klength + ~TAILBLOCK_MASK) & TAILBLOCK_MASK)2755
2756 final int candidateLeftSize = leftSize + KEYBLOCK_LENGTH + ((klength + ~TAILBLOCK_MASK) & TAILBLOCK_MASK)
2753 + _tailHeaderSize;2757 + _tailHeaderSize;
27542758
2755 int rightKeyCount = ((buffer.getKeyBlockEnd() - foundAt2) + (foundAt1 - p)) / KEYBLOCK_LENGTH;2759 final int rightKeyCount = ((buffer.getKeyBlockEnd() - foundAt2) + (foundAt1 - p)) / KEYBLOCK_LENGTH;
27562760
2757 int joinFit = policy.rebalanceFit(this, buffer, p, foundAt1, foundAt2, virtualSize, candidateLeftSize,2761 final int joinFit = policy.rebalanceFit(this, buffer, p, foundAt1, foundAt2, virtualSize,
2758 candidateRightSize, _bufferSize - KEY_BLOCK_START);2762 candidateLeftSize, candidateRightSize, _bufferSize - KEY_BLOCK_START);
27592763
2760 if (joinFit > joinBest && rightKeyCount < _pool.getMaxKeys()) {2764 if (joinFit > joinBest && rightKeyCount < _pool.getMaxKeys()) {
2761 joinBest = joinFit;2765 joinBest = joinFit;
@@ -2770,10 +2774,10 @@
2770 */2774 */
2771 for (int p = foundAt2; p < buffer._keyBlockEnd; p += KEYBLOCK_LENGTH) {2775 for (int p = foundAt2; p < buffer._keyBlockEnd; p += KEYBLOCK_LENGTH) {
2772 kbData = buffer.getInt(p);2776 kbData = buffer.getInt(p);
2773 int ebc = decodeKeyBlockEbc(kbData);2777 final int ebc = decodeKeyBlockEbc(kbData);
2774 tail = decodeKeyBlockTail(kbData);2778 tail = decodeKeyBlockTail(kbData);
2775 tbData = buffer.getInt(tail);2779 tbData = buffer.getInt(tail);
2776 int size = decodeTailBlockSize(tbData);2780 final int size = decodeTailBlockSize(tbData);
2777 klength = decodeTailBlockKLength(tbData);2781 klength = decodeTailBlockKLength(tbData);
27782782
2779 /*2783 /*
@@ -2781,23 +2785,24 @@
2781 * rebalance key would have to grow if it became the first key on2785 * rebalance key would have to grow if it became the first key on
2782 * the right page and its ebc became zero.2786 * the right page and its ebc became zero.
2783 */2787 */
2784 int delta = ((size + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK);2788 final int delta = ((size + ebc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK)
2789 - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK);
27852790
2786 /*2791 /*
2787 * Amount by which the current tail block needs to grow to2792 * Amount by which the current tail block needs to grow to
2788 * accommodate reduced ebc.2793 * accommodate reduced ebc.
2789 */2794 */
2790 int adjustment = (p == foundAt2) ? adjustmentForNewEbc : 0;2795 final int adjustment = (p == foundAt2) ? adjustmentForNewEbc : 0;
27912796
2792 int candidateRightSize = virtualSize - leftSize + delta;2797 final int candidateRightSize = virtualSize - leftSize + delta;
27932798
2794 int candidateLeftSize = leftSize + ((klength + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) + adjustment2799 final int candidateLeftSize = leftSize + ((klength + ~TAILBLOCK_MASK) & TAILBLOCK_MASK) + adjustment
2795 + _tailHeaderSize + KEYBLOCK_LENGTH;2800 + _tailHeaderSize + KEYBLOCK_LENGTH;
27962801
2797 int leftKeyCount = ((foundAt1 - KEY_BLOCK_START) + (p - foundAt2)) / KEYBLOCK_LENGTH;2802 final int leftKeyCount = ((foundAt1 - KEY_BLOCK_START) + (p - foundAt2)) / KEYBLOCK_LENGTH;
27982803
2799 int joinFit = policy.rebalanceFit(this, buffer, p, foundAt1, foundAt2, virtualSize, candidateLeftSize,2804 final int joinFit = policy.rebalanceFit(this, buffer, p, foundAt1, foundAt2, virtualSize,
2800 candidateRightSize, _bufferSize - KEY_BLOCK_START);2805 candidateLeftSize, candidateRightSize, _bufferSize - KEY_BLOCK_START);
28012806
2802 if (joinFit > joinBest && leftKeyCount < _pool.getMaxKeys()) {2807 if (joinFit > joinBest && leftKeyCount < _pool.getMaxKeys()) {
2803 joinBest = joinFit;2808 joinBest = joinFit;
@@ -2821,12 +2826,12 @@
2821 return _fastIndex;2826 return _fastIndex;
2822 }2827 }
28232828
2824 private void reduceEbc(int p, int newEbc, byte[] indexKeyBytes) {2829 private void reduceEbc(final int p, final int newEbc, final byte[] indexKeyBytes) {
2825 int kbData = getInt(p);2830 int kbData = getInt(p);
2826 int oldDb = decodeKeyBlockDb(kbData);2831 final int oldDb = decodeKeyBlockDb(kbData);
2827 int oldEbc = decodeKeyBlockEbc(kbData);2832 final int oldEbc = decodeKeyBlockEbc(kbData);
2828 int tail = decodeKeyBlockTail(kbData);2833 int tail = decodeKeyBlockTail(kbData);
2829 int tbData = getInt(tail);2834 final int tbData = getInt(tail);
2830 int size = decodeTailBlockSize(tbData);2835 int size = decodeTailBlockSize(tbData);
2831 int klength = decodeTailBlockKLength(tbData);2836 int klength = decodeTailBlockKLength(tbData);
28322837
@@ -2836,7 +2841,7 @@
2836 throw new IllegalArgumentException("newEbc=" + newEbc + " must be less than oldEbc=" + oldEbc);2841 throw new IllegalArgumentException("newEbc=" + newEbc + " must be less than oldEbc=" + oldEbc);
2837 }2842 }
28382843
2839 int delta = ((size + oldEbc - newEbc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK)2844 final int delta = ((size + oldEbc - newEbc + ~TAILBLOCK_MASK) & TAILBLOCK_MASK)
2840 - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK);2845 - ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK);
2841 int newTail;2846 int newTail;
2842 boolean wedged = false;2847 boolean wedged = false;
@@ -2881,7 +2886,7 @@
28812886
2882 size += oldEbc - newEbc;2887 size += oldEbc - newEbc;
2883 klength += oldEbc - newEbc;2888 klength += oldEbc - newEbc;
2884 int newDb = indexKeyBytes[newEbc] & 0xFF;2889 final int newDb = indexKeyBytes[newEbc] & 0xFF;
28852890
2886 putInt(newTail, encodeTailBlock(size, klength));2891 putInt(newTail, encodeTailBlock(size, klength));
28872892
@@ -2897,7 +2902,7 @@
2897 * @param insertAt2902 * @param insertAt
2898 * @param includesRightEdge2903 * @param includesRightEdge
2899 */2904 */
2900 void moveRecords(Buffer buffer, int p1, int p2, int insertAt, boolean includesRightEdge) {2905 void moveRecords(final Buffer buffer, final int p1, final int p2, int insertAt, final boolean includesRightEdge) {
2901 if (p2 - p1 + _keyBlockEnd > _alloc) {2906 if (p2 - p1 + _keyBlockEnd > _alloc) {
2902 repack();2907 repack();
2903 }2908 }
@@ -2912,15 +2917,15 @@
2912 setKeyBlockEnd(getKeyBlockEnd() + KEYBLOCK_LENGTH);2917 setKeyBlockEnd(getKeyBlockEnd() + KEYBLOCK_LENGTH);
29132918
2914 for (int p = p1; p < p2 || includesRightEdge && p == p2; p += KEYBLOCK_LENGTH) {2919 for (int p = p1; p < p2 || includesRightEdge && p == p2; p += KEYBLOCK_LENGTH) {
2915 int kbData = buffer.getInt(p);2920 final int kbData = buffer.getInt(p);
2916 int ebc = decodeKeyBlockEbc(kbData);2921 final int ebc = decodeKeyBlockEbc(kbData);
2917 int db = decodeKeyBlockDb(kbData);2922 final int db = decodeKeyBlockDb(kbData);
2918 int tail = decodeKeyBlockTail(kbData);2923 final int tail = decodeKeyBlockTail(kbData);
2919 int tbData = buffer.getInt(tail);2924 final int tbData = buffer.getInt(tail);
2920 int size = decodeTailBlockSize(tbData);2925 final int size = decodeTailBlockSize(tbData);
2921 int klength = decodeTailBlockKLength(tbData);2926 final int klength = decodeTailBlockKLength(tbData);
2922 int newSize = size;2927 int newSize = size;
2923 boolean edgeCase = includesRightEdge && p == p2;2928 final boolean edgeCase = includesRightEdge && p == p2;
2924 if (edgeCase) {2929 if (edgeCase) {
2925 // this is just for the right edge key of the left page2930 // this is just for the right edge key of the left page
2926 newSize = _tailHeaderSize + klength;2931 newSize = _tailHeaderSize + klength;
@@ -2972,7 +2977,7 @@
2972 */2977 */
2973 private int allocTail(int size) {2978 private int allocTail(int size) {
2974 size = (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;2979 size = (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
2975 int alloc = _alloc - size;2980 final int alloc = _alloc - size;
2976 if (alloc >= _keyBlockEnd) {2981 if (alloc >= _keyBlockEnd) {
2977 _alloc = alloc;2982 _alloc = alloc;
2978 return alloc;2983 return alloc;
@@ -2981,7 +2986,7 @@
2981 }2986 }
2982 }2987 }
29832988
2984 private void deallocTail(int tail, int size) {2989 private void deallocTail(final int tail, int size) {
2985 size = (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;2990 size = (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
29862991
2987 Debug.$assert0.t((size > 0 && size <= _bufferSize - _alloc) && (tail >= _alloc && tail < _bufferSize)2992 Debug.$assert0.t((size > 0 && size <= _bufferSize - _alloc) && (tail >= _alloc && tail < _bufferSize)
@@ -2993,9 +2998,9 @@
2993 // any free space above this block.2998 // any free space above this block.
2994 //2999 //
2995 while (tail + size < _bufferSize) {3000 while (tail + size < _bufferSize) {
2996 int kbNext = getInt(tail + size);3001 final int kbNext = getInt(tail + size);
2997 if ((kbNext & TAILBLOCK_INUSE_MASK) == 0) {3002 if ((kbNext & TAILBLOCK_INUSE_MASK) == 0) {
2998 int sizeNext = decodeTailBlockSize(kbNext);3003 final int sizeNext = decodeTailBlockSize(kbNext);
2999 Debug.$assert0.t((sizeNext & ~TAILBLOCK_MASK) == 0 && sizeNext != 0);3004 Debug.$assert0.t((sizeNext & ~TAILBLOCK_MASK) == 0 && sizeNext != 0);
3000 _slack -= sizeNext;3005 _slack -= sizeNext;
3001 putInt(tail + size, 0);3006 putInt(tail + size, 0);
@@ -3018,7 +3023,7 @@
3018 private void repack() {3023 private void repack() {
3019 Debug.$assert0.t(isMine());3024 Debug.$assert0.t(isMine());
30203025
3021 int[] plan = getRepackPlanBuffer();3026 final int[] plan = getRepackPlanBuffer();
3022 //3027 //
3023 // Phase 1:3028 // Phase 1:
3024 // For each allocated tail block, post the offset of its3029 // For each allocated tail block, post the offset of its
@@ -3028,9 +3033,9 @@
3028 int free = 0;3033 int free = 0;
3029 int back = 0;3034 int back = 0;
3030 for (int tail = _alloc; tail < _bufferSize;) {3035 for (int tail = _alloc; tail < _bufferSize;) {
3031 int tbData = getInt(tail);3036 final int tbData = getInt(tail);
30323037
3033 int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;3038 final int size = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
3034 if (size <= 0) {3039 if (size <= 0) {
3035 _persistit.fatal("Buffer has invalid tailblock length " + size + " at " + tail + " in " + this, null);3040 _persistit.fatal("Buffer has invalid tailblock length " + size + " at " + tail + " in " + this, null);
3036 }3041 }
@@ -3058,9 +3063,9 @@
3058 if (free > 0)3063 if (free > 0)
3059 moveSize += alloc - tail - free;3064 moveSize += alloc - tail - free;
3060 alloc = tail + free;3065 alloc = tail + free;
3061 int planData = plan[tail / TAILBLOCK_FACTOR];3066 final int planData = plan[tail / TAILBLOCK_FACTOR];
3062 plan[tail / TAILBLOCK_FACTOR] = free + tail;3067 plan[tail / TAILBLOCK_FACTOR] = free + tail;
3063 int deltaFree = planData & 0xFFFF;3068 final int deltaFree = planData & 0xFFFF;
3064 if (deltaFree > 0 && moveSize > 0 && free > 0) {3069 if (deltaFree > 0 && moveSize > 0 && free > 0) {
3065 System.arraycopy(_bytes, moveFrom, _bytes, moveFrom + free, moveSize);3070 System.arraycopy(_bytes, moveFrom, _bytes, moveFrom + free, moveSize);
3066 moveSize = 0;3071 moveSize = 0;
@@ -3080,14 +3085,14 @@
3080 //3085 //
3081 if (free > 0) {3086 if (free > 0) {
3082 for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) {3087 for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) {
3083 int kbData = getInt(p);3088 final int kbData = getInt(p);
3084 //3089 //
3085 // For certain remove operations, we may have invalid keyblocks3090 // For certain remove operations, we may have invalid keyblocks
3086 // in range. We can safely ignore them here.3091 // in range. We can safely ignore them here.
3087 //3092 //
3088 if (kbData != 0) {3093 if (kbData != 0) {
3089 int tail = decodeKeyBlockTail(kbData);3094 final int tail = decodeKeyBlockTail(kbData);
3090 int newTail = plan[tail / KEYBLOCK_LENGTH];3095 final int newTail = plan[tail / KEYBLOCK_LENGTH];
30913096
3092 if (newTail != tail) {3097 if (newTail != tail) {
3093 putInt(p, encodeKeyBlockTail(kbData, newTail));3098 putInt(p, encodeKeyBlockTail(kbData, newTail));
@@ -3105,7 +3110,7 @@
3105 * The size required by the proposed new tailblock.3110 * The size required by the proposed new tailblock.
3106 * @return boolean <i>true</i> if it will fit, else <i>false</i>.3111 * @return boolean <i>true</i> if it will fit, else <i>false</i>.
3107 */3112 */
3108 private boolean willFit(int needed) {3113 private boolean willFit(final int needed) {
3109 return needed <= (_alloc - _keyBlockEnd + _slack);3114 return needed <= (_alloc - _keyBlockEnd + _slack);
3110 }3115 }
31113116
@@ -3116,8 +3121,8 @@
3116 * @param foundAt3121 * @param foundAt
3117 * The keyblock index3122 * The keyblock index
3118 */3123 */
3119 boolean isAfterRightEdge(int foundAt) {3124 boolean isAfterRightEdge(final int foundAt) {
3120 int p = foundAt & P_MASK;3125 final int p = foundAt & P_MASK;
3121 return (p >= _keyBlockEnd) || ((p == _keyBlockEnd - KEYBLOCK_LENGTH && (foundAt & EXACT_MASK) != 0));3126 return (p >= _keyBlockEnd) || ((p == _keyBlockEnd - KEYBLOCK_LENGTH && (foundAt & EXACT_MASK) != 0));
3122 }3127 }
31233128
@@ -3127,7 +3132,7 @@
3127 * 3132 *
3128 * @param foundAt3133 * @param foundAt
3129 */3134 */
3130 boolean isBeforeLeftEdge(int foundAt) {3135 boolean isBeforeLeftEdge(final int foundAt) {
3131 return (((foundAt & EXACT_MASK) == 0 && (foundAt & P_MASK) <= KEY_BLOCK_START) || (foundAt & P_MASK) < KEY_BLOCK_START);3136 return (((foundAt & EXACT_MASK) == 0 && (foundAt & P_MASK) <= KEY_BLOCK_START) || (foundAt & P_MASK) < KEY_BLOCK_START);
3132 }3137 }
31333138
@@ -3136,11 +3141,11 @@
3136 return _bytes;3141 return _bytes;
3137 }3142 }
31383143
3139 int getByte(int index) {3144 int getByte(final int index) {
3140 return (_bytes[index] & 0xFF);3145 return (_bytes[index] & 0xFF);
3141 }3146 }
31423147
3143 int getChar(int index) {3148 int getChar(final int index) {
3144 if (Persistit.BIG_ENDIAN) {3149 if (Persistit.BIG_ENDIAN) {
3145 return (_bytes[index + 1] & 0xFF) | (_bytes[index] & 0xFF) << 8;3150 return (_bytes[index + 1] & 0xFF) | (_bytes[index] & 0xFF) << 8;
3146 } else {3151 } else {
@@ -3148,7 +3153,7 @@
3148 }3153 }
3149 }3154 }
31503155
3151 int getInt(int index) {3156 int getInt(final int index) {
3152 if (Persistit.BIG_ENDIAN) {3157 if (Persistit.BIG_ENDIAN) {
3153 return (_bytes[index + 3] & 0xFF) | (_bytes[index + 2] & 0xFF) << 8 | (_bytes[index + 1] & 0xFF) << 163158 return (_bytes[index + 3] & 0xFF) | (_bytes[index + 2] & 0xFF) << 8 | (_bytes[index + 1] & 0xFF) << 16
3154 | (_bytes[index] & 0xFF) << 24;3159 | (_bytes[index] & 0xFF) << 24;
@@ -3158,21 +3163,21 @@
3158 }3163 }
3159 }3164 }
31603165
3161 long getLong(int index) {3166 long getLong(final int index) {
3162 if (Persistit.BIG_ENDIAN) {3167 if (Persistit.BIG_ENDIAN) {
3163 return (long) (_bytes[index + 7] & 0xFF) | (long) (_bytes[index + 6] & 0xFF) << 83168 return _bytes[index + 7] & 0xFF | (long) (_bytes[index + 6] & 0xFF) << 8
3164 | (long) (_bytes[index + 5] & 0xFF) << 16 | (long) (_bytes[index + 4] & 0xFF) << 243169 | (long) (_bytes[index + 5] & 0xFF) << 16 | (long) (_bytes[index + 4] & 0xFF) << 24
3165 | (long) (_bytes[index + 3] & 0xFF) << 32 | (long) (_bytes[index + 2] & 0xFF) << 403170 | (long) (_bytes[index + 3] & 0xFF) << 32 | (long) (_bytes[index + 2] & 0xFF) << 40
3166 | (long) (_bytes[index + 1] & 0xFF) << 48 | (long) (_bytes[index] & 0xFF) << 56;3171 | (long) (_bytes[index + 1] & 0xFF) << 48 | (long) (_bytes[index] & 0xFF) << 56;
3167 } else {3172 } else {
3168 return (long) (_bytes[index] & 0xFF) | (long) (_bytes[index + 1] & 0xFF) << 83173 return _bytes[index] & 0xFF | (long) (_bytes[index + 1] & 0xFF) << 8
3169 | (long) (_bytes[index + 2] & 0xFF) << 16 | (long) (_bytes[index + 3] & 0xFF) << 243174 | (long) (_bytes[index + 2] & 0xFF) << 16 | (long) (_bytes[index + 3] & 0xFF) << 24
3170 | (long) (_bytes[index + 4] & 0xFF) << 32 | (long) (_bytes[index + 5] & 0xFF) << 403175 | (long) (_bytes[index + 4] & 0xFF) << 32 | (long) (_bytes[index + 5] & 0xFF) << 40
3171 | (long) (_bytes[index + 6] & 0xFF) << 48 | (long) (_bytes[index + 7] & 0xFF) << 56;3176 | (long) (_bytes[index + 6] & 0xFF) << 48 | (long) (_bytes[index + 7] & 0xFF) << 56;
3172 }3177 }
3173 }3178 }
31743179
3175 int getDb(int index) {3180 int getDb(final int index) {
3176 if (Persistit.BIG_ENDIAN) {3181 if (Persistit.BIG_ENDIAN) {
3177 return _bytes[index + 3] & 0xFF;3182 return _bytes[index + 3] & 0xFF;
3178 } else {3183 } else {
@@ -3180,12 +3185,12 @@
3180 }3185 }
3181 }3186 }
31823187
3183 void putByte(int index, int value) {3188 void putByte(final int index, final int value) {
3184 Debug.$assert0.t(index >= 0 && index + 1 <= _bytes.length);3189 Debug.$assert0.t(index >= 0 && index + 1 <= _bytes.length);
3185 _bytes[index] = (byte) (value);3190 _bytes[index] = (byte) (value);
3186 }3191 }
31873192
3188 void putChar(int index, int value) {3193 void putChar(final int index, final int value) {
3189 Debug.$assert0.t(index >= 0 && index + 2 <= _bytes.length);3194 Debug.$assert0.t(index >= 0 && index + 2 <= _bytes.length);
3190 if (Persistit.BIG_ENDIAN) {3195 if (Persistit.BIG_ENDIAN) {
3191 _bytes[index + 1] = (byte) (value);3196 _bytes[index + 1] = (byte) (value);
@@ -3196,7 +3201,7 @@
3196 }3201 }
3197 }3202 }
31983203
3199 void putInt(int index, int value) {3204 void putInt(final int index, final int value) {
3200 Debug.$assert0.t(index >= 0 && index + 4 <= _bytes.length);3205 Debug.$assert0.t(index >= 0 && index + 4 <= _bytes.length);
3201 if (Persistit.BIG_ENDIAN) {3206 if (Persistit.BIG_ENDIAN) {
3202 _bytes[index + 3] = (byte) (value);3207 _bytes[index + 3] = (byte) (value);
@@ -3211,7 +3216,7 @@
3211 }3216 }
3212 }3217 }
32133218
3214 void putLong(int index, long value) {3219 void putLong(final int index, final long value) {
3215 Debug.$assert0.t(index >= 0 && index + 8 <= _bytes.length);3220 Debug.$assert0.t(index >= 0 && index + 8 <= _bytes.length);
32163221
3217 if (Persistit.BIG_ENDIAN) {3222 if (Persistit.BIG_ENDIAN) {
@@ -3235,7 +3240,7 @@
3235 }3240 }
3236 }3241 }
32373242
3238 static void writeLongRecordDescriptor(byte[] bytes, int size, long pageAddr) {3243 static void writeLongRecordDescriptor(final byte[] bytes, final int size, final long pageAddr) {
3239 if (bytes.length != LONGREC_SIZE) {3244 if (bytes.length != LONGREC_SIZE) {
3240 throw new IllegalArgumentException("Bad LONG_RECORD descriptor size: " + size);3245 throw new IllegalArgumentException("Bad LONG_RECORD descriptor size: " + size);
3241 }3246 }
@@ -3246,7 +3251,7 @@
3246 Util.putLong(bytes, LONGREC_PAGE_OFFSET, pageAddr);3251 Util.putLong(bytes, LONGREC_PAGE_OFFSET, pageAddr);
3247 }3252 }
32483253
3249 static int decodeLongRecordDescriptorSize(byte[] bytes, int offset) {3254 static int decodeLongRecordDescriptorSize(final byte[] bytes, final int offset) {
3250 int type;3255 int type;
3251 if ((type = (bytes[offset] & 0xFF)) != LONGREC_TYPE) {3256 if ((type = (bytes[offset] & 0xFF)) != LONGREC_TYPE) {
3252 throw new IllegalArgumentException("Bad LONG_RECORD descriptor type: " + type);3257 throw new IllegalArgumentException("Bad LONG_RECORD descriptor type: " + type);
@@ -3254,7 +3259,7 @@
3254 return (int) Util.getLong(bytes, offset + LONGREC_SIZE_OFFSET);3259 return (int) Util.getLong(bytes, offset + LONGREC_SIZE_OFFSET);
3255 }3260 }
32563261
3257 static long decodeLongRecordDescriptorPointer(byte[] bytes, int offset) {3262 static long decodeLongRecordDescriptorPointer(final byte[] bytes, final int offset) {
3258 int type;3263 int type;
3259 if ((type = (bytes[offset] & 0xFF)) != LONGREC_TYPE) {3264 if ((type = (bytes[offset] & 0xFF)) != LONGREC_TYPE) {
3260 throw new IllegalArgumentException("Bad LONG_RECORD descriptor type: " + type);3265 throw new IllegalArgumentException("Bad LONG_RECORD descriptor type: " + type);
@@ -3263,7 +3268,7 @@
3263 }3268 }
32643269
3265 static int bufferSizeWithOverhead(final int bufferSize) {3270 static int bufferSizeWithOverhead(final int bufferSize) {
3266 int fastIndexSize = ((bufferSize - HEADER_SIZE) / MAX_KEY_RATIO) * FastIndex.BYTES_PER_ENTRY;3271 final int fastIndexSize = ((bufferSize - HEADER_SIZE) / MAX_KEY_RATIO) * FastIndex.BYTES_PER_ENTRY;
3267 return bufferSize + fastIndexSize + ESTIMATED_FIXED_BUFFER_OVERHEAD;3272 return bufferSize + fastIndexSize + ESTIMATED_FIXED_BUFFER_OVERHEAD;
3268 }3273 }
32693274
@@ -3314,16 +3319,16 @@
3314 return (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;3319 return (size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
3315 }3320 }
33163321
3317 static int encodeKeyBlock(int ebc, int db, int tail) {3322 static int encodeKeyBlock(final int ebc, final int db, final int tail) {
3318 return ((ebc << EBC_SHIFT) & EBC_MASK) | ((db /* << DB_SHIFT */) & DB_MASK)3323 return ((ebc << EBC_SHIFT) & EBC_MASK) | ((db /* << DB_SHIFT */) & DB_MASK)
3319 | ((tail << TAIL_SHIFT) & TAIL_MASK);3324 | ((tail << TAIL_SHIFT) & TAIL_MASK);
3320 }3325 }
33213326
3322 static int encodeKeyBlockTail(int kbData, int tail) {3327 static int encodeKeyBlockTail(final int kbData, final int tail) {
3323 return (kbData & ~TAIL_MASK) | ((tail << TAIL_SHIFT) & TAIL_MASK);3328 return (kbData & ~TAIL_MASK) | ((tail << TAIL_SHIFT) & TAIL_MASK);
3324 }3329 }
33253330
3326 static int encodeTailBlock(int size, int klength) {3331 static int encodeTailBlock(final int size, final int klength) {
3327 return ((klength << TAILBLOCK_KLENGTH_SHIFT) & TAILBLOCK_KLENGTH_MASK) | ((size /*3332 return ((klength << TAILBLOCK_KLENGTH_SHIFT) & TAILBLOCK_KLENGTH_MASK) | ((size /*
3328 * <<3333 * <<
3329 * TAILBLOCK_SIZE_SHIFT3334 * TAILBLOCK_SIZE_SHIFT
@@ -3331,35 +3336,35 @@
3331 | TAILBLOCK_INUSE_MASK;3336 | TAILBLOCK_INUSE_MASK;
3332 }3337 }
33333338
3334 static int encodeFreeBlock(int size) {3339 static int encodeFreeBlock(final int size) {
3335 return ((size /* << TAILBLOCK_SIZE_SHIFT */) & TAILBLOCK_SIZE_MASK);3340 return ((size /* << TAILBLOCK_SIZE_SHIFT */) & TAILBLOCK_SIZE_MASK);
3336 }3341 }
33373342
3338 static int decodeKeyBlockEbc(int kbData) {3343 static int decodeKeyBlockEbc(final int kbData) {
3339 return (kbData & EBC_MASK) >>> EBC_SHIFT;3344 return (kbData & EBC_MASK) >>> EBC_SHIFT;
3340 }3345 }
33413346
3342 static int decodeKeyBlockDb(int kbData) {3347 static int decodeKeyBlockDb(final int kbData) {
3343 return (kbData & DB_MASK) /* >>> DB_SHIFT */;3348 return (kbData & DB_MASK) /* >>> DB_SHIFT */;
3344 }3349 }
33453350
3346 static int decodeKeyBlockTail(int kbData) {3351 static int decodeKeyBlockTail(final int kbData) {
3347 return (kbData & TAIL_MASK) >>> TAIL_SHIFT;3352 return (kbData & TAIL_MASK) >>> TAIL_SHIFT;
3348 }3353 }
33493354
3350 static int decodeTailBlockSize(int tbData) {3355 static int decodeTailBlockSize(final int tbData) {
3351 return (tbData & TAILBLOCK_SIZE_MASK) /* >>> TAILBLOCK_SIZE_SHIFT */;3356 return (tbData & TAILBLOCK_SIZE_MASK) /* >>> TAILBLOCK_SIZE_SHIFT */;
3352 }3357 }
33533358
3354 static int decodeTailBlockKLength(int tbData) {3359 static int decodeTailBlockKLength(final int tbData) {
3355 return (tbData & TAILBLOCK_KLENGTH_MASK) >>> TAILBLOCK_KLENGTH_SHIFT;3360 return (tbData & TAILBLOCK_KLENGTH_MASK) >>> TAILBLOCK_KLENGTH_SHIFT;
3356 }3361 }
33573362
3358 static boolean decodeTailBlockInUse(int tbData) {3363 static boolean decodeTailBlockInUse(final int tbData) {
3359 return (tbData & TAILBLOCK_INUSE_MASK) != 0;3364 return (tbData & TAILBLOCK_INUSE_MASK) != 0;
3360 }3365 }
33613366
3362 static int decodeDepth(int foundAt) {3367 static int decodeDepth(final int foundAt) {
3363 return (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT;3368 return (foundAt & DEPTH_MASK) >>> DEPTH_SHIFT;
3364 }3369 }
33653370
@@ -3367,7 +3372,7 @@
3367 return _persistit.getThreadLocalIntArray(MAX_BUFFER_SIZE / TAILBLOCK_FACTOR);3372 return _persistit.getThreadLocalIntArray(MAX_BUFFER_SIZE / TAILBLOCK_FACTOR);
3368 }3373 }
33693374
3370 PersistitException verify(Key key, VerifyVisitor visitor) {3375 PersistitException verify(Key key, final VerifyVisitor visitor) {
3371 try {3376 try {
3372 if (_page == 0) {3377 if (_page == 0) {
3373 return new InvalidPageStructureException("head page is neither a data page nor an index page");3378 return new InvalidPageStructureException("head page is neither a data page nor an index page");
@@ -3380,8 +3385,8 @@
3380 key = new Key(_persistit);3385 key = new Key(_persistit);
3381 }3386 }
33823387
3383 byte[] kb = key.getEncodedBytes();3388 final byte[] kb = key.getEncodedBytes();
3384 int[] plan = getRepackPlanBuffer();3389 final int[] plan = getRepackPlanBuffer();
3385 for (int index = 0; index < plan.length; index++) {3390 for (int index = 0; index < plan.length; index++) {
3386 plan[index] = 0;3391 plan[index] = 0;
3387 }3392 }
@@ -3392,10 +3397,10 @@
3392 }3397 }
33933398
3394 for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) {3399 for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) {
3395 int kbData = getInt(p);3400 final int kbData = getInt(p);
3396 int db = decodeKeyBlockDb(kbData);3401 final int db = decodeKeyBlockDb(kbData);
3397 int ebc = decodeKeyBlockEbc(kbData);3402 final int ebc = decodeKeyBlockEbc(kbData);
3398 int tail = decodeKeyBlockTail(kbData);3403 final int tail = decodeKeyBlockTail(kbData);
33993404
3400 if (p == KEY_BLOCK_START && ebc != 0) {3405 if (p == KEY_BLOCK_START && ebc != 0) {
3401 return new InvalidPageStructureException("invalid initial ebc " + ebc + " for keyblock at " + p3406 return new InvalidPageStructureException("invalid initial ebc " + ebc + " for keyblock at " + p
@@ -3407,8 +3412,8 @@
3407 return new InvalidPageStructureException("invalid tail block offset " + tail + " for keyblock at "3412 return new InvalidPageStructureException("invalid tail block offset " + tail + " for keyblock at "
3408 + p + " --[" + summarize() + "]");3413 + p + " --[" + summarize() + "]");
3409 }3414 }
3410 int tbData = getInt(tail);3415 final int tbData = getInt(tail);
3411 int klength = decodeTailBlockKLength(tbData);3416 final int klength = decodeTailBlockKLength(tbData);
3412 if ((tbData & TAILBLOCK_INUSE_MASK) == 0) {3417 if ((tbData & TAILBLOCK_INUSE_MASK) == 0) {
3413 return new InvalidPageStructureException("not in-use tail block offset " + tail3418 return new InvalidPageStructureException("not in-use tail block offset " + tail
3414 + " for keyblock at " + p + " --[" + summarize() + "]");3419 + " for keyblock at " + p + " --[" + summarize() + "]");
@@ -3426,14 +3431,14 @@
3426 compare = (kb[index] & 0xFF) - (_bytes[tail + _tailHeaderSize + index - 1] & 0xFF);3431 compare = (kb[index] & 0xFF) - (_bytes[tail + _tailHeaderSize + index - 1] & 0xFF);
3427 }3432 }
3428 if (compare != 0) {3433 if (compare != 0) {
3429 String s = compare < 0 ? "too big" : "too small";3434 final String s = compare < 0 ? "too big" : "too small";
3430 return new InvalidPageStructureException("initial key " + s + " at offset " + index3435 return new InvalidPageStructureException("initial key " + s + " at offset " + index
3431 + " for keyblock at " + p + " --[" + summarize() + "]");3436 + " for keyblock at " + p + " --[" + summarize() + "]");
3432 }3437 }
3433 }3438 }
3434 // Verify that successor keys follow in sequence.3439 // Verify that successor keys follow in sequence.
3435 if (p > KEY_BLOCK_START && ebc < key.getEncodedSize()) {3440 if (p > KEY_BLOCK_START && ebc < key.getEncodedSize()) {
3436 int dbPrev = kb[ebc] & 0xFF;3441 final int dbPrev = kb[ebc] & 0xFF;
3437 if (db < dbPrev) {3442 if (db < dbPrev) {
3438 return new InvalidPageStructureException("db not greater: db=" + db + " dbPrev=" + dbPrev3443 return new InvalidPageStructureException("db not greater: db=" + db + " dbPrev=" + dbPrev
3439 + " for keyblock at " + p + " --[" + summarize() + "]");3444 + " for keyblock at " + p + " --[" + summarize() + "]");
@@ -3444,7 +3449,7 @@
3444 // redundant3449 // redundant
3445 //3450 //
3446 if (isIndexPage()) {3451 if (isIndexPage()) {
3447 int pointer = getInt(tail + 4);3452 final int pointer = getInt(tail + 4);
3448 if (visitor != null) {3453 if (visitor != null) {
3449 visitor.visitIndexRecord(key, p, tail, klength, pointer);3454 visitor.visitIndexRecord(key, p, tail, klength, pointer);
3450 }3455 }
@@ -3455,9 +3460,9 @@
3455 }3460 }
3456 }3461 }
3457 } else if (isDataPage()) {3462 } else if (isDataPage()) {
3458 int size = decodeTailBlockSize(tbData);3463 final int size = decodeTailBlockSize(tbData);
3459 int offset = tail + _tailHeaderSize + klength;3464 final int offset = tail + _tailHeaderSize + klength;
3460 int length = size - klength - _tailHeaderSize;3465 final int length = size - klength - _tailHeaderSize;
3461 if (visitor != null) {3466 if (visitor != null) {
3462 visitor.visitDataRecord(key, p, tail, klength, offset, length, getBytes());3467 visitor.visitDataRecord(key, p, tail, klength, offset, length, getBytes());
3463 }3468 }
@@ -3477,13 +3482,13 @@
34773482
3478 // Now check the free blocks3483 // Now check the free blocks
34793484
3480 int formerBlock = _alloc;3485 final int formerBlock = _alloc;
3481 for (int tail = _alloc; tail < _bufferSize;) {3486 for (int tail = _alloc; tail < _bufferSize;) {
3482 if ((tail & ~TAILBLOCK_MASK) != 0 || tail < 0 || tail > _bufferSize) {3487 if ((tail & ~TAILBLOCK_MASK) != 0 || tail < 0 || tail > _bufferSize) {
3483 return new InvalidPageStructureException("Tail block at " + formerBlock + " is invalid");3488 return new InvalidPageStructureException("Tail block at " + formerBlock + " is invalid");
3484 }3489 }
3485 int tbData = getInt(tail);3490 final int tbData = getInt(tail);
3486 int size = decodeTailBlockSize(tbData);3491 final int size = decodeTailBlockSize(tbData);
3487 if (size <= ~TAILBLOCK_MASK || size >= _bufferSize - _keyBlockEnd) {3492 if (size <= ~TAILBLOCK_MASK || size >= _bufferSize - _keyBlockEnd) {
3488 return new InvalidPageStructureException("Tailblock at " + tail + " has invalid size=" + size);3493 return new InvalidPageStructureException("Tailblock at " + tail + " has invalid size=" + size);
3489 }3494 }
@@ -3492,7 +3497,7 @@
3492 return new InvalidPageStructureException("Tailblock at " + tail + " is in use, but no key "3497 return new InvalidPageStructureException("Tailblock at " + tail + " is in use, but no key "
3493 + " block points to it.");3498 + " block points to it.");
3494 }3499 }
3495 int klength = decodeTailBlockKLength(tbData);3500 final int klength = decodeTailBlockKLength(tbData);
3496 {3501 {
3497 if (klength + _tailHeaderSize > size) {3502 if (klength + _tailHeaderSize > size) {
3498 return new InvalidPageStructureException("Tailblock at " + tail + " has klength=" + klength3503 return new InvalidPageStructureException("Tailblock at " + tail + " has klength=" + klength
@@ -3508,7 +3513,7 @@
3508 tail += ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK);3513 tail += ((size + ~TAILBLOCK_MASK) & TAILBLOCK_MASK);
3509 }3514 }
3510 return null;3515 return null;
3511 } catch (PersistitException pe) {3516 } catch (final PersistitException pe) {
3512 return pe;3517 return pe;
3513 }3518 }
35143519
@@ -3528,7 +3533,7 @@
3528 * @return3533 * @return
3529 * @throws PersistitException3534 * @throws PersistitException
3530 */3535 */
3531 boolean pruneMvvValues(final Tree tree, boolean pruneLongMVVs) throws PersistitException {3536 boolean pruneMvvValues(final Tree tree, final boolean pruneLongMVVs) throws PersistitException {
35323537
3533 boolean changed = false;3538 boolean changed = false;
3534 try {3539 try {
@@ -3541,7 +3546,7 @@
3541 final long timestamp = _persistit.getTimestampAllocator().updateTimestamp();3546 final long timestamp = _persistit.getTimestampAllocator().updateTimestamp();
3542 _mvvCount = 0;3547 _mvvCount = 0;
3543 writePageOnCheckpoint(timestamp);3548 writePageOnCheckpoint(timestamp);
3544 List<PrunedVersion> prunedVersions = new ArrayList<PrunedVersion>();3549 final List<PrunedVersion> prunedVersions = new ArrayList<PrunedVersion>();
3545 for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) {3550 for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) {
3546 final int kbData = getInt(p);3551 final int kbData = getInt(p);
3547 final int tail = decodeKeyBlockTail(kbData);3552 final int tail = decodeKeyBlockTail(kbData);
@@ -3567,9 +3572,9 @@
3567 true, prunedVersions);3572 true, prunedVersions);
3568 if (newSize != oldSize) {3573 if (newSize != oldSize) {
3569 changed = true;3574 changed = true;
3570 int newTailSize = klength + newSize + _tailHeaderSize;3575 final int newTailSize = klength + newSize + _tailHeaderSize;
3571 int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;3576 final int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
3572 int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;3577 final int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
3573 if (newNext < oldNext) {3578 if (newNext < oldNext) {
3574 // Free the remainder of the old tail block3579 // Free the remainder of the old tail block
3575 deallocTail(newNext, oldNext - newNext);3580 deallocTail(newNext, oldNext - newNext);
@@ -3600,11 +3605,11 @@
3600 prunedVersions.clear();3605 prunedVersions.clear();
36013606
3602 if (pruneLongMVVs && hasLongMvvRecords) {3607 if (pruneLongMVVs && hasLongMvvRecords) {
3603 List<PersistitException> deferredExceptions = new ArrayList<PersistitException>();3608 final List<PersistitException> deferredExceptions = new ArrayList<PersistitException>();
3604 List<Long> oldChainsToDeallocate = new ArrayList<Long>();3609 final List<Long> oldChainsToDeallocate = new ArrayList<Long>();
36053610
3606 Buffer copy = new Buffer(this);3611 final Buffer copy = new Buffer(this);
3607 boolean copyChanged = copy.pruneLongMvvValues(tree, prunedVersions, deferredExceptions,3612 final boolean copyChanged = copy.pruneLongMvvValues(tree, prunedVersions, deferredExceptions,
3608 oldChainsToDeallocate);3613 oldChainsToDeallocate);
3609 if (copyChanged) {3614 if (copyChanged) {
3610 changed = true;3615 changed = true;
@@ -3666,17 +3671,17 @@
3666 boolean pruned = false;3671 boolean pruned = false;
3667 try {3672 try {
3668 pruned = pruneLongMvv(_bytes, offset, oldSize, value, prunedVersions, toDeallocate);3673 pruned = pruneLongMvv(_bytes, offset, oldSize, value, prunedVersions, toDeallocate);
3669 } catch (PersistitException pe) {3674 } catch (final PersistitException pe) {
3670 deferredExceptions.add(pe);3675 deferredExceptions.add(pe);
3671 }3676 }
3672 if (pruned) {3677 if (pruned) {
3673 changed = true;3678 changed = true;
3674 int newSize = value.getEncodedSize();3679 final int newSize = value.getEncodedSize();
3675 assert newSize <= oldSize : "Pruned long value overflow";3680 assert newSize <= oldSize : "Pruned long value overflow";
3676 System.arraycopy(value.getEncodedBytes(), 0, _bytes, offset, newSize);3681 System.arraycopy(value.getEncodedBytes(), 0, _bytes, offset, newSize);
3677 int newTailSize = klength + newSize + _tailHeaderSize;3682 final int newTailSize = klength + newSize + _tailHeaderSize;
3678 int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;3683 final int oldNext = (tail + oldTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
3679 int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;3684 final int newNext = (tail + newTailSize + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
3680 if (newNext < oldNext) {3685 if (newNext < oldNext) {
3681 // Free the remainder of the old tail block3686 // Free the remainder of the old tail block
3682 deallocTail(newNext, oldNext - newNext);3687 deallocTail(newNext, oldNext - newNext);
@@ -3709,8 +3714,7 @@
3709 if (!_enqueuedForAntiValuePruning) {3714 if (!_enqueuedForAntiValuePruning) {
3710 final int treeHandle = tree.getHandle();3715 final int treeHandle = tree.getHandle();
3711 assert treeHandle != 0 : "MVV found in a temporary tree " + tree;3716 assert treeHandle != 0 : "MVV found in a temporary tree " + tree;
3712 if (_persistit.getCleanupManager().offer(3717 if (_persistit.getCleanupManager().offer(new CleanupAntiValue(treeHandle, getPageAddress()))) {
3713 new CleanupAntiValue(treeHandle, getPageAddress()))) {
3714 _enqueuedForAntiValuePruning = true;3718 _enqueuedForAntiValuePruning = true;
3715 }3719 }
3716 }3720 }
@@ -3731,19 +3735,19 @@
3731 private boolean pruneLongMvv(final byte[] bytes, final int offset, final int oldSize, final Value value,3735 private boolean pruneLongMvv(final byte[] bytes, final int offset, final int oldSize, final Value value,
3732 final List<PrunedVersion> prunedVersions, final List<Long> toDeallocate) throws PersistitException {3736 final List<PrunedVersion> prunedVersions, final List<Long> toDeallocate) throws PersistitException {
3733 assert isLongMVV(bytes, offset, oldSize) : "Not a long MVV";3737 assert isLongMVV(bytes, offset, oldSize) : "Not a long MVV";
3734 long oldLongRecordChain = decodeLongRecordDescriptorPointer(bytes, offset);3738 final long oldLongRecordChain = decodeLongRecordDescriptorPointer(bytes, offset);
3735 value.changeLongRecordMode(false);3739 value.changeLongRecordMode(false);
3736 value.ensureFit(oldSize);3740 value.ensureFit(oldSize);
3737 System.arraycopy(bytes, offset, value.getEncodedBytes(), 0, oldSize);3741 System.arraycopy(bytes, offset, value.getEncodedBytes(), 0, oldSize);
3738 value.setEncodedSize(oldSize);3742 value.setEncodedSize(oldSize);
3739 final LongRecordHelper helper = new LongRecordHelper(_persistit, _vol);3743 final LongRecordHelper helper = new LongRecordHelper(_persistit, _vol);
3740 helper.fetchLongRecord(value, Integer.MAX_VALUE);3744 helper.fetchLongRecord(value, Integer.MAX_VALUE);
3741 byte[] rawBytes = value.getEncodedBytes();3745 final byte[] rawBytes = value.getEncodedBytes();
3742 int oldLongSize = value.getEncodedSize();3746 final int oldLongSize = value.getEncodedSize();
3743 // TODO - perhaps remove. Done as a precaution for now.3747 // TODO - perhaps remove. Done as a precaution for now.
3744 MVV.verify(rawBytes, 0, oldLongSize);3748 MVV.verify(rawBytes, 0, oldLongSize);
3745 List<PrunedVersion> provisionalPrunedVersions = new ArrayList<PrunedVersion>();3749 final List<PrunedVersion> provisionalPrunedVersions = new ArrayList<PrunedVersion>();
3746 int newLongSize = MVV.prune(rawBytes, 0, oldLongSize, _persistit.getTransactionIndex(), true,3750 final int newLongSize = MVV.prune(rawBytes, 0, oldLongSize, _persistit.getTransactionIndex(), true,
3747 provisionalPrunedVersions);3751 provisionalPrunedVersions);
3748 if (newLongSize == oldLongSize) {3752 if (newLongSize == oldLongSize) {
3749 // No pruning done.3753 // No pruning done.
@@ -3771,6 +3775,7 @@
3771 getTimestamp(), getGeneration());3775 getTimestamp(), getGeneration());
3772 }3776 }
37733777
3778 @Override
3774 public String toString() {3779 public String toString() {
3775 if (_toStringDebug) {3780 if (_toStringDebug) {
3776 return toStringDetail();3781 return toStringDetail();
@@ -3818,7 +3823,7 @@
3818 }3823 }
3819 boolean elision = false;3824 boolean elision = false;
3820 for (int index = 0; index < records.length; index++) {3825 for (int index = 0; index < records.length; index++) {
3821 RecordInfo r = records[index];3826 final RecordInfo r = records[index];
3822 r.getKeyState().copyTo(key);3827 r.getKeyState().copyTo(key);
3823 String mark = " ";3828 String mark = " ";
3824 boolean selected = all | index < contextLines || index >= records.length - contextLines;3829 boolean selected = all | index < contextLines || index >= records.length - contextLines;
@@ -3843,16 +3848,16 @@
3843 r.getValueState().getEncodedBytes().length, Util.abridge(value.toString(),3848 r.getValueState().getEncodedBytes().length, Util.abridge(value.toString(),
3844 maxValueDisplayLength)));3849 maxValueDisplayLength)));
3845 } else {3850 } else {
3846 sb.append(String.format("\n%s %5d: db=%3d ebc=%3d tb=%,5d [%,d]%s->%,d", mark, r3851 sb.append(String.format("\n%s %5d: db=%3d ebc=%3d tb=%,5d [%,d]%s->%,d", mark,
3847 .getKbOffset(), r.getDb(), r.getEbc(), r.getTbOffset(), r.getKLength(), Util3852 r.getKbOffset(), r.getDb(), r.getEbc(), r.getTbOffset(), r.getKLength(),
3848 .abridge(key.toString(), maxKeyDisplayLength), r.getPointerValue()));3853 Util.abridge(key.toString(), maxKeyDisplayLength), r.getPointerValue()));
3849 }3854 }
3850 } else {3855 } else {
3851 elision = true;3856 elision = true;
3852 }3857 }
38533858
3854 }3859 }
3855 } catch (Exception e) {3860 } catch (final Exception e) {
3856 sb.append(" - " + e);3861 sb.append(" - " + e);
3857 }3862 }
3858 } else if (isHeadPage()) {3863 } else if (isHeadPage()) {
@@ -3876,7 +3881,7 @@
3876 }3881 }
38773882
3878 String foundAtString(int p) {3883 String foundAtString(int p) {
3879 StringBuilder sb = new StringBuilder("<");3884 final StringBuilder sb = new StringBuilder("<");
3880 sb.append(p & P_MASK);3885 sb.append(p & P_MASK);
3881 if ((p & EXACT_MASK) != 0)3886 if ((p & EXACT_MASK) != 0)
3882 sb.append(":exact");3887 sb.append(":exact");
@@ -3892,7 +3897,7 @@
3892 else if (p + KEYBLOCK_LENGTH == _keyBlockEnd)3897 else if (p + KEYBLOCK_LENGTH == _keyBlockEnd)
3893 sb.append(":end");3898 sb.append(":end");
3894 else {3899 else {
3895 int kbData = getInt(p);3900 final int kbData = getInt(p);
3896 sb.append(":ebc=" + decodeKeyBlockEbc(kbData));3901 sb.append(":ebc=" + decodeKeyBlockEbc(kbData));
3897 sb.append(":db=" + decodeKeyBlockDb(kbData));3902 sb.append(":db=" + decodeKeyBlockDb(kbData));
3898 sb.append(":tail=" + decodeKeyBlockTail(kbData));3903 sb.append(":tail=" + decodeKeyBlockTail(kbData));
@@ -3908,23 +3913,23 @@
3908 ManagementImpl.RecordInfo[] result = null;3913 ManagementImpl.RecordInfo[] result = null;
39093914
3910 if (isIndexPage() || isDataPage()) {3915 if (isIndexPage() || isDataPage()) {
3911 Key key = new Key(_persistit);3916 final Key key = new Key(_persistit);
3912 Value value = new Value(_persistit);3917 final Value value = new Value(_persistit);
39133918
3914 int count = (_keyBlockEnd - KEY_BLOCK_START) / KEYBLOCK_LENGTH;3919 final int count = (_keyBlockEnd - KEY_BLOCK_START) / KEYBLOCK_LENGTH;
3915 result = new ManagementImpl.RecordInfo[count];3920 result = new ManagementImpl.RecordInfo[count];
3916 int n = 0;3921 int n = 0;
3917 for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) {3922 for (int p = KEY_BLOCK_START; p < _keyBlockEnd; p += KEYBLOCK_LENGTH) {
3918 int kbData = getInt(p);3923 final int kbData = getInt(p);
3919 int db = decodeKeyBlockDb(kbData);3924 final int db = decodeKeyBlockDb(kbData);
3920 int ebc = decodeKeyBlockEbc(kbData);3925 final int ebc = decodeKeyBlockEbc(kbData);
3921 int tail = decodeKeyBlockTail(kbData);3926 final int tail = decodeKeyBlockTail(kbData);
3922 int tbData = tail != 0 ? getInt(tail) : 0;3927 final int tbData = tail != 0 ? getInt(tail) : 0;
3923 int size = decodeTailBlockSize(tbData);3928 final int size = decodeTailBlockSize(tbData);
3924 int klength = decodeTailBlockKLength(tbData);3929 final int klength = decodeTailBlockKLength(tbData);
3925 boolean inUse = decodeTailBlockInUse(tbData);3930 final boolean inUse = decodeTailBlockInUse(tbData);
39263931
3927 ManagementImpl.RecordInfo rec = new ManagementImpl.RecordInfo();3932 final ManagementImpl.RecordInfo rec = new ManagementImpl.RecordInfo();
3928 rec._kbOffset = p;3933 rec._kbOffset = p;
3929 rec._tbOffset = tail;3934 rec._tbOffset = tail;
3930 rec._ebc = ebc;3935 rec._ebc = ebc;
@@ -3933,7 +3938,7 @@
3933 rec._size = size;3938 rec._size = size;
3934 rec._inUse = inUse;3939 rec._inUse = inUse;
39353940
3936 byte[] kbytes = key.getEncodedBytes();3941 final byte[] kbytes = key.getEncodedBytes();
3937 kbytes[ebc] = (byte) db;3942 kbytes[ebc] = (byte) db;
3938 System.arraycopy(_bytes, tail + _tailHeaderSize, kbytes, ebc + 1, klength);3943 System.arraycopy(_bytes, tail + _tailHeaderSize, kbytes, ebc + 1, klength);
3939 key.setEncodedSize(ebc + 1 + klength);3944 key.setEncodedSize(ebc + 1 + klength);
@@ -3956,11 +3961,11 @@
3956 result[n++] = rec;3961 result[n++] = rec;
3957 }3962 }
3958 } else if (isGarbagePage()) {3963 } else if (isGarbagePage()) {
3959 int count = (_bufferSize - _alloc) / GARBAGE_BLOCK_SIZE;3964 final int count = (_bufferSize - _alloc) / GARBAGE_BLOCK_SIZE;
3960 result = new ManagementImpl.RecordInfo[count];3965 result = new ManagementImpl.RecordInfo[count];
3961 int n = 0;3966 int n = 0;
3962 for (int p = _alloc; p < _bufferSize; p += GARBAGE_BLOCK_SIZE) {3967 for (int p = _alloc; p < _bufferSize; p += GARBAGE_BLOCK_SIZE) {
3963 ManagementImpl.RecordInfo rec = new ManagementImpl.RecordInfo();3968 final ManagementImpl.RecordInfo rec = new ManagementImpl.RecordInfo();
3964 rec._tbOffset = p;3969 rec._tbOffset = p;
3965 rec._garbageStatus = getInt(p + GARBAGE_BLOCK_STATUS);3970 rec._garbageStatus = getInt(p + GARBAGE_BLOCK_STATUS);
3966 rec._garbageLeftPage = getLong(p + GARBAGE_BLOCK_LEFT_PAGE);3971 rec._garbageLeftPage = getLong(p + GARBAGE_BLOCK_LEFT_PAGE);
@@ -3973,12 +3978,12 @@
39733978
3974 void assertVerify() {3979 void assertVerify() {
3975 if (Debug.VERIFY_PAGES) {3980 if (Debug.VERIFY_PAGES) {
3976 Exception verifyException = verify(null, null);3981 final Exception verifyException = verify(null, null);
3977 Debug.$assert1.t(verifyException == null);3982 Debug.$assert1.t(verifyException == null);
3978 }3983 }
3979 }3984 }
39803985
3981 boolean addGarbageChain(long left, long right, long expectedCount) {3986 boolean addGarbageChain(final long left, final long right, final long expectedCount) {
3982 Debug.$assert0.t(left > 0 && left <= MAX_VALID_PAGE_ADDR && left != _page && right != _page && isGarbagePage());3987 Debug.$assert0.t(left > 0 && left <= MAX_VALID_PAGE_ADDR && left != _page && right != _page && isGarbagePage());
39833988
3984 if (_alloc - GARBAGE_BLOCK_SIZE < _keyBlockEnd) {3989 if (_alloc - GARBAGE_BLOCK_SIZE < _keyBlockEnd) {
@@ -4006,7 +4011,7 @@
4006 Debug.$assert0.t(isGarbagePage());4011 Debug.$assert0.t(isGarbagePage());
4007 if (_alloc + GARBAGE_BLOCK_SIZE > _bufferSize)4012 if (_alloc + GARBAGE_BLOCK_SIZE > _bufferSize)
4008 return -1;4013 return -1;
4009 long page = getLong(_alloc + GARBAGE_BLOCK_LEFT_PAGE);4014 final long page = getLong(_alloc + GARBAGE_BLOCK_LEFT_PAGE);
4010 Debug.$assert0.t(page > 0 && page <= MAX_VALID_PAGE_ADDR && page != _page);4015 Debug.$assert0.t(page > 0 && page <= MAX_VALID_PAGE_ADDR && page != _page);
4011 return page;4016 return page;
4012 }4017 }
@@ -4019,13 +4024,13 @@
4019 return getLong(_alloc + GARBAGE_BLOCK_RIGHT_PAGE);4024 return getLong(_alloc + GARBAGE_BLOCK_RIGHT_PAGE);
4020 }4025 }
40214026
4022 long getGarbageChainLeftPage(int p) {4027 long getGarbageChainLeftPage(final int p) {
4023 long page = getLong(p + GARBAGE_BLOCK_LEFT_PAGE);4028 final long page = getLong(p + GARBAGE_BLOCK_LEFT_PAGE);
4024 Debug.$assert1.t(page > 0 && page <= MAX_VALID_PAGE_ADDR && page != _page);4029 Debug.$assert1.t(page > 0 && page <= MAX_VALID_PAGE_ADDR && page != _page);
4025 return page;4030 return page;
4026 }4031 }
40274032
4028 long getGarbageChainRightPage(int p) {4033 long getGarbageChainRightPage(final int p) {
4029 return getLong(p + GARBAGE_BLOCK_RIGHT_PAGE);4034 return getLong(p + GARBAGE_BLOCK_RIGHT_PAGE);
4030 }4035 }
40314036
@@ -4036,18 +4041,18 @@
4036 bumpGeneration();4041 bumpGeneration();
4037 }4042 }
40384043
4039 void setGarbageLeftPage(long left) {4044 void setGarbageLeftPage(final long left) {
4040 Debug.$assert1.t(isMine() && isGarbagePage() && left > 0 && left <= MAX_VALID_PAGE_ADDR && left != _page4045 Debug.$assert1.t(isMine() && isGarbagePage() && left > 0 && left <= MAX_VALID_PAGE_ADDR && left != _page
4041 && _alloc + GARBAGE_BLOCK_SIZE <= _bufferSize && _alloc >= _keyBlockEnd);4046 && _alloc + GARBAGE_BLOCK_SIZE <= _bufferSize && _alloc >= _keyBlockEnd);
4042 putLong(_alloc + GARBAGE_BLOCK_LEFT_PAGE, left);4047 putLong(_alloc + GARBAGE_BLOCK_LEFT_PAGE, left);
4043 bumpGeneration();4048 bumpGeneration();
4044 }4049 }
40454050
4046 void populateInfo(ManagementImpl.BufferInfo info) {4051 void populateInfo(final ManagementImpl.BufferInfo info) {
4047 info.poolIndex = _poolIndex;4052 info.poolIndex = _poolIndex;
4048 info.pageAddress = _page;4053 info.pageAddress = _page;
4049 info.rightSiblingAddress = _rightSibling;4054 info.rightSiblingAddress = _rightSibling;
4050 Volume vol = _vol;4055 final Volume vol = _vol;
4051 if (vol != null) {4056 if (vol != null) {
4052 info.volumeName = vol.getPath();4057 info.volumeName = vol.getPath();
4053 } else {4058 } else {
@@ -4064,7 +4069,7 @@
4064 info.timestamp = _timestamp;4069 info.timestamp = _timestamp;
4065 info.status = getStatus();4070 info.status = getStatus();
4066 info.statusName = getStatusCode();4071 info.statusName = getStatusCode();
4067 Thread writerThread = getWriterThread();4072 final Thread writerThread = getWriterThread();
4068 if (writerThread != null) {4073 if (writerThread != null) {
4069 info.writerThreadName = writerThread.getName();4074 info.writerThreadName = writerThread.getName();
4070 } else {4075 } else {
@@ -4075,10 +4080,10 @@
40754080
4076 void enqueuePruningAction(final int treeHandle) {4081 void enqueuePruningAction(final int treeHandle) {
4077 if (_mvvCount > 0) {4082 if (_mvvCount > 0) {
4078 long delay = _persistit.getCleanupManager().getMinimumPruningDelay();4083 final long delay = _persistit.getCleanupManager().getMinimumPruningDelay();
4079 if (delay > 0) {4084 if (delay > 0) {
4080 long last = _lastPrunedTime;4085 final long last = _lastPrunedTime;
4081 long now = System.currentTimeMillis();4086 final long now = System.currentTimeMillis();
4082 if (now - last > delay) {4087 if (now - last > delay) {
4083 _lastPrunedTime = now;4088 _lastPrunedTime = now;
4084 _persistit.getCleanupManager().offer(4089 _persistit.getCleanupManager().offer(
@@ -4105,9 +4110,9 @@
4105 * writes an IV record.4110 * writes an IV record.
4106 * @throws Exception4111 * @throws Exception
4107 */4112 */
4108 void dump(final ByteBuffer bb, final boolean secure, boolean verbose, final Set<Volume> identifiedVolumes)4113 void dump(final ByteBuffer bb, final boolean secure, final boolean verbose, final Set<Volume> identifiedVolumes)
4109 throws Exception {4114 throws Exception {
4110 byte[] bytes = new byte[_bufferSize];4115 final byte[] bytes = new byte[_bufferSize];
4111 int type;4116 int type;
4112 int keyBlockEnd;4117 int keyBlockEnd;
4113 int alloc;4118 int alloc;
@@ -4120,7 +4125,7 @@
4120 /*4125 /*
4121 * Copy all the information needed quickly and then release the buffer.4126 * Copy all the information needed quickly and then release the buffer.
4122 */4127 */
4123 boolean claimed = claim(false, Persistit.SHORT_DELAY);4128 final boolean claimed = claim(false, Persistit.SHORT_DELAY);
4124 try {4129 try {
4125 bufferSize = _bufferSize;4130 bufferSize = _bufferSize;
4126 type = _type;4131 type = _type;
@@ -4138,12 +4143,12 @@
4138 }4143 }
4139 }4144 }
41404145
4141 String toString = toString();4146 final String toString = toString();
4142 if (verbose) {4147 if (verbose) {
4143 System.out.println(toString);4148 System.out.println(toString);
4144 }4149 }
41454150
4146 int volumeHandle = volume == null ? 0 : volume.getHandle();4151 final int volumeHandle = volume == null ? 0 : volume.getHandle();
4147 if (volume != null && !identifiedVolumes.contains(volume)) {4152 if (volume != null && !identifiedVolumes.contains(volume)) {
4148 IV.putType(bb);4153 IV.putType(bb);
4149 IV.putHandle(bb, volumeHandle);4154 IV.putHandle(bb, volumeHandle);
@@ -4154,9 +4159,9 @@
4154 identifiedVolumes.add(volume);4159 identifiedVolumes.add(volume);
4155 }4160 }
41564161
4157 boolean isDataPage = type == PAGE_TYPE_DATA;4162 final boolean isDataPage = type == PAGE_TYPE_DATA;
4158 boolean isIndexPage = type >= PAGE_TYPE_INDEX_MIN && type <= PAGE_TYPE_INDEX_MAX;4163 final boolean isIndexPage = type >= PAGE_TYPE_INDEX_MIN && type <= PAGE_TYPE_INDEX_MAX;
4159 boolean isLongRecordPage = type == PAGE_TYPE_LONG_RECORD;4164 final boolean isLongRecordPage = type == PAGE_TYPE_LONG_RECORD;
41604165
4161 /*4166 /*
4162 * Following is equivalent to the save method, except written to the4167 * Following is equivalent to the save method, except written to the
@@ -4187,7 +4192,7 @@
4187 } else if (secure && isLongRecordPage) {4192 } else if (secure && isLongRecordPage) {
4188 left = KEY_BLOCK_START;4193 left = KEY_BLOCK_START;
4189 }4194 }
4190 int recordSize = PA.OVERHEAD + left + right;4195 final int recordSize = PA.OVERHEAD + left + right;
4191 PA.putLength(bb, recordSize);4196 PA.putLength(bb, recordSize);
4192 PA.putType(bb);4197 PA.putType(bb);
4193 PA.putVolumeHandle(bb, volumeHandle);4198 PA.putVolumeHandle(bb, volumeHandle);
@@ -4207,7 +4212,7 @@
4207 * @param bytes4212 * @param bytes
4208 * buffer image4213 * buffer image
4209 */4214 */
4210 private void dumpSecureOverwriteValues(byte[] bytes) {4215 private void dumpSecureOverwriteValues(final byte[] bytes) {
4211 if (bytes[0] != PAGE_TYPE_DATA) {4216 if (bytes[0] != PAGE_TYPE_DATA) {
4212 return;4217 return;
4213 }4218 }
@@ -4216,12 +4221,12 @@
4216 * overwrite values.4221 * overwrite values.
4217 */4222 */
4218 for (int p = KEY_BLOCK_START; p < Util.getInt(bytes, KEY_BLOCK_END_OFFSET); p += KEYBLOCK_LENGTH) {4223 for (int p = KEY_BLOCK_START; p < Util.getInt(bytes, KEY_BLOCK_END_OFFSET); p += KEYBLOCK_LENGTH) {
4219 int kbData = Util.getInt(bytes, p);4224 final int kbData = Util.getInt(bytes, p);
4220 int db = decodeKeyBlockDb(kbData);4225 final int db = decodeKeyBlockDb(kbData);
4221 if (db == 0 && p == KEY_BLOCK_START) {4226 if (db == 0 && p == KEY_BLOCK_START) {
4222 continue;4227 continue;
4223 } else if (db == Key.TYPE_STRING) {4228 } else if (db == Key.TYPE_STRING) {
4224 int tail = decodeKeyBlockTail(kbData);4229 final int tail = decodeKeyBlockTail(kbData);
4225 if (bytes[tail + TAILBLOCK_HDR_SIZE_DATA] == '_') {4230 if (bytes[tail + TAILBLOCK_HDR_SIZE_DATA] == '_') {
4226 // Probably a system key - don't overwrite values4231 // Probably a system key - don't overwrite values
4227 return;4232 return;
@@ -4235,9 +4240,9 @@
42354240
4236 int tail = Util.getChar(bytes, FREE_OFFSET);4241 int tail = Util.getChar(bytes, FREE_OFFSET);
4237 for (; tail < bytes.length;) {4242 for (; tail < bytes.length;) {
4238 int tbData = Util.getInt(bytes, tail);4243 final int tbData = Util.getInt(bytes, tail);
4239 int tbSize = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;4244 final int tbSize = (decodeTailBlockSize(tbData) + ~TAILBLOCK_MASK) & TAILBLOCK_MASK;
4240 int tbKLength = decodeTailBlockKLength(tbData);4245 final int tbKLength = decodeTailBlockKLength(tbData);
4241 //4246 //
4242 // If the tbSize field is corrupt then just dump the4247 // If the tbSize field is corrupt then just dump the
4243 // remainder of the buffer4248 // remainder of the buffer
@@ -4250,7 +4255,7 @@
4250 // Otherwise, dump just the portion of the tailblock we4255 // Otherwise, dump just the portion of the tailblock we
4251 // need for analysis and fill the rest with 'x's.4256 // need for analysis and fill the rest with 'x's.
4252 //4257 //
4253 boolean tbInUse = decodeTailBlockInUse(tbData);4258 final boolean tbInUse = decodeTailBlockInUse(tbData);
4254 // Number of bytes we need to dump4259 // Number of bytes we need to dump
4255 int keep;4260 int keep;
4256 if (tbInUse) {4261 if (tbInUse) {
@@ -4272,7 +4277,8 @@
4272 }4277 }
4273 }4278 }
42744279
4275 static void deallocatePrunedVersions(Persistit persistit, Volume volume, List<PrunedVersion> prunedVersions) {4280 static void deallocatePrunedVersions(final Persistit persistit, final Volume volume,
4281 final List<PrunedVersion> prunedVersions) {
4276 for (final PrunedVersion pv : prunedVersions) {4282 for (final PrunedVersion pv : prunedVersions) {
4277 final TransactionStatus ts = persistit.getTransactionIndex().getStatus(pv.getTs());4283 final TransactionStatus ts = persistit.getTransactionIndex().getStatus(pv.getTs());
4278 if (ts != null && ts.getTc() == TransactionStatus.ABORTED) {4284 if (ts != null && ts.getTc() == TransactionStatus.ABORTED) {
@@ -4281,7 +4287,7 @@
4281 if (pv.getLongRecordPage() != 0) {4287 if (pv.getLongRecordPage() != 0) {
4282 try {4288 try {
4283 volume.getStructure().deallocateGarbageChain(pv.getLongRecordPage(), 0);4289 volume.getStructure().deallocateGarbageChain(pv.getLongRecordPage(), 0);
4284 } catch (PersistitException e) {4290 } catch (final PersistitException e) {
4285 persistit.getLogBase().pruneException.log(e, ts);4291 persistit.getLogBase().pruneException.log(e, ts);
4286 }4292 }
4287 }4293 }
@@ -4289,20 +4295,20 @@
4289 prunedVersions.clear();4295 prunedVersions.clear();
4290 }4296 }
42914297
4292 static boolean isLongRecord(byte[] bytes, int offset, int length) {4298 static boolean isLongRecord(final byte[] bytes, final int offset, final int length) {
4293 return (length > 0) && ((bytes[offset] & 0xFF) == LONGREC_TYPE);4299 return (length > 0) && ((bytes[offset] & 0xFF) == LONGREC_TYPE);
4294 }4300 }
42954301
4296 static boolean isLongMVV(byte[] bytes, int offset, int length) {4302 static boolean isLongMVV(final byte[] bytes, final int offset, final int length) {
4297 return isLongRecord(bytes, offset, length) && (length > LONGREC_PREFIX_OFFSET)4303 return isLongRecord(bytes, offset, length) && (length > LONGREC_PREFIX_OFFSET)
4298 && MVV.isArrayMVV(bytes, offset + LONGREC_PREFIX_OFFSET, length - LONGREC_PREFIX_OFFSET);4304 && MVV.isArrayMVV(bytes, offset + LONGREC_PREFIX_OFFSET, length - LONGREC_PREFIX_OFFSET);
4299 }4305 }
43004306
4301 static boolean isValueMVV(byte[] bytes, int offset, int length) {4307 static boolean isValueMVV(final byte[] bytes, final int offset, final int length) {
4302 return MVV.isArrayMVV(bytes, offset, length) || isLongMVV(bytes, offset, length);4308 return MVV.isArrayMVV(bytes, offset, length) || isLongMVV(bytes, offset, length);
4303 }4309 }
43044310
4305 private void incCountIfMvv(byte[] bytes, int offset, int length) {4311 private void incCountIfMvv(final byte[] bytes, final int offset, final int length) {
4306 if (isValueMVV(bytes, offset, length)) {4312 if (isValueMVV(bytes, offset, length)) {
4307 ++_mvvCount;4313 ++_mvvCount;
4308 }4314 }
43094315
=== modified file 'src/main/java/com/persistit/BufferPool.java'
--- src/main/java/com/persistit/BufferPool.java 2012-08-07 21:11:28 +0000
+++ src/main/java/com/persistit/BufferPool.java 2012-08-24 18:21:19 +0000
@@ -16,9 +16,13 @@
16package com.persistit;16package com.persistit;
1717
18import java.io.DataOutputStream;18import java.io.DataOutputStream;
19import java.io.IOException;
19import java.nio.ByteBuffer;20import java.nio.ByteBuffer;
21import java.util.ArrayList;
20import java.util.Arrays;22import java.util.Arrays;
23import java.util.Collections;
21import java.util.HashSet;24import java.util.HashSet;
25import java.util.List;
22import java.util.Set;26import java.util.Set;
23import java.util.concurrent.atomic.AtomicBoolean;27import java.util.concurrent.atomic.AtomicBoolean;
24import java.util.concurrent.atomic.AtomicInteger;28import java.util.concurrent.atomic.AtomicInteger;
@@ -26,6 +30,7 @@
26import java.util.concurrent.atomic.AtomicLongArray;30import java.util.concurrent.atomic.AtomicLongArray;
27import java.util.concurrent.locks.ReentrantLock;31import java.util.concurrent.locks.ReentrantLock;
2832
33import com.persistit.JournalManager.PageNode;
29import com.persistit.exception.InUseException;34import com.persistit.exception.InUseException;
30import com.persistit.exception.InvalidPageAddressException;35import com.persistit.exception.InvalidPageAddressException;
31import com.persistit.exception.InvalidPageStructureException;36import com.persistit.exception.InvalidPageStructureException;
@@ -36,7 +41,6 @@
36import com.persistit.exception.VolumeClosedException;41import com.persistit.exception.VolumeClosedException;
37import com.persistit.util.Debug;42import com.persistit.util.Debug;
38import com.persistit.util.Util;43import com.persistit.util.Util;
39import java.io.*;
4044
41/**45/**
42 * A pool of {@link Buffer} objects, maintained on various lists that permit46 * A pool of {@link Buffer} objects, maintained on various lists that permit
@@ -52,7 +56,7 @@
52 private final static long DEFAULT_WRITER_POLL_INTERVAL = 5000;56 private final static long DEFAULT_WRITER_POLL_INTERVAL = 5000;
5357
54 private final static int PAGE_WRITER_TRANCHE_SIZE = 5000;58 private final static int PAGE_WRITER_TRANCHE_SIZE = 5000;
55 59
56 /**60 /**
57 * Sleep time when buffers are exhausted61 * Sleep time when buffers are exhausted
58 */62 */
@@ -87,6 +91,17 @@
87 */91 */
88 private final static int WRITE_AGE_THRESHOLD_RATIO = 4;92 private final static int WRITE_AGE_THRESHOLD_RATIO = 4;
8993
94 private final static String INVENTORY_TREE_NAME = "_buffers";
95 /**
96 * Maximum number of buffer inventory versions to retain
97 */
98 private final static int INVENTORY_VERSIONS = 3;
99
100 /**
101 * Preload log multiple
102 */
103 private final static int INVENTORY_PRELOAD_LOG_MESSAGE_MULTIPLE = 10000;
104
90 /**105 /**
91 * The Persistit instance that references this BufferPool.106 * The Persistit instance that references this BufferPool.
92 */107 */
@@ -148,7 +163,7 @@
148 /**163 /**
149 * Count of newly created pages164 * Count of newly created pages
150 */165 */
151 private AtomicLong _newCounter = new AtomicLong();166 private final AtomicLong _newCounter = new AtomicLong();
152167
153 /**168 /**
154 * Count of valid buffers evicted to make room for another page.169 * Count of valid buffers evicted to make room for another page.
@@ -188,7 +203,7 @@
188 * Timestamp to which all dirty pages should be written. PAGE_WRITER writes203 * Timestamp to which all dirty pages should be written. PAGE_WRITER writes
189 * any page with a lower update timestamp regardless of urgency.204 * any page with a lower update timestamp regardless of urgency.
190 */205 */
191 private AtomicLong _flushTimestamp = new AtomicLong();206 private final AtomicLong _flushTimestamp = new AtomicLong();
192207
193 /**208 /**
194 * Polling interval for PageWriter209 * Polling interval for PageWriter
@@ -196,24 +211,12 @@
196 private volatile long _writerPollInterval = DEFAULT_WRITER_POLL_INTERVAL;211 private volatile long _writerPollInterval = DEFAULT_WRITER_POLL_INTERVAL;
197212
198 private volatile int _pageWriterTrancheSize = PAGE_WRITER_TRANCHE_SIZE;213 private volatile int _pageWriterTrancheSize = PAGE_WRITER_TRANCHE_SIZE;
199 214
200 /**
201 * Polling interval for PageCacher
202 */
203 private volatile long _cacherPollInterval;
204
205 /**215 /**
206 * The PAGE_WRITER IOTaskRunnable216 * The PAGE_WRITER IOTaskRunnable
207 */217 */
208 private PageWriter _writer;218 private PageWriter _writer;
209 219
210 /**
211 * The PAGE_CACHER IOTaskRunnable
212 */
213 private PageCacher _cacher;
214
215 private String _defaultLogPath;
216
217 /**220 /**
218 * Construct a BufferPool with the specified count of <code>Buffer</code>s221 * Construct a BufferPool with the specified count of <code>Buffer</code>s
219 * of the specified size.222 * of the specified size.
@@ -223,7 +226,7 @@
223 * @param size226 * @param size
224 * The size (in bytes) of each buffer227 * The size (in bytes) of each buffer
225 */228 */
226 BufferPool(int count, int size, Persistit persistit) {229 BufferPool(final int count, final int size, final Persistit persistit) {
227 _persistit = persistit;230 _persistit = persistit;
228 if (count < MINIMUM_POOL_COUNT) {231 if (count < MINIMUM_POOL_COUNT) {
229 throw new IllegalArgumentException("Buffer pool count too small: " + count);232 throw new IllegalArgumentException("Buffer pool count too small: " + count);
@@ -250,7 +253,7 @@
250 _hashTable = new Buffer[_bufferCount * HASH_MULTIPLE];253 _hashTable = new Buffer[_bufferCount * HASH_MULTIPLE];
251 _hashLocks = new ReentrantLock[HASH_LOCKS];254 _hashLocks = new ReentrantLock[HASH_LOCKS];
252 _maxKeys = (_bufferSize - Buffer.HEADER_SIZE) / Buffer.MAX_KEY_RATIO;255 _maxKeys = (_bufferSize - Buffer.HEADER_SIZE) / Buffer.MAX_KEY_RATIO;
253 256
254 for (int index = 0; index < HASH_LOCKS; index++) {257 for (int index = 0; index < HASH_LOCKS; index++) {
255 _hashLocks[index] = new ReentrantLock();258 _hashLocks[index] = new ReentrantLock();
256 }259 }
@@ -263,11 +266,11 @@
263 byte[] reserve = new byte[1024 * 1024];266 byte[] reserve = new byte[1024 * 1024];
264 try {267 try {
265 for (int index = 0; index < _bufferCount; index++) {268 for (int index = 0; index < _bufferCount; index++) {
266 Buffer buffer = new Buffer(size, index, this, _persistit);269 final Buffer buffer = new Buffer(size, index, this, _persistit);
267 _buffers[index] = buffer;270 _buffers[index] = buffer;
268 buffers++;271 buffers++;
269 }272 }
270 } catch (OutOfMemoryError e) {273 } catch (final OutOfMemoryError e) {
271 //274 //
272 // Note: written this way to try to avoid another OOME.275 // Note: written this way to try to avoid another OOME.
273 // Do not use String.format here.276 // Do not use String.format here.
@@ -284,38 +287,6 @@
284 throw e;287 throw e;
285 }288 }
286 _writer = new PageWriter();289 _writer = new PageWriter();
287 _cacher = new PageCacher();
288 }
289
290 void warmupBufferPool(String pathName, String fname) throws PersistitException {
291 File file = new File(pathName, fname + ".log");
292 _defaultLogPath = file.getAbsolutePath();
293
294 try {
295 if (!file.exists()) {
296 file.createNewFile();
297 }
298
299 BufferedReader reader = new BufferedReader(new FileReader(file));
300 String currLine;
301 while ((currLine = reader.readLine()) != null) {
302 String[] info = currLine.split(" ");
303 if (info.length == 2) {
304 Volume vol = _persistit.getVolume(info[1]);
305 if (vol != null) {
306 long page = Long.parseLong(info[0]);
307 Buffer buff = get(vol, page, false, true);
308 buff.release();
309 }
310 }
311 }
312 reader.close();
313 _cacherPollInterval = _persistit.getConfiguration().getBufferInventoryPollingInterval();
314 _cacher.start();
315 }
316 catch (IOException e) {
317 throw new PersistitException(e);
318 }
319 }290 }
320291
321 void startThreads() throws PersistitException {292 void startThreads() throws PersistitException {
@@ -325,18 +296,15 @@
325 void close() {296 void close() {
326 _closed.set(true);297 _closed.set(true);
327 _persistit.waitForIOTaskStop(_writer);298 _persistit.waitForIOTaskStop(_writer);
328 _persistit.waitForIOTaskStop(_cacher);
329 _writer = null;299 _writer = null;
330 _cacher = null;
331 }300 }
332301
333 /**302 /**
334 * Abruptly stop (using {@link Thread#stop()}) the writer, cacher, and collector303 * Abruptly stop (using {@link Thread#stop()}) the writer, cacher, and
335 * threads. This method should be used only by tests.304 * collector threads. This method should be used only by tests.
336 */305 */
337 void crash() {306 void crash() {
338 IOTaskRunnable.crash(_writer);307 IOTaskRunnable.crash(_writer);
339 IOTaskRunnable.crash(_cacher);
340 }308 }
341309
342 void flush(final long timestamp) throws PersistitInterruptedException {310 void flush(final long timestamp) throws PersistitInterruptedException {
@@ -351,14 +319,14 @@
351 return _flushTimestamp.get() != 0;319 return _flushTimestamp.get() != 0;
352 }320 }
353321
354 int hashIndex(Volume vol, long page) {322 int hashIndex(final Volume vol, final long page) {
355 return (int) (((page ^ vol.hashCode()) & Integer.MAX_VALUE) % _hashTable.length);323 return (int) (((page ^ vol.hashCode()) & Integer.MAX_VALUE) % _hashTable.length);
356 }324 }
357325
358 int countInUse(Volume vol, boolean writer) {326 int countInUse(final Volume vol, final boolean writer) {
359 int count = 0;327 int count = 0;
360 for (int i = 0; i < _bufferCount; i++) {328 for (int i = 0; i < _bufferCount; i++) {
361 Buffer buffer = _buffers[i];329 final Buffer buffer = _buffers[i];
362 if ((vol == null || buffer.getVolume() == vol)330 if ((vol == null || buffer.getVolume() == vol)
363 && ((buffer.getStatus() & SharedResource.CLAIMED_MASK) != 0 && (!writer || (buffer.getStatus() & SharedResource.WRITER_MASK) != 0))) {331 && ((buffer.getStatus() & SharedResource.CLAIMED_MASK) != 0 && (!writer || (buffer.getStatus() & SharedResource.WRITER_MASK) != 0))) {
364 count++;332 count++;
@@ -367,7 +335,7 @@
367 return count;335 return count;
368 }336 }
369337
370 void populateBufferPoolInfo(ManagementImpl.BufferPoolInfo info) {338 void populateBufferPoolInfo(final ManagementImpl.BufferPoolInfo info) {
371 info.bufferCount = _bufferCount;339 info.bufferCount = _bufferCount;
372 info.bufferSize = _bufferSize;340 info.bufferSize = _bufferSize;
373 info.missCount = _missCounter.get();341 info.missCount = _missCounter.get();
@@ -383,8 +351,8 @@
383 int writerClaimedPages = 0;351 int writerClaimedPages = 0;
384352
385 for (int index = 0; index < _bufferCount; index++) {353 for (int index = 0; index < _bufferCount; index++) {
386 Buffer buffer = _buffers[index];354 final Buffer buffer = _buffers[index];
387 int status = buffer.getStatus();355 final int status = buffer.getStatus();
388 if ((status & SharedResource.VALID_MASK) != 0)356 if ((status & SharedResource.VALID_MASK) != 0)
389 validPages++;357 validPages++;
390 if ((status & SharedResource.WRITER_MASK) != 0)358 if ((status & SharedResource.WRITER_MASK) != 0)
@@ -400,12 +368,13 @@
400 info.updateAcquisitonTime();368 info.updateAcquisitonTime();
401 }369 }
402370
403 int populateInfo(ManagementImpl.BufferInfo[] array, int traveralType, int includeMask, int excludeMask) {371 int populateInfo(final ManagementImpl.BufferInfo[] array, final int traveralType, final int includeMask,
372 final int excludeMask) {
404 int index = 0;373 int index = 0;
405 switch (traveralType) {374 switch (traveralType) {
406 case 0:375 case 0:
407 for (int i = 0; i < _bufferCount; i++) {376 for (int i = 0; i < _bufferCount; i++) {
408 Buffer buffer = _buffers[i];377 final Buffer buffer = _buffers[i];
409 if (selected(buffer, includeMask, excludeMask)) {378 if (selected(buffer, includeMask, excludeMask)) {
410 populateInfo1(array, index, buffer);379 populateInfo1(array, index, buffer);
411 index++;380 index++;
@@ -420,44 +389,15 @@
420 return index;389 return index;
421 }390 }
422391
423 private static void populateInfo1(ManagementImpl.BufferInfo[] array, int index, Buffer buffer) {392 private static void populateInfo1(final ManagementImpl.BufferInfo[] array, final int index, final Buffer buffer) {
424 if (index < array.length) {393 if (index < array.length) {
425 if (array[index] == null)394 if (array[index] == null)
426 array[index] = new ManagementImpl.BufferInfo();395 array[index] = new ManagementImpl.BufferInfo();
427 buffer.populateInfo(array[index]);396 buffer.populateInfo(array[index]);
428 }397 }
429 }398 }
430
431 private void populateWarmupFile() throws PersistitException {
432 File file = new File(_defaultLogPath);
433
434 try {
435 BufferedWriter writer = new BufferedWriter(new FileWriter(file));
436 for (int i = 0; i < _buffers.length; ++i) {
437 Buffer b = _buffers[i];
438 if (b != null && b.isValid() && !b.isDirty()) {
439 long page = b.getPageAddress();
440 Volume volume = b.getVolume();
441 long page2 = b.getPageAddress();
442 Volume volume2 = b.getVolume();
443
444 // Check if buffer has changed while reading
445 if (page == page2 && volume == volume2 && volume != null) {
446 String addr = Long.toString(page);
447 String vol = volume.getName();
448 writer.append(addr + " " + vol);
449 writer.newLine();
450 writer.flush();
451 }
452 }
453 }
454 writer.close();
455 } catch (IOException e) {
456 throw new PersistitException(e);
457 }
458 }
459399
460 private boolean selected(Buffer buffer, int includeMask, int excludeMask) {400 private boolean selected(final Buffer buffer, final int includeMask, final int excludeMask) {
461 return ((includeMask == 0) || (buffer.getStatus() & includeMask) != 0)401 return ((includeMask == 0) || (buffer.getStatus() & includeMask) != 0)
462 && (buffer.getStatus() & excludeMask) == 0;402 && (buffer.getStatus() & excludeMask) == 0;
463 }403 }
@@ -599,7 +539,7 @@
599 * The volume539 * The volume
600 * @throws PersistitInterruptedException540 * @throws PersistitInterruptedException
601 */541 */
602 boolean invalidate(Volume volume) throws PersistitInterruptedException {542 boolean invalidate(final Volume volume) throws PersistitInterruptedException {
603 final float ratio = (float) volume.getStorage().getNextAvailablePage() / (float) _bufferCount;543 final float ratio = (float) volume.getStorage().getNextAvailablePage() / (float) _bufferCount;
604 if (ratio < SMALL_VOLUME_RATIO) {544 if (ratio < SMALL_VOLUME_RATIO) {
605 return invalidateSmallVolume(volume);545 return invalidateSmallVolume(volume);
@@ -612,7 +552,7 @@
612 boolean result = true;552 boolean result = true;
613 int markedAvailable = 0;553 int markedAvailable = 0;
614 for (long page = 1; page < volume.getStorage().getNextAvailablePage(); page++) {554 for (long page = 1; page < volume.getStorage().getNextAvailablePage(); page++) {
615 int hashIndex = hashIndex(volume, page);555 final int hashIndex = hashIndex(volume, page);
616 _hashLocks[hashIndex % HASH_LOCKS].lock();556 _hashLocks[hashIndex % HASH_LOCKS].lock();
617 try {557 try {
618 for (Buffer buffer = _hashTable[hashIndex]; buffer != null; buffer = buffer.getNext()) {558 for (Buffer buffer = _hashTable[hashIndex]; buffer != null; buffer = buffer.getNext()) {
@@ -630,9 +570,9 @@
630 buffer.release();570 buffer.release();
631 }571 }
632 if (invalidated) {572 if (invalidated) {
633 int q = buffer.getIndex() / 64;573 final int q = buffer.getIndex() / 64;
634 int p = buffer.getIndex() % 64;574 final int p = buffer.getIndex() % 64;
635 long bits = _availablePagesBits.get(q);575 final long bits = _availablePagesBits.get(q);
636 if (_availablePagesBits.compareAndSet(q, bits, bits | (1L << p))) {576 if (_availablePagesBits.compareAndSet(q, bits, bits | (1L << p))) {
637 markedAvailable++;577 markedAvailable++;
638 }578 }
@@ -657,7 +597,7 @@
657 boolean result = true;597 boolean result = true;
658 int markedAvailable = 0;598 int markedAvailable = 0;
659 for (int index = 0; index < _bufferCount; index++) {599 for (int index = 0; index < _bufferCount; index++) {
660 Buffer buffer = _buffers[index];600 final Buffer buffer = _buffers[index];
661 if ((buffer.getVolume() == volume || volume == null) && !buffer.isFixed() && buffer.isValid()) {601 if ((buffer.getVolume() == volume || volume == null) && !buffer.isFixed() && buffer.isValid()) {
662 if (buffer.claim(true, 0)) {602 if (buffer.claim(true, 0)) {
663 // re-check after claim603 // re-check after claim
@@ -671,9 +611,9 @@
671 buffer.release();611 buffer.release();
672 }612 }
673 if (invalidated) {613 if (invalidated) {
674 int q = buffer.getIndex() / 64;614 final int q = buffer.getIndex() / 64;
675 int p = buffer.getIndex() % 64;615 final int p = buffer.getIndex() % 64;
676 long bits = _availablePagesBits.get(q);616 final long bits = _availablePagesBits.get(q);
677 if (_availablePagesBits.compareAndSet(q, bits, bits | (1L << p))) {617 if (_availablePagesBits.compareAndSet(q, bits, bits | (1L << p))) {
678 markedAvailable++;618 markedAvailable++;
679 }619 }
@@ -689,29 +629,33 @@
689 return result;629 return result;
690 }630 }
691631
692 private void invalidate(Buffer buffer) {632 private void invalidate(final Buffer buffer) {
693 Debug.$assert0.t(buffer.isValid() && buffer.isMine());633 Debug.$assert0.t(buffer.isValid() && buffer.isMine());
694634
695 while (!detach(buffer)) {635 while (!detach(buffer)) {
696 //636 //
697 // Spin until detach succeeds. Note: this method must not throw an Exception637 // Spin until detach succeeds. Note: this method must not throw an
698 // because it is called in at at critical time when cleanup must be done.638 // Exception
699 // It is not possible to lock the hash bucket here due to possible deadlock.639 // because it is called in at at critical time when cleanup must be
700 // However, the likelihood of a lengthy live-lock is infinitesimal so polling640 // done.
641 // It is not possible to lock the hash bucket here due to possible
642 // deadlock.
643 // However, the likelihood of a lengthy live-lock is infinitesimal
644 // so polling
701 // is acceptable.645 // is acceptable.
702 //646 //
703 try {647 try {
704 Thread.sleep(1);648 Thread.sleep(1);
705 } catch (InterruptedException ie) {649 } catch (final InterruptedException ie) {
706 // ignore650 // ignore
707 }651 }
708 }652 }
709 buffer.clearValid();653 buffer.clearValid();
710 buffer.clearDirty();654 buffer.clearDirty();
711 buffer.setPageAddressAndVolume(0, null);655 buffer.setPageAddressAndVolume(0, null);
712 }656 }
713657
714 private boolean detach(Buffer buffer) {658 private boolean detach(final Buffer buffer) {
715 final int hash = hashIndex(buffer.getVolume(), buffer.getPageAddress());659 final int hash = hashIndex(buffer.getVolume(), buffer.getPageAddress());
716 if (!_hashLocks[hash % HASH_LOCKS].tryLock()) {660 if (!_hashLocks[hash % HASH_LOCKS].tryLock()) {
717 return false;661 return false;
@@ -756,8 +700,9 @@
756 * @return Buffer The Buffer describing the buffer containing the page.700 * @return Buffer The Buffer describing the buffer containing the page.
757 * @throws InUseException701 * @throws InUseException
758 */702 */
759 Buffer get(Volume vol, long page, boolean writer, boolean wantRead) throws PersistitException {703 Buffer get(final Volume vol, final long page, final boolean writer, final boolean wantRead)
760 int hash = hashIndex(vol, page);704 throws PersistitException {
705 final int hash = hashIndex(vol, page);
761 Buffer buffer = null;706 Buffer buffer = null;
762707
763 for (;;) {708 for (;;) {
@@ -904,10 +849,10 @@
904 * @throws RetryException849 * @throws RetryException
905 * @throws IOException850 * @throws IOException
906 */851 */
907 public Buffer getBufferCopy(Volume vol, long page) throws InvalidPageAddressException,852 public Buffer getBufferCopy(final Volume vol, final long page) throws InvalidPageAddressException,
908 InvalidPageStructureException, VolumeClosedException, InUseException, PersistitIOException,853 InvalidPageStructureException, VolumeClosedException, InUseException, PersistitIOException,
909 PersistitInterruptedException {854 PersistitInterruptedException {
910 int hash = hashIndex(vol, page);855 final int hash = hashIndex(vol, page);
911 Buffer buffer = null;856 Buffer buffer = null;
912 _hashLocks[hash % HASH_LOCKS].lock();857 _hashLocks[hash % HASH_LOCKS].lock();
913 try {858 try {
@@ -934,7 +879,7 @@
934 // Didn't find it in the pool, so we'll read a copy.879 // Didn't find it in the pool, so we'll read a copy.
935 //880 //
936 buffer = new Buffer(_bufferSize, -1, this, _persistit);881 buffer = new Buffer(_bufferSize, -1, this, _persistit);
937 boolean acquired = buffer.claim(true);882 final boolean acquired = buffer.claim(true);
938 assert acquired : "buffer not unavailable";883 assert acquired : "buffer not unavailable";
939 buffer.load(vol, page);884 buffer.load(vol, page);
940 buffer.setValid();885 buffer.setValid();
@@ -968,7 +913,7 @@
968 // since no valid page will need to be evicted.913 // since no valid page will need to be evicted.
969 //914 //
970 if (_availablePages.get()) {915 if (_availablePages.get()) {
971 int start = (_clock.get() / 64) * 64;916 final int start = (_clock.get() / 64) * 64;
972 for (int q = start;;) {917 for (int q = start;;) {
973 q += 64;918 q += 64;
974 if (q >= _bufferCount) {919 if (q >= _bufferCount) {
@@ -1007,12 +952,12 @@
1007 // Look for a page to evict.952 // Look for a page to evict.
1008 //953 //
1009 for (int retry = 0; retry < _bufferCount * 2;) {954 for (int retry = 0; retry < _bufferCount * 2;) {
1010 int clock = _clock.get();955 final int clock = _clock.get();
1011 assert clock < _bufferCount;956 assert clock < _bufferCount;
1012 if (!_clock.compareAndSet(clock, (clock + 1) % _bufferCount)) {957 if (!_clock.compareAndSet(clock, (clock + 1) % _bufferCount)) {
1013 continue;958 continue;
1014 }959 }
1015 Buffer buffer = _buffers[clock];960 final Buffer buffer = _buffers[clock];
1016 if (buffer.isTouched()) {961 if (buffer.isTouched()) {
1017 buffer.clearTouched();962 buffer.clearTouched();
1018 } else {963 } else {
@@ -1081,7 +1026,7 @@
10811026
1082 void setFlushTimestamp(final long timestamp) {1027 void setFlushTimestamp(final long timestamp) {
1083 while (true) {1028 while (true) {
1084 long current = _flushTimestamp.get();1029 final long current = _flushTimestamp.get();
1085 if (timestamp > current) {1030 if (timestamp > current) {
1086 if (_flushTimestamp.compareAndSet(current, timestamp)) {1031 if (_flushTimestamp.compareAndSet(current, timestamp)) {
1087 break;1032 break;
@@ -1099,7 +1044,7 @@
1099 * polling cycle1044 * polling cycle
1100 */1045 */
1101 boolean shouldWritePages() {1046 boolean shouldWritePages() {
1102 int cleanCount = _bufferCount - _dirtyPageCount.get();1047 final int cleanCount = _bufferCount - _dirtyPageCount.get();
1103 if (getEarliestDirtyTimestamp() < _flushTimestamp.get()) {1048 if (getEarliestDirtyTimestamp() < _flushTimestamp.get()) {
1104 return true;1049 return true;
1105 }1050 }
@@ -1116,7 +1061,7 @@
1116 }1061 }
11171062
1118 void writeDirtyBuffers(final int[] priorities, final BufferHolder[] selectedBuffers) throws PersistitException {1063 void writeDirtyBuffers(final int[] priorities, final BufferHolder[] selectedBuffers) throws PersistitException {
1119 int count = selectDirtyBuffers(priorities, selectedBuffers);1064 final int count = selectDirtyBuffers(priorities, selectedBuffers);
1120 if (count > 0) {1065 if (count > 0) {
1121 Arrays.sort(selectedBuffers, 0, count);1066 Arrays.sort(selectedBuffers, 0, count);
1122 for (int index = 0; index < count; index++) {1067 for (int index = 0; index < count; index++) {
@@ -1144,7 +1089,7 @@
1144 final long currentTimestamp = _persistit.getCurrentTimestamp();1089 final long currentTimestamp = _persistit.getCurrentTimestamp();
11451090
1146 long earliestDirtyTimestamp = currentTimestamp;1091 long earliestDirtyTimestamp = currentTimestamp;
1147 long flushTimestamp = _flushTimestamp.get();1092 final long flushTimestamp = _flushTimestamp.get();
11481093
1149 boolean flushed = true;1094 boolean flushed = true;
1150 for (int index = clock; index < clock + _bufferCount; index++) {1095 for (int index = clock; index < clock + _bufferCount; index++) {
@@ -1202,8 +1147,9 @@
1202 }1147 }
1203 return count;1148 return count;
1204 }1149 }
1205 1150
1206 int addSelectedBufferByPriority(final Buffer buffer, final int priority, final int[] priorities, final BufferHolder[] holders, final int initialCount) {1151 int addSelectedBufferByPriority(final Buffer buffer, final int priority, final int[] priorities,
1152 final BufferHolder[] holders, final int initialCount) {
1207 int count = initialCount;1153 int count = initialCount;
1208 if (priority > 0) {1154 if (priority > 0) {
1209 if (count == 0 || priorities[count - 1] > priority) {1155 if (count == 0 || priorities[count - 1] > priority) {
@@ -1214,13 +1160,13 @@
1214 }1160 }
1215 } else {1161 } else {
1216 count = Math.min(count, priorities.length - 1);1162 count = Math.min(count, priorities.length - 1);
1217 int where = count; 1163 int where = count;
1218 while (where > 0 && priorities[where - 1] < priority) {1164 while (where > 0 && priorities[where - 1] < priority) {
1219 where--;1165 where--;
1220 }1166 }
1221 int move = count - where ;1167 final int move = count - where;
1222 if (move > 0) {1168 if (move > 0) {
1223 BufferHolder lastHolder = holders[count];1169 final BufferHolder lastHolder = holders[count];
1224 System.arraycopy(priorities, where, priorities, where + 1, move);1170 System.arraycopy(priorities, where, priorities, where + 1, move);
1225 System.arraycopy(holders, where, holders, where + 1, move);1171 System.arraycopy(holders, where, holders, where + 1, move);
1226 holders[where] = lastHolder;1172 holders[where] = lastHolder;
@@ -1240,8 +1186,8 @@
1240 * 1186 *
1241 * @return priority1187 * @return priority
1242 */1188 */
1243 int writePriority(final Buffer buffer, int clock, long checkpointTimestamp, final long currentTimestamp) {1189 int writePriority(final Buffer buffer, final int clock, final long checkpointTimestamp, final long currentTimestamp) {
1244 int status = buffer.getStatus();1190 final int status = buffer.getStatus();
1245 if ((status & Buffer.VALID_MASK) == 0 || (status & Buffer.DIRTY_MASK) == 0) {1191 if ((status & Buffer.VALID_MASK) == 0 || (status & Buffer.DIRTY_MASK) == 0) {
1246 // ineligible1192 // ineligible
1247 return 0;1193 return 0;
@@ -1336,7 +1282,7 @@
1336 * address order.1282 * address order.
1337 */1283 */
1338 @Override1284 @Override
1339 public int compareTo(BufferHolder buffer) {1285 public int compareTo(final BufferHolder buffer) {
1340 return _volumeId > buffer._volumeId ? 1 : _volumeId < buffer._volumeId ? -1 : _page > buffer._page ? 11286 return _volumeId > buffer._volumeId ? 1 : _volumeId < buffer._volumeId ? -1 : _page > buffer._page ? 1
1341 : _page < buffer._page ? -1 : 0;1287 : _page < buffer._page ? -1 : 0;
13421288
@@ -1367,7 +1313,7 @@
13671313
1368 @Override1314 @Override
1369 public void runTask() throws PersistitException {1315 public void runTask() throws PersistitException {
1370 int size = _pageWriterTrancheSize;1316 final int size = _pageWriterTrancheSize;
1371 if (size != _priorities.length) {1317 if (size != _priorities.length) {
1372 _priorities = new int[size];1318 _priorities = new int[size];
1373 _selectedBuffers = new BufferHolder[size];1319 _selectedBuffers = new BufferHolder[size];
@@ -1391,35 +1337,6 @@
1391 return isFlushing() ? 0 : _writerPollInterval;1337 return isFlushing() ? 0 : _writerPollInterval;
1392 }1338 }
1393 }1339 }
1394
1395 /**
1396 * Implementation of PAGE_CACHER thread
1397 */
1398 class PageCacher extends IOTaskRunnable {
1399
1400 PageCacher() {
1401 super(BufferPool.this._persistit);
1402 }
1403
1404 void start() {
1405 start("PAGE_CACHER:" + _bufferSize, _cacherPollInterval);
1406 }
1407
1408 @Override
1409 public void runTask() throws Exception {
1410 populateWarmupFile();
1411 }
1412
1413 @Override
1414 protected boolean shouldStop() {
1415 return _closed.get() && !isFlushing();
1416 }
1417
1418 @Override
1419 protected long pollInterval() {
1420 return isFlushing() ? 0 : _cacherPollInterval;
1421 }
1422 }
14231340
1424 @Override1341 @Override
1425 public String toString() {1342 public String toString() {
@@ -1431,7 +1348,7 @@
1431 * @param detail1348 * @param detail
1432 * @return toString value for buffer at index <code>i</code>.1349 * @return toString value for buffer at index <code>i</code>.
1433 */1350 */
1434 String toString(int i, boolean detail) {1351 String toString(final int i, final boolean detail) {
1435 if (detail) {1352 if (detail) {
1436 return _buffers[i].toStringDetail();1353 return _buffers[i].toStringDetail();
1437 } else {1354 } else {
@@ -1475,4 +1392,133 @@
1475 }1392 }
1476 stream.flush();1393 stream.flush();
1477 }1394 }
1395
1396 void recordBufferInventory(final long timestamp) throws PersistitException {
1397 final Exchange exchange = getBufferInventoryExchange();
1398 /*
1399 * Advisory only - transaction integrity not needed
1400 */
1401 exchange.ignoreTransactions();
1402 try {
1403 int total = 0;
1404 exchange.clear().append(_bufferSize).append(timestamp).append(Key.BEFORE);
1405 final Value value = exchange.getValue();
1406 final int clockValueBefore = _clock.get();
1407 for (int index = 0; index < _buffers.length; index++) {
1408 final Buffer buffer = _buffers[index];
1409 long page1 = -1, page2 = -1;
1410 Volume volume1 = null, volume2 = null;
1411 if (buffer != null && buffer.isValid()) {
1412 while (true) {
1413 page1 = buffer.getPageAddress();
1414 volume1 = buffer.getVolume();
1415 page2 = buffer.getPageAddress();
1416 volume2 = buffer.getVolume();
1417 if (page1 == page2 && volume1 == volume2) {
1418 break;
1419 }
1420 Util.spinSleep();
1421 }
1422 if (volume1 != null && !volume1.isTemporary()) {
1423 value.clear().setStreamMode(true);
1424 value.put(volume1.getHandle());
1425 value.put(page1);
1426 exchange.to(index).store();
1427 total++;
1428 }
1429 }
1430 }
1431 final int clockValueAfter = _clock.get();
1432 exchange.cut();
1433 value.clear().setStreamMode(true);
1434 value.put(_bufferCount);
1435 value.put(total);
1436 value.put(clockValueBefore);
1437 value.put(clockValueAfter);
1438 value.put(System.currentTimeMillis());
1439 exchange.store();
1440 int count = 0;
1441 while (exchange.previous()) {
1442 if (++count > INVENTORY_VERSIONS) {
1443 exchange.remove(Key.GTEQ);
1444 }
1445 }
1446 } catch (final PersistitException e) {
1447 _persistit.getLogBase().bufferInventoryException.log(e);
1448 }
1449 }
1450
1451 void preloadBufferInventory() {
1452 int count = 0;
1453 int total = 0;
1454 try {
1455 final JournalManager jman = _persistit.getJournalManager();
1456 final Exchange exchange = getBufferInventoryExchange();
1457 final Value value = exchange.getValue();
1458 final List<PageNode> pageNodes = new ArrayList<PageNode>();
1459 boolean foundInventory = false;
1460 exchange.clear().append(_bufferSize).append(Key.AFTER);
1461 while (exchange.previous()) {
1462 if (exchange.getValue().isDefined()) {
1463 foundInventory = true;
1464 break;
1465 }
1466 }
1467 if (!foundInventory) {
1468 return;
1469 }
1470 value.setStreamMode(true);
1471 /* int bufferCount = */value.getInt();
1472 total = value.getInt();
1473 /* int clockValueBefore = */value.getInt();
1474 /* int clockValueAfter = */value.getInt();
1475 final long systemTime = value.getLong();
1476
1477 _persistit.getLogBase().bufferInventoryLoad.log(systemTime);
1478
1479 exchange.append(Key.BEFORE);
1480
1481 while (exchange.next()) {
1482 value.setStreamMode(true);
1483 final int volumeHandle = value.getInt();
1484 final long pageAddress = value.getLong();
1485 final PageNode pn = new PageNode(volumeHandle, pageAddress);
1486 pageNodes.add(pn);
1487 }
1488
1489 Collections.sort(pageNodes, PageNode.READ_COMPARATOR);
1490 for (final PageNode pn : pageNodes) {
1491 final Volume vol = jman.volumeForHandle(pn.getVolumeHandle());
1492 if (vol == null) {
1493 continue;
1494 }
1495 try {
1496 final Buffer buff = get(vol, pn.getPageAddress(), false, true);
1497 buff.release();
1498 count++;