public static void insertPost(Post post, String type) { try { String postId = post.getId(); IdNameEntity idNameEntity = post.getFrom(); String userId = idNameEntity.getId(); String userName = idNameEntity.getName(); String commentsCount = post.getComments() == null ? "0" : post.getComments().size() + ""; String likeCount = post.getLikes() == null ? "0" : post.getLikes().size() + ""; String columnFamily = COLUMN_FAMILY_FACEBOOK_POST; String rowKey = type; String superColumn = postId + "-" + userId + "-" + userName; Clock clock = new Clock(System.nanoTime()); Column column = new Column(); String columnName = commentsCount + "-" + likeCount; column.setName(columnName.getBytes(UTF8)); String columnValue = post.getMessage(); if (!StringUtils.isBlank(columnValue)) { column.setValue(columnValue.getBytes(UTF8)); } else { column.setValue("".getBytes(UTF8)); } column.setTimestamp(clock.timestamp); cassandra.insertSuperColumn(columnFamily, rowKey, superColumn, column); } catch (UnsupportedEncodingException e) { logger.error("[Info: encoding invalid] - [Error: {}]", e.toString()); } }