Skip to content

Commit dc20510

Browse files
author
zhgwen
committed
add storage level code
1 parent 615b133 commit dc20510

File tree

12 files changed

+42
-42
lines changed

12 files changed

+42
-42
lines changed

c++/spark/Class.o

62.9 KB
Binary file not shown.

c++/spark/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ OBJS = convert.o \
2222
cpairrdd.o \
2323
csparkcontext.o \
2424
Class.o \
25-
mapping.o
25+
mapping.o \
26+
storageLevel.o
2627

2728

2829
TARGET = libsparkAPI.so

c++/spark/convert.o

375 KB
Binary file not shown.

c++/spark/cpairrdd.o

4.15 KB
Binary file not shown.

c++/spark/crdd.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "spark/require.hpp"
1414
#include "spark/convert.hpp"
1515
#include "spark/Class.h"
16+
#include "spark/storageLevel.h"
1617

1718
using namespace std;
1819

@@ -36,25 +37,23 @@ CRDD& CRDD::cache() {
3637
jobject obj = env->CallObjectMethod(rdd, mid);
3738
assure(obj != NULL, env);
3839

39-
CRDD result(env, obj, sparkctx);
40-
return result;
41-
/*rdd = obj;
42-
return *this;*/
40+
rdd = obj;
41+
return *this;
4342
}
4443

4544
CRDD& CRDD::persist() {
4645
return persist(MEMORY_ONLY);
4746
}
4847

4948
CRDD& CRDD::persist(const StorageLevel newlevel) {
50-
/*if (level != NONE && newlevel != level) {
49+
if (level != NONE && newlevel != level) {
5150
cerr
5251
<< "Cannot change storage level of an RDD after it was already assigned a level"
5352
<< endl;
5453
}
5554

5655
level = newlevel;
57-
char* ss = "";//getStorageLevel(level);
56+
char* ss = getStorageLevel(level);
5857

5958
jclass storagecls = env->FindClass("spark/api/java/StorageLevel");
6059
assert(storagecls != NULL);
@@ -73,7 +72,7 @@ CRDD& CRDD::persist(const StorageLevel newlevel) {
7372
jobject obj = env->CallObjectMethod(rdd, mid, levelObj);
7473
assert(obj != NULL);
7574

76-
rdd = obj;*/
75+
rdd = obj;
7776
return *this;
7877
}
7978

c++/spark/crdd.o

15.3 KB
Binary file not shown.

c++/spark/csparkcontext.o

17.2 KB
Binary file not shown.

c++/spark/libsparkAPI.so

329 KB
Binary file not shown.

c++/spark/mapping.o

88 KB
Binary file not shown.

c++/spark/storageLevel.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <iostream>
2+
#include "spark/storageLevel.h"
3+
4+
using namespace std;
5+
6+
char* getStorageLevel(StorageLevel level) {
7+
switch(level) {
8+
case NONE:
9+
return "NONE";
10+
case DISK_ONLY:
11+
return "DISK_ONLY";
12+
case DISK_ONLY_2:
13+
return "DISK_ONLY_2";
14+
case MEMORY_ONLY:
15+
return "MEMORY_ONLY";
16+
case MEMORY_ONLY_2:
17+
return "MEMORY_ONLY_2";
18+
case MEMORY_ONLY_SER:
19+
return "MEMORY_ONLY_SER";
20+
case MEMORY_ONLY_SER_2:
21+
return "MEMORY_ONLY_SER_2";
22+
case MEMORY_AND_DISK:
23+
return "MEMORY_AND_DISK";
24+
case MEMORY_AND_DISK_2:
25+
return "MEMORY_AND_DISK_2";
26+
case MEMORY_AND_DISK_SER:
27+
return "MEMORY_AND_DISK_SER";
28+
case MEMORY_AND_DISK_SER_2:
29+
return "MEMORY_AND_DISK_SER_2";
30+
default:
31+
return "MEMORY_ONLY";
32+
}
33+
}

0 commit comments

Comments
 (0)