Skip to content

Commit

Permalink
Fixing merge bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyczek committed Jul 27, 2011
1 parent c04cb98 commit d819d60
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ For more details see examples and unit tests.

### Leiningen

[simple-avro/simple-avro "0.0.4"]
[simple-avro/simple-avro "0.0.5"]

### Maven

<dependency>
<groupId>simple-avro</groupId>
<artifactId>simple-avro</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
</dependency>


Expand Down
16 changes: 6 additions & 10 deletions src/simple_avro/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@
GenericData$Record
GenericDatumWriter
GenericDatumReader)
(org.apache.avro.io JsonEncoder
BinaryEncoder
JsonDecoder
DecoderFactory)
(org.apache.avro.io DecoderFactory EncoderFactory)
(org.apache.avro.util Utf8)))


;
; Encoding
;
Expand Down Expand Up @@ -49,7 +45,7 @@

Schema$Type/ENUM (fn pack-enum [#^Schema schema obj]
(if-let [enum (some #{obj} (.getEnumSymbols schema))]
(GenericData$EnumSymbol. enum)
(GenericData$EnumSymbol. schema enum)
(throw-with-log "Enum does not define '" obj "'.")))

Schema$Type/UNION (fn pack-union [#^Schema schema obj]
Expand Down Expand Up @@ -114,15 +110,15 @@
(fn json-encoder-fn [#^Schema schema obj]
(encode-to schema obj
(fn [#^Schema schema #^ByteArrayOutputStream stream]
(JsonEncoder. schema stream))
(.jsonEncoder (EncoderFactory/get) schema stream))
(fn [#^ByteArrayOutputStream stream]
(.toString stream "UTF-8")))))

(def binary-encoder
(fn binary-encoder-fn [#^Schema schema obj]
(encode-to schema obj
(fn [#^Schema schema #^ByteArrayOutputStream stream]
(BinaryEncoder. stream))
(.binaryEncoder (EncoderFactory/get) stream nil))
(fn [#^ByteArrayOutputStream stream]
(.. stream toByteArray)))))

Expand Down Expand Up @@ -235,13 +231,13 @@
(decode-from schema obj
(fn decode-from-json [#^Schema schema #^String obj]
(let [is (ByteArrayInputStream. (.getBytes obj "UTF-8"))]
(JsonDecoder. schema is))))))
(.jsonDecoder (DecoderFactory/get) schema obj))))))

(def binary-decoder
(let [factory (DecoderFactory/defaultFactory)
decode-from-binary (fn decode-from-binary
[#^Schema schema #^bytes obj]
(.createBinaryDecoder factory obj nil))]
(.binaryDecoder factory obj nil))]
(fn binary-decoder-fn [#^Schema schema obj]
(decode-from schema obj decode-from-binary))))

Expand Down

0 comments on commit d819d60

Please sign in to comment.