Uploaded image for project: 'Pig'
  1. Pig
  2. PIG-5300

hashCode for Bag needs to be order independent

    Details

    • Type: Bug
    • Status: Patch Available
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      This is a follow up from PIG-5041 where Daniel Dai and others discussed about

      Anyway, the bag as the key is a different issue. Need to address separately. Maybe we can write a hashcode which is order independent.

        Activity

        Hide
        knoguchi Koji Noguchi added a comment -

        Attaching my first try, pig-5300-v01.patch.

        This change will update

         DefaultDataBag
         DistinctDataBag
         InternalCachedBag
         InternalDistinctBag
         InternalSortedBag
         SortedDataBag
        

        which extends from DefaultAbstractBag and also
        SingleTupleBag and NonSpillableDataBag which have their own implementation of DataBag.

        NOT touching AccumulativeBag, LimitedSortedDataBag and ReadOnceBag in the belief that they will not be used in hashcode/equals/compareTo. At the same time, I didn't have the courage to throw Exceptions from them.

        Also added hashcode method to DataBag interface just for documentation purposes. (Just like Map interface in Java.) Also added null check for "equals" calls since java api documents that they should return false (and not throw NPE).

        Show
        knoguchi Koji Noguchi added a comment - Attaching my first try, pig-5300-v01.patch . This change will update DefaultDataBag DistinctDataBag InternalCachedBag InternalDistinctBag InternalSortedBag SortedDataBag which extends from DefaultAbstractBag and also SingleTupleBag and NonSpillableDataBag which have their own implementation of DataBag. NOT touching AccumulativeBag , LimitedSortedDataBag and ReadOnceBag in the belief that they will not be used in hashcode/equals/compareTo. At the same time, I didn't have the courage to throw Exceptions from them. Also added hashcode method to DataBag interface just for documentation purposes. (Just like Map interface in Java.) Also added null check for "equals" calls since java api documents that they should return false (and not throw NPE).
        Hide
        knoguchi Koji Noguchi added a comment -

        Tests passed. Making it patch available.

        Daniel Dai, appreciate if you could take a look when you have time.

        Show
        knoguchi Koji Noguchi added a comment - Tests passed. Making it patch available. Daniel Dai , appreciate if you could take a look when you have time.
        Hide
        rohini Rohini Palaniswamy added a comment -

        +1. Daniel Dai, can you please take a look as well?

        Show
        rohini Rohini Palaniswamy added a comment - +1. Daniel Dai , can you please take a look as well?

          People

          • Assignee:
            knoguchi Koji Noguchi
            Reporter:
            knoguchi Koji Noguchi
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Development