Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:clj-sys/cascading-clojure
- Loading branch information
Showing
6 changed files
with
107 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cascading.clojure; | ||
|
||
import clojure.lang.IPersistentCollection; | ||
import clojure.lang.Util; | ||
import org.apache.hadoop.io.Writable; | ||
import java.io.DataOutput; | ||
import java.io.DataInput; | ||
import java.io.IOException; | ||
import clj_serializer.Serializer; | ||
|
||
public class ClojureWrapper implements Comparable, Writable { | ||
private static final Object EOF = new Object(); | ||
private Object obj; | ||
|
||
public ClojureWrapper() { | ||
this.obj = null; | ||
} | ||
|
||
public ClojureWrapper(Object obj) { | ||
this.obj = obj; | ||
} | ||
|
||
public Object toClojure() { | ||
return this.obj; | ||
} | ||
|
||
public int hashCode() { | ||
return this.obj.hashCode(); | ||
} | ||
|
||
public boolean equals(Object o) { | ||
return ((ClojureWrapper)o).toClojure().equals(this.toClojure()); | ||
} | ||
|
||
public int compareTo(Object o) { | ||
return this.hashCode() - ((ClojureWrapper)o).hashCode(); | ||
} | ||
|
||
public void write(DataOutput out) throws IOException { | ||
Serializer.serialize(out, this.obj); | ||
} | ||
|
||
public void readFields(DataInput in) throws IOException { | ||
this.obj = Serializer.deserialize(in, EOF); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters