[ 
https://issues.apache.org/jira/browse/APEXMALHAR-2501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16295124#comment-16295124
 ] 

ASF GitHub Bot commented on APEXMALHAR-2501:
--------------------------------------------

vrozov closed pull request #626: APEXMALHAR-2501 Deprecate BufferSlice
URL: https://github.com/apache/apex-malhar/pull/626
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/library/src/main/java/org/apache/apex/malhar/lib/state/managed/Bucket.java 
b/library/src/main/java/org/apache/apex/malhar/lib/state/managed/Bucket.java
index 6292fe27bd..f3c7370449 100644
--- a/library/src/main/java/org/apache/apex/malhar/lib/state/managed/Bucket.java
+++ b/library/src/main/java/org/apache/apex/malhar/lib/state/managed/Bucket.java
@@ -34,7 +34,6 @@
 import org.slf4j.LoggerFactory;
 
 import org.apache.apex.malhar.lib.utils.serde.KeyValueByteStreamProvider;
-import org.apache.apex.malhar.lib.utils.serde.SliceUtils;
 import org.apache.apex.malhar.lib.utils.serde.WindowedBlockStream;
 
 import com.google.common.annotations.VisibleForTesting;
@@ -337,7 +336,6 @@ public Slice get(Slice key, long timeBucket, ReadSource 
readSource)
     {
       // This call is lightweight
       releaseMemory();
-      key = SliceUtils.toBufferSlice(key);
       switch (readSource) {
         case MEMORY:
           return getFromMemory(key);
@@ -417,8 +415,6 @@ public void put(Slice key, long timeBucket, Slice value)
     {
       // This call is lightweight
       releaseMemory();
-      key = SliceUtils.toBufferSlice(key);
-      value = SliceUtils.toBufferSlice(value);
 
       BucketedValue bucketedValue = flash.get(key);
       if (bucketedValue == null) {
diff --git 
a/library/src/main/java/org/apache/apex/malhar/lib/state/spillable/SpillableMapImpl.java
 
b/library/src/main/java/org/apache/apex/malhar/lib/state/spillable/SpillableMapImpl.java
index 56a3b0e948..8cc06df04f 100644
--- 
a/library/src/main/java/org/apache/apex/malhar/lib/state/spillable/SpillableMapImpl.java
+++ 
b/library/src/main/java/org/apache/apex/malhar/lib/state/spillable/SpillableMapImpl.java
@@ -29,7 +29,6 @@
 import org.apache.apex.malhar.lib.state.managed.ManagedTimeUnifiedStateImpl;
 import org.apache.apex.malhar.lib.state.managed.TimeExtractor;
 import org.apache.apex.malhar.lib.utils.serde.AffixKeyValueSerdeManager;
-import org.apache.apex.malhar.lib.utils.serde.BufferSlice;
 import org.apache.apex.malhar.lib.utils.serde.Serde;
 import org.apache.hadoop.classification.InterfaceStability;
 
@@ -259,7 +258,7 @@ public void endWindow()
         bucketId = 
((ManagedTimeUnifiedStateImpl)store).getTimeBucketAssigner().getTimeBucket(timeOrBucketId);
       }
       keyValueSerdeManager.updateBuffersForBucketChange(bucketId);
-      store.put(timeOrBucketId, keyValueSerdeManager.serializeDataKey(key, 
true), BufferSlice.EMPTY_SLICE);
+      store.put(timeOrBucketId, keyValueSerdeManager.serializeDataKey(key, 
true), new Slice(null, 0, 0));
     }
     cache.endWindow();
     keyValueSerdeManager.resetReadBuffer();
diff --git 
a/library/src/main/java/org/apache/apex/malhar/lib/state/spillable/inmem/InMemSpillableStateStore.java
 
b/library/src/main/java/org/apache/apex/malhar/lib/state/spillable/inmem/InMemSpillableStateStore.java
index 8acb04401d..76ebcc51e7 100644
--- 
a/library/src/main/java/org/apache/apex/malhar/lib/state/spillable/inmem/InMemSpillableStateStore.java
+++ 
b/library/src/main/java/org/apache/apex/malhar/lib/state/spillable/inmem/InMemSpillableStateStore.java
@@ -25,8 +25,6 @@
 
 import org.apache.apex.malhar.lib.state.managed.Bucket;
 import org.apache.apex.malhar.lib.state.spillable.SpillableStateStore;
-import org.apache.apex.malhar.lib.utils.serde.BufferSlice;
-import org.apache.apex.malhar.lib.utils.serde.SliceUtils;
 import org.apache.hadoop.classification.InterfaceStability;
 
 import com.google.common.collect.Maps;
@@ -77,8 +75,6 @@ public void put(long bucketId, @NotNull Slice key, @NotNull 
Slice value)
       bucket = Maps.newHashMap();
       store.put(bucketId, bucket);
     }
-    key = SliceUtils.toBufferSlice(key);
-    value = SliceUtils.toBufferSlice(value);
 
     bucket.put(key, value);
   }
