 (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 #{})))
+
+(defn ^:private named-schema?
+  [^Schema schema] (-> schema .getFullName primitive-types not))
 
 (defn parse-schema
   "Parse Avro schemas in `sources`.  Each schema source may be a JSON

    (reduce (fn [_ source]
              (if (instance? Schema source)
                (returning source
                  (.addTypes parser {(.getFullName ^Schema source) source}))
                (->> (if (raw-schema? source) source (clj->json source))
                     (.parse parser))))
            nil

            [abracad.avro.util :refer [returning mangle unmangle]])
  (:import [java.io ByteArrayOutputStream InputStream EOFException]
           [clojure.lang Named]
           [org.apache.avro Schema Schema$Parser Schema$Type]
           [org.apache.avro.file CodecFactory DataFileWriter DataFileReader]
           [org.apache.avro.io
             DatumReader DatumWriter Decoder DecoderFactory
