Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Hash-join/Common-Lisp/hash-join.lisp
Normal file
17
Task/Hash-join/Common-Lisp/hash-join.lisp
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
(defparameter *table-A* '((27 "Jonah") (18 "Alan") (28 "Glory") (18 "Popeye") (28 "Alan")))
|
||||
|
||||
(defparameter *table-B* '(("Jonah" "Whales") ("Jonah" "Spiders") ("Alan" "Ghosts") ("Alan" "Zombies") ("Glory" "Buffy")))
|
||||
|
||||
;; Hash phase
|
||||
(defparameter *hash-table* (make-hash-table :test #'equal))
|
||||
|
||||
(loop for (i r) in *table-A*
|
||||
for value = (gethash r *hash-table* (list nil)) do
|
||||
(setf (gethash r *hash-table*) value)
|
||||
(push (list i r) (first value)))
|
||||
|
||||
;; Join phase
|
||||
(loop for (i r) in *table-B* do
|
||||
(let ((val (car (gethash i *hash-table*))))
|
||||
(loop for (a b) in val do
|
||||
(format t "{~a ~a} {~a ~a}~%" a b i r))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue