ifesdjeen commented on code in PR #4410:
URL: https://github.com/apache/cassandra/pull/4410#discussion_r2410822020


##########
src/java/org/apache/cassandra/journal/Segments.java:
##########
@@ -192,6 +208,13 @@ void selectStatic(Collection<StaticSegment<K, V>> into)
                 into.add(segment.asStatic());
     }
 
+    void selectStatic(Predicate<StaticSegment<K, V>> filter, 
Collection<StaticSegment<K, V>> into)

Review Comment:
   Should we cache static segments to avoid re-filtering every time?



##########
src/java/org/apache/cassandra/journal/StaticSegment.java:
##########
@@ -135,9 +138,13 @@ static <K, V> StaticSegment<K, V> open(Descriptor 
descriptor, KeySupport<K> keyS
         if (index == null)
             index = OnDiskIndex.rebuildAndPersist(descriptor, keySupport, 
metadata.fsyncLimit());
 
+        KeyStats.Static<K> keyStats = keyStatsFactory.load(descriptor);

Review Comment:
   `OffsetRangesFactory#load` doesn't seem to have any path that would return 
`null`. Maybe instead of throwing `JournalReadError` we should log it and 
return null? 



##########
src/java/org/apache/cassandra/service/accord/AccordJournal.java:
##########
@@ -134,23 +133,10 @@ public AccordJournal(Params params)
     public AccordJournal(Params params, File directory, ColumnFamilyStore cfs)
     {
         Version userVersion = Version.fromVersion(params.userVersion());
-        this.journal = new Journal<>("AccordJournal", directory, params, 
JournalKey.SUPPORT,
-                                     // In Accord, we are using streaming 
serialization, i.e. Reader/Writer interfaces instead of materializing objects
-                                     new ValueSerializer<>()
-                                     {
-                                         @Override
-                                         public void serialize(JournalKey key, 
Object value, DataOutputPlus out, int userVersion)
-                                         {
-                                             throw new 
UnsupportedOperationException();
-                                         }
-
-                                         @Override
-                                         public Object deserialize(JournalKey 
key, DataInputPlus in, int userVersion)
-                                         {
-                                             throw new 
UnsupportedOperationException();
-                                         }
-                                     },
-                                     compactor(cfs, userVersion));
+        this.journal =

Review Comment:
   Would be great to extract this portion of the patch and get it committed to 
`trunk`.



##########
src/java/org/apache/cassandra/journal/Journal.java:
##########
@@ -1279,4 +1297,66 @@ enum State
         SHUTDOWN,
         TERMINATED
     }
+
+    /*
+     * Test helpers
+     */
+
+    @VisibleForTesting
+    public void unsafeConsumeBytesForTesting(int entrySize, 
Consumer<ByteBuffer> corrupt)
+    {
+        // TODO (require): Find a better way to test unwritten allocations 
and/or corruption
+        allocate(entrySize).consumeBufferUnsafe(corrupt);
+    }
+
+    @VisibleForTesting
+    public void truncateForTesting()
+    {
+        ActiveSegment<?, ?> discarding = currentSegment;
+        if (!discarding.isEmpty()) // if there is no data in the segement then 
ignore it

Review Comment:
   nit, and I know this is not your code, but `segement` 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to