-
Notifications
You must be signed in to change notification settings - Fork 3.8k
global table datasource for broadcast segments #10020
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
Merged
gianm
merged 9 commits into
apache:master
from
clintropolis:global-table-for-broadcast-segments
Jun 17, 2020
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
489fdc6
global table datasource for broadcast segments
clintropolis eeb174a
tests
clintropolis bda1c7f
fix
clintropolis aff3b0a
fix test
clintropolis 9d7a9b6
comments and javadocs
clintropolis d0631b5
Merge remote-tracking branch 'upstream/master' into global-table-for-…
clintropolis 7c50674
review stuffs
clintropolis a7d3443
Merge remote-tracking branch 'upstream/master' into global-table-for-…
clintropolis 5f0e4c2
use generated equals and hashcode
clintropolis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
processing/src/main/java/org/apache/druid/query/GlobalTableDataSource.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.druid.query; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.fasterxml.jackson.annotation.JsonTypeName; | ||
|
|
||
| /** | ||
| * {@link TableDataSource} variant for globally available 'broadcast' segments. If bound to a | ||
| * {@link org.apache.druid.segment.join.JoinableFactory} that can create an | ||
| * {@link org.apache.druid.segment.join.table.IndexedTable} using DruidBinders.joinableFactoryBinder, this allows | ||
| * optimal usage of segments using this DataSource type in join operations (because they are global), and so can be | ||
| * pushed down to historicals as a {@link JoinDataSource}, instead of requiring a subquery join using | ||
| * {@link InlineDataSource} to construct an {@link org.apache.druid.segment.join.table.IndexedTable} on the fly on the | ||
| * broker. Because it is also a {@link TableDataSource}, when queried directly, or on the left hand side of a join, | ||
| * they will be treated as any normal table datasource. | ||
| */ | ||
| @JsonTypeName("globalTable") | ||
| public class GlobalTableDataSource extends TableDataSource | ||
| { | ||
| @JsonCreator | ||
| public GlobalTableDataSource(@JsonProperty("name") String name) | ||
| { | ||
| super(name); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isGlobal() | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() | ||
| { | ||
| return "GlobalTableDataSource{" + | ||
| "name='" + getName() + '\'' + | ||
| '}'; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
processing/src/test/java/org/apache/druid/query/GlobalTableDataSourceTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.druid.query; | ||
|
|
||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import nl.jqno.equalsverifier.EqualsVerifier; | ||
| import org.apache.druid.segment.TestHelper; | ||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
|
|
||
| public class GlobalTableDataSourceTest | ||
| { | ||
| private static final GlobalTableDataSource GLOBAL_TABLE_DATA_SOURCE = new GlobalTableDataSource("foo"); | ||
|
|
||
| @Test | ||
| public void testEquals() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a test for nonequality with a TableDataSource of the same name.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
| { | ||
| EqualsVerifier.forClass(GlobalTableDataSource.class) | ||
| .usingGetClass() | ||
| .withNonnullFields("name") | ||
| .verify(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGlobalTableIsNotEqualsTable() | ||
| { | ||
| TableDataSource tbl = new TableDataSource(GLOBAL_TABLE_DATA_SOURCE.getName()); | ||
| Assert.assertNotEquals(GLOBAL_TABLE_DATA_SOURCE, tbl); | ||
| Assert.assertNotEquals(tbl, GLOBAL_TABLE_DATA_SOURCE); | ||
| } | ||
|
|
||
| @Test | ||
| public void testIsGlobal() | ||
| { | ||
| Assert.assertTrue(GLOBAL_TABLE_DATA_SOURCE.isGlobal()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSerde() throws JsonProcessingException | ||
| { | ||
| final ObjectMapper jsonMapper = TestHelper.makeJsonMapper(); | ||
| final GlobalTableDataSource deserialized = (GlobalTableDataSource) jsonMapper.readValue( | ||
| jsonMapper.writeValueAsString(GLOBAL_TABLE_DATA_SOURCE), | ||
| DataSource.class | ||
| ); | ||
|
|
||
| Assert.assertEquals(GLOBAL_TABLE_DATA_SOURCE, deserialized); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding a javadoc explaining why this datasource type exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added javadoc 👍