问:
toString the data Pyspark Dataframe
I am trying to do some regex operation operation on a column. In order to do that I stated with the basic lowercase operation as below:

```<code>df.select('name').map(lambda x: x.lower())
</code>```

Here df is a DataFrame, and the operation is throwing an exception when I call collect() operation.

```<code>Ques 1: After map(or reduce) operation, every DataFrame converts to a Pipelined RDD. Am I right?
</code>```

If so, why this command throwing exception while collecting the Pipelined RDD.

Am I missing anything?

Exception is too big to read:

```    17/07/07 13:51:41 INFO SparkContext: Starting job: collect at <stdin>:1
17/07/07 13:51:41 INFO DAGScheduler: Got job 55 (collect at <stdin>:1) with 4 output partitions
17/07/07 13:51:41 INFO DAGScheduler: Final stage: ResultStage 63 (collect at <stdin>:1)
17/07/07 13:51:41 INFO DAGScheduler: Parents of final stage: List()
17/07/07 13:51:41 INFO DAGScheduler: Missing parents: List()
17/07/07 13:51:41 INFO DAGScheduler: Submitting ResultStage 63 (PythonRDD[195] at collect at <stdin>:1), which has no missing parents
17/07/07 13:51:41 INFO MemoryStore: Block broadcast_61 stored as values in memory (estimated size 11.7 KB, free 11.7 KB)
17/07/07 13:51:41 INFO MemoryStore: Block broadcast_61_piece0 stored as bytes in memory (estimated size 6.7 KB, free 18.3 KB)
17/07/07 13:51:41 INFO BlockManagerInfo: Added broadcast_61_piece0 in memory on localhost:54574 (size: 6.7 KB, free: 511.1 MB)
17/07/07 13:51:41 INFO SparkContext: Created broadcast 61 from broadcast at DAGScheduler.scala:1006
17/07/07 13:51:41 INFO DAGScheduler: Submitting 4 missing tasks from ResultStage 63 (PythonRDD[195] at collect at <stdin>:1)
17/07/07 13:51:41 INFO TaskSchedulerImpl: Adding task set 63.0 with 4 tasks
17/07/07 13:51:41 INFO TaskSetManager: Starting task 0.0 in stage 63.0 (TID 744, localhost, partition 0,PROCESS_LOCAL, 2097 bytes)
17/07/07 13:51:41 INFO TaskSetManager: Starting task 1.0 in stage 63.0 (TID 745, localhost, partition 1,PROCESS_LOCAL, 2131 bytes)
17/07/07 13:51:41 INFO TaskSetManager: Starting task 2.0 in stage 63.0 (TID 746, localhost, partition 2,PROCESS_LOCAL, 2132 bytes)
17/07/07 13:51:41 INFO TaskSetManager: Starting task 3.0 in stage 63.0 (TID 747, localhost, partition 3,PROCESS_LOCAL, 2131 bytes)
17/07/07 13:51:41 INFO Executor: Running task 0.0 in stage 63.0 (TID 744)
17/07/07 13:51:41 INFO Executor: Running task 1.0 in stage 63.0 (TID 745)
17/07/07 13:51:41 INFO Executor: Running task 2.0 in stage 63.0 (TID 746)
17/07/07 13:51:41 INFO Executor: Running task 3.0 in stage 63.0 (TID 747)
17/07/07 13:51:41 INFO PythonRunner: Times: total = 22, boot = 14, init = 7, finish = 1
17/07/07 13:51:41 INFO PythonRunner: Times: total = 11, boot = 7, init = 3, finish = 1
17/07/07 13:51:41 INFO PythonRunner: Times: total = 8, boot = 4, init = 3, finish = 1
17/07/07 13:51:41 INFO PythonRunner: Times: total = 56, boot = 30, init = 26, finish = 0
17/07/07 13:51:41 ERROR Executor: Exception in task 2.0 in stage 63.0 (TID 746)
org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
17/07/07 13:51:41 ERROR Executor: Exception in task 3.0 in stage 63.0 (TID 747)
org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
17/07/07 13:51:41 ERROR Executor: Exception in task 0.0 in stage 63.0 (TID 744)
org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
17/07/07 13:51:41 ERROR Executor: Exception in task 1.0 in stage 63.0 (TID 745)
org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
17/07/07 13:51:41 WARN TaskSetManager: Lost task 1.0 in stage 63.0 (TID 745, localhost): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

17/07/07 13:51:41 ERROR TaskSetManager: Task 1 in stage 63.0 failed 1 times; aborting job
17/07/07 13:51:41 INFO TaskSchedulerImpl: Removed TaskSet 63.0, whose tasks have all completed, from pool
17/07/07 13:51:41 INFO TaskSetManager: Lost task 0.0 in stage 63.0 (TID 744) on executor localhost: org.apache.spark.api.python.PythonException (Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower
) [duplicate 1]
17/07/07 13:51:41 INFO TaskSchedulerImpl: Removed TaskSet 63.0, whose tasks have all completed, from pool
17/07/07 13:51:41 INFO TaskSetManager: Lost task 3.0 in stage 63.0 (TID 747) on executor localhost: org.apache.spark.api.python.PythonException (Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower
) [duplicate 2]
17/07/07 13:51:41 INFO TaskSchedulerImpl: Removed TaskSet 63.0, whose tasks have all completed, from pool
17/07/07 13:51:41 INFO TaskSetManager: Lost task 2.0 in stage 63.0 (TID 746) on executor localhost: org.apache.spark.api.python.PythonException (Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower
) [duplicate 3]
17/07/07 13:51:41 INFO TaskSchedulerImpl: Removed TaskSet 63.0, whose tasks have all completed, from pool
17/07/07 13:51:41 INFO TaskSchedulerImpl: Cancelling stage 63
17/07/07 13:51:41 INFO DAGScheduler: ResultStage 63 (collect at <stdin>:1) failed in 0.114 s
17/07/07 13:51:41 INFO DAGScheduler: Job 55 failed: collect at <stdin>:1, took 0.120849 s
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/spark/python/pyspark/rdd.py", line 771, in collect
    port = self.ctx._jvm.PythonRDD.collectAndServe(self._jrdd.rdd())
  File "/usr/local/spark/python/lib/py4j-0.9-src.zip/py4j/java_gateway.py", line 813, in __call__
  File "/usr/local/spark/python/pyspark/sql/utils.py", line 45, in deco
    return f(*a, **kw)
  File "/usr/local/spark/python/lib/py4j-0.9-src.zip/py4j/protocol.py", line 308, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.collectAndServe.
: org.apache.spark.SparkException: Job aborted due to stage failure: Task 1 in stage 63.0 failed 1 times, most recent failure: Lost task 1.0 in stage 63.0 (TID 745, localhost): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Driver stacktrace:
    at org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1431)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1419)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1418)
    at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
    at org.apache.spark.scheduler.DAGScheduler.abortStage(DAGScheduler.scala:1418)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:799)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:799)
    at scala.Option.foreach(Option.scala:236)
    at org.apache.spark.scheduler.DAGScheduler.handleTaskSetFailed(DAGScheduler.scala:799)
    at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.doOnReceive(DAGScheduler.scala:1640)
    at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1599)
    at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1588)
    at org.apache.spark.util.EventLoop$$anon$1.run(EventLoop.scala:48)
    at org.apache.spark.scheduler.DAGScheduler.runJob(DAGScheduler.scala:620)
    at org.apache.spark.SparkContext.runJob(SparkContext.scala:1832)
    at org.apache.spark.SparkContext.runJob(SparkContext.scala:1845)
    at org.apache.spark.SparkContext.runJob(SparkContext.scala:1858)
    at org.apache.spark.SparkContext.runJob(SparkContext.scala:1929)
    at org.apache.spark.rdd.RDD$$anonfun$collect$1.apply(RDD.scala:927)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:150)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:111)
    at org.apache.spark.rdd.RDD.withScope(RDD.scala:316)
    at org.apache.spark.rdd.RDD.collect(RDD.scala:926)
    at org.apache.spark.api.python.PythonRDD$.collectAndServe(PythonRDD.scala:405)
    at org.apache.spark.api.python.PythonRDD.collectAndServe(PythonRDD.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:231)
    at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:381)
    at py4j.Gateway.invoke(Gateway.java:259)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:133)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:209)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concu

rrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    ... 1 more
```

