mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
JSON toString wrapper
This commit is contained in:
parent
2028293d8f
commit
351e8e333b
@ -22,6 +22,7 @@ import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import io.nosqlbench.virtdata.library.hdf5.from_long.AbstractHdfFileToVectorType;
|
||||
import io.nosqlbench.virtdata.library.hdf5.helpers.EmbeddingGenerator;
|
||||
import io.nosqlbench.virtdata.library.hdf5.helpers.EmbeddingGeneratorFactory;
|
||||
import io.nosqlbench.virtdata.library.wrappers.JsonListWrapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.LongFunction;
|
||||
@ -49,7 +50,7 @@ public class HdfFileToFloatList extends AbstractHdfFileToVectorType implements L
|
||||
@Override
|
||||
public List<Float> apply(long l) {
|
||||
Object data = getDataFrom(l);
|
||||
return embeddingGenerator.generateFloatListEmbeddingFrom(data, dims);
|
||||
return new JsonListWrapper<>(embeddingGenerator.generateFloatListEmbeddingFrom(data, dims));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.wrappers;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class JsonListWrapper<T> extends ArrayList<T> {
|
||||
private final static Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
public JsonListWrapper(int initialCapacity) {
|
||||
super(initialCapacity);
|
||||
}
|
||||
|
||||
public JsonListWrapper() {
|
||||
}
|
||||
|
||||
public JsonListWrapper(@NotNull Collection<? extends T> c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user