minor optimizations and corrections

This commit is contained in:
Mark Wolters 2023-12-05 12:38:28 -04:00
parent 17b7dbdaa4
commit 93d9dc5914
3 changed files with 9 additions and 15 deletions

View File

@ -18,16 +18,12 @@ package io.nosqlbench.datamappers.functions.hdf_to_cql;
public interface DatasetParser {
static DatasetParser parserFactory(String parsername) {
switch(parsername) {
case "default":
return new DefaultDatasetParser();
case "noop":
return new NoopDatasetParser();
case "jaw":
return new JAWDatasetParser();
default:
throw new RuntimeException("Unknown parser name: " + parsername);
}
return switch (parsername) {
case "default" -> new DefaultDatasetParser();
case "noop" -> new NoopDatasetParser();
case "jaw" -> new JAWDatasetParser();
default -> throw new RuntimeException("Unknown parser name: " + parsername);
};
}
String parse(String raw);

View File

@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class DefaultDatasetPerserTest {
public class DefaultDatasetParserTest {
String test1 = "{\"conditions\": {\"and\": [{\"a\": {\"match\": {\"value\": 53}}}]}}";
String test2 = "{\"conditions\": {\"and\": [{\"a\": {\"match\": {\"value\": \"thirteen\"}}}, {\"b\": {\"match\": {\"value\": \"fifty-four\"}}}]}}";
String test3 = "{\"conditions\": {\"and\": [{\"a\": {\"match\": {\"value\": 13}}}, {\"b\": {\"match\": {\"value\": 54}}}, {\"a\": {\"match\": {\"value\": 154}}}]}}";

View File

@ -43,9 +43,7 @@ public class HdfDatasetToStrings extends AbstractHdfFileToVectorType implements
int[] sliceDimensions = new int[dims.length];
sliceDimensions[0] = 1;
if (dims.length > 1) {
for (int i = 1; i < dims.length; i++) {
sliceDimensions[i] = dims[i];
}
System.arraycopy(dims, 1, sliceDimensions, 1, dims.length - 1);
}
String payload = null;
switch(dataset.getJavaType().getSimpleName().toLowerCase()) {
@ -67,7 +65,7 @@ public class HdfDatasetToStrings extends AbstractHdfFileToVectorType implements
if (payload == null) {
throw new RuntimeException("Unsupported datatype: " + dataset.getJavaType().getSimpleName());
}
payload = payload.replaceAll("\\[", "").replaceAll("\\]", "");
payload = payload.replaceAll("\\[", "").replaceAll("]", "");
return payload;
}