50
50
import java .util .ArrayList ;
51
51
import java .util .Iterator ;
52
52
53
- public class CSVPersonSerializerWithWeights extends PersonSerializer {
53
+ public class CSVPersonSerializerExtended extends PersonSerializer {
54
54
55
55
private HDFSCSVWriter [] writers ;
56
56
57
57
private enum FileNames {
58
+ PERSON ("person" ),
58
59
PERSON_KNOWS_PERSON ("person_knows_person" );
59
60
60
61
private final String name ;
@@ -67,7 +68,7 @@ public String toString() {
67
68
}
68
69
}
69
70
70
- public CSVPersonSerializerWithWeights () {
71
+ public CSVPersonSerializerExtended () {
71
72
}
72
73
73
74
public void initialize (Configuration conf , int reducerId ) {
@@ -78,9 +79,15 @@ public void initialize(Configuration conf, int reducerId) {
78
79
}
79
80
80
81
ArrayList <String > arguments = new ArrayList <String >();
82
+ arguments .add ("id" );
83
+ arguments .add ("creationDate" );
84
+ writers [FileNames .PERSON .ordinal ()].writeEntry (arguments );
85
+
86
+ arguments .clear ();
81
87
arguments .clear ();
82
88
arguments .add ("Person.id" );
83
89
arguments .add ("Person.id" );
90
+ arguments .add ("CreationDate" );
84
91
arguments .add ("Weight" );
85
92
writers [FileNames .PERSON_KNOWS_PERSON .ordinal ()].writeEntry (arguments );
86
93
@@ -96,7 +103,10 @@ public void close() {
96
103
97
104
@ Override
98
105
protected void serialize (Person p ) {
99
-
106
+ ArrayList <String > arguments = new ArrayList <String >();
107
+ arguments .add (Long .toString (p .accountId ()));
108
+ arguments .add (Dictionaries .dates .formatDateTime (p .creationDate ()));
109
+ writers [FileNames .PERSON .ordinal ()].writeEntry (arguments );
100
110
}
101
111
102
112
@ Override
@@ -111,6 +121,7 @@ protected void serialize(Person p, Knows knows) {
111
121
ArrayList <String > arguments = new ArrayList <String >();
112
122
arguments .add (Long .toString (p .accountId ()));
113
123
arguments .add (Long .toString (knows .to ().accountId ()));
124
+ arguments .add (Dictionaries .dates .formatDateTime (knows .creationDate ()));
114
125
arguments .add (Float .toString (knows .weight ()));
115
126
writers [FileNames .PERSON_KNOWS_PERSON .ordinal ()].writeEntry (arguments );
116
127
}
0 commit comments