答:
You can use the built-in functions available for DataFrames, instead of converting it to RDD:

from pyspark.sql.functions import *
from pyspark.sql import Row

df = sqlContext.createDataFrame([Row("John"), Row("Mary")], ["name"])

lower_df = df.withColumn("name", lower(col("name")))
```

<p>Then, to apply regex, you can use <code>regexp_replace(str, pattern, replacement)</code>:</p>

<pre class="lang-py prettyprint-override"><code>result = lower_df.withColumn("new_col", regexp_replace("name", "o", "\*"))

result.show()

+----+-------+
|name|new_col|
+----+-------+
|john|   j*hn|
|mary|   mary|
+----+-------+
</code>```

More info about the available functions can be found in the pyspark docs.

Title: toString the data Pyspark Dataframe

Body:
I am trying to do some regex operation operation on a column. In order to do that I stated with the basic lowercase operation as below:

df.select('name').map(lambda x: x.lower())

Here df is a DataFrame, and the operation is throwing an exception when I call collect() operation.

Ques 1: After map(or reduce) operation, every DataFrame converts to a Pipelined RDD. Am I right?

If so, why this command throwing exception while collecting the Pipelined RDD.

Am I missing anything?

Exception is too big to read:

    17/07/07 13:51:41 INFO SparkContext: Starting job: collect at <stdin>:1
17/07/07 13:51:41 INFO DAGScheduler: Got job 55 (collect at <stdin>:1) with 4 output partitions
17/07/07 13:51:41 INFO DAGScheduler: Final stage: ResultStage 63 (collect at <stdin>:1)
17/07/07 13:51:41 INFO DAGScheduler: Parents of final stage: List()
17/07/07 13:51:41 INFO DAGScheduler: Missing parents: List()
17/07/07 13:51:41 INFO DAGScheduler: Submitting ResultStage 63 (PythonRDD[195] at collect at <stdin>:1), which has no missing parents
17/07/07 13:51:41 INFO MemoryStore: Block broadcast_61 stored as values in memory (estimated size 11.7 KB, free 11.7 KB)
17/07/07 13:51:41 INFO MemoryStore: Block broadcast_61_piece0 stored as bytes in memory (estimated size 6.7 KB, free 18.3 KB)
17/07/07 13:51:41 INFO BlockManagerInfo: Added broadcast_61_piece0 in memory on localhost:54574 (size: 6.7 KB, free: 511.1 MB)
17/07/07 13:51:41 INFO SparkContext: Created broadcast 61 from broadcast at DAGScheduler.scala:1006
17/07/07 13:51:41 INFO DAGScheduler: Submitting 4 missing tasks from ResultStage 63 (PythonRDD[195] at collect at <stdin>:1)
17/07/07 13:51:41 INFO TaskSchedulerImpl: Adding task set 63.0 with 4 tasks
17/07/07 13:51:41 INFO TaskSetManager: Starting task 0.0 in stage 63.0 (TID 744, localhost, partition 0,PROCESS_LOCAL, 2097 bytes)
17/07/07 13:51:41 INFO TaskSetManager: Starting task 1.0 in stage 63.0 (TID 745, localhost, partition 1,PROCESS_LOCAL, 2131 bytes)
17/07/07 13:51:41 INFO TaskSetManager: Starting task 2.0 in stage 63.0 (TID 746, localhost, partition 2,PROCESS_LOCAL, 2132 bytes)
17/07/07 13:51:41 INFO TaskSetManager: Starting task 3.0 in stage 63.0 (TID 747, localhost, partition 3,PROCESS_LOCAL, 2131 bytes)
17/07/07 13:51:41 INFO Executor: Running task 0.0 in stage 63.0 (TID 744)
17/07/07 13:51:41 INFO Executor: Running task 1.0 in stage 63.0 (TID 745)
17/07/07 13:51:41 INFO Executor: Running task 2.0 in stage 63.0 (TID 746)
17/07/07 13:51:41 INFO Executor: Running task 3.0 in stage 63.0 (TID 747)
17/07/07 13:51:41 INFO PythonRunner: Times: total = 22, boot = 14, init = 7, finish = 1
17/07/07 13:51:41 INFO PythonRunner: Times: total = 11, boot = 7, init = 3, finish = 1
17/07/07 13:51:41 INFO PythonRunner: Times: total = 8, boot = 4, init = 3, finish = 1
17/07/07 13:51:41 INFO PythonRunner: Times: total = 56, boot = 30, init = 26, finish = 0
17/07/07 13:51:41 ERROR Executor: Exception in task 2.0 in stage 63.0 (TID 746)
org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
17/07/07 13:51:41 ERROR Executor: Exception in task 3.0 in stage 63.0 (TID 747)
org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
17/07/07 13:51:41 ERROR Executor: Exception in task 0.0 in stage 63.0 (TID 744)
org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
17/07/07 13:51:41 ERROR Executor: Exception in task 1.0 in stage 63.0 (TID 745)
org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
17/07/07 13:51:41 WARN TaskSetManager: Lost task 1.0 in stage 63.0 (TID 745, localhost): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

17/07/07 13:51:41 ERROR TaskSetManager: Task 1 in stage 63.0 failed 1 times; aborting job
17/07/07 13:51:41 INFO TaskSchedulerImpl: Removed TaskSet 63.0, whose tasks have all completed, from pool
17/07/07 13:51:41 INFO TaskSetManager: Lost task 0.0 in stage 63.0 (TID 744) on executor localhost: org.apache.spark.api.python.PythonException (Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower
) [duplicate 1]
17/07/07 13:51:41 INFO TaskSchedulerImpl: Removed TaskSet 63.0, whose tasks have all completed, from pool
17/07/07 13:51:41 INFO TaskSetManager: Lost task 3.0 in stage 63.0 (TID 747) on executor localhost: org.apache.spark.api.python.PythonException (Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower
) [duplicate 2]
17/07/07 13:51:41 INFO TaskSchedulerImpl: Removed TaskSet 63.0, whose tasks have all completed, from pool
17/07/07 13:51:41 INFO TaskSetManager: Lost task 2.0 in stage 63.0 (TID 746) on executor localhost: org.apache.spark.api.python.PythonException (Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower
) [duplicate 3]
17/07/07 13:51:41 INFO TaskSchedulerImpl: Removed TaskSet 63.0, whose tasks have all completed, from pool
17/07/07 13:51:41 INFO TaskSchedulerImpl: Cancelling stage 63
17/07/07 13:51:41 INFO DAGScheduler: ResultStage 63 (collect at <stdin>:1) failed in 0.114 s
17/07/07 13:51:41 INFO DAGScheduler: Job 55 failed: collect at <stdin>:1, took 0.120849 s
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/spark/python/pyspark/rdd.py", line 771, in collect
    port = self.ctx._jvm.PythonRDD.collectAndServe(self._jrdd.rdd())
  File "/usr/local/spark/python/lib/py4j-0.9-src.zip/py4j/java_gateway.py", line 813, in __call__
  File "/usr/local/spark/python/pyspark/sql/utils.py", line 45, in deco
    return f(*a, **kw)
  File "/usr/local/spark/python/lib/py4j-0.9-src.zip/py4j/protocol.py", line 308, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.collectAndServe.
