Skip to content

Commit 1e7baba

Browse files
committed
Merge branch 'master' of github.com:ldbc/ldbc_socialnet_bm
2 parents 3a814b0 + 5f00d48 commit 1e7baba

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

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

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import ldbc.socialnet.dbgen.util.*;
4747

4848
import org.apache.hadoop.conf.Configuration;
49+
import org.apache.hadoop.fs.FSDataInputStream;
4950
import org.apache.hadoop.fs.FSDataOutputStream;
5051
import org.apache.hadoop.fs.FileSystem;
5152
import org.apache.hadoop.fs.Path;
@@ -98,17 +99,18 @@ protected void setup(Context context){
9899
FileSystem fs = FileSystem.get(conf);
99100
String strTaskId = context.getTaskAttemptID().getTaskID().toString();
100101
int attempTaskId = Integer.parseInt(strTaskId.substring(strTaskId.length() - 3));
102+
int reducerId = conf.getInt("reducerId",0);
101103
int partitionId = conf.getInt("partitionId",0);
102104
String streamType = conf.get("streamType");
103105
if( Boolean.parseBoolean(conf.get("compressed")) == true ) {
104-
Path outFile = new Path(context.getConfiguration().get("outputDir")+"/social_network/updateStream_"+attempTaskId+"_"+partitionId+"_"+streamType+".csv.gz");
106+
Path outFile = new Path(context.getConfiguration().get("outputDir")+"/social_network/updateStream_"+reducerId+"_"+partitionId+"_"+streamType+".csv.gz");
105107
out = new GZIPOutputStream( fs.create(outFile));
106108
} else {
107-
Path outFile = new Path(context.getConfiguration().get("outputDir")+"/social_network/updateStream_"+attempTaskId+"_"+partitionId+"_"+streamType+".csv");
109+
Path outFile = new Path(context.getConfiguration().get("outputDir")+"/social_network/updateStream_"+reducerId+"_"+partitionId+"_"+streamType+".csv");
108110
out = fs.create(outFile);
109111
}
110112
if (conf.getBoolean("updateStreams",false)) {
111-
properties = fs.create(new Path(context.getConfiguration().get("outputDir")+"/social_network/updateStream_"+attempTaskId+"_"+partitionId+"_"+streamType+".properties"));
113+
properties = fs.create(new Path(context.getConfiguration().get("outputDir")+"/social_network/updateStream_"+reducerId+"_"+partitionId+"_"+streamType+".properties"));
112114
}
113115
} catch (IOException e) {
114116
e.printStackTrace();
@@ -552,6 +554,7 @@ public int runGenerateJob(Configuration conf) throws Exception {
552554
for( int j = 0; j < numPartitions; ++j ) {
553555
/// --------------- Fifth job: Sort update streams ----------------
554556
conf.setInt("mapred.line.input.format.linespermap", 1000000);
557+
conf.setInt("reducerId",i);
555558
conf.setInt("partitionId",j);
556559
conf.set("streamType","forum");
557560
Job jobForum = new Job(conf, "Soring update streams "+j+" of reducer "+i);
@@ -574,6 +577,7 @@ public int runGenerateJob(Configuration conf) throws Exception {
574577
fs.delete(new Path(hadoopDir + "/sibEnd"), true);
575578

576579
conf.setInt("mapred.line.input.format.linespermap", 1000000);
580+
conf.setInt("reducerId",i);
577581
conf.setInt("partitionId",j);
578582
conf.set("streamType","person");
579583
Job jobPerson = new Job(conf, "Soring update streams "+j+" of reducer "+i);
@@ -597,21 +601,26 @@ public int runGenerateJob(Configuration conf) throws Exception {
597601

598602
if(conf.getBoolean("updateStreams",false)) {
599603
Properties properties = new Properties();
600-
properties.load(fs.open(new Path(conf.get("outputDir") + "/social_network/updateStream_" + i + "_" + j + "_person.properties")));
601-
Long auxMin = Long.parseLong(properties.getProperty("min_write_event_start_time"));
602-
min = auxMin < min ? auxMin : min;
603-
Long auxMax = Long.parseLong(properties.getProperty("max_write_event_start_time"));
604-
max = auxMax > max ? auxMax : max;
605-
numEvents += Long.parseLong(properties.getProperty("num_events"));
606-
607-
properties.load(fs.open(new Path(conf.get("outputDir") + "/social_network/updateStream_" + i + "_" + j + "_forum.properties")));
608-
609-
auxMin = Long.parseLong(properties.getProperty("min_write_event_start_time"));
610-
min = auxMin < min ? auxMin : min;
611-
auxMax = Long.parseLong(properties.getProperty("max_write_event_start_time"));
612-
max = auxMax > max ? auxMax : max;
613-
numEvents += Long.parseLong(properties.getProperty("num_events"));
614-
604+
FSDataInputStream file = fs.open(new Path(conf.get("outputDir") + "/social_network/updateStream_" + i + "_" + j + "_person.properties"));
605+
properties.load(file);
606+
if( properties.getProperty("min_write_event_start_time") != null ) {
607+
Long auxMin = Long.parseLong(properties.getProperty("min_write_event_start_time"));
608+
min = auxMin < min ? auxMin : min;
609+
Long auxMax = Long.parseLong(properties.getProperty("max_write_event_start_time"));
610+
max = auxMax > max ? auxMax : max;
611+
numEvents += Long.parseLong(properties.getProperty("num_events"));
612+
}
613+
file.close();
614+
file = fs.open(new Path(conf.get("outputDir") + "/social_network/updateStream_" + i + "_" + j + "_forum.properties"));
615+
properties.load(file);
616+
if( properties.getProperty("min_write_event_start_time") != null ) {
617+
Long auxMin = Long.parseLong(properties.getProperty("min_write_event_start_time"));
618+
min = auxMin < min ? auxMin : min;
619+
Long auxMax = Long.parseLong(properties.getProperty("max_write_event_start_time"));
620+
max = auxMax > max ? auxMax : max;
621+
numEvents += Long.parseLong(properties.getProperty("num_events"));
622+
}
623+
file.close();
615624
fs.delete(new Path(conf.get("outputDir") + "/social_network/updateStream_" + i + "_" + j + "_person.properties"),true);
616625
fs.delete(new Path(conf.get("outputDir") + "/social_network/updateStream_" + i + "_" + j + "_forum.properties"),true);
617626
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ public void serialize(Friend friend) {
426426
data.add(Long.toString(friend.getFriendAcc()));
427427
date.setTimeInMillis(friend.getCreatedTime());
428428
data.add(Long.toString(date.getTime().getTime()));
429-
endEvent(Stream.PERSON_STREAM);
429+
//endEvent(Stream.PERSON_STREAM);
430+
endEvent(Stream.FORUM_STREAM);
430431
}
431432
}
432433

0 commit comments

Comments
 (0)