/** * Parses edge table keys into the various fields encoded within the key. The source and sink are unescaped, ready to send to external clients. * * @param key * a key from the Datawave edge table * @return an immutable EdgeKey object */ public static EdgeKey decode(Key key) { return decode(key, EdgeKey.newBuilder().unescape()); }
public static EdgeKey swapSourceSink(EdgeKey swap) { EdgeKeyBuilder builder = newBuilder(swap); builder.setSourceData(swap.getSinkData()); builder.setSinkData(swap.getSourceData()); builder.setSourceRelationship(swap.getSinkRelationship()); builder.setSinkRelationship(swap.getSourceRelationship()); builder.setSourceAttribute1(swap.getSinkAttribute1()); builder.setSinkAttribute1(swap.getSourceAttribute1()); return builder.build(); }
/** * Determines if the edge key matches the desired date type.<br> * <strong>note:</strong> Some edges qualify as both an event and an activity edge. Hence, can't simply negate the return value of isEventEdge or * isActivityEdge. * * @param k * @param V * @return boolean - true if it is a match. */ @Override public boolean accept(Key k, Value V) { return (state[EdgeKey.getDateType(k).ordinal()]); }
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(); }
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 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(); }
/** * Creates the metadata table key entry for a given edge table Key * * @return a key object for use in the Datawave Metadata table */ public static Key getMetadataKey(Key key) { EdgeKey eKey = EdgeKey.decode(key); return eKey.getMetadataKey(); }
public String getAttribute1() { // return a relationship string based on the edge type. if ((this.getFormat() == EDGE_FORMAT.STANDARD) || ((getFormat() == EDGE_FORMAT.STATS) && this.getStatsType() == STATS_TYPE.LINKS)) { return getSourceAttribute1() + COL_SUB_SEPARATOR + getSinkAttribute1(); } return getSourceAttribute1(); }
/** * Determine as fast as possible the date type of an edge key without having to decode into and EdgeKey * * @param key * @return the date type of this accumulo edge key */ public static DATE_TYPE getDateType(Key key) { EdgeColumnParts parts = new EdgeColumnParts(key); EDGE_VERSION version = EDGE_VERSION.getEdgeVersion(parts); if (version == EDGE_VERSION.DATE_STATS_PROTOBUF) { return DATE_TYPE.parse(parts.get(8)); } else if (version == EDGE_VERSION.DATE_PROTOBUF) { return DATE_TYPE.parse(parts.get(6)); } else { return DATE_TYPE.OLD_EVENT; } } }
public static EdgeKeyBuilder newBuilder(EdgeKey.EDGE_FORMAT format) { EdgeKeyBuilder builder = EdgeKey.newBuilder(); return builder.setFormat(format); }
public String getRelationship() { // return a relationship string based on the edge type. if (this.getFormat() == EDGE_FORMAT.STANDARD) { return getSourceRelationship() + COL_SUB_SEPARATOR + getSinkRelationship(); } return getSourceRelationship(); }
protected static EdgeKey decode(Key key, EdgeKeyBuilder builder) { EdgeKeyDecoder edgeKeyDecoder = new EdgeKeyDecoder(); // to maintain method's static modifier return edgeKeyDecoder.decode(key, builder); }
public static EdgeKeyBuilder newBuilder(EdgeKey edgeKey) { return new EdgeKeyBuilder(edgeKey); }
/** * 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); }
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); }
public static EdgeValueBuilder newBuilder() { return new EdgeValueBuilder(); }
public boolean isStatsKey() { return (this.getFormat() == EDGE_FORMAT.STATS); }
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 EdgeKeyBuilder newBuilder() { return new EdgeKeyBuilder(); }