Skip to content

Commit

Permalink
Use toString in StringValues
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtDu committed Jun 26, 2024
1 parent cfa0ca1 commit f2c5fc3
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 16 deletions.
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<version>1.6.14</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface OperationWithYieldEveryOptions<T extends OperationWithYieldEver
* Sets number of tuples processed on storage to yield after, "yield_every" should be > 0.
* @param yieldEvery number of tuples processed on storage to yield after, "yield_every" should be > 0.
* @return this option instance.
* @throws IllegalArgumentException if yieldEvery < 0.
* @throws IllegalArgumentException {@code if yieldEvery < 0}.
*/
default T withYieldEvery(int yieldEvery) throws IllegalArgumentException {
if (yieldEvery <= 0) {
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

0 comments on commit f2c5fc3

Please sign in to comment.