Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. public static void insertEntitiesInGDM(Map<String, Map<String, Long>> frequencyOfTopFrequentItems,
  2. String fileName, long rowsCount) {
  3. List<Tuple2<String, Document>> docList = new LinkedList<Tuple2<String, Document>>();
  4. for (Entry<String, Map<String, Long>> entry : frequencyOfTopFrequentItems.entrySet()) {
  5. String columnName = entry.getKey();
  6. String datasetColumnKey = fileName.replace(".",",") + "|%#-#%|" + columnName;
  7. Map<String, Long> topFrequentMap = entry.getValue();
  8. for (Entry<String, Long> topFrequentEntry : topFrequentMap.entrySet()) {
  9. Integer topFrequentCount = topFrequentMap.entrySet().size();
  10. String entityName = topFrequentEntry.getKey();
  11. Long entityOccurrencies = topFrequentEntry.getValue();
  12. Document datasetAndColumnDocument = new Document("datasetAndColumn", datasetColumnKey);
  13. Document details = new Document("occurrencies", entityOccurrencies)
  14. .append("topFrequentCount", topFrequentCount);
  15. datasetAndColumnDocument.append("details", details);
  16. docList.add(new Tuple2<>(entityName, datasetAndColumnDocument));
  17.  
  18.  
  19. }
  20. }
  21. for (Tuple2<String, Document> element : docList) {
  22. MongoCollection<Document> entityCollection = GDMENTITYDATABASE.getCollection(element._1());
  23. entityCollection.insertOne(element._2());
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement