/** * Returns a boolean array with the decoded hourly activity from the Value's bitmask. * * @param value * @return the hourly activity * @throws InvalidProtocolBufferException */ public static boolean[] decodeHourlyActivityToBooleanArray(Value value) throws InvalidProtocolBufferException { boolean[] hourlyActivity = new boolean[24]; EdgeValue edgeValue = EdgeValue.decode(value); if (null != edgeValue) { int bitmask = edgeValue.getBitmask(); if (bitmask != 0) {// if the protobuff did not include a value no point parsing nulls out. byte[] bytes = ByteBuffer.allocate(4).putInt(bitmask).array(); for (int i = 0; i < 24; i++) { hourlyActivity[i] = (getBitInBitmask(bytes, i)) == 1; } } } return hourlyActivity; }
private EdgeValueBuilder(EdgeValue edgeValue) { this.count = edgeValue.getCount(); this.bitmask = edgeValue.getBitmask(); this.sourceValue = edgeValue.getSourceValue(); this.sinkValue = edgeValue.getSinkValue(); this.hours = edgeValue.getHours(); this.duration = edgeValue.getDuration(); this.loadDate = edgeValue.getLoadDate(); this.hasOnlyUuidString = edgeValue.hasOnlyUuidString; this.uuidObj = edgeValue.getUuidObject(); this.uuidString = edgeValue.getUuid(); }
public EdgeValue build() { return new EdgeValue(this.count, this.bitmask, this.sourceValue, this.sinkValue, this.hours, this.duration, this.loadDate, this.uuidString, this.hasOnlyUuidString, this.uuidObj, this.badActivityDate); }
edgeValue = EdgeValue.decode(value); edge.setSource(edgeValue.getSourceValue()); edge.setSink(edgeValue.getSinkValue()); if (edgeValue.hasLoadDate()) { edge.setLoadDate(edgeValue.getLoadDate()); } else { edge.setLoadDate(edgeKey.getYyyymmdd()); edge.setCount(edgeValue.getCount());
public Value encode() { Builder builder = EdgeData.EdgeValue.newBuilder(); if (this.hasCount()) { builder.setCount(this.getCount()); } else { builder.setCount(0l); if (this.hasBitmask()) { builder.setHourBitmask(this.getBitmask()); } else if (StringUtils.isNotBlank(this.uuidString)) { try { // try to parse the uuid string to a UUID object this.uuidObj = convertUuidStringToUuidObj(this.uuidString); builder.setUuid(this.uuidObj); } catch (Exception e) {
EdgeValue value = EdgeValue.decode(V); if (value.hasLoadDate()) { loadDate = value.getLoadDate(); } else { loadDate = extractEventDate(k);
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(); }
public static String getPrintableValue(final Value value) { if ((value != null) && (value.getSize() > 0)) { try { final Uid.List uidList = Uid.List.parseFrom(value.get()); return (uidList.getUIDList().toString()); } catch (final InvalidProtocolBufferException e1) { try { return (ReflectionToStringBuilder.toString(EdgeValue.decode(value), ToStringStyle.SHORT_PREFIX_STYLE)); } catch (final Exception e2) { try { final ExtendedHyperLogLogPlus ehllp = new ExtendedHyperLogLogPlus(value); return (String.valueOf(ehllp.getCardinality())); } catch (final Exception e3) { logger.error("Could not deserialize protobuff" + e2); } } } } return (""); } }
public EdgeData.EdgeValue.UUID getUuidObject() { if (this.hasOnlyUuidString) { return null; } if (null == uuidObj && StringUtils.isNotBlank(this.uuidString)) { try { // try to parse the uuid string to a UUID object this.uuidObj = convertUuidStringToUuidObj(this.uuidString); } catch (Exception e) { // if it failed to parse, settle for the uuid_string this.hasOnlyUuidString = true; } } return uuidObj; }
public String getUuid() { // if human readable string is missing, attempt to create one from the uuidObj if ((null == this.uuidString || this.uuidString.isEmpty()) && null != this.uuidObj) { this.uuidString = convertUuidObjectToString(this.uuidObj); } return this.uuidString; }
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(); }
public EdgeData.EdgeValue.UUID getUuidObj() { if (this.hasOnlyUuidString) { return null; } if (null == uuidObj && StringUtils.isNotBlank(this.uuidString)) { try { // try to parse the uuid string to a UUID object this.uuidObj = convertUuidStringToUuidObj(this.uuidString); } catch (Exception e) { // if it failed to parse, settle for the uuid_string this.hasOnlyUuidString = true; } } return uuidObj; }
private Value combineStandardKey(Key key, Iterator<Value> iter) { EdgeValueBuilder builder = EdgeValue.newBuilder(); int combineCount = 0; while (iter.hasNext()) { 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(); }
public Value getEdgeValue(boolean forwardEdge, EdgeKey.DATE_TYPE date_type) { EdgeValueBuilder builder = datawave.edge.util.EdgeValue.newBuilder(); int hour = -1; return builder.build().encode();