/** * Determines the oldest load date and updates the builder with it * * @param builder * will be updated by this method with the oldest load date * @param protoEdgeValue * the current value, decoded */ private void useEarliestLoadDate(Key key, EdgeValueBuilder builder, EdgeData.EdgeValue protoEdgeValue) { String loadDate = builder.getLoadDate(); if (protoEdgeValue.hasLoadDate()) { if (null == loadDate || loadDate.compareTo(protoEdgeValue.getLoadDate()) > 0) { builder.setLoadDate(protoEdgeValue.getLoadDate()); } } else if (null == loadDate) { builder.setLoadDate(getDateFromKey(key)); } }
private void combineSourceAndSink(EdgeValueBuilder builder, EdgeData.EdgeValue protoEdgeValue) { if (StringUtils.isBlank(builder.getSourceValue()) && protoEdgeValue.hasSourceValue()) { builder.setSourceValue(protoEdgeValue.getSourceValue()); } if (StringUtils.isBlank(builder.getSinkValue()) && protoEdgeValue.hasSinkValue()) { builder.setSinkValue(protoEdgeValue.getSinkValue()); } }
EdgeValueBuilder builder = new EdgeValueBuilder(); if (proto.hasCount()) { builder.setCount(proto.getCount()); } else { builder.setCount(0l); builder.setBitmask(proto.getHourBitmask()); builder.setSourceValue(proto.getSourceValue()); builder.setSinkValue(proto.getSinkValue()); builder.setHours(hoursList); builder.setDuration(durationList); builder.setLoadDate(proto.getLoadDate()); builder.setOnlyUuidString(false); builder.setUuidObj(proto.getUuid()); } else if (proto.hasUuidString()) { builder.setOnlyUuidString(true); builder.setUuid(proto.getUuidString()); builder.setBadActivityDate(proto.getBadActivity()); return builder.build();
builder.setBadActivityDate(false); } else { builder.setBadActivityDate(true); builder.setCount(1l); } else { builder.setCount(-1l); builder.setHour(hour); builder.setSourceValue(source.getValue(ValueType.EVENT)); builder.setSinkValue(sink.getValue(ValueType.EVENT)); } else { builder.setSourceValue(sink.getValue(ValueType.EVENT)); builder.setSinkValue(source.getValue(ValueType.EVENT)); builder.setLoadDate(loadDate); builder.setUuid(uuid); return builder.build().encode();
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(); }
private Value combineStatsKey(STATS_TYPE statsType, Key key, Iterator<Value> iter) { // If this is a STATS link count edge, merge all the values into a single one. if (STATS_TYPE.LINKS == statsType) { return (StatsLinksEdgeCombiner.combineStatsLinksEdgeValues(key, iter)); } EdgeValueBuilder builder = EdgeValue.newBuilder(); List<Long> combinedList = new ArrayList<>(); while (iter.hasNext()) { Value value = iter.next(); try { EdgeData.EdgeValue protoEdgeValue = EdgeData.EdgeValue.parseFrom(value.get()); useEarliestLoadDate(key, builder, protoEdgeValue); combineSourceAndSink(builder, protoEdgeValue); useEarliestUuid(builder, protoEdgeValue); combineBadActivityDate(builder, protoEdgeValue); combineHistogram(statsType, builder, combinedList, protoEdgeValue); // already decoded the value } catch (InvalidProtocolBufferException e) { // value wasn't previously a protobuf, so we don't get the source or sink // combine the stats hours/duration with the raw value combineHistogramFromLegacyValue(statsType, builder, combinedList, value); } } return builder.build().encode(); }
private void combineBadActivityDate(EdgeValueBuilder builder, EdgeData.EdgeValue protoEdgeValue) { // Only set the bad activity flag if one of the edges to be combined contains the bad activity flag. // This should only happen with the new EVENT_ONLY date type edges if (protoEdgeValue.hasBadActivity()) { if (builder.badActivityDateSet()) { // If one of the activity dates is good then the edge will be treated as good // They all must be bad for it to be treated as a bad activity date. builder.setBadActivityDate(builder.isBadActivityDate() && protoEdgeValue.getBadActivity()); } else { builder.setBadActivityDate(protoEdgeValue.getBadActivity()); } } } }
private void useEarliestUuid(EdgeValueBuilder builder, EdgeData.EdgeValue protoEdgeValue) { // Keeps overriding value of 'uuid' so the last(earliest) one will always be used // the value corresponding to the key with the most recent timestamp will come first // the value corresponding to the key with the oldest timestamp will come last if (protoEdgeValue.hasUuid()) { // previously, we took uuid from proto.EdgeValue, converted it to UUID, then to String // then when encoding we converted it back to a UUID and then into a UUID builder builder.setUuidObj(protoEdgeValue.getUuid()); builder.setOnlyUuidString(false); } else if (protoEdgeValue.hasUuidString()) { builder.setOnlyUuidString(true); builder.setUuid(protoEdgeValue.getUuidString()); } }
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(); }
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); } }
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); } }