<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>27891</integer>
    </number>
    <user>
      <string>jsnell</string>
    </user>
    <title>
      <string>basically like this</string>
    </title>
    <contents>
      <string>(defun create-lisp-mem ()
  (declare (optimize (speed 1)))
  (let ((files (directory (merge-pathnames #p&quot;download/training_set/*.*&quot;
                                           *root*)))
        (count 0))
    (with-open-file (map-file *map-file*
                              :direction :output
                              :if-exists :supersede
                              :element-type '(unsigned-byte 64))
      ;; Header
      (write-byte sb-vm::simple-array-unsigned-byte-60-widetag map-file)
      ;; Array size placeholder
      (write-byte 8 map-file)
      (dolist (file files)
        (print file)
        (with-open-file (stream file)
          (let ((index (parse-integer (read-line stream) :junk-allowed t)))
            (let ((lines (loop for line = (read-line stream nil nil)
                               while line
                               collect line)))
              (loop for line in lines
                    for i from 0
                    do (multiple-value-bind (uid end)
                           (parse-integer line :junk-allowed t)
                         (let* ((stars (parse-integer line
                                                      :start (1+ end)
                                                      :junk-allowed t))
                                (data
                                 (ash (logior uid
                                              (ash index 32)
                                              (ash stars (+ 32 16)))
                                      sb-vm::n-fixnum-tag-bits)))
                           (incf count)
                           (write-byte data map-file))))))))
      (file-position map-file 1)
      (write-byte (ash count sb-vm:n-fixnum-tag-bits)
                  map-file))
    (load-lisp-mem *map-file* '*ratings*)))

(defun load-lisp-mem (map-file variable)
  (with-open-file (file map-file)
    (let* ((sap (sb-posix:mmap nil
                               (file-length file)
                               sb-posix:prot-read
                               sb-posix:map-private
                               (sb-impl::fd-stream-fd file)
                               0))
           (addr (logior (sb-sys:sap-int sap)
                         sb-vm:other-pointer-lowtag)))
      (setf (symbol-value variable) (sb-kernel:make-lisp-obj addr))
      (values))))
</string>
    </contents>
    <universal-time>
      <integer>3369726490</integer>
    </universal-time>
    <channel>
      <string>#lisp</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </paste>
  <annotation>
    <number>
      <integer>1</integer>
    </number>
    <user>
      <string>msingh</string>
    </user>
    <title>
      <string>minor fix</string>
    </title>
    <contents>
      <string>;; use %make-lisp-obj instead of make-lisp-ojb

(setf (symbol-value variable) (sb-kernel:%make-lisp-obj addr)) </string>
    </contents>
    <universal-time>
      <integer>3417601803</integer>
    </universal-time>
    <channel>
      <string>#lisp</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
</paste-with-annotations>