Announcement Announcement Module
Collapse
No announcement yet.
MapReduceResults Throws ClassCaseException while convert counts to Integer Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MapReduceResults Throws ClassCaseException while convert counts to Integer

    hello.
    I use mapReduce method to do some querys. At first, I use 1.0.1 release and the source code segments throw a ClassCastException :
    Code:
     if (counts.get("input") != null && counts.get("emit") != null && counts.get("output") != null) {
    			return new MapReduceCounts((Integer) counts.get("input"), (Integer) counts.get("emit"),
    					(Integer) counts.get("output"));
    		}
    And 1.0.2 realse tells me that "* [DATAMONGO-378] - MapReduceResults ClassCastException due to raw results counts as Long" , so I think the new version has fixed this problem, and I upgrade, but the problem still exsits. I
    read the soure code, there is no different between 1.0.1 and 1.0.2.
    Does anyone know what is the problem?

  • #2
    Here's the commit that changed the handling in the 1.0.x branch [0]. According to Git it was released in 1.0.2:

    Code:
    $ git name-rev --name-only 11f0c515b013efcd99a471845c516d20e3c0b353
    tags/1.0.2.RELEASE~6
    What MongoDB version are you using? The map reduce results type has changed in 2.1.0 so whatever version you use - it migt affect the results. The change *is* in 1.0.2.RELEASE. So if you're not seeing any changes in the sources it might be the case that your dependency upgrade didn't complete (you still had 1.0.1.RELEASE in the classpath or the like). You also might wanna try upgrading to the latest 1.0.4.RELEASE.

    If all of that isn't working, please open a new ticket accompanied with a test case, the MongoDB version you use as well as the SD MongoDB library version.

    [0] https://github.com/SpringSource/spri...516d20e3c0b353

    Comment


    • #3
      Originally posted by Oliver Gierke View Post
      Here's the commit that changed the handling in the 1.0.x branch [0]. According to Git it was released in 1.0.2:

      Code:
      $ git name-rev --name-only 11f0c515b013efcd99a471845c516d20e3c0b353
      tags/1.0.2.RELEASE~6
      What MongoDB version are you using? The map reduce results type has changed in 2.1.0 so whatever version you use - it migt affect the results. The change *is* in 1.0.2.RELEASE. So if you're not seeing any changes in the sources it might be the case that your dependency upgrade didn't complete (you still had 1.0.1.RELEASE in the classpath or the like). You also might wanna try upgrading to the latest 1.0.4.RELEASE.

      If all of that isn't working, please open a new ticket accompanied with a test case, the MongoDB version you use as well as the SD MongoDB library version.

      [0] https://github.com/SpringSource/spri...516d20e3c0b353
      I manually download 1.0.2 realease version from this place : http://www.springsource.org/download/community, but find the source code is still not fixed. While the code in github is Ok "https://github.com/SpringSource/spring-data-mongodb/commit/11f0c515b013efcd99a471845c516d20e3c0b353".

      My mongoDB is 2.0.6

      Comment


      • #4
        The code on the download distribution, *is* exactly the one I've shown. In general, we recommend using a dependency management system and not manually download artifacts. So the bug is indeed fixed in 1.0.2.RELEASE.

        Comment


        • #5
          Thank you, I have got the right code, but my problem changed to another one : I got an ClassCastException when converting elements from counts :
          Code:
          return new MapReduceCounts((Integer) counts.get("input"), (Integer) counts.get("emit"),
          					(Integer) counts.get("output"));
          The exception tjava.lang.ClassCastException:
          Code:
          java.lang.Long cannot be cast to java.lang.Integer
          	at org.springframework.data.mongodb.core.mapreduce.MapReduceResults.parseCounts(MapReduceResults.java:125)
          	at org.springframework.data.mongodb.core.mapreduce.MapReduceResults.<init>(MapReduceResults.java:54)
          	at org.springframework.data.mongodb.core.MongoTemplate.mapReduce(MongoTemplate.java:1027)
          	at org.springframework.data.mongodb.core.MongoTemplate.mapReduce(MongoTemplate.java:982)
          I use MongoDB 2.0.6 and connect to a mogos fro sharding.

          Comment

          Working...
          X