Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Retrieve sub doc in a LinkedHashMap using Java MongoDB driver 3

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

I struggled a bit using with Java MongoDB driver 3 since it is a bit hard to find ressources that explains some advanced features.  

What I need is to get a document by its _id and then retrieve only the sub document "data" in a LinkedHashMap<Integer,BigDecimal>. The following code works but I feel there could be some optimization.

Do I really need 2 steps(see below) for this task? I have to process many thousands of Document containing a few hundred objects in each array.  Performance matters.

Here a sample of the Mongo DB Doc:



And my code:

MongoCollection<Document> collection = db.getCollection("filesdata");
 
Bob Speagle
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bump... Any advanced user of MongoDB driver 3?
 
    Bookmark Topic Watch Topic
  • New Topic