/** * Builds a list of row keys necessary to retrieve a profile's measurements over * a time horizon. * <p> * This method is useful when attempting to read ProfileMeasurements stored in HBase. * * @param profile The name of the profile. * @param entity The name of the entity. * @param groups The group(s) used to sort the profile data. * @param periods The profile measurement periods to compute the rowkeys for * @return All of the row keys necessary to retrieve the profile measurements. */ @Override public List<byte[]> rowKeys(String profile, String entity, List<Object> groups, Iterable<ProfilePeriod> periods) { List<byte[]> ret = new ArrayList<>(); for(ProfilePeriod period : periods) { ret.add(rowKey(profile, entity, period, groups)); } return ret; }
/** * Build the row key. * @param profile The name of the profile. * @param entity The name of the entity. * @param period The period in which the measurement was taken. * @param groups The groups. * @return The HBase row key. */ public byte[] rowKey(String profile, String entity, ProfilePeriod period, List<Object> groups) { return rowKey(profile, entity, period.getPeriod(), groups); }
/** * Builds a list of row keys necessary to retrieve profile measurements over * a time horizon. * * @param profile The name of the profile. * @param entity The name of the entity. * @param groups The group(s) used to sort the profile data. * @param start When the time horizon starts in epoch milliseconds. * @param end When the time horizon ends in epoch milliseconds. * @return All of the row keys necessary to retrieve the profile measurements. */ @Override public List<byte[]> rowKeys(String profile, String entity, List<Object> groups, long start, long end) { // be forgiving of out-of-order start and end times; order is critical to this algorithm long max = Math.max(start, end); start = Math.min(start, end); end = max; // find the starting period and advance until the end time is reached return ProfilePeriod.visitPeriods( start , end , periodDurationMillis , TimeUnit.MILLISECONDS , Optional.empty() , period -> rowKey(profile, entity, period, groups) ); }
/** * Builds the row key for a given profile measurement. * @param m The profile measurement. * @return The HBase row key. */ @Override public byte[] rowKey(ProfileMeasurement m) { return rowKey(m.getProfileName(), m.getEntity(), m.getPeriod(), m.getGroups()); }