Skip to content

Commit b5250b4

Browse files
committed
do not generate updateStream.properties if there are no updates
1 parent b5c1a82 commit b5250b4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ protected void setup(Context context){
104104
Path outFile = new Path(context.getConfiguration().get("outputDir")+"/social_network/updateStream_"+attempTaskId+".csv");
105105
out = fs.create(outFile);
106106
}
107-
properties = fs.create(new Path(context.getConfiguration().get("outputDir")+"/social_network/updateStream_"+attempTaskId+".properties"));
107+
if (conf.getBoolean("updateStreams",false)) {
108+
properties = fs.create(new Path(context.getConfiguration().get("outputDir")+"/social_network/updateStream_"+attempTaskId+".properties"));
109+
}
108110
} catch (IOException e) {
109111
e.printStackTrace();
110112
}
@@ -125,10 +127,13 @@ public void reduce(LongWritable key, Iterable<Text> valueSet,
125127
protected void cleanup(Context context){
126128
try {
127129
System.out.println("Number of events reduced "+numEvents);
128-
String propertiesStr = new String("gctdeltaduration:"+context.getConfiguration().get("deltaTime")+"\nmin_write_event_start_time:"+min+"\nmax_write_event_start_time:"+max+"\nupdate_interleave:"+(max-min)/numEvents);
129-
properties.write(propertiesStr.getBytes("UTF8"));
130-
properties.flush();
131-
properties.close();
130+
if (numEvents > 0) {
131+
long updateDistance = (max-min)/numEvents;
132+
String propertiesStr = new String("gctdeltaduration:"+context.getConfiguration().get("deltaTime")+"\nmin_write_event_start_time:"+min+"\nmax_write_event_start_time:"+max+"\nupdate_interleave:"+updateDistance);
133+
properties.write(propertiesStr.getBytes("UTF8"));
134+
properties.flush();
135+
properties.close();
136+
}
132137
out.flush();
133138
out.close();
134139
} catch (IOException e) {

0 commit comments

Comments
 (0)