You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "rsingh433 (via GitHub)" <gi...@apache.org> on 2023/11/30 16:31:13 UTC

[PR] "getValue() method is redundant, use fromMetaWalEntry instead" [accumulo]

rsingh433 opened a new pull request, #3997:
URL: https://github.com/apache/accumulo/pull/3997

   getValue() method is redundant, the same value can be obtained using the fromMetaWalEntry method.


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] "getValue() method is redundant, use fromMetaWalEntry instead" [accumulo]

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on PR #3997:
URL: https://github.com/apache/accumulo/pull/3997#issuecomment-1845810362

   These changes look good, as-is, and can be merged now to drop storing the "filePath" in the Value and reading it from the column qualifier instead. However, there's some follow-on actions that you can add to this PR, or can create a separate PR for, at your discretion. Here's some things I saw while looking at this code, where there's room for improvement:
   
   1. Pull in the mutation modification work into the LogEntry class. So, instead of calling code calling in to LogEntry to get the column qualifier, value, etc. to update a mutation, you just pass a mutation into the LogEntry class like: `logEntry.addToMutation(mutation);`, and the mutation updating is done internal to that method. That way, the column qualifier, value, etc. doesn't need to be used outside the class (except maybe for unit testing) and they can be made private, or even simplified or removed.
   2. Get rid of switchFile method, since that's outdated, and simplify how VolumeUtil is using it
   3. Rename "filePath", "filename", and "getFilePath()", etc. to something that reflects what is actually stored there. From what I can tell, what's stored there is a "-/host:port/UUID" (with "-/" ignored). So, maybe a better name is "logReference", since the host and UUID together could be called that. Or something like "serverAndUUID", but that's not really very friendly. If there's a better name, I'm open to that as well.
   4. Make the validate method more rigorous and expect exactly 3 items (`"-/host:port/UUID" -> {"-", "host:port", "UUID"}`. Right now validates either 2 or 3... and it's not clear why. Probably so it could validate the old value, which did not contain the "-/" portion, as well as the column qualifier, which did. But it doesn't need to validate the 2-item version, since that shouldn't exist
   5. Add upgrade code to drop the "-/" portion entirely, and further simplify all the code that tries to handle that, so it's only "host:port/UUID" instead in the column qualifier.
   
   Some of these are certainly more complicated than others, and would require a separate PR. But some of these are small enough to include with this.
   


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] "getValue() method is redundant, use fromMetaWalEntry instead" [accumulo]

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on code in PR #3997:
URL: https://github.com/apache/accumulo/pull/3997#discussion_r1424398856


##########
core/src/main/java/org/apache/accumulo/core/tabletserver/log/LogEntry.java:
##########
@@ -107,13 +109,18 @@ public int hashCode() {
   }
 
   public static LogEntry fromMetaWalEntry(Entry<Key,Value> entry) {
-    final Value value = entry.getValue();
 
-    String filePath = value.toString();
+    final Text columnQualifier = entry.getKey().getColumnQualifier();
 
-    validateFilePath(filePath);
+    String filePath = columnQualifier.toString();
+
+    String[] parts = filePath.split("/", 2);

Review Comment:
   #4057 should cover improvements to the validation



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] "getValue() method is redundant, use fromMetaWalEntry instead" [accumulo]

Posted by "rsingh433 (via GitHub)" <gi...@apache.org>.
rsingh433 commented on PR #3997:
URL: https://github.com/apache/accumulo/pull/3997#issuecomment-1847626454

   I removed the switchFile method and updated the switchVolumes method to directly create a new LogEntry instance with the switched file path. Now, the LogEntry class itself is responsible for creating instances based on the file path. Also, I added the functionality to add LogEntry information to a mutation by calling logEntry.addToMutation(mutation).


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] "getValue() method is redundant, use fromMetaWalEntry instead" [accumulo]

Posted by "rsingh433 (via GitHub)" <gi...@apache.org>.
rsingh433 commented on code in PR #3997:
URL: https://github.com/apache/accumulo/pull/3997#discussion_r1420889910