: org.apache.spark.SparkException: Job aborted due to stage failure: Task 1 in stage 63.0 failed 1 times, most recent failure: Lost task 1.0 in stage 63.0 (TID 745, localhost): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Driver stacktrace:
    at org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1431)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1419)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1418)
    at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
    at org.apache.spark.scheduler.DAGScheduler.abortStage(DAGScheduler.scala:1418)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:799)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:799)
    at scala.Option.foreach(Option.scala:236)
    at org.apache.spark.scheduler.DAGScheduler.handleTaskSetFailed(DAGScheduler.scala:799)
    at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.doOnReceive(DAGScheduler.scala:1640)
    at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1599)
    at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1588)
    at org.apache.spark.util.EventLoop$$anon$1.run(EventLoop.scala:48)
    at org.apache.spark.scheduler.DAGScheduler.runJob(DAGScheduler.scala:620)
    at org.apache.spark.SparkContext.runJob(SparkContext.scala:1832)
    at org.apache.spark.SparkContext.runJob(SparkContext.scala:1845)
    at org.apache.spark.SparkContext.runJob(SparkContext.scala:1858)
    at org.apache.spark.SparkContext.runJob(SparkContext.scala:1929)
    at org.apache.spark.rdd.RDD$$anonfun$collect$1.apply(RDD.scala:927)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:150)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:111)
    at org.apache.spark.rdd.RDD.withScope(RDD.scala:316)
    at org.apache.spark.rdd.RDD.collect(RDD.scala:926)
    at org.apache.spark.api.python.PythonRDD$.collectAndServe(PythonRDD.scala:405)
    at org.apache.spark.api.python.PythonRDD.collectAndServe(PythonRDD.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:231)
    at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:381)
    at py4j.Gateway.invoke(Gateway.java:259)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:133)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:209)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.spark.api.python.PythonException: Traceback (most recent call last):
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 111, in main
    process()
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 106, in process
    serializer.dump_stream(func(split_index, iterator), outfile)
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 263, in dump_stream
    vs = list(itertools.islice(iterator, batch))
  File "<stdin>", line 1, in <lambda>
  File "/usr/local/spark/python/lib/pyspark.zip/pyspark/sql/types.py", line 1272, in __getattr__
    raise AttributeError(item)
AttributeError: lower

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concu

rrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    ... 1 more

Body:
You can use the built-in functions available for DataFrames, instead of converting it to RDD:

from pyspark.sql.functions import *
from pyspark.sql import Row

df = sqlContext.createDataFrame([Row("John"), Row("Mary")], ["name"])

lower_df = df.withColumn("name", lower(col("name")))

Then, to apply regex, you can use regexp_replace(str, pattern, replacement):

result = lower_df.withColumn("new_col", regexp_replace("name", "o", "\*"))

result.show()

+----+-------+
|name|new_col|
+----+-------+
|john|   j*hn|
|mary|   mary|
+----+-------+

More info about the available functions can be found in the pyspark docs.


来源: stackexchange

问:
why not display in jsp page
Item's Path doesn't display in jsp page,I want to export this sentence   ${pageContext.request.contextPath}

```<code><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
        <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
        <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
        <c:set var="basePath" scope="request">${pageContext.request.contextPath}</c:set>
        <%
            response.setHeader("Cache-Control","no-catch");
            response.setHeader("Pragma","no-catch");
            response.setDateHeader("Expires",0);
            String a=request.getContextPath();
            System.out.println(a);
             %>
    <html>
        <head>
            <meta charset="utf-8"/>
            <title>code-serv-web</title>
        </head>
        <body>
            <h1>code-serv-web</h1>
            <button id="but">点击</button>

        </body>

    </html>
</code>```

why not display in jsp page  ${pageContext.request.contextPath}

答:
EL expressions ${} can be run in JSP files not HTML files.

You have two solutions in your case

Rename your file from filename.html to filename.jsp

or

Add mapping to your web.xml file

```<code><servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>
</code>```

ContentLicense: CC BY-SA 3.0

Title: why not display in jsp page

Body:
Item's Path doesn't display in jsp page,I want to export this sentence   ${pageContext.request.contextPath}

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
        <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
        <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
        <c:set var="basePath" scope="request">${pageContext.request.contextPath}</c:set>
        <%
            response.setHeader("Cache-Control","no-catch");
            response.setHeader("Pragma","no-catch");
            response.setDateHeader("Expires",0);
            String a=request.getContextPath();
            System.out.println(a);
             %>

            <meta charset="utf-8"/>
            <title>code-serv-web</title>

code-serv-web

            <button id="but">点击</button>

why not display in jsp page  ${pageContext.request.contextPath}

Body:
EL expressions ${} can be run in JSP files not HTML files.

You have two solutions in your case

Rename your file from filename.html to filename.jsp

or

Add mapping to your web.xml file

<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>


问:
Inline juqery syntax error
Inside a .php page i have a function.Inside that function, some of my code looks like the following:-

```<code>$html='';
$html.='<div id="imgContainer"></div>';
$html.='<img  src="elements/18_lr.jpg"  data-highres="elements/18_hr.jpg" onclick="$(this).mbZoomify({screen:'#imgContainer'});">';//<<----shows error near #imgContainer
</code>```

At the above indicated line, it shows incorrect HTML error.Please advise how to get rid of the error.

答:
The issue is due to mis-matching quotes. You need to escape the ' within the object value, like this:

```<code>$html.='<img src="elements/18_lr.jpg" data-highres="elements/18_hr.jpg" onclick="$(this).mbZoomify({ screen:\'#imgContainer\' });">';
</code>```

However, a much better solution entirely would be to remove the outdated and ugly on* event attribute completely and use unobtrusive event handlers. As you've already included jQuery in the page, here's how you can do that:

```<code>$html.='<img src="elements/18_lr.jpg" data-highres="elements/18_hr.jpg" data-screen="#imgContainer" />';
</code>```

$('#container img').click(function() {
  $(this).mbZoomify({
    screen: $(this).data('screen');
  });
});
```

Title: Inline juqery syntax error

Body:
Inside a .php page i have a function.Inside that function, some of my code looks like the following:-

$html='';
$html.='

';
$html.='';//<<----shows error near #imgContainer

At the above indicated line, it shows incorrect HTML error.Please advise how to get rid of the error.

Body:
The issue is due to mis-matching quotes. You need to escape the ' within the object value, like this:

$html.='<img src="elements/18_lr.jpg" data-highres="elements/18_hr.jpg" onclick="$(this).mbZoomify({ screen:\'#imgContainer\' });">';

However, a much better solution entirely would be to remove the outdated and ugly on* event attribute completely and use unobtrusive event handlers. As you've already included jQuery in the page, here's how you can do that:

$html.='<img src="elements/18_lr.jpg" data-highres="elements/18_hr.jpg" data-screen="#imgContainer" />';

$('#container img').click(function() {
  $(this).mbZoomify({
    screen: $(this).data('screen');
  });
});


问:
Validation error with simple-schema
I'm trying to insert an array into an object and I'm not having any luck. I think the schema is rejecting it based on validation but I'm not sure why. If I console.log(this.state.typeOfWork) and check typeof it states its an Object which contains:

```<code>(2) ["Audit - internal", "Audit - external"]
0: "Audit - internal"
1: "Audit - external"
</code>```

My collection after an update contains:

```<code>"roleAndSkills": {
    "typeOfWork": []
  }
</code>```

Example: Schema

```<code>roleAndSkills: { type: Object, optional: true },
  'roleAndSkills.typeOfWork': { type: Array, optional: true },
  'roleAndSkills.typeOfWork.$': { type: String, optional: true }
</code>```

Example: update

```<code>ProfileCandidate.update(this.state.profileCandidateCollectionId, {
      $set: {
        roleAndSkills: {
          typeOfWork: [this.state.typeOfWork]
        }
      }
    });
</code>```

答:
typeOfWork is an Array. You should push your value in it :

```<code>$push: {
    "roleAndSkills.typeOfWork": this.state.typeOfWork
}
</code>```

for multiple values :

```<code>$push: {
    "roleAndSkills.typeOfWork": { $each: [ "val1", "val2" ] }
}
</code>```

mongo $push operator

mongo dot notation

Title: Validation error with simple-schema

Body:
I'm trying to insert an array into an object and I'm not having any luck. I think the schema is rejecting it based on validation but I'm not sure why. If I console.log(this.state.typeOfWork) and check typeof it states its an Object which contains:

(2) ["Audit - internal", "Audit - external"]
0: "Audit - internal"
1: "Audit - external"

My collection after an update contains:

"roleAndSkills": {
    "typeOfWork": []
  }

Example: Schema

roleAndSkills: { type: Object, optional: true },
  'roleAndSkills.typeOfWork': { type: Array, optional: true },
  'roleAndSkills.typeOfWork.$': { type: String, optional: true }

Example: update

ProfileCandidate.update(this.state.profileCandidateCollectionId, {
      $set: {
        roleAndSkills: {
          typeOfWork: [this.state.typeOfWork]
        }
      }
    });

Body:
typeOfWork is an Array. You should push your value in it :

$push: {
    "roleAndSkills.typeOfWork": this.state.typeOfWork
}

for multiple values :

$push: {
    "roleAndSkills.typeOfWork": { $each: [ "val1", "val2" ] }
}

mongo $push operator

mongo dot notation


问:
App freezing when clicked on done button after selecting row from UIPickerView
I have view consisting of UIPickerView and Done button and it is assigned as inputView to textField. After selecting any row from picker view and clicking Done app is un-expectingly freezing. I have attached stack trace screen shot at the time freeze. Please let know if this due something weird thread action.

答:
```<code>dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//here everything you want to perform in background

