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

Use toString in StringValues #476

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased]

## [0.14.0] - 2024-06-26

### Bugfixes

- Significantly reduce memory allocation overhead and excessive GC pressure ([#401](https://github.com/tarantool/cartridge-java/issues/401))
Expand All @@ -19,6 +21,7 @@
- Add support for crud `balance` option ([#462](https://github.com/tarantool/cartridge-java/pull/472))
- Add support for crud `vshard_router` option ([#463](https://github.com/tarantool/cartridge-java/pull/473))
- Add support for crud `fetch_latest_metadata` option ([#465](https://github.com/tarantool/cartridge-java/pull/474))
- Use toString in StringValues to map incorrect UTF-8 string

### Features

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ If you use this code in another project don't forget to add a `cartridge-driver`
<dependency>
<groupId>io.tarantool</groupId>
<artifactId>cartridge-driver</artifactId>
<version>0.13.0</version>
<version>0.14.0</version>
</dependency>
```
## Advanced usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public Map<String, TarantoolFieldMetadata> fromValue(ArrayValue format) {
spaceFormatMetadata.put(
fieldMap.get(FORMAT_FIELD_NAME).toString(),
new TarantoolFieldMetadataImpl(
fieldMap.get(FORMAT_FIELD_NAME).asStringValue().asString(),
fieldMap.get(FORMAT_FIELD_TYPE).asStringValue().asString(),
fieldMap.get(FORMAT_FIELD_NAME).asStringValue().toString(),
fieldMap.get(FORMAT_FIELD_TYPE).asStringValue().toString(),
fieldPosition,
isNullable.isPresent() && isNullable.get().asBooleanValue().getBoolean()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public TarantoolMetadataContainer fromValue(Value value) {

TarantoolSpaceMetadataImpl spaceMetadata = new TarantoolSpaceMetadataImpl();
spaceMetadata.setOwnerId(ID_UNKNOWN);
spaceMetadata.setSpaceName(nameValue.asStringValue().asString());
spaceMetadata.setSpaceName(nameValue.asStringValue().toString());

Value formatValue = space.get(SPACE_FORMAT_KEY);
if (formatValue == null) {
Expand Down Expand Up @@ -140,14 +140,14 @@ private Map<String, TarantoolIndexMetadata> parseIndexes(
throw new TarantoolClientException(
"Unsupported index metadata format: key '" + INDEX_NAME_KEY + "' must have string value");
}
String indexName = indexNameValue.asStringValue().asString();
String indexName = indexNameValue.asStringValue().toString();

Value indexTypeValue = indexMap.get(INDEX_TYPE_KEY);
if (indexTypeValue == null || !indexTypeValue.isStringValue()) {
throw new TarantoolClientException(
"Unsupported index metadata format: key '" + INDEX_TYPE_KEY + "' must have string value");
}
String indexType = indexTypeValue.asStringValue().asString();
String indexType = indexTypeValue.asStringValue().toString();

Value indexUniqueValue = indexMap.get(INDEX_UNIQUE_KEY);
if (indexUniqueValue == null || !indexUniqueValue.isBooleanValue()) {
Expand Down Expand Up @@ -196,7 +196,7 @@ private Map<String, TarantoolIndexMetadata> parseIndexes(
int fieldNumber;
Object fieldPath;
if (fieldPathValue.isStringValue()) {
fieldPath = fieldPathValue.asStringValue().asString();
fieldPath = fieldPathValue.asStringValue().toString();
fieldNumber = getFieldNumberFromFieldPath(fields, (String) fieldPath);
} else {
fieldNumber = fieldPathValue.asIntegerValue().asInt();
Expand All @@ -208,7 +208,7 @@ private Map<String, TarantoolIndexMetadata> parseIndexes(
throw new TarantoolClientException("Unsupported index metadata format: key '" +
INDEX_PARTS_TYPE_KEY + "' must have string value");
}
String fieldType = fieldTypeValue.asStringValue().asString();
String fieldType = fieldTypeValue.asStringValue().toString();

return new TarantoolIndexPartMetadataImpl<>(fieldNumber, fieldType, fieldPath);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public TarantoolIndexMetadata fromValue(ArrayValue value) {
indexParts = indexPartsValue.list().stream()
.map(partValue -> new TarantoolIndexPartMetadataImpl<>(
partValue.asArrayValue().get(0).asIntegerValue().asInt(),
partValue.asArrayValue().get(1).asStringValue().asString()
partValue.asArrayValue().get(1).asStringValue().toString()
)).collect(Collectors.toList());
} else {
indexParts = indexPartsValue.list().stream()
.map(partValue -> new TarantoolIndexPartMetadataImpl<>(
partValue.asMapValue().map().get(INDEX_FIELD_KEY).asIntegerValue().asInt(),
partValue.asMapValue().map().get(INDEX_TYPE_KEY).asStringValue().asString()
partValue.asMapValue().map().get(INDEX_TYPE_KEY).asStringValue().toString()
)).collect(Collectors.toList());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public class DefaultStringValueToCharacterConverter implements ValueConverter<St

@Override
public Character fromValue(StringValue value) {
String stringFromStringValue = value.asString();
String stringFromStringValue = value.toString();
return stringFromStringValue.charAt(0);
}

@Override
public boolean canConvertValue(StringValue value) {
String stringFromStringValue = value.asString();
String stringFromStringValue = value.toString();
return stringFromStringValue.length() == 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public class DefaultStringValueToStringConverter implements ValueConverter<Strin

@Override
public String fromValue(StringValue value) {
return value.asString();
return value.toString();
}
}
2 changes: 1 addition & 1 deletion src/main/java/io/tarantool/driver/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* // the default parameters are set to unlimited, though
* new TarantoolSelectOptions(),
* // convert raw MessagePack array to object by hand
* (v) -> new CustomTuple(v.get(0).asIntegerValue().asInt(), v.get(1).asStringValue().asString()))
* (v) -> new CustomTuple(v.get(0).asIntegerValue().asInt(), v.get(1).asStringValue().toString()))
* .get();
*
* customTuples.forEach(
Expand Down
Loading