nosqlbench-1140 Restore ModuloCSVLineToUUID functionality with ToUUID methods (#1141)

This commit is contained in:
Jonathan Shook
2023-02-28 11:25:36 -06:00
committed by GitHub
parent 1ebae7fd3b
commit 152593388a
2 changed files with 68 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2023 nosqlbench
*
* Licensed 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 io.nosqlbench.virtdata.library.basics.shared.conversions.from_string;
import io.nosqlbench.virtdata.api.annotations.Categories;
import io.nosqlbench.virtdata.api.annotations.Category;
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
import java.util.UUID;
import java.util.function.Function;
/**
* Convert the incoming String value to the equivalent UUID with {@link UUID#fromString(String)}
*/
@Categories(Category.datetime)
@ThreadSafeMapper
public class ToUUID implements Function<String, UUID> {
@Override
public UUID apply(String s) {
return UUID.fromString(s);
}
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 2023 nosqlbench
*
* Licensed 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 io.nosqlbench.virtdata.library.basics.shared.conversions.from_string;
import org.junit.jupiter.api.Test;
import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat;
public class ToUUIDTest {
@Test
public void testStringToUUID() {
assertThat(new ToUUID().apply("ad3b5598-8620-41f7-9631-3ae47c7aa465"))
.isEqualTo(UUID.fromString("ad3b5598-8620-41f7-9631-3ae47c7aa465"));
}
}