com.aerospike.jdbc.query.InsertQueryHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aerospike-jdbc Show documentation
Show all versions of aerospike-jdbc Show documentation
A JDBC driver for the Aerospike database
The newest version!
package com.aerospike.jdbc.query;
import com.aerospike.client.*;
import com.aerospike.client.policy.BatchPolicy;
import com.aerospike.client.policy.BatchWritePolicy;
import com.aerospike.client.policy.WritePolicy;
import com.aerospike.jdbc.async.EventLoopProvider;
import com.aerospike.jdbc.async.FutureBatchOperateListListener;
import com.aerospike.jdbc.async.FutureWriteListener;
import com.aerospike.jdbc.model.AerospikeQuery;
import com.aerospike.jdbc.model.Pair;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import static com.aerospike.jdbc.util.Constants.PRIMARY_KEY_COLUMN_NAME;
public class InsertQueryHandler extends BaseQueryHandler {
private static final Logger logger = Logger.getLogger(InsertQueryHandler.class.getName());
public InsertQueryHandler(IAerospikeClient client, Statement statement) {
super(client, statement);
}
@Override
public Pair execute(AerospikeQuery query) {
if (aerospikeVersion.isBatchOpsSupported()) {
logger.info("INSERT batch");
return putBatch(query);
}
logger.info("INSERT individual");
return putConsecutively(query);
}
public Pair putConsecutively(AerospikeQuery query) {
List binNames = getBinNames(query);
FutureWriteListener listener = new FutureWriteListener(query.getValues().size());
WritePolicy writePolicy = policyBuilder.buildCreateOnlyPolicy();
for (Object aerospikeRecord : query.getValues()) {
@SuppressWarnings("unchecked")
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy