コード例 #1
0
ファイル: spark.py プロジェクト: jitendra42/atk
 def add_many_columns(row):
     result = row_function(row)
     data = []
     for i, data_type in enumerate(data_types):
         try:
             value = result[i]
         except TypeError as e:
             raise RuntimeError("UDF returned non-indexable value. Provided schema indicated an Indexable return type")
         except IndexError as e:
             raise RuntimeError("UDF return value did not match the number of items in the provided schema")
         cast_value = valid_data_types.cast(value, data_type)
         data.append(numpy_to_bson_friendly(cast_value))
     # return json.dumps(data, cls=NumpyJSONEncoder)
     return data
コード例 #2
0
 def add_many_columns(row):
     result = row_function(row)
     data = []
     for i, data_type in enumerate(data_types):
         try:
             value = result[i]
         except TypeError as e:
             raise RuntimeError("UDF returned non-indexable value. Provided schema indicated an Indexable return type")
         except IndexError as e:
             raise RuntimeError("UDF return value did not match the number of items in the provided schema")
         cast_value = valid_data_types.cast(value, data_type)
         data.append(numpy_to_bson_friendly(cast_value))
     # return json.dumps(data, cls=NumpyJSONEncoder)
     return data
コード例 #3
0
ファイル: spark.py プロジェクト: jitendra42/atk
 def aggregate(acc, row):
     accumulator_wrapper = acc
     aggregator_row_function(accumulator_wrapper, row)
     acc_data = accumulator_wrapper._get_data()
     data = []
     for i, data_type in enumerate(data_types):
         try:
             value = acc_data[i]
         except TypeError as e:
             raise RuntimeError("UDF returned non-indexable value. Provided schema indicated an Indexable return type")
         except IndexError as e:
             raise RuntimeError("UDF return value did not match the number of items in the provided schema")
         cast_value = valid_data_types.cast(value, data_type)
         data.append(cast_value)
     return data
コード例 #4
0
 def aggregate(acc, row):
     accumulator_wrapper = acc
     aggregator_row_function(accumulator_wrapper, row)
     acc_data = accumulator_wrapper._get_data()
     data = []
     for i, data_type in enumerate(data_types):
         try:
             value = acc_data[i]
         except TypeError as e:
             raise RuntimeError("UDF returned non-indexable value. Provided schema indicated an Indexable return type")
         except IndexError as e:
             raise RuntimeError("UDF return value did not match the number of items in the provided schema")
         cast_value = valid_data_types.cast(value, data_type)
         data.append(cast_value)
     return data
コード例 #5
0
 def add_one_column(row):
     result = row_function(row)
     cast_value = valid_data_types.cast(result, data_type)
     return [numpy_to_bson_friendly(cast_value)]
コード例 #6
0
ファイル: spark.py プロジェクト: jitendra42/atk
 def add_one_column(row):
     result = row_function(row)
     cast_value = valid_data_types.cast(result, data_type)
     return [numpy_to_bson_friendly(cast_value)]