Skip to content

Conversation

@dmytro-grankin
Copy link
Contributor

@dmytro-grankin dmytro-grankin commented Oct 13, 2017

Storage of Aggregate event records stores event enrichments, that aren't needed and take a lot of space.

To fix this behavior, AggregateStorage.writeEvent(...) method was changed and now it clears enrichments from the event context and the enrichment from the first-level origin of the specified event. But the event will still contain enrichments from second-level and deeper origins, because their removal is a heavy performance operation.

Other changes:

  • EEntity was fixed. Now, it removes only enrichments from an event.
  • GivenEnrichment utility was introduced.
  • The framework version was increased to 0.9.78-SNAPSHOT.

@codecov
Copy link

codecov bot commented Oct 13, 2017

Codecov Report

Merging #602 into master will increase coverage by 0.02%.
The diff coverage is 93.93%.

@@             Coverage Diff              @@
##             master     #602      +/-   ##
============================================
+ Coverage     92.83%   92.86%   +0.02%     
- Complexity     2730     2732       +2     
============================================
  Files           329      330       +1     
  Lines          9377     9387      +10     
  Branches        625      625              
============================================
+ Hits           8705     8717      +12     
+ Misses          490      489       -1     
+ Partials        182      181       -1

@dmytro-grankin dmytro-grankin self-assigned this Oct 13, 2017
@dmytro-grankin dmytro-grankin requested a review from armiol October 13, 2017 12:50
@dmytro-grankin
Copy link
Contributor Author

@armiol PTAL.

Copy link
Contributor

@armiol armiol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmytro-grankin please see my comments. Also, as discussed, please mention that enrichments are only cleared from the first level of origins.

case ORIGIN_NOT_SET:
// Does nothing because there is no origin for this event.
break;
default:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as this method is public this branch can be tested. Please do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It cannot be tested even with using of reflection.

switch (originCase) {
case EVENT_CONTEXT:
resultContext.setEventContext(context.getEventContext()
.toBuilder()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, do not clear this. And please mention that in docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

public static Enrichment enabledEnrichment() {
final String key = newUuid();
final Any value = pack(toMessage(newUuid()));
return Enrichment.newBuilder()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a result for such a complex expression before returning it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@dmytro-grankin
Copy link
Contributor Author

@armiol PTAL.

@SpineEventEngine SpineEventEngine deleted a comment Oct 13, 2017
@SpineEventEngine SpineEventEngine deleted a comment Oct 13, 2017
@SpineEventEngine SpineEventEngine deleted a comment Oct 13, 2017
Copy link
Contributor

@armiol armiol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmytro-grankin LGTM for the most part. See the comments.


/**
* Creates a non-{@linkplain io.spine.validate.Validate#isDefault(com.google.protobuf.Message)
* default} {@link Enrichment}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please describe what's in there. And then you'll be able to remove this "non-default" phrase.

import static io.spine.protobuf.TypeConverter.toMessage;

/**
* Factory methods to create {@code Enrichment} instances for test purposes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in test purposes.

Copy link
Contributor

@armiol armiol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmytro-grankin please also see one more comment.

return context.getExternal();
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss this description. Right now the name of the method does not correspond with it.

In particular, the description says that this is a procedure one would do before storing an event. And the rest of the content is about enrichments. So to me it looks more like a clearEnrichments() method. And even so I would adjust a few things.

However, we can stay with compact(). I like the name and the idea behind this name. However, there should be a more generic description, that this one.

Let's discuss this change.

@dmytro-grankin
Copy link
Contributor Author

@armiol PTAL.

@SpineEventEngine SpineEventEngine deleted a comment Oct 16, 2017
@dmytro-grankin
Copy link
Contributor Author

@armiol PTAL.

@SpineEventEngine SpineEventEngine deleted a comment Oct 16, 2017
Copy link
Contributor

@armiol armiol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmytro-grankin LGTM with the exception of two comments to address before merge.

default:
throw newIllegalStateException("Unsupported origin case is encountered: %s",
originCase);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract a result variable.

public class GivenEnrichment {

private GivenEnrichment() {
// Prevent instantiation of this utility class.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reformat in a way Events utility does that.

@SpineEventEngine SpineEventEngine deleted a comment Oct 17, 2017
@dmytro-grankin dmytro-grankin merged commit d87cc9a into master Oct 17, 2017
@dmytro-grankin dmytro-grankin deleted the aggregate-storage-events-compacting branch October 17, 2017 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants