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 2024/01/19 20:29:25 UTC

[PR] checks the entire map, solves #3522 [accumulo]

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

   (no comment)


-- 
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] checks the entire map, solves #3522 [accumulo]

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


##########
server/base/src/main/java/org/apache/accumulo/server/metadata/iterators/SetEqualityIterator.java:
##########
@@ -83,14 +83,22 @@ public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean i
       int count = 0;
 
       while (source.hasTop()) {
-        byte[] ba = source.getTopKey().getColumnQualifierData().toArray();
-        dos.writeInt(ba.length);
-        dos.write(ba, 0, ba.length);
-
         if (includeValue) {
+          byte[] ba = source.getTopKey().getColumnQualifierData().toArray();
           byte[] valueData = source.getTopValue().get();
-          dos.writeInt(valueData.length);
-          dos.write(valueData, 0, valueData.length);
+
+          byte[] encodedData = encodeEntry(Map.entry(ba, valueData));

Review Comment:
   I did not know that Map.entry existed.  Looks like it was added in java v9.  This is not something for this PR, but I think we could replace all usage of AbstractMap.Simple*Entry in the code with Map.entry() in another PR.  Seems like there are least 35 usages in the code.
   
   ```
    find . -name "*.java" | xargs grep -E "SimpleImmutableEntry|SimpleEntry" | wc
        35     163    5131
   
   ```



-- 
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] checks the entire map, solves #3522 [accumulo]

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

   Superceded by #4486 


-- 
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] checks the entire map, solves #3522 [accumulo]

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

   I don't think this is the correct interpretation of #3522. I think that issue is saying to modify the code  [here](https://github.com/apache/accumulo/blob/elasticity/server/base/src/main/java/org/apache/accumulo/server/metadata/ConditionalTabletMutatorImpl.java#L172) when looking at the files.


-- 
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] checks the entire map, solves #3522 [accumulo]

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


##########
server/base/src/main/java/org/apache/accumulo/server/metadata/iterators/SetEqualityIterator.java:
##########
@@ -82,6 +86,13 @@ public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean i
         byte[] ba = source.getTopKey().getColumnQualifierData().toArray();
         dos.writeInt(ba.length);
         dos.write(ba, 0, ba.length);
+
+        if (includeValue) {
+          byte[] valueData = source.getTopValue().get();
+          dos.writeInt(valueData.length);
+          dos.write(valueData, 0, valueData.length);
+        }
+

Review Comment:
   Implemented the recommended modifications and pushed the changes. Thank you for your review.



-- 
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] checks the entire map, solves #3522 [accumulo]

Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion closed pull request #4175: checks the entire map, solves #3522
URL: https://github.com/apache/accumulo/pull/4175


-- 
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] checks the entire map, solves #3522 [accumulo]

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


