mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
JDBC enhancement PR#1624 - address Madhavan' review comments.
This commit is contained in:
parent
179a51c20b
commit
8fb7446a24
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* 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.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* 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.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* 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.
|
||||
|
@ -17,13 +17,10 @@
|
||||
package io.nosqlbench.adapter.jdbc.opdispensers;
|
||||
|
||||
import io.nosqlbench.adapter.jdbc.JDBCSpace;
|
||||
import io.nosqlbench.adapter.jdbc.optypes.JDBCDMLOp;
|
||||
import io.nosqlbench.adapter.jdbc.optypes.JDBCOp;
|
||||
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public abstract class JDBCBaseOpDispenser extends BaseOpDispenser<JDBCOp, JDBCSpace> {
|
||||
protected static final String ERROR_STATEMENT_CREATION =
|
||||
|
@ -44,6 +44,7 @@ public abstract class JDBCDMLOp extends JDBCOp {
|
||||
String pStmtSqlStr,
|
||||
List<Object> pStmtValList) {
|
||||
super(jdbcSpace);
|
||||
assert(StringUtils.isNotBlank(pStmtSqlStr));
|
||||
|
||||
this.isReadStmt = isReadStmt;
|
||||
this.pStmtSqlStr = pStmtSqlStr;
|
||||
@ -77,24 +78,29 @@ public abstract class JDBCDMLOp extends JDBCOp {
|
||||
|
||||
for (int i=0; i<valList.size(); i++) {
|
||||
int fieldIdx = i + 1;
|
||||
String inputFieldVal = ((String)valList.get(i)).trim();
|
||||
Object fieldValObj = valList.get(i);
|
||||
assert (fieldValObj != null);
|
||||
|
||||
try {
|
||||
Object fieldValObj = inputFieldVal;
|
||||
|
||||
// If the 'fieldVal' is a string like "[<float_num_1>, <float_num_2>, ... <float_num_n>]" format,
|
||||
// convert it to the Vector object
|
||||
if ( inputFieldVal.startsWith("[") && inputFieldVal.endsWith("]") ) {
|
||||
JDBCPgVector vector = new JDBCPgVector();
|
||||
vector.setValue(inputFieldVal);
|
||||
fieldValObj = vector;
|
||||
// Special processing for Vector
|
||||
if (fieldValObj instanceof String) {
|
||||
String strObj = (String)fieldValObj;
|
||||
if (StringUtils.isNotBlank(strObj)) {
|
||||
strObj = strObj.trim();
|
||||
// If the 'fieldVal' is a string like "[<float_num_1>, <float_num_2>, ... <float_num_n>]" format,
|
||||
// convert it to the Vector object
|
||||
if (strObj.startsWith("[") && strObj.endsWith("]")) {
|
||||
JDBCPgVector vector = new JDBCPgVector();
|
||||
vector.setValue(strObj);
|
||||
fieldValObj = vector;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stmt.setObject(fieldIdx, fieldValObj);
|
||||
}
|
||||
catch (JDBCPgVectorException | SQLException e) {
|
||||
throw new RuntimeException(
|
||||
"Failed to parse the prepared statement value for field[" + fieldIdx + "] " + inputFieldVal);
|
||||
"Failed to parse the prepared statement value for field[" + fieldIdx + "] " + fieldValObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user