Skip to content

Commit 2ff0b68

Browse files
author
Andy Feng
committed
DataFrame for Spark 1 and Dataset for Spaek 2
1 parent 162dbdc commit 2ff0b68

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎caffe-grid/src/main/python/com/yahoo/ml/caffe/CaffeOnSpark.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ class CaffeOnSpark:
1717

1818
def __init__(self,sc):
1919
registerContext(sc)
20-
wrapClass("org.apache.spark.sql.Dataset")
20+
spark_major_version = int(sc.version.split(' ')[0])
21+
if spark_major_version == 2:
22+
wrapClass("org.apache.spark.sql.Dataset")
23+
else:
24+
wrapClass("org.apache.spark.sql.DataFrame")
2125
self.__dict__['caffeonspark']=wrapClass("com.yahoo.ml.caffe.CaffeOnSpark")
2226
self.__dict__['cos']=self.__dict__.get('caffeonspark')(sc)
2327
self.__dict__['sqlcontext']=SQLContext(sc,self.__dict__['cos'].sqlContext)

0 commit comments

Comments
 (0)