Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10893#discussion_r50771577
  
    --- Diff: 
common/sketch/src/main/java/org/apache/spark/util/sketch/CountMinSketchImpl.java
 ---
    @@ -256,13 +324,48 @@ public CountMinSketch mergeInPlace(CountMinSketch 
other) {
       }
     
       @Override
    -  public void writeTo(OutputStream out) {
    -    throw new UnsupportedOperationException("Not implemented yet");
    +  public void writeTo(OutputStream out) throws IOException {
    +    DataOutputStream dos = new DataOutputStream(out);
    +
    +    dos.writeInt(version().getVersionNumber());
    +
    +    dos.writeLong(this.totalCount);
    +    dos.writeInt(this.depth);
    +    dos.writeInt(this.width);
    +
    +    for (int i = 0; i < this.depth; ++i) {
    +      dos.writeLong(this.hashA[i]);
    +    }
    +
    +    for (int i = 0; i < this.depth; ++i) {
    +      for (int j = 0; j < this.width; ++j) {
    +        dos.writeLong(table[i][j]);
    +      }
    +    }
       }
     
    -  protected static class CMSMergeException extends RuntimeException {
    -    public CMSMergeException(String message) {
    -      super(message);
    +  public static CountMinSketchImpl readFrom(InputStream in) throws 
IOException {
    +    DataInputStream dis = new DataInputStream(in);
    +
    +    // Ignores version number
    +    dis.readInt();
    --- End diff --
    
    should add some check here to throw an exception if the version number is 
not 1.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to