 
 (defn datum-writer
   "Return an Avro DatumWriter which consumes Clojure data structures."
-  {:tag 'abracad.avro.ClojureDatumWriter}
+  {:tag `ClojureDatumWriter}
   ([] (ClojureDatumWriter.))
   ([schema] (ClojureDatumWriter. schema)))
 
 (defn data-file-writer
   "Return an Avro DataFileWriter which consumes Clojure data structures."
-  {:tag 'org.apache.avro.file.DataFileWriter}
+  {:tag `DataFileWriter}
   ([] (DataFileWriter. (datum-writer)))
-  ([sink] (doto (data-file-writer) (.appendTo (sink-for sink))))
-  ([schema sink] (data-file-writer nil schema sink))
+  ([sink]
+     (let [^DataFileWriter dfw (data-file-writer)]
+       (doto dfw (.appendTo (io/file sink)))))
+  ([schema sink]
+     (data-file-writer nil schema sink))
   ([codec schema sink]
-     (let [writer (data-file-writer)]
+     (let [^DataFileWriter writer (data-file-writer)]
        (when codec (.setCodec writer (codec-for codec)))
-       (.create writer schema (sink-for sink))
+       (if (instance? OutputStream)
+         (.create writer ^Schema schema ^OutputStream sink)
+         (.create writer ^Schema schema (io/file sink)))
        writer)))
 
 (defmacro ^:private encoder-factory


(defn binary-encoder
  "Return a binary-encoding encoder for `sink`."
  {:tag 'org.apache.avro.io.Encoder}
  [sink] (encoder-factory binaryEncoder sink nil))

(defn direct-binary-encoder
  "Return an unbuffered binary-encoding encoder for `sink`."
  {:tag 'org.apache.avro.io.Encoder}
  [sink] (encoder-factory directBinaryEncoder sink nil))

(defn json-encoder
  "Return a JSON-encoding encoder for `sink` using `schema`."
  {:tag 'org.apache.avro.io.Encoder}
  [schema sink] (encoder-factory jsonEncoder schema sink))

(defn encode
  "Serially encode each record in `records` to `sink` using `schema`.

            [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]
