Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-11973

Is MemoryUtil.getShort() supposed to return a sign-extended or non-sign-extended value?

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 2.2.8, 3.0.9, 3.8
    • Legacy/Core
    • None
    • Low

    Description

      In org.apache.cassandra.utils.memory.MemoryUtil.getShort(), the returned value of unsafe.getShort(address) is bit-wise-AND'ed with 0xffff, while that of getShortByByte(address) is not. This inconsistency results in different returned values when the short integer is negative. Which is preferred behavior? Looking at NativeClustering and NativeCellTest, it seems like non-sign-extension is assumed.

      By the way, is there any reason MemoryUtil.getShort() and MemoryUtil.getShortByByte() return "int", not "short"?

      Attachments

        1. 11973-2.2.txt
          1 kB
          Rei Odaira

        Activity

          People

            ReiOdaira Rei Odaira
            ReiOdaira Rei Odaira
            Rei Odaira
            Stefania Alborghetti
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: