Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CosIdKeyGenerateAlgorithm / CosIdIntervalShardingAlgorithm /CosIdModShardingAlgorithm #14132

Merged
merged 11 commits into from
Dec 22, 2021

Conversation

Ahoo-Wang
Copy link
Contributor

Fixes #14047 .

Changes proposed in this pull request:

  • add CosIdKeyGenerateAlgorithm
  • add CosIdIntervalShardingAlgorithm
  • add CosIdModShardingAlgorithm

https://github.com/Ahoo-Wang/CosId#shardingsphere-plugin


This pull request does not include (I will finish the rest of the issue in the next time.):

update original SNOWFLAKE

Integrate COSID_SEGMENT and COSID_SEGMENT_CHAIN with ShardingSphere deeply,just reuse reg-center of cluster mode.

@codecov-commenter
Copy link

codecov-commenter commented Dec 17, 2021

Codecov Report

Merging #14132 (bf0ccb4) into master (a2a7bc5) will decrease coverage by 2.75%.
The diff coverage is 13.95%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #14132      +/-   ##
============================================
- Coverage     63.64%   60.88%   -2.76%     
+ Complexity     1843     1766      -77     
============================================
  Files          2865     2858       -7     
  Lines         42737    42502     -235     
  Branches       7269     7250      -19     
============================================
- Hits          27198    25878    -1320     
- Misses        13453    14625    +1172     
+ Partials       2086     1999      -87     
Impacted Files Coverage Δ
...rding/algorithm/sharding/cosid/CosIdAlgorithm.java 0.00% <0.00%> (ø)
...rding/algorithm/sharding/cosid/PropertiesUtil.java 0.00% <0.00%> (ø)
...sharding/cosid/CosIdIntervalShardingAlgorithm.java 4.68% <4.68%> (ø)
...ithm/sharding/cosid/CosIdModShardingAlgorithm.java 20.00% <20.00%> (ø)
...ng/algorithm/keygen/CosIdKeyGenerateAlgorithm.java 87.50% <87.50%> (ø)
...data/pipeline/core/datasource/MetaDataManager.java 0.00% <0.00%> (-100.00%) ⬇️
...st/channel/distribution/AbstractBitSetChannel.java 0.00% <0.00%> (-100.00%) ⬇️
...t/channel/distribution/AutoAcknowledgeChannel.java 0.00% <0.00%> (-100.00%) ⬇️
...core/ingest/channel/distribution/ManualBitSet.java 0.00% <0.00%> (-97.78%) ⬇️
...gest/channel/distribution/DistributionChannel.java 0.00% <0.00%> (-87.33%) ⬇️
... and 167 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a2a7bc5...bf0ccb4. Read the comment docs.

*/
public final class CosIdIntervalShardingAlgorithm implements StandardShardingAlgorithm<Comparable<?>> {

public static final String TYPE = CosIdAlgorithm.TYPE_PREFIX + "INTERVAL";
Copy link
Contributor

Choose a reason for hiding this comment

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

Please confirm whether all variables need public

}

@RunWith(Parameterized.class)
public static class LocalDateTimePreciseValueDoShardingTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

could these test methods be split into test classes?

/**
* CosId key generate algorithm.
*/
public final class CosIdKeyGenerateAlgorithm implements KeyGenerateAlgorithm {
Copy link
Contributor

Choose a reason for hiding this comment

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

I want to know how it works in the cluster mode.

IntervalTimeline intervalTimeline = new IntervalTimeline(logicNamePrefix, Range.closed(effectiveLower, effectiveUpper), IntervalStep.of(stepUnit, stepAmount), suffixFormatter);
boolean isSecondTs = getProps().containsKey(TIMESTAMP_TYPE_KEY)
&& TIMESTAMP_SECOND_TYPE.equalsIgnoreCase(getProps().getProperty(TIMESTAMP_TYPE_KEY));
final String dateTimePattern = getProps().getProperty(DATE_TIME_PATTERN_KEY, DEFAULT_DATE_TIME_PATTERN);
Copy link
Member

Choose a reason for hiding this comment

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

@Ahoo-Wang Please remove this final modifier.

@menghaoranss menghaoranss merged commit ef2f063 into apache:master Dec 22, 2021
@Ahoo-Wang Ahoo-Wang deleted the 14047 branch December 22, 2021 07:15
Copy link
Member

@TeslaCN TeslaCN left a comment

Choose a reason for hiding this comment

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

Reminder: The license files under shardingsphere-distribution should be updated since new dependencies introduced.

@menghaoranss
Copy link
Contributor

Reminder: The license files under shardingsphere-distribution should be updated since new dependencies introduced.

@TeslaCN I will follow up.

@Ahoo-Wang
Copy link
Contributor Author

Ahoo-Wang commented Dec 22, 2021

Reminder: The license files under shardingsphere-distribution should be updated since new dependencies introduced.

@TeslaCN @menghaoranss
add to shardingsphere-distribution/shardingsphere-jdbc-distribution/src/main/release-docs/licenses/LICENSE-cosid.txt ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IntervalShardingAlgorithm performance is too bad
5 participants