private void propertyHourWeekTimeWindow( JsonNode businessObj, JsonNode checkinInfoObj, String category) throws JsonGenerationException, JsonMappingException, IOException { /* e.g.: checkinInfoObj: {"9-5":1,"7-5":1,"13-3":1,"17-6":1,"13-0":1,"17-3":1,"10-0":1,"18-4":1,"14-6":1} iterate through checkinInfoObj and get all of the <keyTimeWindow,valueCount> pairs, and generate the GeoJSONBusinessFeature object of each pair */ Iterator<Map.Entry<String, JsonNode>> checkinInfoFields = checkinInfoObj.fields(); while (checkinInfoFields.hasNext()) { Map.Entry<String, JsonNode> checkinInfoField = checkinInfoFields.next(); String keyTimeWindow = checkinInfoField.getKey(); JsonNode valueCount = checkinInfoField.getValue(); // System.out.println(keyTimeWindow+": "+valueCount); String wholeKey = businessObj.get("state").asText() + ":" + businessObj.get("city").asText() + ":" + category + ":" + keyTimeWindow; String wholeValue = businessObj.get("business_id").asText() + ":" + valueCount.asText(); System.out.println(wholeKey + " <----> " + wholeValue); ObjectMapper businessCountMapper = new ObjectMapper(); Map<String, String> businessCountMap = new HashMap<String, String>(); businessCountMap.put(businessObj.get("business_id").asText(), valueCount.asText()); String businessCountMapValue = businessCountMapper.writeValueAsString(businessCountMap); jedis.set(wholeKey, businessCountMapValue); } };
private void getStateCityCategoryHourWeekBusinessMapping() throws IOException { BufferedReader br = new BufferedReader(new FileReader(checkinFilePath)); ObjectMapper checkInMapper = new ObjectMapper(); try { String line = br.readLine(); while (line != null) { JsonNode checkInObj = checkInMapper.readTree(line); line = br.readLine(); // get checkin info for each business_id in yelp_academic_dataset_checkin.json JsonNode businessID = checkInObj.get("business_id"); String businessInfo = jedis.get(businessID.asText()); if (businessInfo != null) { // fetch business Info from Redis and map the string result to JSON ObjectMapper businessInfoMapper = new ObjectMapper(); JsonNode businessObj = businessInfoMapper.readTree(businessInfo); // Get chech-in info JsonNode checkinInfoObj = checkInObj.get("checkin_info"); this.propertyCategory(businessObj, checkinInfoObj); } else { logWriter.print("\nCan't get info for business " + businessID.asText()); } } } finally { br.close(); } }