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

CASSGO-13 Add support for cassandra 4.0 table options #1791

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

OleksiienkoMykyta
Copy link

@OleksiienkoMykyta OleksiienkoMykyta commented Aug 1, 2024

Cassandra 4.0 has some minor table metadata changes that need to be accounted for:
read_repair_chance is replaced with read_repair
dclocal_read_repair_chance has been removed
additional_write_policy has been added

In the PR implemented backward compatibility with previous versions, and added new types support. To make metadata table support easier for future Cassandra versions, hardcode scan from Cassandra were replaced with new "parseSystemSchemaViews" method which is much easier to expand, even if some fields were added in the middle of the table it wouldn`t be an issue anymore.

MemtableFlushPeriodInMs: 0,
MinIndexInterval: 128,
ReadRepair: expectedReadRepair,
ReadRepairChance: 0,

Choose a reason for hiding this comment

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

As far as I know, read_repair_chance was removed from C* 4.0.

https://issues.apache.org/jira/browse/CASSANDRA-15604

Copy link
Author

Choose a reason for hiding this comment

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

Yes, but this test also runs for C* 3.0.0, so it covers data for all versions. We can make separate tests for each version, but as mentioned in the description for the current PR, the main aim is to implement a backward-compatible metadata getter, and this test case helps to test one.

@OleksiienkoMykyta OleksiienkoMykyta force-pushed the add-support-for-Cassandra-5-0-table-options branch 2 times, most recently from 35cc199 to 58924f7 Compare August 7, 2024 08:33
metadata.go Outdated
Comment on lines 980 to 987
func extensionsBlobToStrings(value interface{}) (map[string]string, error) {
const errorMessage = "gocql.extensionsBlobToStrings failed to read column %s"
byteData, ok := value.(map[string][]byte)
if !ok {
return nil, fmt.Errorf(errorMessage, "extentions")
}

extensions := make(map[string]string, len(byteData))
for key, rowByte := range byteData {
extensions[key] = string(rowByte)
}

return extensions, nil
}
Copy link

Choose a reason for hiding this comment

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

Suggested change
func extensionsBlobToStrings(value interface{}) (map[string]string, error) {
const errorMessage = "gocql.extensionsBlobToStrings failed to read column %s"
byteData, ok := value.(map[string][]byte)
if !ok {
return nil, fmt.Errorf(errorMessage, "extentions")
}
extensions := make(map[string]string, len(byteData))
for key, rowByte := range byteData {
extensions[key] = string(rowByte)
}
return extensions, nil
}
func bytesMapToStringMap(bytesMap map[string][]byte) map[string]string {
stringMap := make(map[string]string, len(bytesMap))
for key, bytes := range bytesMap {
stringMap[key] = string(bytes)
}
return stringMap
}

Let's make this method take map[string][]byte as a param instead of an empty interface. This approach will allow you to return described in this func error more properly from materializedViewMetadataFromMap.
Also, what do you think about renaming this func to something like bytesMapToStringMap?

Copy link
Author

Choose a reason for hiding this comment

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

I agree, it will make bytesMapToStringMap more reusable and error handling much more readable.
Thank You very much!

@OleksiienkoMykyta OleksiienkoMykyta force-pushed the add-support-for-Cassandra-5-0-table-options branch from 58924f7 to e28b00a Compare August 7, 2024 11:36
@OleksiienkoMykyta OleksiienkoMykyta changed the title Add support for cassandra 5.0 table options Add support for cassandra 4.0 table options Oct 29, 2024
@joao-r-reis joao-r-reis changed the title Add support for cassandra 4.0 table options CASSGO-13 Add support for cassandra 4.0 table options Oct 29, 2024
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