Skip to content
Permalink
Browse files

Add method MutableView.setReadTrackingPaused().

  • Loading branch information...
archiecobbs committed Oct 29, 2019
1 parent 0810af1 commit 8c61bc6fa91370f3f2472fd8ac28d3992b4a6961
Showing with 27 additions and 3 deletions.
  1. +1 −0 CHANGES.txt
  2. +26 −3 permazen-kv/src/main/java/io/permazen/kv/mvcc/MutableView.java
@@ -3,6 +3,7 @@ Version Next
- Added new key/value implementation based on MVStore (issue #34)
- Added method NavigableSetPager.getPageNumber()
- Added convenience method NavigableSetPager.reverseViewOrdering()
- Added method MutableView.setReadTrackingPaused()
- Fixed a few minor Java expression parsing bugs

Version 4.1.5 Released May 21, 2019
@@ -32,7 +32,6 @@
*
* <p>
* Unlike writes, reads are passed through to the underlying {@link KVStore}, except where they intersect a previous write.
* Reads may also be optionally recorded.
*
* <p>
* In all cases, the underlying {@link KVStore} is never modified.
@@ -41,6 +40,15 @@
* Instances ensure that counter adjustment mutations never overlap put or remove mutations.
*
* <p>
* <b>Read Tracking</b>
*
* <p>
* During construction, instances may be configured to record all keys read into a {@link Reads} object (this is typically
* used for MVCC conflict detection). When reads are being tracked, tracking may temporarily be paused and resumed via
* {@link #setReadTrackingPaused}. Read tracking may be permanently disabled (and any recorded reads discareded) via
* {@link #disableReadTracking}.
*
* <p>
* Instances are thread safe; however, directly accessing the associated {@link Reads} or {@link Writes} is not thread safe
* without first locking the containing instance.
*/
@@ -55,6 +63,8 @@
private Reads reads;
@GuardedBy("this")
private boolean readOnly;
@GuardedBy("this")
private boolean readTrackingPaused;

// Constructors

@@ -142,8 +152,10 @@ public synchronized Writes getWrites() {
return this.writes;
}

// Read tracking

/**
* Disable read tracking and discard the {@link Reads} associated with this instance.
* Permanently disable read tracking and discard the {@link Reads} associated with this instance.
*
* <p>
* Can be used to save some memory when read tracking information is no longer needed.
@@ -152,6 +164,16 @@ public synchronized void disableReadTracking() {
this.reads = null;
}

/**
* Temporarily disable or re-enable read tracking.
*
* <p>
* Ignored if there is no (longer any) associated {@link Reads} instance.
*/
public synchronized void setReadTrackingPaused(final boolean readTrackingPaused) {
this.readTrackingPaused = readTrackingPaused;
}

/**
* Configure this instance as read-only.
*
@@ -342,6 +364,7 @@ public synchronized String toString() {
return this.getClass().getSimpleName()
+ "[writes=" + this.writes
+ (this.reads != null ? ",reads=" + this.reads : "")
+ (this.readTrackingPaused ? ",readTrackingPaused" : "")
+ (this.readOnly ? ",r/o" : "")
+ "]";
}
@@ -381,7 +404,7 @@ private void recordReads(byte[] minKey, byte[] maxKey) {
assert maxKey == null || ByteUtil.compare(minKey, maxKey) < 0;

// Not tracking reads?
if (this.reads == null)
if (this.reads == null || this.readTrackingPaused)
return;

// Define the range

0 comments on commit 8c61bc6

Please sign in to comment.
You can’t perform that action at this time.