Skip to content

Commit

Permalink
Removed manual serialization and deserialization as it's not needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
eljefe6a committed Jan 4, 2013
1 parent faa0d77 commit ab1b670
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions src/RollGraphWritable.java
Expand Up @@ -2,8 +2,6 @@
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.hadoop.io.Writable;

Expand Down Expand Up @@ -71,43 +69,6 @@ public void readFields(DataInput in) throws IOException {
}
}

/**
* Serializes the object to a string representation
*
* @return The string representation
*/
public String serialize() {
return toString();
}

/**
* Deserializes the string to a RollGraphWritable
*
* @param rollString
* The string represenation
* @return The RollGraphWritable in the string
*/
public static RollGraphWritable deserialize(String rollString) {
String[] parts = rollString.split(" ");

// Use Regex to read out the rows and columns in the string
Pattern pattern = Pattern.compile("\\[(\\d*),(\\d*)\\]");
String nodesString = parts[0].substring(1, parts[0].length() - 1);
Matcher nodeMatcher = pattern.matcher(nodesString);

ArrayList<Node> nodes = new ArrayList<Node>();

// Go through all groups and add their rows and columns
while (nodeMatcher.find()) {
Node node = new Node(nodeMatcher.group(1), nodeMatcher.group(2));
nodes.add(node);
}

RollGraphWritable graphWritable = new RollGraphWritable(nodes, Boolean.parseBoolean(parts[1]));

return graphWritable;
}

@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
Expand Down

0 comments on commit ab1b670

Please sign in to comment.