##########
core/src/main/java/org/apache/accumulo/core/metadata/StoredTabletFile.java:
##########
@@ -55,6 +55,10 @@ public class StoredTabletFile extends AbstractTabletFile<StoredTabletFile> {
   private static final Comparator<StoredTabletFile> comparator = Comparator
       .comparing(StoredTabletFile::getMetadataPath).thenComparing(StoredTabletFile::getRange);
 
+  public byte[] getMetadataBytes() {

Review Comment:
   This method can be removed if its not used.  If it is used the impl is not correct because the getBytes() method on the Text object may return an array that is longer than the data.  Accumulo has a helper method in TextUtil to deal 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] checks the entire map, solves #3522 [accumulo]

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


##########
core/src/main/java/org/apache/accumulo/core/metadata/StoredTabletFile.java:
##########
@@ -55,6 +55,10 @@ public class StoredTabletFile extends AbstractTabletFile<StoredTabletFile> {
   private static final Comparator<StoredTabletFile> comparator = Comparator
       .comparing(StoredTabletFile::getMetadataPath).thenComparing(StoredTabletFile::getRange);
 
+  public byte[] getMetadataBytes() {

Review Comment:
   I don't believe this method is in use, so I plan to remove it.



-- 
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] checks the entire map, solves #3522 [accumulo]

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

   Now that #4227 is merged, it would be good to merge elasticity into this branch and then add unit test for this new code.


-- 
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] checks the entire map, solves #3522 [accumulo]

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


##########
server/base/src/main/java/org/apache/accumulo/server/metadata/ConditionalTabletMutatorImpl.java:
##########
@@ -158,6 +161,14 @@ public Ample.ConditionalTabletMutator requireOperation(TabletOperationId opid) {
     return this;
   }
 
+  private byte[] convertStringToByteArray(String string) {

Review Comment:
   I introduced the private method to address the error "The method getBytes() in the type Text is not applicable for the arguments (Charset)." Following your feedback, I noticed the usage of getBytes(UTF_8) and implemented it appropriately. This led to the removal of unnecessary code.



-- 
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] checks the entire map, solves #3522 [accumulo]

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


##########
server/base/src/main/java/org/apache/accumulo/server/metadata/iterators/SetEqualityIterator.java:
##########
@@ -79,9 +83,24 @@ public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean i
       int count = 0;
 
       while (source.hasTop()) {
-        byte[] ba = source.getTopKey().getColumnQualifierData().toArray();
-        dos.writeInt(ba.length);
-        dos.write(ba, 0, ba.length);
+        if (includeValue) {
+          byte[] ba = source.getTopKey().getColumnQualifierData().toArray();
+          byte[] valueData = source.getTopValue().get();
+
+          byte[] encodedData = encodeEntry(Map.entry(ba, valueData));
+
+          dos.writeInt(encodedData.length);
+          dos.write(encodedData, 0, encodedData.length);
+        }
+
+        else {

Review Comment:
   The build failed because of a checkstyle violation.  If I am reading the error correctly I think it wants the following.
   
   ```suggestion
           } else {
   ```



##########
server/base/src/main/java/org/apache/accumulo/server/metadata/ConditionalTabletMutatorImpl.java:
##########
@@ -171,8 +172,15 @@ private void requireSameSingle(TabletMetadata tabletMetadata, ColumnType type) {
         break;
       case FILES: {
         // ELASTICITY_TODO compare values?

Review Comment:
   Can remove this TODO now that its done



-- 
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] checks the entire map, solves #3522 [accumulo]

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

   > I don't think this is the correct interpretation of #3522. I think that issue is saying to modify the code [here](https://github.com/apache/accumulo/blob/elasticity/server/base/src/main/java/org/apache/accumulo/server/metadata/ConditionalTabletMutatorImpl.java#L172) when looking at the files.
   
   
   Thank you for guiding me in the right direction. @keith-turner, could you please verify if the modifications I implemented in the code align with your expectations?
   


-- 
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] checks the entire map, solves #3522 [accumulo]

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


##########
server/base/src/main/java/org/apache/accumulo/server/metadata/iterators/SetEqualityIterator.java:
##########
@@ -82,6 +86,13 @@ public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean i
         byte[] ba = source.getTopKey().getColumnQualifierData().toArray();
         dos.writeInt(ba.length);
         dos.write(ba, 0, ba.length);
+
+        if (includeValue) {
+          byte[] valueData = source.getTopValue().get();
+          dos.writeInt(valueData.length);
+          dos.write(valueData, 0, valueData.length);
+        }
+

Review Comment:
   This needs be structured a bit differently to encode the map on the server side in the same way its being encoded on the client side.
   
   ```suggestion
         if (includeValue) {
              //encode the key+value same way as the client side.  So encode both into a single byte array and then write that byte array out to 'dos'
          
              
         } else {
         // only encode the key/qualifier
           byte[] ba = source.getTopKey().getColumnQualifierData().toArray();
           dos.writeInt(ba.length);
           dos.write(ba, 0, ba.length);
         }
   ```



-- 
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] checks the entire map, solves #3522 [accumulo]

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


##########
server/base/src/main/java/org/apache/accumulo/server/metadata/ConditionalTabletMutatorImpl.java:
##########
@@ -158,6 +161,14 @@ public Ample.ConditionalTabletMutator requireOperation(TabletOperationId opid) {
     return this;
   }
 
+  private byte[] convertStringToByteArray(String string) {

Review Comment:
   Why introduce a method to replace a call to getBytes()?  Also, should the conversion include a character set (UTF_8)?



-- 
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] checks the entire map, solves #3522 [accumulo]

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


##########
server/base/src/main/java/org/apache/accumulo/server/metadata/iterators/SetEqualityIterator.java:
##########
@@ -186,4 +187,49 @@ public static <T> Condition createCondition(Collection<T> set, Function<T,byte[]
     return new Condition(family, EMPTY).setValue(encode((Set<T>) set, encoder)).setIterators(is);
   }
 
+  private static <K,T> Set<T> extractValuesFromMap(Map<K,T> map) {
+    return new HashSet<>(map.values());
+  }
+
+  private static <K,T> Set<K> extractKeysFromMap(Map<K,T> map) {
+    return new HashSet<>(map.keySet());
+  }
+
+  public static <K,T> byte[] encodeMapValues(Map<K,T> map, Function<T,byte[]> encoder) {
+    Set<T> valuesSet = extractValuesFromMap(map);
+    return encode(valuesSet, encoder);
+  }
+
+  public static <K,T> byte[] encodeMapKeys(Map<K,T> map, Function<K,byte[]> encoder) {
+    Set<K> keysSet = extractKeysFromMap(map);
+    return encode(keysSet, encoder);
+  }
+
+  public static <K,T> Condition createMapValuesCondition(Map<K,T> map, Function<T,byte[]> encoder,
+      Text family) {
+    Preconditions.checkArgument(map instanceof Map);
+    IteratorSetting is = new IteratorSetting(ConditionalTabletMutatorImpl.INITIAL_ITERATOR_PRIO,
+        SetEqualityIterator.class);
+    return new Condition(family, EMPTY).setValue(encodeMapValues(map, encoder)).setIterators(is);
+  }
+
+  public static <K,T> Condition createMapKeysCondition(Map<K,T> map, Function<K,byte[]> encoder,
+      Text family) {

Review Comment:
   We could possibly change this to encode the keys and values for the map with a method like the following.
   
   ```suggestion
     public static <K,T> Condition createMapKeysCondition(Map<K,T> map, Function<Entry<K,T>,Entry<byte[],byte[]>> encoder,
         Text family) {
   ```
   
   This could then call entry set on the map and then encode the entry set using existing methods.  Would also need to add an option to the iterator to encode the values on the server side.



-- 
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