yunfengzhou-hub commented on code in PR #97:
URL: https://github.com/apache/flink-ml/pull/97#discussion_r889669817


##########
flink-ml-iteration/src/main/java/org/apache/flink/iteration/datacache/nonkeyed/Segment.java:
##########
@@ -18,61 +18,37 @@
 
 package org.apache.flink.iteration.datacache.nonkeyed;
 
-import org.apache.flink.core.fs.Path;
+import org.apache.flink.annotation.Internal;
 
-import java.io.Serializable;
-import java.util.Objects;
+/** A segment contains the information about a cache unit. */
+@Internal
+class Segment {
 
-/** A segment represents a single file for the cache. */
-public class Segment implements Serializable {
+    private FileSegment fileSegment;
 
-    private final Path path;
+    private MemorySegment memorySegment;
 
-    /** The count of the records in the file. */
-    private final int count;
-
-    /** The total length of file. */
-    private final long size;
-
-    public Segment(Path path, int count, long size) {
-        this.path = path;
-        this.count = count;
-        this.size = size;
-    }
-
-    public Path getPath() {
-        return path;
+    Segment(FileSegment fileSegment) {
+        this.fileSegment = fileSegment;
     }
 
-    public int getCount() {
-        return count;
+    Segment(MemorySegment memorySegment) {
+        this.memorySegment = memorySegment;
     }
 
-    public long getSize() {
-        return size;
+    void setFileSegment(FileSegment fileSegment) {
+        this.fileSegment = fileSegment;
     }
 
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) {
-            return true;
-        }
-
-        if (!(o instanceof Segment)) {
-            return false;
-        }
-
-        Segment segment = (Segment) o;
-        return count == segment.count && size == segment.size && 
Objects.equals(path, segment.path);
+    FileSegment getFileSegment() {
+        return fileSegment;
     }
 
-    @Override
-    public int hashCode() {
-        return Objects.hash(path, count, size);
+    void setMemorySegment(MemorySegment memorySegment) {

Review Comment:
   It is used in `DataCache.tryCacheSegmentToMemory`. I just found that there 
is a bug in this method that it should call 
`segment.setMemorySegment(x.getMemorySegment())`. I'll make the modification.



-- 
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: issues-unsubscr...@flink.apache.org

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

Reply via email to