@@ -93,10 +89,6 @@ public Slice getSync(long bucketId, @NotNull Slice key)
       store.put(bucketId, bucket);
     }
 
-    if (key.getClass() == Slice.class) {
-      //The hashCode of Slice was not correct, so correct it
-      key = new BufferSlice(key);
-    }
     return bucket.get(key);
   }
 
diff --git 
a/library/src/main/java/org/apache/apex/malhar/lib/utils/serde/Block.java 
b/library/src/main/java/org/apache/apex/malhar/lib/utils/serde/Block.java
index 4b621d1049..27608ef5cf 100644
--- a/library/src/main/java/org/apache/apex/malhar/lib/utils/serde/Block.java
+++ b/library/src/main/java/org/apache/apex/malhar/lib/utils/serde/Block.java
@@ -156,12 +156,12 @@ public void moveLastObjectDataTo(Block newBlock)
    *
    * @return
    */
-  public BufferSlice toSlice()
+  public Slice toSlice()
   {
     if (size == objectBeginOffset) {
       throw new RuntimeException("data size is zero.");
     }
-    BufferSlice slice = new BufferSlice(buffer, objectBeginOffset, size - 
objectBeginOffset);
+    Slice slice = new Slice(buffer, objectBeginOffset, size - 
objectBeginOffset);
     //prepare for next object
     objectBeginOffset = size;
     exposedSlices = true;
diff --git 
a/library/src/main/java/org/apache/apex/malhar/lib/utils/serde/BufferSlice.java 
b/library/src/main/java/org/apache/apex/malhar/lib/utils/serde/BufferSlice.java
index 237115a20a..82c2c40906 100644
--- 
a/library/src/main/java/org/apache/apex/malhar/lib/utils/serde/BufferSlice.java
+++ 
b/library/src/main/java/org/apache/apex/malhar/lib/utils/serde/BufferSlice.java
@@ -31,6 +31,7 @@
  *
  * @since 3.6.0
  */
+@Deprecated
 public class BufferSlice extends Slice
 {
   private static final long serialVersionUID = -471209532589983329L;
diff --git a/library/src/test/java/com/datatorrent/lib/util/TestUtils.java 
b/library/src/test/java/com/datatorrent/lib/util/TestUtils.java
index 92937a9bae..403072df0e 100644
--- a/library/src/test/java/com/datatorrent/lib/util/TestUtils.java
+++ b/library/src/test/java/com/datatorrent/lib/util/TestUtils.java
@@ -24,7 +24,6 @@
 import org.junit.rules.TestWatcher;
 import org.junit.runner.Description;
 
-import org.apache.apex.malhar.lib.utils.serde.BufferSlice;
 import org.apache.commons.io.FileUtils;
 
 import com.google.common.base.Preconditions;
@@ -58,7 +57,7 @@
 
   public static Slice getSlice(int val)
   {
-    return new BufferSlice(getBytes(val));
+    return new Slice(getBytes(val));
   }
 
   public static class TestInfo extends TestWatcher
diff --git 
a/library/src/test/java/org/apache/apex/malhar/lib/state/managed/ManagedStateTestUtils.java
 
b/library/src/test/java/org/apache/apex/malhar/lib/state/managed/ManagedStateTestUtils.java
index 393a3a8fc9..a81031afcd 100644
--- 
a/library/src/test/java/org/apache/apex/malhar/lib/state/managed/ManagedStateTestUtils.java
+++ 
b/library/src/test/java/org/apache/apex/malhar/lib/state/managed/ManagedStateTestUtils.java
@@ -28,7 +28,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.apex.malhar.lib.utils.serde.BufferSlice;
 import org.apache.hadoop.fs.LocatedFileStatus;
 import org.apache.hadoop.fs.RemoteIterator;
 
@@ -130,6 +129,6 @@ public static OperatorContext getOperatorContext(int 
operatorId)
 
   public static Slice getSliceFor(String x)
   {
-    return new BufferSlice(x.getBytes());
+    return new Slice(x.getBytes());
   }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Deprecate BufferSlice
> ---------------------
>
>                 Key: APEXMALHAR-2501
>                 URL: https://issues.apache.org/jira/browse/APEXMALHAR-2501
>             Project: Apache Apex Malhar
>          Issue Type: Improvement
>            Reporter: Vlad Rozov
>            Priority: Minor
>
> BufferSlice was introduced to workaround incorrect Slice.hashCode() 
> implementation in older versions of netlet. The issue is fixed in netlet 
> 1.3.0 and it is not necessary to use BufferSlice workaround.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to