Skip to content

Commit 35f5c09

Browse files
committed
Fixed serializers
1 parent 130bdfc commit 35f5c09

File tree

3 files changed

+11
-27
lines changed

3 files changed

+11
-27
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ public void writeReducedUserProfiles(int from, int to, int pass,
6565
try {
6666
to = to % windowSize;
6767
for (int i = from; i != to; i = (i+1)%windowSize) {
68-
//int key = userProfiles[i].getDicElementId(pass);
69-
int key[] = userProfiles[i].getDicElementIds();
68+
int key = userProfiles[i].getDicElementId(pass);
7069
int block = 0;
7170
long id = userProfiles[i].getAccountId();
7271
MapReduceKey mpk = new MapReduceKey(block,key,id);

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

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,11 @@ public void mrGenerateUserInfo(int pass, Context context){
901901
ReducedUserProfile reduceUserProf = generateGeneralInformation(j);
902902
++numUsersToGenerate;
903903
try {
904-
context.write(generateKey(pass,reduceUserProf), reduceUserProf);
904+
int block = 0; // The mapreduce group this university will be assigned.
905+
int key = reduceUserProf.getDicElementId(pass); // The key used to sort within the block.
906+
long id = reduceUserProf.getAccountId(); // The id used to sort within the key, to guarantee determinism.
907+
MapReduceKey mpk = new MapReduceKey( block, key, id );
908+
context.write(mpk, reduceUserProf);
905909
} catch (IOException e) {
906910
e.printStackTrace();
907911
} catch (InterruptedException e) {
@@ -911,17 +915,6 @@ public void mrGenerateUserInfo(int pass, Context context){
911915
}
912916
System.out.println("Number of generated users: "+numUsersToGenerate);
913917
}
914-
private MapReduceKey generateKey( int pass, ReducedUserProfile user ) {
915-
int block = 0; // The mapreduce group this university will be assigned.
916-
int key[] = new int[3];
917-
= reduceUserProf.getDicElementIds(); // The key used to sort within the block.
918-
for( int i = 0; i < NUM_FRIENDSHIP_HADOOP_JOBS;++i) {
919-
key[]
920-
}
921-
long id = reduceUserProf.getAccountId(); // The id used to sort within the key, to guarantee determinism.
922-
MapReduceKey mpk = new MapReduceKey( block, key, id );
923-
return mpk;
924-
}
925918

926919
private void generateCellOfUsers2(int newStartIndex, ReducedUserProfile[] _cellReduceUserProfiles){
927920
int curIdxInWindow;

src/main/java/ldbc/socialnet/dbgen/util/MapReduceKey.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,37 +49,29 @@
4949

5050
public class MapReduceKey implements WritableComparable<MapReduceKey> {
5151
public int block;
52-
public int key[];
52+
public int key;
5353
public long id;
5454

5555
public MapReduceKey( ) {
56-
this.key = new int[3];
5756
}
5857

59-
public MapReduceKey( int block, int key[], long id) {
58+
public MapReduceKey( int block, int key, long id) {
6059
this.block = block;
61-
this.key = new int[3];
62-
this.key[0] = key[0];
63-
this.key[1] = key[1];
64-
this.key[2] = key[2];
60+
this.key = key;
6561
this.id = id;
6662
}
6763

6864
@Override
6965
public void write(DataOutput out) throws IOException {
7066
out.writeInt(block);
71-
out.writeInt(key[0]);
72-
out.writeInt(key[1]);
73-
out.writeInt(key[2]);
67+
out.writeInt(key);
7468
out.writeLong(id);
7569
}
7670

7771
@Override
7872
public void readFields(DataInput in) throws IOException {
7973
block = in.readInt();
80-
key[0] = in.readInt();
81-
key[1] = in.readInt();
82-
key[2] = in.readInt();
74+
key = in.readInt();
8375
id = in.readLong();
8476
}
8577

0 commit comments

Comments
 (0)