Code review cleanup. Commit test for new repo.
This commit is contained in:
@@ -19,6 +19,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -805,19 +806,27 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
|||||||
* @see org.springframework.cassandra.core.CassandraOperations#execute(java.lang.String, java.util.List)
|
* @see org.springframework.cassandra.core.CassandraOperations#execute(java.lang.String, java.util.List)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void ingest(String cql, List<List<?>> rows, Map<String, Object> optionsByName) {
|
public void ingest(String cql, final List<List<?>> rows, Map<String, Object> optionsByName) {
|
||||||
|
|
||||||
Assert.notNull(optionsByName);
|
Assert.notNull(optionsByName);
|
||||||
Assert.notNull(rows);
|
Assert.notNull(rows);
|
||||||
Assert.notEmpty(rows);
|
Assert.notEmpty(rows);
|
||||||
|
|
||||||
Object[][] values = new Object[rows.size()][];
|
ingest(cql, new RowIterator() {
|
||||||
int i = 0;
|
|
||||||
for (List<?> row : rows) {
|
|
||||||
values[i++] = row.toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
ingest(cql, values, optionsByName);
|
Iterator<List<?>> i = rows.iterator();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] next() {
|
||||||
|
return i.next().toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return i.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
}, optionsByName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -895,7 +904,7 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
|||||||
* @param q
|
* @param q
|
||||||
* @param optionsByName
|
* @param optionsByName
|
||||||
*/
|
*/
|
||||||
public static void addQueryOptions(Query q, Map<String, Object> optionsByName) {
|
protected static void addQueryOptions(Query q, Map<String, Object> optionsByName) {
|
||||||
|
|
||||||
if (optionsByName == null) {
|
if (optionsByName == null) {
|
||||||
return;
|
return;
|
||||||
@@ -921,7 +930,7 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
|
|||||||
* @param q
|
* @param q
|
||||||
* @param optionsByName
|
* @param optionsByName
|
||||||
*/
|
*/
|
||||||
public static void addPreparedStatementOptions(PreparedStatement s, Map<String, Object> optionsByName) {
|
protected static void addPreparedStatementOptions(PreparedStatement s, Map<String, Object> optionsByName) {
|
||||||
|
|
||||||
if (optionsByName == null) {
|
if (optionsByName == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2011-2013 the original author or authors.
|
|
||||||
*
|
|
||||||
* 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 org.springframework.cassandra.core;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author David Webb
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface CqlProvider {
|
|
||||||
|
|
||||||
String getCql();
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -26,7 +26,7 @@ import com.datastax.driver.core.exceptions.DriverException;
|
|||||||
* @author David Webb
|
* @author David Webb
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PreparedStatementCreatorImpl implements PreparedStatementCreator, CqlProvider, PreparedStatementBinder {
|
public class PreparedStatementCreatorImpl implements PreparedStatementCreator, PreparedStatementBinder {
|
||||||
|
|
||||||
private final String cql;
|
private final String cql;
|
||||||
private List<Object> values;
|
private List<Object> values;
|
||||||
@@ -54,10 +54,6 @@ public class PreparedStatementCreatorImpl implements PreparedStatementCreator, C
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.springframework.cassandra.core.CqlProvider#getCql()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getCql() {
|
public String getCql() {
|
||||||
return this.cql;
|
return this.cql;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import com.datastax.driver.core.exceptions.DriverException;
|
|||||||
* @author David Webb
|
* @author David Webb
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SimplePreparedStatementCreator implements PreparedStatementCreator, CqlProvider {
|
public class SimplePreparedStatementCreator implements PreparedStatementCreator {
|
||||||
|
|
||||||
private final String cql;
|
private final String cql;
|
||||||
|
|
||||||
@@ -39,10 +39,6 @@ public class SimplePreparedStatementCreator implements PreparedStatementCreator,
|
|||||||
this.cql = cql;
|
this.cql = cql;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.springframework.cassandra.core.CqlProvider#getCql()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getCql() {
|
public String getCql() {
|
||||||
return this.cql;
|
return this.cql;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user