          lidx* []
          last-non-zero 0]
     (if (<= i largest-lidx-seen)
-      (let [l (nth lidx i)]
+      (let [l (long (nth lidx i))]
         (if (zero? l)
           (recur (inc i) (conj lidx* last-non-zero) last-non-zero)
           (recur (inc i) (conj lidx* l) l)))

                 (conj (pop chunks) l))
               (conj chunks achunk))
             (vector achunk)))))

(defn- init-linear-index []
  {:index (gen-vec max-lidx-size 0)

            ;; # of bins
            (lsb/write-int wtr (inc n-bin))
            (doseq [bin (:bins index)]
              (write-bin wtr (:bin bin) (:chunks bin)))
            ;; meta data
            (write-meta-data wtr (:meta index))))
        ;; linear index
