Skip to content

Commit ebd67ec

Browse files
committed
Added dependant event date
1 parent 6c2ad42 commit ebd67ec

File tree

6 files changed

+103
-105
lines changed

6 files changed

+103
-105
lines changed

src/main/java/ldbc/socialnet/dbgen/generator/ScalableGenerator.java

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,9 @@ public void generateUserActivity( ReducedUserProfile userProfile, Reducer<MapRed
795795
firstNameCount.put(extraInfo.getFirstName(), nameCount+1);
796796
long init = System.currentTimeMillis();
797797
if(conf.getBoolean("activity",true)) {
798-
generatePosts(uniformPostGenerator, reducedUserProfiles[index], extraInfo);
799-
generatePosts(flashmobPostGenerator, reducedUserProfiles[index], extraInfo);
798+
Group wall = generateWall(userInfo);
799+
generatePosts(uniformPostGenerator, reducedUserProfiles[index], extraInfo, wall);
800+
generatePosts(flashmobPostGenerator, reducedUserProfiles[index], extraInfo, wall);
800801
generatePhotos(reducedUserProfiles[index], extraInfo);
801802
generateUserGroups(reducedUserProfiles[index], extraInfo);
802803
}
@@ -982,7 +983,27 @@ private void mr2SlideLastCellsFriendShip(int pass, int cellPos, int numleftCell,
982983
exactOutput = exactOutput + cellSize;
983984
}
984985

985-
private void generatePosts(PostGenerator postGenerator, ReducedUserProfile user, UserExtraInfo extraInfo){
986+
987+
private Group generateWall(UserInfo userInfo) {
988+
Group group = new Group();
989+
group.setCreatedDate(userInfo.user.getCreationDate()+deltaTime);
990+
group.setGroupName("Wall of " + userInfo.extraInfo.getFirstName() + " " + userInfo.extraInfo.getLastName());
991+
group.setGroupId(userInfo.user.getForumWallId());
992+
group.setModeratorId(userInfo.user.getAccountId());
993+
994+
Iterator<Integer> itTags = userInfo.user.getSetOfTags().iterator();
995+
Integer tags[] = new Integer[userInfo.user.getSetOfTags().size()];
996+
int index = 0;
997+
while (itTags.hasNext()){
998+
tags[index] = itTags.next();
999+
index++;
1000+
}
1001+
group.setTags(tags);
1002+
dataExporter.export(group,userInfo.user.getCreationDate());
1003+
return group;
1004+
}
1005+
1006+
private void generatePosts(PostGenerator postGenerator, ReducedUserProfile user, UserExtraInfo extraInfo, Group group){
9861007
Vector<Post> createdPosts = postGenerator.createPosts( randomFarm, user, extraInfo, postId );
9871008
postId+=createdPosts.size();
9881009
Iterator<Post> it = createdPosts.iterator();
@@ -1021,7 +1042,7 @@ private void generatePosts(PostGenerator postGenerator, ReducedUserProfile user,
10211042
stats.minPostCreationDate = strCreationDate;
10221043
}
10231044
}
1024-
dataExporter.export(post);
1045+
dataExporter.export(post,group.getCreatedDate());
10251046
// Generate comments
10261047
int numComment = randomFarm.get(RandomGeneratorFarm.Aspect.NUM_COMMENT).nextInt(maxNumComments+1);
10271048
ArrayList<Message> replyCandidates = new ArrayList<Message>();
@@ -1051,7 +1072,7 @@ private void generatePosts(PostGenerator postGenerator, ReducedUserProfile user,
10511072
postCount = postsPerCountry.containsKey(locationID) ? postsPerCountry.get(locationID) : 0;
10521073
postsPerCountry.put(locationID, postCount+1);
10531074
stats.countries.add(countryName);
1054-
dataExporter.export(comment);
1075+
dataExporter.export(comment,post.getCreationDate());
10551076
if( comment.getTextSize() > 10 ) replyCandidates.add(comment);
10561077
postId++;
10571078
}
@@ -1071,7 +1092,7 @@ private void generatePhotos(ReducedUserProfile user, UserExtraInfo extraInfo){
10711092
Group album = groupGenerator.createAlbum(randomFarm, groupId, user, extraInfo, m, joinProbs[0]);
10721093
if( album != null ) {
10731094
groupId++;
1074-
dataExporter.export(album);
1095+
dataExporter.export(album,user.getCreationDate());
10751096

10761097
// Generate photos for this album
10771098
int numPhotos = randomFarm.get(RandomGeneratorFarm.Aspect.NUM_PHOTO).nextInt(maxNumPhotoPerAlbums+1);
@@ -1089,7 +1110,7 @@ private void generatePhotos(ReducedUserProfile user, UserExtraInfo extraInfo){
10891110
int postCount = postsPerCountry.containsKey(locationID) ? postsPerCountry.get(locationID) : 0;
10901111
postsPerCountry.put(locationID, postCount+1);
10911112
stats.countries.add(countryName);
1092-
dataExporter.export(photo);
1113+
dataExporter.export(photo,album.getCreatedDate());
10931114

10941115
if (photo.getTags() != null) {
10951116
for (Integer t: photo.getTags()){
@@ -1184,7 +1205,7 @@ private void createGroupForUser(ReducedUserProfile user,
11841205
numLoop++;
11851206
}
11861207

1187-
dataExporter.export(group);
1208+
dataExporter.export(group,user.getCreationDate());
11881209
generatePostForGroup(uniformPostGenerator,group);
11891210
generatePostForGroup(flashmobPostGenerator,group);
11901211
}
@@ -1212,7 +1233,7 @@ private void generatePostForGroup(PostGenerator postGenerator, Group group) {
12121233
int postCount = postsPerCountry.containsKey(locationID) ? postsPerCountry.get(locationID) : 0;
12131234
postsPerCountry.put(locationID, postCount+1);
12141235
stats.countries.add(countryName);
1215-
dataExporter.export(groupPost);
1236+
dataExporter.export(groupPost,group.getCreatedDate());
12161237

12171238
int numComment = randomFarm.get(RandomGeneratorFarm.Aspect.NUM_COMMENT).nextInt(maxNumComments+1);
12181239
ArrayList<Message> replyCandidates = new ArrayList<Message>();
@@ -1232,7 +1253,7 @@ private void generatePostForGroup(PostGenerator postGenerator, Group group) {
12321253
postCount = postsPerCountry.containsKey(locationID) ? postsPerCountry.get(locationID) : 0;
12331254
postsPerCountry.put(locationID, postCount+1);
12341255
stats.countries.add(countryName);
1235-
dataExporter.export(comment);
1256+
dataExporter.export(comment,groupPost.getCreationDate());
12361257
if( comment.getTextSize() > 10 ) replyCandidates.add(comment);
12371258

12381259
if (comment.getTags() != null) {

src/main/java/ldbc/socialnet/dbgen/objects/Friend.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class Friend implements Serializable{
4545
private static final long serialVersionUID = 3657773293974543890L;
4646
long from;
4747
long to;
48+
public long dependantDate;
4849
long createdTime; //approved Time
4950
long requestTime;
5051
long declinedTime;
@@ -78,6 +79,7 @@ public Friend(){}
7879
public void readFields(DataInput arg0) throws IOException{
7980
from = arg0.readLong();
8081
to = arg0.readLong();
82+
dependantDate = arg0.readLong();
8183
createdTime = arg0.readLong();
8284
requestTime = arg0.readLong();
8385
declinedTime = arg0.readLong();
@@ -96,6 +98,7 @@ public void readFields(DataInput arg0) throws IOException{
9698
public void write(DataOutput arg0) throws IOException {
9799
arg0.writeLong(from);
98100
arg0.writeLong(to);
101+
arg0.writeLong(dependantDate);
99102
arg0.writeLong(createdTime);
100103
arg0.writeLong(requestTime);
101104
arg0.writeLong(declinedTime);
@@ -115,6 +118,7 @@ public Friend(ReducedUserProfile from, ReducedUserProfile to, long _requestedTim
115118
byte passidx, byte initiator){
116119
this.from = from.getAccountId();
117120
this.to = to.getAccountId();
121+
this.dependantDate = Math.max(from.getCreationDate(), to.getCreationDate());
118122
this.requestTime = _requestedTime;
119123
this.declinedTime = _declinedTime;
120124
this.createdTime = _createdTime;

src/main/java/ldbc/socialnet/dbgen/objects/UpdateEvent.java

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -56,71 +56,77 @@ public enum UpdateEventType {
5656
}
5757

5858
public long date;
59+
public long dependantDate;
5960
public String eventData;
6061
public UpdateEventType type;
6162

62-
public static void writeEvent( OutputStream os, UpdateEvent event ) {
63-
try{
64-
StringBuffer string = new StringBuffer();
65-
string.append(Long.toString(event.date));
66-
string.append("|");
67-
string.append(Integer.toString(event.type.ordinal()+1));
68-
string.append("|");
69-
string.append(event.eventData);
70-
string.append("\n");
71-
//fileOutputStream.write(string.toString().getBytes("UTF8"));
72-
os.write(string.toString().getBytes("UTF8"));
73-
} catch(IOException e){
74-
System.err.println(e.getMessage());
75-
System.exit(-1);
76-
}
77-
}
78-
79-
public static void writeEventKeyValue( OutputStream os, UpdateEvent event ) {
80-
try{
81-
StringBuffer string = new StringBuffer();
82-
string.append(Long.toString(event.date));
83-
string.append("|");
84-
string.append(event.type.toString());
85-
string.append("|");
86-
string.append(event.eventData);
87-
string.append("\n");
88-
//fileOutputStream.write(string.toString().getBytes("UTF8"));
89-
os.write(string.toString().getBytes("UTF8"));
90-
} catch(IOException e){
91-
System.err.println(e.getMessage());
92-
System.exit(-1);
93-
}
94-
}
63+
// public static void writeEvent( OutputStream os, UpdateEvent event ) {
64+
// try{
65+
// StringBuffer string = new StringBuffer();
66+
// string.append(Long.toString(event.date));
67+
// string.append("|");
68+
// string.append(Integer.toString(event.type.ordinal()+1));
69+
// string.append("|");
70+
// string.append(event.eventData);
71+
// string.append("\n");
72+
// //fileOutputStream.write(string.toString().getBytes("UTF8"));
73+
// os.write(string.toString().getBytes("UTF8"));
74+
// } catch(IOException e){
75+
// System.err.println(e.getMessage());
76+
// System.exit(-1);
77+
// }
78+
// }
79+
//
80+
// public static void writeEventKeyValue( OutputStream os, UpdateEvent event ) {
81+
// try{
82+
// StringBuffer string = new StringBuffer();
83+
// string.append(Long.toString(event.date));
84+
// string.append("|");
85+
// string.append(event.type.toString());
86+
// string.append("|");
87+
// string.append(event.eventData);
88+
// string.append("\n");
89+
// //fileOutputStream.write(string.toString().getBytes("UTF8"));
90+
// os.write(string.toString().getBytes("UTF8"));
91+
// } catch(IOException e){
92+
// System.err.println(e.getMessage());
93+
// System.exit(-1);
94+
// }
95+
// }
9596

96-
public UpdateEvent( long date, UpdateEventType type, String eventData) {
97+
public UpdateEvent( long date, long dependantDate, UpdateEventType type, String eventData) {
9798
this.date = date;
9899
this.type = type;
99100
this.eventData = eventData;
101+
this.dependantDate = dependantDate;
100102
}
101103

102104
public void readObject(java.io.ObjectInputStream stream)
103105
throws IOException, ClassNotFoundException{
104-
this.date = stream.readLong();
105-
this.type = UpdateEventType.values()[stream.readInt()];
106-
this.eventData = stream.readUTF();
106+
this.date = stream.readLong();
107+
this.dependantDate = stream.readLong();
108+
this.type = UpdateEventType.values()[stream.readInt()];
109+
this.eventData = stream.readUTF();
107110
}
108111

109112
public void writeObject(java.io.ObjectOutputStream stream)
110113
throws IOException{
111114
stream.writeLong(this.date);
115+
stream.writeLong(this.dependantDate);
112116
stream.writeInt(type.ordinal());
113117
stream.writeUTF(eventData);
114118
}
115119

116120
public void readFields(DataInput arg0) throws IOException {
117121
this.date = arg0.readLong();
122+
this.dependantDate = arg0.readLong();
118123
this.type = UpdateEventType.values()[arg0.readInt()];
119124
this.eventData = arg0.readUTF();
120125
}
121126

122127
public void write(DataOutput arg0) throws IOException {
123128
arg0.writeLong(date);
129+
arg0.writeLong(dependantDate);
124130
arg0.writeInt(type.ordinal());
125131
arg0.writeUTF(eventData);
126132
}

src/main/java/ldbc/socialnet/dbgen/serializer/CSVOriginal.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,6 @@ public void serialize(Comment comment) {
542542

543543
@Override
544544
public void serialize(Group group) {
545-
546545
Vector<String> arguments = new Vector<String>();
547546

548547
date.setTimeInMillis(group.getCreatedDate());
@@ -563,7 +562,6 @@ public void serialize(Group group) {
563562
arguments.add(Integer.toString(groupTags[i]));
564563
ToCSV(arguments,Files.FORUM_HASTAG_TAG.ordinal());
565564
}
566-
567565
}
568566

569567
@Override

0 commit comments

Comments
 (0)