                               dep (when dep (get @data-types dep))
                               reader (or reader (get dep :reader))
                               reader (if decoder (comp decoder reader) reader)
-                              length (or length (calc-dynamic-field-length trunk unit-length (.getCurrLoc cell-reader)))]
+                              length (or length (calc-dynamic-type-length trunk unit-length (.getCurrLoc cell-reader)))]
                           (.streamRead cell-reader reader length))])
                      (:f schema)))
                  {:*schema* schema-id

(defn mark-cell-deleted [trunk cell-loc data-length]
  (add-frag trunk cell-loc (dec (+ cell-loc cell-head-len data-length))))

(defn calc-dynamic-field-length [trunk unit-length field-loc]
  (+ (* (reader/readInt trunk field-loc)
        unit-length)
     type_lengths/intLen))

(defn calc-trunk-cell-length [^trunk trunk ^Long cell-loc schema]
  (let [cell-data-loc (+ cell-loc cell-head-len)
        cell-reader (cellReader. trunk cell-data-loc)]
    (reduce + (map
                (fn [[_ data-type]]
                  (let [{:keys [unit-length length]} (get @data-types data-type)
                        field-length (or length (calc-dynamic-field-length trunk unit-length (.getCurrLoc cell-reader)))]
                    (.advancePointer cell-reader field-length)
                    field-length))
                (:f schema)))))

(defn delete-cell [^trunk trunk ^Long hash]

(ns neb.cell
  (:require [neb.types :refer [data-types]]
            [neb.schema :refer [schema-store schema-by-id schema-id-by-sname]]
            [cluster-connector.utils.for-debug :refer [spy $]])
  (:import (org.shisoft.neb trunk schemaStore)
           (org.shisoft.neb.io cellReader cellWriter reader type_lengths cellMeta)))
