Skip to content

Commit e02446c

Browse files
tooryxcopybara-github
authored andcommitted
Fix the imports and reformat the spark fingerprinting example.
PiperOrigin-RevId: 729061087 Change-Id: I87a2a5515c3a69951ab949d06ea4250136590196
1 parent 131c8f4 commit e02446c

File tree

1 file changed

+11
-11
lines changed
  • google/fingerprinters/web/scripts/updater/community/spark/app/examples

1 file changed

+11
-11
lines changed
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
from pyspark.sql import SparkSession
21
import time
2+
from pyspark.sql import SparkSession
33

44
# Initialize Spark session
5-
spark = SparkSession.builder \
6-
.appName("Fibonacci with Spark") \
7-
.getOrCreate()
5+
spark = SparkSession.builder.appName("Fibonacci with Spark").getOrCreate()
6+
87

98
# Function to calculate Fibonacci numbers
109
def fibonacci(n):
11-
a, b = 0, 1
12-
for _ in range(n):
13-
yield a
14-
a, b = b, a + b
10+
a, b = 0, 1
11+
for _ in range(n):
12+
yield a
13+
a, b = b, a + b
14+
1515

1616
# Create an RDD with the range of Fibonacci numbers to calculate
1717
n = 10 # Number of Fibonacci numbers to generate
@@ -23,11 +23,11 @@ def fibonacci(n):
2323
# Introduce a unlimit loop with a sleep time to keep spark WebUI running
2424
# We actually dont' want to calculate fibonacci :)
2525
while True:
26-
time.sleep(1)
26+
time.sleep(1)
2727

2828
# Collect and print the Fibonacci numbers
2929
for result in fibonacci_result.collect():
30-
print(result)
30+
print(result)
3131

3232
# Stop the Spark session
33-
spark.stop()
33+
spark.stop()

0 commit comments

Comments
 (0)