 
 (defn ^:private codec-for
   "Return Avro codec factory for `codec`."
-  {:tag 'org.apache.avro.file.CodecFactory}
+  {:tag `CodecFactory}
   [codec] (if-not (string? codec) codec (CodecFactory/fromString codec)))
 
-(defn ^:private sink-for
-  "Return sinkable endpoint for `sink`."
-  [sink] (if-not (string? sink) sink (io/file sink)))
+(defn ^:private source-for
+  "Return seekable input for `source`."
+  {:tag `SeekableInput}
+  [source]
+  (condp instance? source
+    SeekableInput source
+    File          (SeekableFileInput. ^File source)
+    String        (SeekableFileInput. (io/file source))))
 
 (defn ^:private raw-schema?
   "True if schema `source` should be parsed as-is."
   [source] (or (string? source) (instance? InputStream source)))
 
 (def ^:private primitive-types
-  (->> Schema$Type .getEnumConstants (map #(.getName %)) (into #{})))
+  "Set of Avro primitive type schema strings."
+  (->> Schema$Type .getEnumConstants
+       (map #(.getName ^Schema$Type %))
+       (into #{})))
 
 (defn ^:private named-schema?
   [^Schema schema] (-> schema .getFullName primitive-types not))
+
+(defn ^:private parse-schema*
+  [^Schema$Parser parser source]
+  (if (instance? String source)
+    (.parse parser ^String source)
+    (.parse parser ^InputStream source)))
 
 (defn parse-schema
   "Parse Avro schemas in `sources`.  Each schema source may be a JSON

                  (when (named-schema? source)
                    (.addTypes parser {(.getFullName ^Schema source) source})))
                (->> (if (raw-schema? source) source (clj->json source))
                     (.parse parser))))
            nil
            sources)))

(defn datum-reader
  "Return an Avro DatumReader which produces Clojure data structures."
  {:tag 'abracad.avro.ClojureDatumReader}
  ([] (ClojureDatumReader.))
  ([schema] (ClojureDatumReader. schema))
  ([expected actual] (ClojureDatumReader. expected actual)))

(defn data-file-reader
  "Return an Avro DataFileReader which produces Clojure data structures."
  {:tag 'org.apache.avro.file.DataFileReader}
  ([source] (data-file-reader nil source))
  ([expected source]
     (DataFileReader. (sink-for source) (datum-reader expected))))

(defmacro ^:private decoder-factory
  "Invoke static methods of default Avro Decoder factory."

            [clojure.walk :refer [postwalk]]
            [cheshire.core :as json]
            [abracad.avro.util :refer [returning mangle unmangle]])
  (:import [java.io
             ByteArrayOutputStream EOFException File InputStream OutputStream]
           [clojure.lang Named]
           [org.apache.avro Schema Schema$Parser Schema$Type]
           [org.apache.avro.file
             CodecFactory DataFileWriter DataFileReader SeekableInput
             SeekableFileInput]
           [org.apache.avro.io
             DatumReader DatumWriter Decoder DecoderFactory
             Encoder EncoderFactory]
