Commit 5eefc26b authored by feng's avatar feng

Order inversion 4

parent 3814f4f8
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="05d59ada-3cd7-4c26-9a9f-8ed545f37173" name="Default" comment=""> <list default="true" id="05d59ada-3cd7-4c26-9a9f-8ed545f37173" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/OrderInversion.java" afterPath="$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/OrderInversion.java" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/OrderInversion.java" afterPath="$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/OrderInversion.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/StringToIntMapWritable.java" afterPath="$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/StringToIntMapWritable.java" />
</list> </list>
<ignored path="labs.iws" /> <ignored path="labs.iws" />
<ignored path=".idea/workspace.xml" /> <ignored path=".idea/workspace.xml" />
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<entry file="file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/Stripes.java"> <entry file="file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/Stripes.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="0.0">
<caret line="105" column="0" selection-start-line="105" selection-start-column="0" selection-end-line="105" selection-end-column="0" /> <caret line="122" column="65" selection-start-line="122" selection-start-column="65" selection-end-line="122" selection-end-column="65" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
</folding> </folding>
...@@ -41,14 +41,14 @@ ...@@ -41,14 +41,14 @@
<file leaf-file-name="StringToIntMapWritable.java" pinned="false" current-in-tab="false"> <file leaf-file-name="StringToIntMapWritable.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/StringToIntMapWritable.java"> <entry file="file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/StringToIntMapWritable.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="2.625">
<caret line="61" column="0" selection-start-line="61" selection-start-column="0" selection-end-line="61" selection-end-column="0" /> <caret line="40" column="0" selection-start-line="40" selection-start-column="0" selection-end-line="40" selection-end-column="0" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#2235#2236#0" expanded="true" /> <element signature="e#2027#2028#0" expanded="true" />
<element signature="e#2298#2299#0" expanded="true" /> <element signature="e#2090#2091#0" expanded="true" />
<element signature="e#2537#2538#0" expanded="true" /> <element signature="e#2329#2330#0" expanded="true" />
<element signature="e#2588#2589#0" expanded="true" /> <element signature="e#2380#2381#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
...@@ -57,8 +57,8 @@ ...@@ -57,8 +57,8 @@
<file leaf-file-name="OrderInversion.java" pinned="false" current-in-tab="true"> <file leaf-file-name="OrderInversion.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/OrderInversion.java"> <entry file="file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/OrderInversion.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.48630136"> <state vertical-scroll-proportion="-0.10273973">
<caret line="89" column="0" selection-start-line="89" selection-start-column="0" selection-end-line="89" selection-end-column="0" /> <caret line="61" column="41" selection-start-line="61" selection-start-column="41" selection-end-line="61" selection-end-column="41" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
</folding> </folding>
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
<component name="ProjectFrameBounds"> <component name="ProjectFrameBounds">
<option name="x" value="-1" /> <option name="x" value="-1" />
<option name="y" value="27" /> <option name="y" value="27" />
<option name="width" value="1922" /> <option name="width" value="962" />
<option name="height" value="1054" /> <option name="height" value="1054" />
</component> </component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false"> <component name="ProjectLevelVcsManager" settingsEditedManually="false">
...@@ -457,7 +457,7 @@ ...@@ -457,7 +457,7 @@
<servers /> <servers />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="-1" y="27" width="1922" height="1054" extended-state="6" /> <frame x="-1" y="27" width="962" height="1054" extended-state="4" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info id="Palette&#9;" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Palette&#9;" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
...@@ -563,10 +563,10 @@ ...@@ -563,10 +563,10 @@
<caret line="76" column="27" selection-start-line="76" selection-start-column="27" selection-end-line="76" selection-end-column="27" /> <caret line="76" column="27" selection-start-line="76" selection-start-column="27" selection-end-line="76" selection-end-column="27" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#2235#2236#0" expanded="true" /> <element signature="e#2027#2028#0" expanded="true" />
<element signature="e#2298#2299#0" expanded="true" /> <element signature="e#2090#2091#0" expanded="true" />
<element signature="e#2537#2538#0" expanded="true" /> <element signature="e#2329#2330#0" expanded="true" />
<element signature="e#2588#2589#0" expanded="true" /> <element signature="e#2380#2381#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
...@@ -640,10 +640,10 @@ ...@@ -640,10 +640,10 @@
<caret line="22" column="28" selection-start-line="22" selection-start-column="28" selection-end-line="22" selection-end-column="28" /> <caret line="22" column="28" selection-start-line="22" selection-start-column="28" selection-end-line="22" selection-end-column="28" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#2235#2236#0" expanded="true" /> <element signature="e#2027#2028#0" expanded="true" />
<element signature="e#2298#2299#0" expanded="true" /> <element signature="e#2090#2091#0" expanded="true" />
<element signature="e#2537#2538#0" expanded="true" /> <element signature="e#2329#2330#0" expanded="true" />
<element signature="e#2588#2589#0" expanded="true" /> <element signature="e#2380#2381#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
...@@ -925,34 +925,34 @@ ...@@ -925,34 +925,34 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/Stripes.java"> <entry file="file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/StringToIntMapWritable.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="2.625">
<caret line="105" column="0" selection-start-line="105" selection-start-column="0" selection-end-line="105" selection-end-column="0" /> <caret line="40" column="0" selection-start-line="40" selection-start-column="0" selection-end-line="40" selection-end-column="0" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#2027#2028#0" expanded="true" />
<element signature="e#2090#2091#0" expanded="true" />
<element signature="e#2329#2330#0" expanded="true" />
<element signature="e#2380#2381#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/StringToIntMapWritable.java"> <entry file="file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/Stripes.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="0.0">
<caret line="61" column="0" selection-start-line="61" selection-start-column="0" selection-end-line="61" selection-end-column="0" /> <caret line="122" column="65" selection-start-line="122" selection-start-column="65" selection-end-line="122" selection-end-column="65" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#2235#2236#0" expanded="true" />
<element signature="e#2298#2299#0" expanded="true" />
<element signature="e#2537#2538#0" expanded="true" />
<element signature="e#2588#2589#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/OrderInversion.java"> <entry file="file://$PROJECT_DIR$/src/main/java/fr/eurecom/dsg/mapreduce/OrderInversion.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.48630136"> <state vertical-scroll-proportion="-0.10273973">
<caret line="89" column="0" selection-start-line="89" selection-start-column="0" selection-end-line="89" selection-end-column="0" /> <caret line="61" column="41" selection-start-line="61" selection-start-column="41" selection-end-line="61" selection-end-column="41" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
</folding> </folding>
......
...@@ -59,6 +59,7 @@ public class OrderInversion extends Configured implements Tool { ...@@ -59,6 +59,7 @@ public class OrderInversion extends Configured implements Tool {
// TODO: implement the map method // TODO: implement the map method
String line = value.toString(); String line = value.toString();
line.replaceAll("^\\s+", "");
String[] words = line.split("\\s+"); String[] words = line.split("\\s+");
for (String firstWord : words) { for (String firstWord : words) {
......
...@@ -35,30 +35,24 @@ public class StringToIntMapWritable implements Writable { ...@@ -35,30 +35,24 @@ public class StringToIntMapWritable implements Writable {
public void readFields(DataInput in) throws IOException { public void readFields(DataInput in) throws IOException {
// TODO: implement deserialization // TODO: implement deserialization
IntWritable sizeWritable = new IntWritable(); // Warning: for efficiency reasons, Hadoop attempts to re-use old instances of
sizeWritable.readFields(in); // StringToIntMapWritable when reading new records. Remember to initialize your variables
int size = sizeWritable.get(); // inside this function, in order to get rid of old data.
hashMap.clear();
int size = in.readInt();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
word = new Text();
word.readFields(in); // read the size of word from in word.readFields(in); // read the size of word from in
count = new IntWritable();
count.readFields(in); count.readFields(in);
hashMap.put(word, count); hashMap.put(word, count);
} }
// Warning: for efficiency reasons, Hadoop attempts to re-use old instances of
// StringToIntMapWritable when reading new records. Remember to initialize your variables
// inside this function, in order to get rid of old data.
} }
@Override @Override
public void write(DataOutput out) throws IOException { public void write(DataOutput out) throws IOException {
// TODO: implement serialization // TODO: implement serialization
int size = hashMap.size(); out.writeInt(hashMap.size());
IntWritable sizeWritable = new IntWritable(size);
sizeWritable.write(out);
Set<Text> keys = hashMap.keySet(); Set<Text> keys = hashMap.keySet();
Iterator iterator = keys.iterator(); Iterator iterator = keys.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment