{"action":"created","issue":{"url":"https://api.github.com/repos/julianpeeters/avro-scala-macro-annotations/issues/1","labels_url":"https://api.github.com/repos/julianpeeters/avro-scala-macro-annotations/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/julianpeeters/avro-scala-macro-annotations/issues/1/comments","events_url":"https://api.github.com/repos/julianpeeters/avro-scala-macro-annotations/issues/1/events","html_url":"https://github.com/julianpeeters/avro-scala-macro-annotations/issues/1","id":34721343,"number":1,"title":"make schema accessible from the companion object of the annotated class","user":{"login":"julianpeeters","id":589614,"avatar_url":"https://avatars.githubusercontent.com/u/589614?v=3","gravatar_id":"","url":"https://api.github.com/users/julianpeeters","html_url":"https://github.com/julianpeeters","followers_url":"https://api.github.com/users/julianpeeters/followers","following_url":"https://api.github.com/users/julianpeeters/following{/other_user}","gists_url":"https://api.github.com/users/julianpeeters/gists{/gist_id}","starred_url":"https://api.github.com/users/julianpeeters/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julianpeeters/subscriptions","organizations_url":"https://api.github.com/users/julianpeeters/orgs","repos_url":"https://api.github.com/users/julianpeeters/repos","events_url":"https://api.github.com/users/julianpeeters/events{/privacy}","received_events_url":"https://api.github.com/users/julianpeeters/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/julianpeeters/avro-scala-macro-annotations/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/julianpeeters/avro-scala-macro-annotations/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2014-06-01T04:25:34Z","updated_at":"2015-04-15T07:18:24Z","closed_at":null,"body":"If we just need to get the schema of an annotated class, currently we have to construct an object like `MyRecord(1).getSchema`.  It would be nice to be able to just say `MyRecord.getSchema` or `MyRecord.schema`"},"comment":{"url":"https://api.github.com/repos/julianpeeters/avro-scala-macro-annotations/issues/comments/93233020","html_url":"https://github.com/julianpeeters/avro-scala-macro-annotations/issues/1#issuecomment-93233020","issue_url":"https://api.github.com/repos/julianpeeters/avro-scala-macro-annotations/issues/1","id":93233020,"user":{"login":"julianpeeters","id":589614,"avatar_url":"https://avatars.githubusercontent.com/u/589614?v=3","gravatar_id":"","url":"https://api.github.com/users/julianpeeters","html_url":"https://github.com/julianpeeters","followers_url":"https://api.github.com/users/julianpeeters/followers","following_url":"https://api.github.com/users/julianpeeters/following{/other_user}","gists_url":"https://api.github.com/users/julianpeeters/gists{/gist_id}","starred_url":"https://api.github.com/users/julianpeeters/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julianpeeters/subscriptions","organizations_url":"https://api.github.com/users/julianpeeters/orgs","repos_url":"https://api.github.com/users/julianpeeters/repos","events_url":"https://api.github.com/users/julianpeeters/events{/privacy}","received_events_url":"https://api.github.com/users/julianpeeters/received_events","type":"User","site_admin":false},"created_at":"2015-04-15T07:18:24Z","updated_at":"2015-04-15T07:18:24Z","body":"Turns out this will also fix a bug that prevents annotated case classes from being easily used as avro records when the avros are read as a stream:\r\n\r\n\" When deserializing from a stream, the Avro reader expects the read-mark to point to the schema. If we use a GenericRecord reader to read in the schema first, the read-mark points to the records so the read-mark needs to be reset (and the stream needs to allow it).  \r\nFor some reason this does not seem to be an issue when reading from Files.\"\r\n\r\n- Raj Kumar\r\n\r\nCurrent workaround from Raj Kumar:\r\n\r\n    def deserialize[R]( is: InputStream): Iterator[R] = {\r\n        val bis = if( is.markSupported ) is\r\n                  else new BufferedInputStream( is )\r\n        bis.mark( MAX_SCHEMA_SIZE )\r\n        val schema = new DataFileStream( bis, new GenericDatumReader[R]).getSchema\r\n        bis.reset\r\n        val dr = new SpecificDatumReader[R]( schema )\r\n        val dfr= new DataFileStream[R]( bis, dr)\r\n        dfr.iterator\r\n      }\r\n\r\nAgain, the bug and the workaround will be obviated when SCHEMA$ is introduced as a field of the companion object of the avro record case class, a la:\r\n\r\n    val schema = MyRecord.SCHEMA$\r\n    def deserialize[R]( schema: Schema, is: InputStream): Iterator[R] = {\r\n        val dr = new SpecificDatumReader[R]( schema )\r\n        val dfr= new DataFileStream[R]( bis, dr)\r\n        dfr.iterator\r\n      }\r\n"}}