Skip to content

MINOR: code cleanup#6053

Merged
mjsax merged 2 commits intoapache:trunkfrom
mjsax:minor-code-cleanup-main
Jan 9, 2019
Merged

MINOR: code cleanup#6053
mjsax merged 2 commits intoapache:trunkfrom
mjsax:minor-code-cleanup-main

Conversation

@mjsax
Copy link
Copy Markdown
Member

@mjsax mjsax commented Dec 20, 2018

While working on #6044, I did code cleanup on the side. Extracted parts of those cleanups into this PR for easier review. This PR should not change any behavior, but do:

  • Java8 rewrites
  • removed unused classed
  • remove warnings
  • break long lines that are hard to read into short lines
  • some code re-formatting
  • JavaDoc improvements

Only change is a dependency change, that I need for #6044, and will make reviewing PRs for KIP-258 simpler.

@mjsax mjsax added the streams label Dec 20, 2018
Copy link
Copy Markdown
Member Author

@mjsax mjsax left a comment

Choose a reason for hiding this comment

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

Call for review @guozhangwang @bbejeck @vvcephei

try {
if (getTime.shouldRecord()) {
return measureLatency(() -> outerValue(inner.get(Bytes.wrap(serdes.rawKey(key)))), getTime);
return measureLatency(() -> outerValue(inner.get(keyBytes(key))), getTime);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Extracted into it's own method, to align with code of other stores.

This was referenced Dec 20, 2018
Copy link
Copy Markdown
Member

@bbejeck bbejeck left a comment

Choose a reason for hiding this comment

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

Just one clarifying question, LGTM otherwise.

this.map = new TreeMap<>();
}

public KeyValueStore<K, V> enableLogging() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this mean we won't have logging for in-memory key-value stores?

Copy link
Copy Markdown
Member Author

@mjsax mjsax Dec 21, 2018

Choose a reason for hiding this comment

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

No. This is old code before the state store refactoring via KIP-182. Both, persistent and in-memory key-value store are wrapped with ChangeLoggingKeyValueBytesStore since then, and this method is not called anywhere anymore, and thus the class is not used any longer. Compare Stores and KeyValueStoreBuilder.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the clarification. I noticed after I checked out the PR that the enableLogging call was not used at all. I guess I missed that during KIP-182.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 Thanks for the catch.

Copy link
Copy Markdown
Contributor

@vvcephei vvcephei left a comment

Choose a reason for hiding this comment

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

LGTM for the most part! Thanks for cleaning all this up.

Comment thread gradle/dependencies.gradle Outdated
joptSimple: "net.sf.jopt-simple:jopt-simple:$versions.jopt",
junit: "junit:junit:$versions.junit",
hamcrest: "org.hamcrest:hamcrest-all:1.3",
hamcrest: "org.hamcrest:java-hamcrest:$versions.hamcrest",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

According to http://hamcrest.org/JavaHamcrest/distributables,
it seems like this should be org:hamcrest:hamcrest:2.1.

But I haven't followed the history of the project. Can you elaborate on the choice of hamcrest-java and 2.0.0.0?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah. Good catch. I was checking for hamcrast-all versions and there was no newer one available and was not aware the there is hamcrast, too.

final Set<Pattern> sourcePatterns = new HashSet<>();
final Set<SourceNodeFactory> sourceNodesForPredecessor = findSourcesForProcessorPredecessors(processorNodeFactory.predecessors);
final Set<SourceNodeFactory> sourceNodesForPredecessor
= findSourcesForProcessorPredecessors(processorNodeFactory.predecessors);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: seems a little weird to put the assignment operator at the start of this line instead of the end of the previous one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree -- typically only +/- between terms of an expression start a new line

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I like it better this way, but I don't care too much either. Will update accordingly.

if (!stateChangelogTopics.containsKey(topicName)) {
final InternalTopicConfig internalTopicConfig = createChangelogTopicConfig(stateFactory, topicName);
final InternalTopicConfig internalTopicConfig
= createChangelogTopicConfig(stateFactory, topicName);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same comment

private void adjust(final StreamsConfig config) {
final boolean enableOptimization20 = config.getString(StreamsConfig.TOPOLOGY_OPTIMIZATION).equals(StreamsConfig.OPTIMIZE);
final boolean enableOptimization20
= config.getString(StreamsConfig.TOPOLOGY_OPTIMIZATION).equals(StreamsConfig.OPTIMIZE);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same comment

for (final Map.Entry<String, Pattern> stringPatternEntry : nodeToSourcePatterns.entrySet()) {
final SourceNodeFactory sourceNode = (SourceNodeFactory) nodeFactories.get(stringPatternEntry.getKey());
final SourceNodeFactory sourceNode
= (SourceNodeFactory) nodeFactories.get(stringPatternEntry.getKey());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same comment

final TopologyDescription.Subtopology[] sortedSubtopologies
= subtopologies.descendingSet().toArray(new Subtopology[0]);
final TopologyDescription.GlobalStore[] sortedGlobalStores
= globalStores.descendingSet().toArray(new GlobalStore[0]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same comment x2


/**
* Put a key-value pair with the given timestamp into the corresponding window
* Put a key-value pair into the window with given window start timestamp
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Much better. Thanks!

this.map = new TreeMap<>();
}

public KeyValueStore<K, V> enableLogging() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 Thanks for the catch.

final List<T> globalStore = globalStoreProvider.stores(storeName, queryableStoreType);
if (!globalStore.isEmpty()) {
return queryableStoreType.create(new WrappingStoreProvider(Collections.<StateStoreProvider>singletonList(globalStoreProvider)), storeName);
return queryableStoreType.create(new WrappingStoreProvider(Collections.singletonList(globalStoreProvider)), storeName);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this line is still a bit long... You could try a static import for singletonList.

@guozhangwang
Copy link
Copy Markdown
Contributor

lgtm. @mjsax please feel free to merge after addressing the above comments.

@mjsax
Copy link
Copy Markdown
Member Author

mjsax commented Jan 3, 2019

Thanks for the review. Updates this PR. Will merge after build finished.

@vvcephei
Copy link
Copy Markdown
Contributor

vvcephei commented Jan 4, 2019

👍 Thanks @mjsax !

@mjsax
Copy link
Copy Markdown
Member Author

mjsax commented Jan 8, 2019

Retest this please.

@mjsax
Copy link
Copy Markdown
Member Author

mjsax commented Jan 9, 2019

Unrelated tests in core and connect failed. Retest this please.

@mjsax mjsax merged commit 1c7bf4e into apache:trunk Jan 9, 2019
@mjsax mjsax deleted the minor-code-cleanup-main branch January 9, 2019 17:03
pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
Reviewers: Bill Bejeck <bill@confluent.io>, John Roesler <john@confluent.io>, Ryanne Dolan <ryannedolan@gmail.com>, Guozhang Wang <guozhang@confluent.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants