private void combineHistogramFromLegacyValue(STATS_TYPE statsType, EdgeValueBuilder builder, List<Long> combinedList, Value value) { if (STATS_TYPE.ACTIVITY == statsType) { List<Long> sourceList = EdgeValueHelper.decodeActivityHistogram(EdgeValueHelper.getVarLongList(value.get())); EdgeValueHelper.combineHistogram(sourceList, combinedList); builder.setHours(combinedList); } else if (STATS_TYPE.DURATION == statsType) { List<Long> sourceList = EdgeValueHelper.decodeDurationHistogram(EdgeValueHelper.getVarLongList(value.get())); EdgeValueHelper.combineHistogram(sourceList, combinedList); builder.setDuration(combinedList); } }
public static List<Long> decodeDurationHistogram(List<Long> durations) { List<Long> retLong = new ArrayList<>(DURATION_HISTOGRAM_LENGTH); retLong.addAll(durations); // check size of return list fillHistogramGaps(retLong, DURATION_HISTOGRAM_LENGTH); return retLong; }
/** * Creates a long[24] array and sets element N, where N is the hour of the day (0 - 23). The element will be set to 1 if deleteRecord is false, else -1. * * @param hour * @param delete * @return bytes of long[24] */ public static List<Long> getLongListForHour(int hour, boolean delete) { return initUnitList(ACTIVITY_HISTOGRAM_LENGTH, hour, delete); }
private void combineHistogram(STATS_TYPE statsType, EdgeValueBuilder builder, List<Long> combinedList, EdgeData.EdgeValue protoEdgeValue) { if (STATS_TYPE.ACTIVITY == statsType) { List<Long> sourceList = EdgeValueHelper.decodeActivityHistogram(protoEdgeValue.getHoursList()); EdgeValueHelper.combineHistogram(sourceList, combinedList); builder.setHours(combinedList); } else if (STATS_TYPE.DURATION == statsType) { List<Long> sourceList = EdgeValueHelper.decodeDurationHistogram(protoEdgeValue.getDurationList()); EdgeValueHelper.combineHistogram(sourceList, combinedList); builder.setDuration(combinedList); } }
public static List<Long> decodeDurationHistogram(Value value) { try { return decodeDurationHistogram(EdgeData.EdgeValue.parseFrom(value.get()).getDurationList()); } catch (InvalidProtocolBufferException e) { // Probably an old edge value return decodeDurationHistogram(getVarLongList(value.get())); } }
public static List<Long> decodeActivityHistogram(Value value) { try { return decodeActivityHistogram(EdgeData.EdgeValue.parseFrom(value.get()).getHoursList()); } catch (InvalidProtocolBufferException e) { // Probably an old edge value return decodeActivityHistogram(getVarLongList(value.get())); } }
switch (edgeKey.getStatsType()) { case ACTIVITY: edge.setCounts(EdgeValueHelper.decodeActivityHistogram(value)); break; case DURATION: edge.setCounts(EdgeValueHelper.decodeDurationHistogram(value)); break; case LINKS:
public static byte[] getByteArrayForHour(int hour, boolean delete) { return new VarLongArrayEncoder().encode(getLongListForHour(hour, delete)); }
public static byte[] getByteArrayForDuration(int elapsed, boolean deleteRecord) { return new VarLongArrayEncoder().encode(getLongListForDuration(elapsed, deleteRecord)); }
public Value getStatsActivityValue(boolean forwardEdge, EdgeKey.DATE_TYPE date_type) { EdgeValueBuilder builder = datawave.edge.util.EdgeValue.newBuilder(); int hour = -1; if (date_type == EdgeKey.DATE_TYPE.ACTIVITY_ONLY || date_type == EdgeKey.DATE_TYPE.ACTIVITY_AND_EVENT) { hour = getHour(activityDate); } else { hour = getHour(eventDate); } if (date_type == EdgeKey.DATE_TYPE.EVENT_ONLY) { if (validActivityDate) { builder.setBadActivityDate(false); } else { builder.setBadActivityDate(true); } } List<Long> hours = EdgeValueHelper.getLongListForHour(hour, this.isDeleting()); builder.setHours(hours); if (forwardEdge == true) { builder.setSourceValue(source.getValue(ValueType.EVENT)); } else { builder.setSourceValue(sink.getValue(ValueType.EVENT)); } builder.setLoadDate(loadDate); builder.setUuid(uuid); return builder.build().encode(); }
public Value getDurationAsValue(boolean forwardEdge) { EdgeValueBuilder builder = datawave.edge.util.EdgeValue.newBuilder(); List<Long> duration = EdgeValueHelper.getLongListForDuration(this.getDuration(), this.isDeleting()); builder.setDuration(duration); if (forwardEdge == true) { builder.setSourceValue(source.getValue(ValueType.EVENT)); } else { builder.setSourceValue(sink.getValue(ValueType.EVENT)); } builder.setLoadDate(loadDate); builder.setUuid(uuid); return builder.build().encode(); }
elapsed = 6; return initUnitList(DURATION_HISTOGRAM_LENGTH, elapsed, deleteRecord);
public static List<Long> decodeActivityHistogram(List<Long> hoursList) { List<Long> retLong = new ArrayList<>(ACTIVITY_HISTOGRAM_LENGTH); retLong.addAll(hoursList); fillHistogramGaps(retLong, ACTIVITY_HISTOGRAM_LENGTH); return retLong; }