dispatch_async(dispatch_get_main_queue(), ^{
    //call back to main queue to update user interface
});
});
</code>```

I think this is help for you:
See this url of stack over flow

enter link description here

Body:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//here everything you want to perform in background

dispatch_async(dispatch_get_main_queue(), ^{
    //call back to main queue to update user interface
});
});

I think this is help for you:
See this url of stack over flow

enter link description here


问:
JS-Canvas: Redraw Shape On Window Resize
my app listens for resize events and adjusts the width and the height of my canvas:

```<code>window.addEventListener('resize', () => {
  this.canvasWidth = innerWidth
  this.canvasHeight = innerHeight
})
</code>```

When I resize the window the canvas resizes perfectly, but the shape that I've drawn on the canvas disappears.

How can I keep the drawn object visible?

答:
suddenly it works, I just had to call it with a requestAnimationFrame-method.</p>

```<code>const loop = () => {
  this.update()
  this.draw()
  requestAnimationFrame(loop)
}
loop()
</code>```

Body:
my app listens for resize events and adjusts the width and the height of my canvas:

window.addEventListener('resize', () => {
  this.canvasWidth = innerWidth
  this.canvasHeight = innerHeight
})

When I resize the window the canvas resizes perfectly, but the shape that I've drawn on the canvas disappears.

How can I keep the drawn object visible?

Body:
suddenly it works, I just had to call it with a requestAnimationFrame-method.

const loop = () => {
  this.update()
  this.draw()
  requestAnimationFrame(loop)
}
loop()


问:
Unable to read View Bag value from controller to view
I have created a view bag in controller's post back event which stores the image path.
Then,i used this view bag value in image src attribute.But image is not displayed.

Model:

```<code>public class FileManagement
     {
    public string FileName { get; set; }
    public string Path { get; set; }
      }
</code>```

Code for uploading image

```<code>      [HttpPost]
      public ActionResult UploadPic(FileManagement fmanage, HttpPostedFileBase file)
      {
        string email = User.Identity.Name;

        if (file != null && file.ContentLength > 0)
        {
            var FileName = string.Format("{0}.{1}", Guid.NewGuid(), Path.GetFileName(file.FileName));
            var path = Path.Combine(Server.MapPath("~/Content/Uploads"), FileName);
            file.SaveAs(path);

         using (var session = DocumentStore.OpenSession("RavenMemberShip"))
            {

                var query = from q in Session.Query<Registration>() where q.Email == email select q;
                if (query.Count() > 0)
                {
                    foreach (var updated in query)
                    {
                        updated.FileName = FileName;
                        updated.Path = path;
                        session.SaveChanges();

                    }
                }
            }
        }
        else ModelState.AddModelError("", "Remove the errors and try again");
        return View();
    }
</code>```

Controller

```<code>    [HttpGet]
    public ActionResult DisplayPic()
    {
        ViewBag.Imagepath = "C:\\Users\\Wasfa\\Documents\\Visual Studio 2012\\Projects\\MvcMembership\\MvcMembership\\App_Data\\Uploads\\annonymous.jpg";

        return View();
    }

    [HttpPost]
    public ActionResult DisplayPic(FileManagement fm)
    {

        using (var session = DocumentStore.OpenSession("RavenMemberShip"))
        {
            string ipath;
            //  string UserName = User.Identity.Name;
            string UserName = "wasfa_anjum@yahoo.com";
            var getPath = from p in Session.Query<Registration>()
                          where p.Email == UserName
                          select p;
            if (getPath.Count() > 0)
            {
                foreach (var imgpath in getPath)
                {

                    ipath = imgpath.Path;
                    ViewBag.Imagepath = ipath;
                }

           }

        }
        return View();
    }
</code>```

View:

```<code>    @using (Html.BeginForm())

   {
    <div>
    <img src="@Url.Content(ViewBag.Imagepath)" width="200" height="200" />
    </div>
    <input type="submit" value="Display" />
   }
</code>```

答:
In case, if the image to be displayed when export to excel from the web page.
Use the server path of the image, otherwise, the image would not be loaded from the assembly image folder.

Example:

config:

```<code><add key="LogoPath" value="http:\\mysite\\images\\" />
</code>```

code:

```<code>companyLogo = string.Format("{0}myLogo.png", System.Web.Configuration.WebConfigurationManager.AppSettings["LogoPath"]);
</code>```

HTML:

```<code><img src='" + @Url.Content(companyLogo) + "' />
</code>```

Body:
I have created a view bag in controller's post back event which stores the image path.
Then,i used this view bag value in image src attribute.But image is not displayed.

Model:

public class FileManagement
     {
    public string FileName { get; set; }
    public string Path { get; set; }
      }

Code for uploading image

      [HttpPost]
      public ActionResult UploadPic(FileManagement fmanage, HttpPostedFileBase file)
      {
        string email = User.Identity.Name;

        if (file != null && file.ContentLength > 0)
        {
            var FileName = string.Format("{0}.{1}", Guid.NewGuid(), Path.GetFileName(file.FileName));
            var path = Path.Combine(Server.MapPath("~/Content/Uploads"), FileName);
            file.SaveAs(path);

         using (var session = DocumentStore.OpenSession("RavenMemberShip"))
            {

                var query = from q in Session.Query<Registration>() where q.Email == email select q;
                if (query.Count() > 0)
                {
                    foreach (var updated in query)
                    {
                        updated.FileName = FileName;
                        updated.Path = path;
                        session.SaveChanges();

                    }
                }
            }
        }
        else ModelState.AddModelError("", "Remove the errors and try again");
        return View();
    }

Controller

    [HttpGet]
    public ActionResult DisplayPic()
    {
        ViewBag.Imagepath = "C:\\Users\\Wasfa\\Documents\\Visual Studio 2012\\Projects\\MvcMembership\\MvcMembership\\App_Data\\Uploads\\annonymous.jpg";

        return View();
    }

    [HttpPost]
    public ActionResult DisplayPic(FileManagement fm)
    {

        using (var session = DocumentStore.OpenSession("RavenMemberShip"))
        {
            string ipath;
            //  string UserName = User.Identity.Name;
            string UserName = "wasfa_anjum@yahoo.com";
            var getPath = from p in Session.Query<Registration>()
                          where p.Email == UserName
                          select p;
            if (getPath.Count() > 0)
            {
                foreach (var imgpath in getPath)
                {

                    ipath = imgpath.Path;
                    ViewBag.Imagepath = ipath;
                }

           }

        }
        return View();
    }

View:

    @using (Html.BeginForm())

   {

    <input type="submit" value="Display" />
   }

Body:
In case, if the image to be displayed when export to excel from the web page.
Use the server path of the image, otherwise, the image would not be loaded from the assembly image folder.

Example:

config:

<add key="LogoPath" value="http:\\mysite\\images\\" />

code:

companyLogo = string.Format("{0}myLogo.png", System.Web.Configuration.WebConfigurationManager.AppSettings["LogoPath"]);

HTML:

<img src='" + @Url.Content(companyLogo) + "' />


问:
Calculating confidence intervals for a non-normal distribution
First, I should specify that my knowledge of statistics is fairly limited, so please forgive me if my question seems trivial or perhaps doesn't even make sense.

I have data that doesn't appear to be normally distributed.  Typically, when I plot confidence intervals, I would use the mean +- 2 standard deviations, but I don't think that is acceptible for a non-uniform distribution.  My sample size is currently set to 1000 samples, which would seem like enough to determine if it was a normal distribution or not.

I use Matlab for all my processing, so are there any functions in Matlab that would make it easy to calculate the confidence intervals (say 95%)?

I know there are the 'quantile' and 'prctile' functions, but I'm not sure if that's what I need to use.  The function 'mle' also returns confidence intervals for normally distributed data, although you can also supply your own pdf.

Could I use ksdensity to create a pdf for my data, then feed that pdf into the mle function to give me confidence intervals?

Also, how would I go about determining if my data is normally distributed.  I mean I can currently tell just by looking at the histogram or pdf from ksdensity, but is there a way to quantitatively measure it?

Thanks!

答:
Are you sure you need confidence intervals or just the 90% range of the random data?

If you need the latter, I suggest you use prctile(). For example, if you have a vector holding independent identically distributed samples of random variables, you can get some useful information by running

```<code>y = prcntile(x, [5 50 95])
</code>```

This will return in [y(1), y(3)] the range where 90% of your samples occur. And in y(2) you get the median of the sample.

Try the following example (using a normally distributed variable):

```<code>t = 0:99;
tt = repmat(t, 1000, 1);
x = randn(1000, 100) .* tt + tt;  % simple gaussian model with varying mean and variance
y = prctile(x, [5 50 95]);

plot(t,  y);
legend('5%','50%','95%')
</code>```

ContentLicense: CC BY-SA 2.5

Body:
Are you sure you need confidence intervals or just the 90% range of the random data?

If you need the latter, I suggest you use prctile(). For example, if you have a vector holding independent identically distributed samples of random variables, you can get some useful information by running

y = prcntile(x, [5 50 95])

This will return in [y(1), y(3)] the range where 90% of your samples occur. And in y(2) you get the median of the sample.

Try the following example (using a normally distributed variable):

t = 0:99;
tt = repmat(t, 1000, 1);
x = randn(1000, 100) .* tt + tt;  % simple gaussian model with varying mean and variance
y = prctile(x, [5 50 95]);

plot(t,  y);
legend('5%','50%','95%')


问:
How to display json data into the android layout?
MY JSON looks like this. I just need to set these values in the layout of the fragment. So that the details about this product will be displayed. </p>

<p>```<code></p>

```<code>{
  "adid": 5,
  "uid": 1130,
  "userName": "Maëly",
  "cid": 5,
  "brand": null,
  "model": null,
  "title": "Nummular dermatitis",
  "description": "Nam sa dea ss "
  "address": "9795 Debra Center",
  "price": 1544,
  "photo1": "../../../img/mobile/oneplus/3t/3t-1.jpg",
  "photo2": null,
  "photo3": null,
  "photo4": null,
  "ip_add": null,
  "created": 1493921700000,
  "expiryDate": null,
  "published": true,
  "sold": null,
  "featured": true,
  "cond": true,
  "price_neg": true,
  "used_for": "8",
  "views": 1575,
  "city": "Kathmandu",
  "landmark": null,
  "quality": null,
  "alert": null,
  "features": [

  ]
}
</code>```

<p>```</code></p>

答:
Ever had a glance at the Retrofit documentation? http://square.github.io/retrofit/?

You can make synchronous, or asynchonous calls to the service, you create for your interface and do with the result as you please. If you want the data shown in a fragment, you'll probably do an asynchonous call and when you get back the data (which via the Gson converter should automatically be converted from JSON to your data model classes) you can e.g. show the list of data objects in a ListView or whatever.

Body:
MY JSON looks like this. I just need to set these values in the layout of the fragment. So that the details about this product will be displayed.

{
  "adid": 5,
  "uid": 1130,
  "userName": "Maëly",
  "cid": 5,
  "brand": null,
  "model": null,
  "title": "Nummular dermatitis",
  "description": "Nam sa dea ss "
  "address": "9795 Debra Center",
  "price": 1544,
  "photo1": "../../../img/mobile/oneplus/3t/3t-1.jpg",
  "photo2": null,
  "photo3": null,
  "photo4": null,
  "ip_add": null,
  "created": 1493921700000,
  "expiryDate": null,
  "published": true,
  "sold": null,
  "featured": true,
  "cond": true,
  "price_neg": true,
  "used_for": "8",
  "views": 1575,
  "city": "Kathmandu",
  "landmark": null,
  "quality": null,
  "alert": null,
  "features": [

  ]
}


问:
Merge two PNG images with PHP. Output image CHANGES and wrong opacity
I need to merge the following images, however my solution is not working.

My code is the following (I pass the URL of the images to the script via GET parameter)

```<code><?php
$dest = imagecreatefrompng($_GET['img1']);
$src = imagecreatefrompng($_GET['img2']);

imagecopymerge($dest, $src, 0, 0, 0, 0, 1500, 1500, 50);

$white = imagecolorallocate($dest, 255, 255, 255);
imagecolortransparent($dest, $white);

header('Content-Type: image/png');
imagepng($dest);
?>
</code>```

Both image are PNG with transparent background and both are 1500x1500.

First image:

Second image:

What I get:

Why can't I make the final image have the right opacity? I tried changing the last value of imagecopymerge() to 0 or 100 but in those cases I only get one image or another. I need them both, exactly overlapped on one another!

Also, if you look carefully around the gem in the final image, there is some extra blue color... how is this possible?

答:
This is caused by setting the resulting image to use image transparency rather than per-pixel alpha-channel transparency by your call to imagecolortransparent which sets any white (#ffffff) pixels to 100% transparent.

The artefacts ('extra blue colour' and edge pixels) on the resulting image are caused by the alpha-channel transparency from the original images not being saved and the pixels (which were 100% transparent but not white) showing their original colour.

The 'washed out' look of your result comes from telling imagecopymerge to merge the two images with 50% transparency.

The solution is to use the correct alpha settings:

```<code><?php

$dest = imagecreatefrompng($_GET['img1']);
$src = imagecreatefrompng($_GET['img2']);

imagesavealpha($dest, true);

imagecopy($dest, $src, 0, 0, 0, 0, 1500, 1500);

header('Content-Type: image/png');
imagepng($dest);
</code>```

Body:
I need to merge the following images, however my solution is not working.

My code is the following (I pass the URL of the images to the script via GET parameter)

<?php
$dest = imagecreatefrompng($_GET['img1']);
$src = imagecreatefrompng($_GET['img2']);

imagecopymerge($dest, $src, 0, 0, 0, 0, 1500, 1500, 50);

$white = imagecolorallocate($dest, 255, 255, 255);
imagecolortransparent($dest, $white);

header('Content-Type: image/png');
imagepng($dest);
?>

Both image are PNG with transparent background and both are 1500x1500.

First image:

Second image:

What I get:

Why can't I make the final image have the right opacity? I tried changing the last value of imagecopymerge() to 0 or 100 but in those cases I only get one image or another. I need them both, exactly overlapped on one another!

Also, if you look carefully around the gem in the final image, there is some extra blue color... how is this possible?

Body:
This is caused by setting the resulting image to use image transparency rather than per-pixel alpha-channel transparency by your call to imagecolortransparent which sets any white (#ffffff) pixels to 100% transparent.

The artefacts ('extra blue colour' and edge pixels) on the resulting image are caused by the alpha-channel transparency from the original images not being saved and the pixels (which were 100% transparent but not white) showing their original colour.

The 'washed out' look of your result comes from telling imagecopymerge to merge the two images with 50% transparency.

The solution is to use the correct alpha settings:

<?php

$dest = imagecreatefrompng($_GET['img1']);
$src = imagecreatefrompng($_GET['img2']);

imagesavealpha($dest, true);

imagecopy($dest, $src, 0, 0, 0, 0, 1500, 1500);

header('Content-Type: image/png');
imagepng($dest);


问:
Using ServiceLoader for log4j-jcl brigde in OSGi environment
I am trying to use the log4j-jcl bridge in osgi mode and found that the java.util.ServiceLoader should be used to get the LogFactoryImpl from the bridge jar. I am new to OSGi and so tried it after referring to a few tutorials but it doesn't seem to work. The bundle is in RESOLVED state.

LoggingActivator.java

```<code>import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import java.util.ServiceLoader;

public class LoggingActivator  implements BundleActivator{

private static Log log;
ServiceLoader<LogFactory> serviceLoader = ServiceLoader.load(LogFactory.class);
LogFactory service = serviceLoader.iterator().next();

public LoggingActivator(){
    if (service != null){
        log = service.getLog(LoggingActivator.class);
    }
}

@Override
public void start(BundleContext bundleContext) throws Exception {
    log.info("Activated Logging");
}

@Override
public void stop(BundleContext bundleContext) throws Exception {
    log.info("Deactivated Logging");
}

}
</code>```

pom.xml

```<code>    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.8.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-jcl</artifactId>
        <version>2.8.2</version>
    </dependency>
</code>```

```<code>    <Export-Package>
        org.apache.logging.log4j.*,
        org.apache.commons.logging.*
    </Export-Package>
    <Import-Package>
        !org.apache.logging.log4j.*,
        !org.apache.commons.logging.*,
        *;resolution:=optional
    </Import-Package>
</code>```

答:
The ServiceLoader does not work well in OSGi. I propose to give Apache Karaf a try. You will not need it later but it has the logging already configured properly so it is easier to start with compared to setting all up yourself from the start.

In your bundle simply initialize a commons logging logger like outside of OSGi.

```<code>class MyClass {
private Log log = LogFactory.getLog(MyClass.class);
...
}
</code>```

Leave the maven-bundle-plugin at defaults. The result is a bundle that imports the commons logging API packages which is exactly what you need.

Then start karaf and deploy your bundle. The logging should work out of the  box. For more information see the karaf logging guide.

Karaf uses pax-logging. If you want to setup this yourself you need the bundles pax-logging-api and pax-logging-service, felix config admin and felix fileinstall. The backend is log4j. You configure it using ConfigAdmin and a config named etc/org.ops4j.pax.logging.cfg. The config is a standard log4j config file.

Body:
I am trying to use the log4j-jcl bridge in osgi mode and found that the java.util.ServiceLoader should be used to get the LogFactoryImpl from the bridge jar. I am new to OSGi and so tried it after referring to a few tutorials but it doesn't seem to work. The bundle is in RESOLVED state.

LoggingActivator.java

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import java.util.ServiceLoader;

public class LoggingActivator  implements BundleActivator{

private static Log log;
ServiceLoader<LogFactory> serviceLoader = ServiceLoader.load(LogFactory.class);
LogFactory service = serviceLoader.iterator().next();

public LoggingActivator(){
    if (service != null){
        log = service.getLog(LoggingActivator.class);
    }
}

@Override
public void start(BundleContext bundleContext) throws Exception {
    log.info("Activated Logging");
}

@Override
public void stop(BundleContext bundleContext) throws Exception {
    log.info("Deactivated Logging");
}

}

pom.xml

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.8.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-jcl</artifactId>
        <version>2.8.2</version>
    </dependency>

    <Export-Package>
        org.apache.logging.log4j.*,
        org.apache.commons.logging.*
    </Export-Package>
    <Import-Package>
        !org.apache.logging.log4j.*,
        !org.apache.commons.logging.*,
        *;resolution:=optional
    </Import-Package>

Body:
The ServiceLoader does not work well in OSGi. I propose to give Apache Karaf a try. You will not need it later but it has the logging already configured properly so it is easier to start with compared to setting all up yourself from the start.

In your bundle simply initialize a commons logging logger like outside of OSGi.

class MyClass {
private Log log = LogFactory.getLog(MyClass.class);
...
}

Leave the maven-bundle-plugin at defaults. The result is a bundle that imports the commons logging API packages which is exactly what you need.

Then start karaf and deploy your bundle. The logging should work out of the  box. For more information see the karaf logging guide.

Karaf uses pax-logging. If you want to setup this yourself you need the bundles pax-logging-api and pax-logging-service, felix config admin and felix fileinstall. The backend is log4j. You configure it using ConfigAdmin and a config named etc/org.ops4j.pax.logging.cfg. The config is a standard log4j config file.


问:
In Codeigniter extends one controller into another controller
I am using codeigniter(3.1.5) and Ihave two controllers in my application/controllers/ folder. with name controller A and Controller B. I want to extends Controller A in Controller B so that I can use methods of Controller A. But it generates class not found error.

Here is my sample code:

A_Controller.php:

```<code>defined('BASEPATH') OR exit('No direct script access allowed');
class A_Controller extends CI_Controller {
  public function index()
  {
  }

  public function display(){
     echo 'base controller function called.';
  }
 }
</code>```

B_Controller.php:

```<code> defined('BASEPATH') OR exit('No direct script access allowed');
 class B_Controller extends A_Controller {

 }
</code>```

I want to execute display() method of controller A in controller B.
If i put controller A in application/core/ folder and in application/config/config.php file make

$config['subclass_prefix'] = 'A_';

then I can able to access methods of controller A.

Please suggest.
Thanks in advance.

答:
Use construct in controller</p>

```<code>defined('BASEPATH') OR exit('No direct script access allowed');
 class B_Controller extends A_Controller {

    public function __construct() {
         parent::__construct();
    }
    public function test()
    {
        $this->display();
    }
 }
</code>```

Body:
I am using codeigniter(3.1.5) and Ihave two controllers in my application/controllers/ folder. with name controller A and Controller B. I want to extends Controller A in Controller B so that I can use methods of Controller A. But it generates class not found error.

Here is my sample code:

A_Controller.php:

defined('BASEPATH') OR exit('No direct script access allowed');
class A_Controller extends CI_Controller {
  public function index()
  {
  }

  public function display(){
     echo 'base controller function called.';
  }
 }

B_Controller.php:

 defined('BASEPATH') OR exit('No direct script access allowed');
 class B_Controller extends A_Controller {

 }

I want to execute display() method of controller A in controller B.
If i put controller A in application/core/ folder and in application/config/config.php file make

$config['subclass_prefix'] = 'A_';

then I can able to access methods of controller A.

Please suggest.
Thanks in advance.

Body:
Use construct in controller

defined('BASEPATH') OR exit('No direct script access allowed');
 class B_Controller extends A_Controller {

    public function __construct() {
         parent::__construct();
    }
    public function test()
    {
        $this->display();
    }
 }


问:
Oracle reclaim disk space after drop user cascade
I am using Oracle Database 12c. I had a big schema which was taking more than 20GB of my disk space. So I dropped it using the command:

```<code> drop user myDB cascade;
</code>```

However, the tablespace files continue to take space from the disk. In the image bellow taken from EM Express, we can see it has a lot of free space in between the data I still need.

My question is: how do I reorganize my tablespace to be in just one file and then have it resized so that I can have some more space in Disk?

Thanks in advance.

答:
One thing to note here is that dropping a user in oracle will not release space from its tablespace. A tablespace takes its own space and it acts as a virtual storage space for database users. So dropping a user will create free space in that tablespace, which can then be used by another user of that tablespace.

To check the available Free space in all tablespaces use this query:

```<code>select tot.tablespace_name, tot.file_name, tot.bytes/1024/1024 size_mb, free.free_mb
from dba_data_files tot, (select file_id, sum(bytes/1024/1024) free_mb FROM dba_free_space free group by file_id) free
where tot.file_id=free.file_id
order by free.free_mb;
</code>```

For reorganizing a tablespace, you will have to reorganize its contents ie, tables and indexes. The reorganizing will need to have double the space in your tablespace, as it will move tables and indexes into new blocks, but after reorganize, you can reclaim the space by resizing the tablespace datafiles.

To Move tables and indexes, first determine which objects are using your tablespace using dba_segments view and then move/rebuild those objects using these commands:

```<code>alter table TABLENAME move;
alter index INDEXNAME rebuild online;
</code>```

Body:
I am using Oracle Database 12c. I had a big schema which was taking more than 20GB of my disk space. So I dropped it using the command:

 drop user myDB cascade;

However, the tablespace files continue to take space from the disk. In the image bellow taken from EM Express, we can see it has a lot of free space in between the data I still need.

My question is: how do I reorganize my tablespace to be in just one file and then have it resized so that I can have some more space in Disk?

Thanks in advance.

Body:
One thing to note here is that dropping a user in oracle will not release space from its tablespace. A tablespace takes its own space and it acts as a virtual storage space for database users. So dropping a user will create free space in that tablespace, which can then be used by another user of that tablespace.

To check the available Free space in all tablespaces use this query:

select tot.tablespace_name, tot.file_name, tot.bytes/1024/1024 size_mb, free.free_mb
from dba_data_files tot, (select file_id, sum(bytes/1024/1024) free_mb FROM dba_free_space free group by file_id) free
where tot.file_id=free.file_id
order by free.free_mb;

For reorganizing a tablespace, you will have to reorganize its contents ie, tables and indexes. The reorganizing will need to have double the space in your tablespace, as it will move tables and indexes into new blocks, but after reorganize, you can reclaim the space by resizing the tablespace datafiles.

To Move tables and indexes, first determine which objects are using your tablespace using dba_segments view and then move/rebuild those objects using these commands:

alter table TABLENAME move;
alter index INDEXNAME rebuild online;


问:
How to create customers/products with HTTP API and guzzle in shopify
I am new to Shopify apps as well as Guzzle and have followed https://www.sitepoint.com/shopify-app-development-made-simple/ to get started with shopify app. But now am not able to create products/customers.Code i have used:</p>

```<code>                <?php
            require 'vendor/autoload.php';

            use GuzzleHttp\Client;

            $dotenv = new Dotenv\Dotenv(__DIR__);
            $dotenv->load();

            $db = new Mysqli(getenv('MYSQL_HOST'), getenv('MYSQL_USER'), getenv('MYSQL_PASS'), getenv('MYSQL_DB'));

            $store = 'customboxes1.myshopify.com';
            $select = $db->query("SELECT access_token FROM installs WHERE store = '$store'");
            $user = $select->fetch_object();
            $access_token = $user->access_token;
            $customerData = array
                    (
                        "customer" => array(
                            "first_name"    =>  "Steve",
                            "last_name"     =>  "Lastnameson",
                            "email"         =>  "steve.lastnameson10@test.com",
                            "verified_email"=>  true,
                        )
                    );
            $client = new Client();

            $response = $client->request(
                'POST',
                "https://{$store}/admin/customers.json",
                [
                    'query' => [
                        'fields' => $customerData,
                        'access_token' => $access_token
                    ]
                ]
            );

            $result = json_decode($response->getBody()->getContents(), true);
            echo $result;
</code>```

答:
```<code>POST /admin/products.json
{
  "product": {
    "title": "Burton Custom Freestyle 151",
    "body_html": "<strong>Good snowboard!<\/strong>",
    "vendor": "Burton",
    "product_type": "Snowboard",
    "tags": "Barnes & Noble, John's Fav, \"Big Air\""
  }
}
</code>```

use this in this code

$client = new Client();

```<code>$response = $client->request(
    'POST',
    "https://{$store}/admin/products.json/access_token",
    [
        'form_params' => [
            'client_id' => $api_key,
            'client_secret' => $secret_key,
            'code' => $query['code']
        ]
    ]
);
</code>```

Body:
I am new to Shopify apps as well as Guzzle and have followed https://www.sitepoint.com/shopify-app-development-made-simple/ to get started with shopify app. But now am not able to create products/customers.Code i have used:

                <?php
            require 'vendor/autoload.php';

            use GuzzleHttp\Client;

            $dotenv = new Dotenv\Dotenv(__DIR__);
            $dotenv->load();

            $db = new Mysqli(getenv('MYSQL_HOST'), getenv('MYSQL_USER'), getenv('MYSQL_PASS'), getenv('MYSQL_DB'));

            $store = 'customboxes1.myshopify.com';
            $select = $db->query("SELECT access_token FROM installs WHERE store = '$store'");
            $user = $select->fetch_object();
            $access_token = $user->access_token;
            $customerData = array
                    (
                        "customer" => array(
                            "first_name"    =>  "Steve",
                            "last_name"     =>  "Lastnameson",
                            "email"         =>  "steve.lastnameson10@test.com",
                            "verified_email"=>  true,
                        )
                    );
            $client = new Client();

            $response = $client->request(
                'POST',
                "https://{$store}/admin/customers.json",
                [
                    'query' => [
                        'fields' => $customerData,
                        'access_token' => $access_token
                    ]
                ]
            );

            $result = json_decode($response->getBody()->getContents(), true);
            echo $result;

Body:
POST /admin/products.json
{
  "product": {
    "title": "Burton Custom Freestyle 151",
    "body_html": "<strong>Good snowboard!<\/strong>",
    "vendor": "Burton",
    "product_type": "Snowboard",
    "tags": "Barnes & Noble, John's Fav, \"Big Air\""
  }
}

use this in this code

$client = new Client();

$response = $client->request(
    'POST',
    "https://{$store}/admin/products.json/access_token",
    [
        'form_params' => [
            'client_id' => $api_key,
            'client_secret' => $secret_key,
            'code' => $query['code']
        ]
    ]
);


问:
Sklearn parallel processing not working in docker container
I'm building and training some RandomForestClassifier models in sklearn. I recently found out about the n_jobs variable to use parallel processing for training and predicting.  However, it seems to have the opposite effect that I'm looking for.

When n_jobs is unassigned (defaults to 1) the training/predicting will entirely use 1 core. I can see 100% CPU usage when running "top".  However, when I bump it to 4, or -1 (number of cores, which is 4) the CPU usage drops to 25%.

Has anyone else run into this before and/or know of a solution?

答:
Looks like this was a misunderstanding on my part.  Apparently my dataset is small enough that the "fit" time is actually pretty negligable (60,000 records or so).  However, I was doing manual cross-validation and would iterate through those records and ask for a prediction on the unseen test set.  This would take several minutes, and I was hoping parallelizing would shave down that time.  However, I think my model is small enough that the overhead of spawning new processes was significantly higher than the speed gained through parallelization.

Basically I generated a sufficiently large (2 million row) random dataset and called "fit" and I did see my CPU usage increase as expected.

Sorry for the confusion, and thanks for those that tried to help!


答:
There are plenty of ways to do this, but personally I'd say the most readable by far is:

```<code>$html = <<<'END'
<div id="imgContainer"></div>
  <img src="elements/18_lr.jpg" data-highres="elements/18_hr.jpg" onclick="$(this).mbZoomify({screen:'#imgContainer'});">
END;
</code>```

No escaping required!

Title: Inline juqery syntax error

Body:
Inside a .php page i have a function.Inside that function, some of my code looks like the following:-

$html='';
$html.='

';
$html.='';//<<----shows error near #imgContainer

At the above indicated line, it shows incorrect HTML error.Please advise how to get rid of the error.

Body:
There are plenty of ways to do this, but personally I'd say the most readable by far is:

$html = <<<'END'
<div id="imgContainer"></div>
  <img src="elements/18_lr.jpg" data-highres="elements/18_hr.jpg" onclick="$(this).mbZoomify({screen:'#imgContainer'});">
END;

No escaping required!


问:
unable to get data from html in angular js
in this code of HTML, we get input text value and send to the Angular controller
so they get to work as defined in code.

```<code>    <div class="row" ng-controller="RegionController">

    <div class="col-lg-12" >
    <div class="hpanel">
    <div class="panel-heading">
      <!--  <div panel-tools></div>  -->
        <h2>Region Master Entry</h2>
    </div>
    <div class="panel-body">

        <!--change form name,and submit controller name-->

        <form role="form">

            <div class="form-group">
                <label class="col-sm-2 control-label">Region Name</label>

                <div class="col-sm-10">
                    <input type="text" placeholder="please enter Region name" class="form-control m-b" required name="Region Name" ng-model="formRegionData.region_name" >

                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">Region Code</label>

                <div class="col-sm-10">
                    <input type="text" placeholder="please enter Region code" class="form-control m-b" required name="Region Code" ng-model="formRegionData.region_code">

                </div>
            </div>

            <div class="form-group">
            <div class="col-sm-3">
                <label>Active</label>
            </div>

             <div class="checkbox checkbox-success col-sm-9">
                 <input id="checkbox3" type="checkbox" checked="" ng-model="formRegionData.status">
                 <label for="checkbox3">

                 </label>
             </div>
         </div>

            <div class="form-group">
                <div class="col-sm-4"></div>

                <div class="col-sm-8">
                    <button  class="btn btn-sm btn-primary btn-xl text-right"  type="submit" ng-click="createRegion()"><strong> Save Region </strong></button>
                </div>

            </div>

 {{formRegionData | json}}
        </form>
    </div>
   </div>
   </div>
 </div>
</code>```

"{{formRegionData | json}}" this will return in HTML input text result of but not send data to the controller

in Controller the code is written as

```<code>.controller('RegionController', function( $scope , regionService) {
$scope.createRegion = function() {
    debugger;
    vm.processing = true;
    vm.message = '';
    console.log(formRegionData);
    regionService.SaveRegion( formRegionData )
        .then(function(data) {
            debugger;
            //console.log(data);
            //.success(function(data) {
            vm.processing = false;
            vm.storyData = {};
            vm.message = data.message;
        });
  }
  })
