Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-186

no clean way to getCompressionCodec from Java-the-language

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.7
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      The obvious thing fails:

      CompressionCodec.getCompressionCodec(1) results in cannot find symbol
      symbol : method getCompressionCodec(int)
      location: interface kafka.message.CompressionCodec

      Writing a switch statement with kafka.message.NoCompressionCodec$.MODULE$ and duplicating the logic in CompressionCodec.getCompressionCodec is no fun, nor is creating a Hashtable just to call Utils.getCompressionCodec. I'm not sure if there is a magic keyword to make it easy for javac to understand which CompressionCodec I'm referring to.

        Activity

        Hide
        junrao Jun Rao added a comment -

        We could just use kafka.message.NoCompression(). It's a static method.

        Also, it doesn't look like there is a constant defined for GzipCompressionCode in the message class.

        Show
        junrao Jun Rao added a comment - We could just use kafka.message.NoCompression(). It's a static method. Also, it doesn't look like there is a constant defined for GzipCompressionCode in the message class.
        Hide
        junrao Jun Rao added a comment -

        Actually, we should use kafka.message.NoCompressionCodec.codec() and kafka.message.GZIPCompressionCodec.codec(). Both are static methods.

        Show
        junrao Jun Rao added a comment - Actually, we should use kafka.message.NoCompressionCodec.codec() and kafka.message.GZIPCompressionCodec.codec(). Both are static methods.
        Hide
        cburroughs Chris Burroughs added a comment -

        That requires everyone to write their own switch statement though.

        Show
        cburroughs Chris Burroughs added a comment - That requires everyone to write their own switch statement though.
        Hide
        junrao Jun Rao added a comment -

        You only need do deal with the codec directly if you use SyncProducer. We recommend most people use Producer, in which compress level can be configured in the producer property.

        Show
        junrao Jun Rao added a comment - You only need do deal with the codec directly if you use SyncProducer. We recommend most people use Producer, in which compress level can be configured in the producer property.
        Hide
        jkreps Jay Kreps added a comment -

        Yes, agreed, I think we can definitely change this but the SyncProducer should be considered an internal class now. We should remove it from the docs with the 0.7 release as I think the Producer api can be either sync or async.

        Show
        jkreps Jay Kreps added a comment - Yes, agreed, I think we can definitely change this but the SyncProducer should be considered an internal class now. We should remove it from the docs with the 0.7 release as I think the Producer api can be either sync or async.
        Hide
        nehanarkhede Neha Narkhede added a comment -

        Chris,

        Based on the discussion above, do you feel like the code needs improvement ? If not, can we close this JIRA ?

        Show
        nehanarkhede Neha Narkhede added a comment - Chris, Based on the discussion above, do you feel like the code needs improvement ? If not, can we close this JIRA ?
        Hide
        omkreddy Manikumar added a comment -

        CompressionType Java class added in newer Kafka version.

        Show
        omkreddy Manikumar added a comment - CompressionType Java class added in newer Kafka version.

          People

          • Assignee:
            Unassigned
            Reporter:
            cburroughs Chris Burroughs
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development