This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
; try this one with read
|
||||
(let* ((file (open-input-file "big_data_gen.sexpr"))
|
||||
(data (read file)))
|
||||
(gc-flip)
|
||||
(print-gc-statistics)
|
||||
(newline)
|
||||
(display "records: ")
|
||||
(display (length data))
|
||||
(newline)
|
||||
(let ((record (car data)))
|
||||
(assert (= (cdr (vector-assq 'index record)) 0))
|
||||
(assert (eq? (cdr (vector-assq 'isActive record)) 'False))
|
||||
(assert (= (cdr (vector-assq 'age record)) 21)))
|
||||
|
||||
(close-input-port file))
|
||||
|
||||
(display "done")
|
||||
(newline)
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
; canada
|
||||
(let ((data (read)))
|
||||
(gc-flip)
|
||||
(print-gc-statistics)
|
||||
(newline)
|
||||
(display "records: ")
|
||||
(display (vector-length data)))
|
||||
|
||||
(gc-flip)
|
||||
(print-gc-statistics)
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,38 @@
|
||||
import json
|
||||
import sys
|
||||
import itertools
|
||||
|
||||
json_data = json.load(sys.stdin)
|
||||
|
||||
def lisp_dump(data):
|
||||
if isinstance(data, int):
|
||||
return str(data)
|
||||
elif isinstance(data, float):
|
||||
return str(data)
|
||||
elif isinstance(data, str):
|
||||
escaped_string = data.encode("unicode_escape").decode("utf-8")
|
||||
return "\"" + escaped_string + "\""
|
||||
elif isinstance(data, list):
|
||||
result = "("
|
||||
for i, item in enumerate(data):
|
||||
result += lisp_dump(item)
|
||||
if i + 1 < len(data):
|
||||
result += " "
|
||||
result += ")"
|
||||
return result
|
||||
elif isinstance(data, dict):
|
||||
result = "#("
|
||||
i = 0
|
||||
for key, item in data.items():
|
||||
result += "(%s . %s)" % (key, lisp_dump(item))
|
||||
if i + 1 < len(data):
|
||||
result += " "
|
||||
i += 1
|
||||
result += ")"
|
||||
return result
|
||||
else:
|
||||
print("error")
|
||||
print(type(data))
|
||||
|
||||
print(lisp_dump(json_data))
|
||||
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
../../lisp --script big_data1.scm
|
||||
cat big_data_canada.sexpr | ../../lisp --script big_data2.scm
|
||||
Reference in New Issue
Block a user