</code>```

and my service to work according to Controller

```<code>   .factory('regionService',function($http ){
          var regionFactory = {};
    regionFactory.SaveRegion = function(formRegionData) {
    debugger;
            return $http.post('/api/region/', formRegionData);

    }
    return regionFactory;
});
</code>```

答:
You have missed $scope

```<code>    $scope.createRegion = function() {
        debugger;
        $scope.processing = true;
        $scope.message = '';
        console.log($scope.formRegionData);
        regionService.SaveRegion($scope.formRegionData )
            .then(function(data) {
                debugger;
                //console.log(data);
                //.success(function(data) {
                $scope.processing = false;
                $scope.storyData = {};
                $scope.message = data.message;
            });
      }
  })
</code>```

and remove ng-click="createRegion()" in your button control and add this code in your form tag by ng-submit. like,

```<code><form ng-submit="createRegion()" role="form">
</code>```

Body:
in this code of HTML, we get input text value and send to the Angular controller
so they get to work as defined in code.

Region Master Entry

        <form role="form">

                Region Name

                    <input type="text" placeholder="please enter Region name" class="form-control m-b" required name="Region Name" ng-model="formRegionData.region_name" >

                Region Code

                    <input type="text" placeholder="please enter Region code" class="form-control m-b" required name="Region Code" ng-model="formRegionData.region_code">

                Active

                 <input id="checkbox3" type="checkbox" checked="" ng-model="formRegionData.status">

                    <button  class="btn btn-sm btn-primary btn-xl text-right"  type="submit" ng-click="createRegion()"> Save Region </button>

 {{formRegionData | json}}
        </form>

"{{formRegionData | json}}" this will return in HTML input text result of but not send data to the controller

in Controller the code is written as

.controller('RegionController', function( $scope , regionService) {
$scope.createRegion = function() {
    debugger;
    vm.processing = true;
    vm.message = '';
    console.log(formRegionData);
    regionService.SaveRegion( formRegionData )
        .then(function(data) {
            debugger;
            //console.log(data);
            //.success(function(data) {
            vm.processing = false;
            vm.storyData = {};
            vm.message = data.message;
        });
  }
  })

and my service to work according to Controller

   .factory('regionService',function($http ){
          var regionFactory = {};
    regionFactory.SaveRegion = function(formRegionData) {
    debugger;
            return $http.post('/api/region/', formRegionData);

    }
    return regionFactory;
});

Body:
You have missed $scope

    $scope.createRegion = function() {
        debugger;
        $scope.processing = true;
        $scope.message = '';
        console.log($scope.formRegionData);
        regionService.SaveRegion($scope.formRegionData )
            .then(function(data) {
                debugger;
                //console.log(data);
                //.success(function(data) {
                $scope.processing = false;
                $scope.storyData = {};
                $scope.message = data.message;
            });
      }
  })

and remove ng-click="createRegion()" in your button control and add this code in your form tag by ng-submit. like,

<form ng-submit="createRegion()" role="form">


问:
How to make a non-modal Dialog window be always on top?
I am using an instance of a Dialog {} in my application to display a small controller window that the user can interact with to affect the functions in the main window (sort of a remote control). I can make this Dialog modal (modality: Qt.WindowModal or modality: Qt.ApplicationModal) or I can make it non-modal with modality: Qt.NonModal.

My problem is that I need to make it non-modal but be always on top of the main window. If I use Qt.NonModal I can still click on the main form but then my Dialog goes behind it. The Dialog class does not seem to have a flags: property, so I can't just set it to Qt.WindowsStaysOnTopHint.

Is there any way to set the flags of a Dialog like this purely from the QML side? Or is it possible to write a simple utility method in c++ that I could call from my Dialog's Component.onCompleted: and pass in the dialog to set its windows flags there?

Update: to illustrate what I'm talking about, here is my dialog on top of my main window:

Here is my dialog underneath my main window:

I want my dialog to not go underneath my main window like this, but I still want to be able to click on and interact with my main window. In other words, I want my dialog to be non-modal, but always-on-top.

答:
Okay, so you simply want to create a Dialog (or a Component which looks like a Dialog) and just want to interact with the Main window and the Dialog window.

Please try the following:

main.qml

```<code>import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0

ApplicationWindow {
    id: rootWindow
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    color: "green"

    Rectangle {
        id: behind
        anchors.fill: parent
        color: Qt.rgba(0, 0, 0,  0.7)
        visible: false
    }

    MouseArea {
        enabled: behind.visible
        anchors.fill: parent

        onClicked: {
            console.log("Root Window")
        }
    }

    Button {

        text: "Open Dialog"

        onClicked: {
            behind.visible = true;
            var comp = Qt.createComponent("qrc:/MyDialog.qml");
            // var comp = Qt.createComponent("qrc:/DialogQt.qml");
            var obj1 = comp.createObject(rootWindow, {});
            obj1.z = 2;
        }
    }
}
</code>```

MyDialog.qml

```<code>import QtQuick 2.7

Rectangle {
    id: modalWindow
    width: 200
    height: 200
    color: "red"

    anchors.centerIn: parent

    MouseArea {
        anchors.fill: parent
        onClicked: {
            console.log("Modal Window")
        }
    }
}
</code>```

Clicking on 'Open Dialog' button will create and open the 'modal' Dialog at top of your Main window component.

Of course you have to adjust "MyDialog.qml" file to fit your design requirements on your own.

However, using this as a 'real' Dialog does also work (for me) like G.M has already pointed out in the comments section:

DialogQt.qml

```<code>Dialog {
    visible: true
    title: "Blue sky dialog"

    modality : Qt.ApplicationModal

    contentItem: Rectangle {
        color: "lightskyblue"
        anchors.fill: parent
        Text {
            text: "Hello blue sky!"
            color: "navy"
            anchors.centerIn: parent
        }
    }

}
</code>```

Body:
Okay, so you simply want to create a Dialog (or a Component which looks like a Dialog) and just want to interact with the Main window and the Dialog window.

Please try the following:

main.qml

import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0

ApplicationWindow {
    id: rootWindow
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    color: "green"

    Rectangle {
        id: behind
        anchors.fill: parent
        color: Qt.rgba(0, 0, 0,  0.7)
        visible: false
    }

    MouseArea {
        enabled: behind.visible
        anchors.fill: parent

        onClicked: {
            console.log("Root Window")
        }
    }

    Button {

        text: "Open Dialog"

        onClicked: {
            behind.visible = true;
            var comp = Qt.createComponent("qrc:/MyDialog.qml");
            // var comp = Qt.createComponent("qrc:/DialogQt.qml");
            var obj1 = comp.createObject(rootWindow, {});
            obj1.z = 2;
        }
    }
}

MyDialog.qml

import QtQuick 2.7

Rectangle {
    id: modalWindow
    width: 200
    height: 200
    color: "red"

    anchors.centerIn: parent

    MouseArea {
        anchors.fill: parent
        onClicked: {
            console.log("Modal Window")
        }
    }
}

Clicking on 'Open Dialog' button will create and open the 'modal' Dialog at top of your Main window component.

Of course you have to adjust "MyDialog.qml" file to fit your design requirements on your own.

However, using this as a 'real' Dialog does also work (for me) like G.M has already pointed out in the comments section:

DialogQt.qml

Dialog {
    visible: true
    title: "Blue sky dialog"

    modality : Qt.ApplicationModal

    contentItem: Rectangle {
        color: "lightskyblue"
        anchors.fill: parent
        Text {
            text: "Hello blue sky!"
            color: "navy"
            anchors.centerIn: parent
        }
    }

}


问:
VSCode Extension embedding an image in editor area
I want to write an extension for VSCode that searches for a certain word in the text file you are editing and replaces that word with an image in the editors view. Once you click on the image it should transform back into the original text, and become editable like usual.

I was hopeful that this would be possible, but after discovering that VSCode doesn't let you manipulate the DOM directly, I am doubtful.

Could someone point me to some documentation that would enable me to add images to the editor window? (and not the line-number area on the left)?

Thanks a lot in advance!

答:
VSCode does not support custom UI, but text decorators may work in your case. Here's an example extension that shows how to use them: https://github.com/Microsoft/vscode-extension-samples/tree/master/decorator-sample

To display an image using decorators, try contentIconPath on ThemableDecorationAttachmentRenderOptions