##########
core/src/main/java/org/apache/accumulo/core/tabletserver/log/LogEntry.java:
##########
@@ -107,13 +109,18 @@ public int hashCode() {
   }
 
   public static LogEntry fromMetaWalEntry(Entry<Key,Value> entry) {
-    final Value value = entry.getValue();
 
-    String filePath = value.toString();
+    final Text columnQualifier = entry.getKey().getColumnQualifier();
 
-    validateFilePath(filePath);
+    String filePath = columnQualifier.toString();
+
+    String[] parts = filePath.split("/", 2);

Review Comment:
   Thank you. Working on that next.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] "getValue() method is redundant, use fromMetaWalEntry instead" [accumulo]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #3997:
URL: https://github.com/apache/accumulo/pull/3997#discussion_r1420900053


##########
core/src/main/java/org/apache/accumulo/core/tabletserver/log/LogEntry.java:
##########
@@ -76,12 +78,12 @@ private static void validateFilePath(String filePath) {
   }
 
   /**
-   * Make a copy of this LogEntry but replace the file path.
+   * Add LogEntry information to the provided mutation.
    *
-   * @param filePath path to use
+   * @param mutation the mutation to update
    */
-  public LogEntry switchFile(String filePath) {
-    return new LogEntry(filePath);
+  public void addToMutation(Mutation mutation) {

Review Comment:
   Could  update the following to use this new method
   
   https://github.com/apache/accumulo/blob/9701ccface1f94b8d4827323b540ddda9d0cd6c6/server/base/src/main/java/org/apache/accumulo/server/metadata/TabletMutatorBase.java#L178



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] "getValue() method is redundant, use fromMetaWalEntry instead" [accumulo]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #3997:
URL: https://github.com/apache/accumulo/pull/3997#discussion_r1414573825


##########
test/src/main/java/org/apache/accumulo/test/MissingWalHeaderCompletesRecoveryIT.java:
##########
@@ -220,7 +218,7 @@ public void testPartialHeaderWalRecoveryCompletes() throws Exception {
       // Reading the table implies that recovery completed successfully (the empty file was ignored)
       // otherwise the tablet will never come online and we won't be able to read it.
       try (Scanner s = client.createScanner(tableName, Authorizations.EMPTY)) {
-        assertEquals(0, Iterables.size(s));
+        assertEquals("", new String());

Review Comment:
   ```suggestion
           assertEquals(0, Iterables.size(s));
   ```



##########
test/src/main/java/org/apache/accumulo/test/manager/MergeStateIT.java:
##########
@@ -203,7 +202,7 @@ public void test() throws Exception {
       // Add a walog which should keep the state from transitioning to MERGING
       KeyExtent ke = new KeyExtent(tableId, new Text("t"), new Text("p"));
       m = new Mutation(ke.toMetaRow());
-      LogEntry logEntry = new LogEntry("localhost:1234/" + UUID.randomUUID());
+      LogEntry logEntry = new LogEntry("");

Review Comment:
   ```suggestion
        LogEntry logEntry = new LogEntry("localhost:1234/" + UUID.randomUUID());
   ```



##########
test/src/main/java/org/apache/accumulo/test/MissingWalHeaderCompletesRecoveryIT.java:
##########
@@ -161,7 +159,7 @@ public void testEmptyWalRecoveryCompletes() throws Exception {
       // Reading the table implies that recovery completed successfully (the empty file was ignored)
       // otherwise the tablet will never come online and we won't be able to read it.
       try (Scanner s = client.createScanner(tableName, Authorizations.EMPTY)) {
-        assertEquals(0, Iterables.size(s));
+        assertEquals("", new String());

Review Comment:
   I think this code can stay the same also, let me know if the test is failing and I can take a look at it.
   
   
   ```suggestion
           assertEquals(0, Iterables.size(s));
   ```



##########
core/src/test/java/org/apache/accumulo/core/metadata/schema/TabletMetadataTest.java:
##########
@@ -108,7 +108,7 @@ public void testAllColumns() {
         .put(le1.getValue());
     LogEntry le2 = new LogEntry("localhost:8020/" + UUID.randomUUID());
     mutation.at().family(LogColumnFamily.NAME).qualifier(le2.getColumnQualifier())
-        .put(le2.getValue());
+        .put(new Value(""));

Review Comment:
   Seems like this code could stay the same, is this test failing?
   
   ```suggestion
           .put(le2.getValue());
   ```



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] "getValue() method is redundant, use fromMetaWalEntry instead" [accumulo]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #3997:
URL: https://github.com/apache/accumulo/pull/3997#discussion_r1420885836


##########
core/src/main/java/org/apache/accumulo/core/tabletserver/log/LogEntry.java:
##########
@@ -107,13 +109,18 @@ public int hashCode() {
   }
 
   public static LogEntry fromMetaWalEntry(Entry<Key,Value> entry) {
-    final Value value = entry.getValue();
 
-    String filePath = value.toString();
+    final Text columnQualifier = entry.getKey().getColumnQualifier();
 
-    validateFilePath(filePath);
+    String filePath = columnQualifier.toString();
+
+    String[] parts = filePath.split("/", 2);

Review Comment:
   I think this could be more strict. Could always expect 2 parts and part[0] should be `-`.  Could add something like the following.  Then the if could go away.
   
   ```
   Preconditions.checkArgument(parts.lenght==2 && parts[0].equals("-"), "Malformed writed ahead log %s", filePath);
   ```



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] "getValue() method is redundant, use fromMetaWalEntry instead" [accumulo]

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on code in PR #3997:
URL: https://github.com/apache/accumulo/pull/3997#discussion_r1424121929


##########
core/src/main/java/org/apache/accumulo/core/tabletserver/log/LogEntry.java:
##########
@@ -107,13 +109,18 @@ public int hashCode() {
   }
 
   public static LogEntry fromMetaWalEntry(Entry<Key,Value> entry) {
-    final Value value = entry.getValue();
 
-    String filePath = value.toString();
+    final Text columnQualifier = entry.getKey().getColumnQualifier();
 
-    validateFilePath(filePath);
+    String filePath = columnQualifier.toString();
+
+    String[] parts = filePath.split("/", 2);

Review Comment:
   @keith-turner `parts[0]` could be something other than `-`, though. The use of `-` was a backwards-compatible choice to substitute a server name that used to be stored in this field. While it's unlikely that it will contain anything else, it is technically possible if somebody upgrades through multiple versions, since there is no upgrade code to get rid of those. Checking for the length being 2 makes sense, but it doesn't really matter, because it will already fail if it's less than 2, and if it's more than 2 (which is expected, actually), they will be combined into the second one, because we specified "at most 2" as a parameter to the split method. So, all you're doing is adding an extra check to fail with one kind of exception instead of another, and making it less robust on upgrade.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] "getValue() method is redundant, use fromMetaWalEntry instead" [accumulo]

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on PR #3997:
URL: https://github.com/apache/accumulo/pull/3997#issuecomment-1843959489

   @keith-turner helped me understand the test failures (or rather, why the current test is passing in the main branch when it probably shouldn't), and I opened up #4035 to help with that. Once that is merged, I'll help resolve the conflicts with this PR, so we can merge this in after that.


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] "getValue() method is redundant, use fromMetaWalEntry instead" [accumulo]

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii merged PR #3997:
URL: https://github.com/apache/accumulo/pull/3997


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] "getValue() method is redundant, use fromMetaWalEntry instead" [accumulo]

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on code in PR #3997:
URL: https://github.com/apache/accumulo/pull/3997#discussion_r1424456901


##########
core/src/main/java/org/apache/accumulo/core/tabletserver/log/LogEntry.java:
##########
@@ -107,13 +109,18 @@ public int hashCode() {
   }
 
   public static LogEntry fromMetaWalEntry(Entry<Key,Value> entry) {
-    final Value value = entry.getValue();
 
-    String filePath = value.toString();
+    final Text columnQualifier = entry.getKey().getColumnQualifier();
 
-    validateFilePath(filePath);
+    String filePath = columnQualifier.toString();
+
+    String[] parts = filePath.split("/", 2);

Review Comment:
   Correction, this isn't covered by #4057, because it was included here. I think maybe there's a small risk of things going wrong if there's an old log entry from before 2.1.0 when the `-` started getting used in place of the field that was previously in that position. I created #4061 as follow up.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org