-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[improve][pulsar-io] Added support for generic record and raw JSON string schemas to CassandraSink #16179
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
Closed
david-streamlio
wants to merge
16
commits into
apache:master
from
david-streamlio:cassandra-sink-fix
Closed
[improve][pulsar-io] Added support for generic record and raw JSON string schemas to CassandraSink #16179
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
609a1f9
Added GenericRecord support
david-streamlio f13c640
Added support for raw JSON String
david-streamlio fb7beb7
Added RecordWrapper interface
david-streamlio 608f32f
fixed issue from code review
david-streamlio d98e02d
Merge branch 'master' into cassandra-sink-fix
tisonkun c748715
license header
tisonkun 21cedba
Switched to TestNG framework
david-streamlio cd87d8e
Merge remote-tracking branch 'origin/master' into cassandra-sink-fix
lhotari fd370b4
Revert unnecessary changes to pom.xml files that ignore cassandra.ver…
lhotari 0f38c18
Fix checkstyle
lhotari 975cf7d
Replace Gson usage with Jackson
lhotari a7bf2e2
Remove version for beanutils
lhotari 071633c
Remove unnecessary dependency
lhotari e09e03f
Add Testcontainers dependency
lhotari 71191c7
Use real Cassandra with Testcontainers
lhotari c3f18f9
Revert renaming of CassandraAbstractSink
lhotari 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
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
32 changes: 32 additions & 0 deletions
32
...io/cassandra/src/main/java/org/apache/pulsar/io/cassandra/CassandraGenericRecordSink.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,32 @@ | ||
| /* | ||
| * 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.pulsar.io.cassandra; | ||
|
|
||
| import org.apache.pulsar.client.api.schema.GenericRecord; | ||
| import org.apache.pulsar.functions.api.Record; | ||
| import org.apache.pulsar.io.cassandra.util.GenericRecordWrapper; | ||
| import org.apache.pulsar.io.cassandra.util.RecordWrapper; | ||
|
|
||
| public class CassandraGenericRecordSink extends CassandraAbstractSink<GenericRecord> { | ||
|
|
||
| @Override | ||
| RecordWrapper<GenericRecord> wrapRecord(Record<GenericRecord> record) { | ||
| return new GenericRecordWrapper(record.getValue()); | ||
| } | ||
| } |
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
45 changes: 45 additions & 0 deletions
45
...o/cassandra/src/main/java/org/apache/pulsar/io/cassandra/util/BoundStatementProvider.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,45 @@ | ||
| /* | ||
| * 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.pulsar.io.cassandra.util; | ||
|
|
||
| import com.datastax.driver.core.BoundStatement; | ||
| import com.datastax.driver.core.PreparedStatement; | ||
|
|
||
| @SuppressWarnings("rawtypes") | ||
| public class BoundStatementProvider { | ||
| final TableMetadataProvider.TableDefinition tableDefinition; | ||
|
|
||
| public BoundStatementProvider(TableMetadataProvider.TableDefinition tableDefinition) { | ||
| this.tableDefinition = tableDefinition; | ||
| } | ||
|
|
||
| public BoundStatement bindStatement(PreparedStatement stmt, RecordWrapper wrapper) { | ||
| Object[] boundValues = new Object[tableDefinition.getColumns().size()]; | ||
| int idx = 0; | ||
|
|
||
| for (TableMetadataProvider.ColumnId column : tableDefinition.getColumns()) { | ||
| if (wrapper.containsKey(column.getName())) { | ||
| boundValues[idx] = wrapper.get(column); | ||
| } | ||
| idx++; | ||
| } | ||
| return stmt.bind(boundValues); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
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.
The behavior of the existing CassandraStringSink shouldn't be modified since it breaks backwards compatibility.