daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Aug 21st, 2018 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Start session
  2. spark = SparkSession
  3. .builder
  4. .appName("Embedding Models")
  5. .config('spark.ui.showConsoleProgress', 'true')
  6. .config("spark.master", "local[2]")
  7. .getOrCreate()
  8.  
  9. sqlContext = sql.SQLContext(spark)
  10. schema = StructType([
  11.          StructField("Index", IntegerType(), True),
  12.          StructField("title", StringType(), True),
  13.          StructField("body", StringType(), True)])
  14.  
  15. df= sqlContext.read.csv("../data/faq_data.csv",
  16.                          header=True,
  17.                          mode="DROPMALFORMED",
  18.                          schema=schema)
  19.    
  20. df.show()
  21.  
  22. +-----+--------------------+--------------------+
  23. |Index|               title|                body|
  24. +-----+--------------------+--------------------+
  25. |    0|What does “quantu...|Quantum theory is...|
  26. |    1|What is a quantum...|A quantum compute...|
  27.    
  28. ---------------------------------------------------------------------------
  29. Py4JJavaError                             Traceback (most recent call last)
  30. <ipython-input-29-913a2f9eb5fc> in <module>()
  31. ----> 1 df.count()
  32.  
  33. ~/anaconda3/envs/Community/lib/python3.6/site-packages/pyspark/sql/dataframe.py in count(self)
  34.     453         2
  35.     454         """
  36. --> 455         return int(self._jdf.count())
  37.     456
  38.     457     @ignore_unicode_prefix
  39.  
  40. ~/anaconda3/envs/Community/lib/python3.6/site-packages/py4j/java_gateway.py in __call__(self, *args)
  41.    1255         answer = self.gateway_client.send_command(command)
  42.    1256         return_value = get_return_value(
  43. -> 1257             answer, self.gateway_client, self.target_id, self.name)
  44.    1258
  45.    1259         for temp_arg in temp_args:
  46.  
  47. ~/anaconda3/envs/Community/lib/python3.6/site-packages/pyspark/sql/utils.py in deco(*a, **kw)
  48.      61     def deco(*a, **kw):
  49.      62         try:
  50. ---> 63             return f(*a, **kw)
  51.      64         except py4j.protocol.Py4JJavaError as e:
  52.      65             s = e.java_exception.toString()
  53.  
  54. ~/anaconda3/envs/Community/lib/python3.6/site-packages/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
  55.     326                 raise Py4JJavaError(
  56.     327                     "An error occurred while calling {0}{1}{2}.n".
  57. --> 328                     format(target_id, ".", name), value)
  58.     329             else:
  59.     330                 raise Py4JError(
  60.  
  61. Py4JJavaError: An error occurred while calling o655.count.
  62. : java.lang.IllegalArgumentException
  63.     at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
  64.     at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
  65.     at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
  66.     at org.apache.spark.util.ClosureCleaner$.getClassReader(ClosureCleaner.scala:46)
  67.     at org.apache.spark.util.FieldAccessFinder$$anon$3$$anonfun$visitMethodInsn$2.apply(ClosureCleaner.scala:449)
  68.     at org.apache.spark.util.FieldAccessFinder$$anon$3$$anonfun$visitMethodInsn$2.apply(ClosureCleaner.scala:432)
  69.     at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:733)
  70.     at scala.collection.mutable.HashMap$$anon$1$$anonfun$foreach$2.apply(HashMap.scala:103)
  71.     at scala.collection.mutable.HashMap$$anon$1$$anonfun$foreach$2.apply(HashMap.scala:103)
  72.     at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:230)
  73.     at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
  74.     at scala.collection.mutable.HashMap$$anon$1.foreach(HashMap.scala:103)
  75.     at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:732)
  76.     at org.apache.spark.util.FieldAccessFinder$$anon$3.visitMethodInsn(ClosureCleaner.scala:432)
  77.     at org.apache.xbean.asm5.ClassReader.a(Unknown Source)
  78.     at org.apache.xbean.asm5.ClassReader.b(Unknown Source)
  79.     at org.apache.xbean.asm5.ClassReader.accept(Unknown Source)
  80.     at org.apache.xbean.asm5.ClassReader.accept(Unknown Source)
  81.     at org.apache.spark.util.ClosureCleaner$$anonfun$org$apache$spark$util$ClosureCleaner$$clean$14.apply(ClosureCleaner.scala:262)
  82.     at org.apache.spark.util.ClosureCleaner$$anonfun$org$apache$spark$util$ClosureCleaner$$clean$14.apply(ClosureCleaner.scala:261)
  83.     at scala.collection.immutable.List.foreach(List.scala:381)
  84.     at org.apache.spark.util.ClosureCleaner$.org$apache$spark$util$ClosureCleaner$$clean(ClosureCleaner.scala:261)
  85.     at org.apache.spark.util.ClosureCleaner$.clean(ClosureCleaner.scala:159)
  86.     at org.apache.spark.SparkContext.clean(SparkContext.scala:2299)
  87.     at org.apache.spark.SparkContext.runJob(SparkContext.scala:2073)
  88.     at org.apache.spark.SparkContext.runJob(SparkContext.scala:2099)
  89.     at org.apache.spark.rdd.RDD$$anonfun$collect$1.apply(RDD.scala:939)
  90.     at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
  91.     at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
  92.     at org.apache.spark.rdd.RDD.withScope(RDD.scala:363)
  93.     at org.apache.spark.rdd.RDD.collect(RDD.scala:938)
  94.     at org.apache.spark.sql.execution.SparkPlan.executeCollect(SparkPlan.scala:297)
  95.     at org.apache.spark.sql.Dataset$$anonfun$count$1.apply(Dataset.scala:2770)
  96.     at org.apache.spark.sql.Dataset$$anonfun$count$1.apply(Dataset.scala:2769)
  97.     at org.apache.spark.sql.Dataset$$anonfun$52.apply(Dataset.scala:3254)
  98.     at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:77)
  99.     at org.apache.spark.sql.Dataset.withAction(Dataset.scala:3253)
  100.     at org.apache.spark.sql.Dataset.count(Dataset.scala:2769)
  101.     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  102.     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  103.     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  104.     at java.base/java.lang.reflect.Method.invoke(Method.java:564)
  105.     at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
  106.     at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
  107.     at py4j.Gateway.invoke(Gateway.java:282)
  108.     at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
  109.     at py4j.commands.CallCommand.execute(CallCommand.java:79)
  110.     at py4j.GatewayConnection.run(GatewayConnection.java:238)
  111.     at java.base/java.lang.Thread.run(Thread.java:844)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top