From 262784315ddc953e80713f47c25fe14b26dda48a Mon Sep 17 00:00:00 2001 From: Jonathan Shook Date: Fri, 3 Nov 2023 13:13:59 -0500 Subject: [PATCH] added ToIntegerList() and ToLongList() --- .../from_ary/to_list/ToIntegerList.java | 43 +++++++++++++++++++ .../shared/from_ary/to_list/ToLongList.java | 43 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_ary/to_list/ToIntegerList.java create mode 100644 virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_ary/to_list/ToLongList.java diff --git a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_ary/to_list/ToIntegerList.java b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_ary/to_list/ToIntegerList.java new file mode 100644 index 000000000..399aa38f8 --- /dev/null +++ b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_ary/to_list/ToIntegerList.java @@ -0,0 +1,43 @@ +package io.nosqlbench.virtdata.library.basics.shared.from_ary.to_list; + +/* + * Copyright (c) 2022 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. + */ + + +import io.nosqlbench.virtdata.api.annotations.Categories; +import io.nosqlbench.virtdata.api.annotations.Category; +import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; + +/** + * Convert an incoming int array to a List of Integer + */ +@Categories(Category.conversion) +@ThreadSafeMapper +public class ToIntegerList implements Function> { + @Override + public List apply(int[] ints) { + ArrayList list = new ArrayList<>(ints.length); + for (int f : ints) { + list.add(f); + } + return list; + } +} diff --git a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_ary/to_list/ToLongList.java b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_ary/to_list/ToLongList.java new file mode 100644 index 000000000..4dfb2fe75 --- /dev/null +++ b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_ary/to_list/ToLongList.java @@ -0,0 +1,43 @@ +package io.nosqlbench.virtdata.library.basics.shared.from_ary.to_list; + +/* + * Copyright (c) 2022 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. + */ + + +import io.nosqlbench.virtdata.api.annotations.Categories; +import io.nosqlbench.virtdata.api.annotations.Category; +import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; + +/** + * Convert an incoming long array to a List of Long + */ +@Categories(Category.conversion) +@ThreadSafeMapper +public class ToLongList implements Function> { + @Override + public List apply(long[] longs) { + ArrayList list = new ArrayList<>(longs.length); + for (long f : longs) { + list.add(f); + } + return list; + } +}