You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2011/04/19 19:13:21 UTC
svn commit: r1095139 [2/2] - in /cassandra/trunk: ./ conf/ contrib/
contrib/pig/src/java/org/apache/cassandra/hadoop/pig/ debian/ doc/cql/
drivers/java/src/org/apache/cassandra/cql/jdbc/
drivers/java/test/org/apache/cassandra/cql/ drivers/java/test/org...
Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g Tue Apr 19 17:13:19 2011
@@ -382,11 +382,9 @@ K_FROM: F R O M;
K_WHERE: W H E R E;
K_AND: A N D;
K_KEY: K E Y;
-K_COLUMN: C O L (U M N)?;
K_INSERT: I N S E R T;
K_UPDATE: U P D A T E;
K_WITH: W I T H;
-K_ROW: R O W;
K_LIMIT: L I M I T;
K_USING: U S I N G;
K_CONSISTENCY: C O N S I S T E N C Y;
Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java Tue Apr 19 17:13:19 2011
@@ -467,20 +467,22 @@ public class QueryProcessor
if (StatementType.requiresKeyspace.contains(statement.type))
keyspace = clientState.getKeyspace();
- CqlResult avroResult = new CqlResult();
+ CqlResult result = new CqlResult();
logger.debug("CQL statement type: {}", statement.type.toString());
-
+ CFMetaData metadata;
+ AbstractType<?> comparator;
switch (statement.type)
{
case SELECT:
SelectStatement select = (SelectStatement)statement.statement;
clientState.hasColumnFamilyAccess(select.getColumnFamily(), Permission.READ);
- validateColumnFamily(keyspace, select.getColumnFamily(), false);
+ metadata = validateColumnFamily(keyspace, select.getColumnFamily(), false);
+ comparator = metadata.getComparatorFor(null);
validateSelect(keyspace, select);
List<org.apache.cassandra.db.Row> rows = null;
-
+
// By-key
if (!select.isKeyRange() && (select.getKeys().size() > 0))
{
@@ -489,12 +491,12 @@ public class QueryProcessor
// Only return the column count, (of the at-most 1 row).
if (select.isCountOperation())
{
- avroResult.type = CqlResultType.INT;
+ result.type = CqlResultType.INT;
if (rows.size() > 0)
- avroResult.setNum(rows.get(0).cf != null ? rows.get(0).cf.getSortedColumns().size() : 0);
+ result.setNum(rows.get(0).cf != null ? rows.get(0).cf.getSortedColumns().size() : 0);
else
- avroResult.setNum(0);
- return avroResult;
+ result.setNum(0);
+ return result;
}
}
else
@@ -511,8 +513,8 @@ public class QueryProcessor
}
}
- List<CqlRow> avroRows = new ArrayList<CqlRow>();
- avroResult.type = CqlResultType.ROWS;
+ List<CqlRow> cqlRows = new ArrayList<CqlRow>();
+ result.type = CqlResultType.ROWS;
// Create the result set
for (org.apache.cassandra.db.Row row : rows)
@@ -520,38 +522,26 @@ public class QueryProcessor
/// No results for this row
if (row.cf == null)
continue;
-
- List<Column> avroColumns = new ArrayList<Column>();
-
- for (IColumn column : row.cf.getSortedColumns())
- {
- if (column.isMarkedForDelete())
- continue;
- Column avroColumn = new Column();
- avroColumn.name = column.name();
- avroColumn.value = column.value();
- avroColumn.timestamp = column.timestamp();
- avroColumns.add(avroColumn);
- }
-
+
+ List<Column> thriftColumns = extractThriftColumns(select, comparator, row);
// Create a new row, add the columns to it, and then add it to the list of rows
- CqlRow avroRow = new CqlRow();
- avroRow.key = row.key.key;
- avroRow.columns = avroColumns;
+ CqlRow cqlRow = new CqlRow();
+ cqlRow.key = row.key.key;
+ cqlRow.columns = thriftColumns;
if (select.isColumnsReversed())
- Collections.reverse(avroRow.columns);
- avroRows.add(avroRow);
+ Collections.reverse(cqlRow.columns);
+ cqlRows.add(cqlRow);
}
- avroResult.rows = avroRows;
- return avroResult;
+ result.rows = cqlRows;
+ return result;
case INSERT: // insert uses UpdateStatement
case UPDATE:
UpdateStatement update = (UpdateStatement)statement.statement;
batchUpdate(clientState, Collections.singletonList(update), update.getConsistencyLevel());
- avroResult.type = CqlResultType.VOID;
- return avroResult;
+ result.type = CqlResultType.VOID;
+ return result;
case BATCH_UPDATE:
BatchUpdateStatement batch = (BatchUpdateStatement)statement.statement;
@@ -562,14 +552,14 @@ public class QueryProcessor
"Consistency level must be set on the BATCH, not individual UPDATE statements");
batchUpdate(clientState, batch.getUpdates(), batch.getConsistencyLevel());
- avroResult.type = CqlResultType.VOID;
- return avroResult;
+ result.type = CqlResultType.VOID;
+ return result;
case USE:
clientState.setKeyspace((String)statement.statement);
- avroResult.type = CqlResultType.VOID;
+ result.type = CqlResultType.VOID;
- return avroResult;
+ return result;
case TRUNCATE:
String columnFamily = (String)statement.statement;
@@ -588,14 +578,14 @@ public class QueryProcessor
throw (UnavailableException) new UnavailableException().initCause(e);
}
- avroResult.type = CqlResultType.VOID;
- return avroResult;
+ result.type = CqlResultType.VOID;
+ return result;
case DELETE:
DeleteStatement delete = (DeleteStatement)statement.statement;
clientState.hasColumnFamilyAccess(delete.getColumnFamily(), Permission.WRITE);
- CFMetaData metadata = validateColumnFamily(keyspace, delete.getColumnFamily(), false);
- AbstractType<?> comparator = metadata.getComparatorFor(null);
+ metadata = validateColumnFamily(keyspace, delete.getColumnFamily(), false);
+ comparator = metadata.getComparatorFor(null);
AbstractType<?> keyType = DatabaseDescriptor.getCFMetaData(keyspace,
delete.getColumnFamily()).getKeyValidator();
@@ -627,8 +617,8 @@ public class QueryProcessor
throw new TimedOutException();
}
- avroResult.type = CqlResultType.VOID;
- return avroResult;
+ result.type = CqlResultType.VOID;
+ return result;
case CREATE_KEYSPACE:
CreateKeyspaceStatement create = (CreateKeyspaceStatement)statement.statement;
@@ -656,8 +646,8 @@ public class QueryProcessor
throw ex;
}
- avroResult.type = CqlResultType.VOID;
- return avroResult;
+ result.type = CqlResultType.VOID;
+ return result;
case CREATE_COLUMNFAMILY:
CreateColumnFamilyStatement createCf = (CreateColumnFamilyStatement)statement.statement;
@@ -681,8 +671,8 @@ public class QueryProcessor
throw ex;
}
- avroResult.type = CqlResultType.VOID;
- return avroResult;
+ result.type = CqlResultType.VOID;
+ return result;
case CREATE_INDEX:
CreateIndexStatement createIdx = (CreateIndexStatement)statement.statement;
@@ -737,8 +727,8 @@ public class QueryProcessor
throw ex;
}
- avroResult.type = CqlResultType.VOID;
- return avroResult;
+ result.type = CqlResultType.VOID;
+ return result;
case DROP_KEYSPACE:
String deleteKeyspace = (String)statement.statement;
@@ -762,8 +752,8 @@ public class QueryProcessor
throw ex;
}
- avroResult.type = CqlResultType.VOID;
- return avroResult;
+ result.type = CqlResultType.VOID;
+ return result;
case DROP_COLUMNFAMILY:
String deleteColumnFamily = (String)statement.statement;
@@ -787,14 +777,51 @@ public class QueryProcessor
throw ex;
}
- avroResult.type = CqlResultType.VOID;
- return avroResult;
+ result.type = CqlResultType.VOID;
+ return result;
}
return null; // We should never get here.
}
-
+
+ private static List<Column> extractThriftColumns(SelectStatement select, AbstractType<?> comparator, Row row)
+ {
+ List<Column> thriftColumns = new ArrayList<Column>();
+ if (select.isColumnRange())
+ {
+ // preserve comparator order
+ for (IColumn c : row.cf.getSortedColumns())
+ {
+ if (c.isMarkedForDelete())
+ continue;
+ thriftColumns.add(new Column(c.name()).setValue(c.value()).setTimestamp(c.timestamp()));
+ }
+ }
+ else
+ {
+ // order columns in the order they were asked for
+ for (Term term : select.getColumnNames())
+ {
+ ByteBuffer name;
+ try
+ {
+ name = term.getByteBuffer(comparator);
+ }
+ catch (InvalidRequestException e)
+ {
+ throw new AssertionError(e);
+ }
+ IColumn c = row.cf.getColumn(name);
+ if (c == null || c.isMarkedForDelete())
+ thriftColumns.add(new Column().setName(name));
+ else
+ thriftColumns.add(new Column(c.name()).setValue(c.value()).setTimestamp(c.timestamp()));
+ }
+ }
+ return thriftColumns;
+ }
+
private static CQLStatement getStatement(String queryStr) throws InvalidRequestException, RecognitionException
{
// Lexer and parser
Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Tue Apr 19 17:13:19 2011
@@ -1459,6 +1459,10 @@ public class ColumnFamilyStore implement
ByteBuffer startKey = clause.start_key;
QueryPath path = new QueryPath(columnFamily);
+ // we need to store last data key accessed to avoid duplicate results
+ // because in the while loop new iteration we can access the same column if start_key was not set
+ ByteBuffer lastDataKey = null;
+
// fetch row keys matching the primary expression, fetch the slice predicate for each
// and filter by remaining expressions. repeat until finished w/ assigned range or index row is exhausted.
outer:
@@ -1490,10 +1494,11 @@ public class ColumnFamilyStore implement
continue;
dataKey = column.name();
n++;
+
DecoratedKey dk = partitioner.decorateKey(dataKey);
if (!range.right.equals(partitioner.getMinimumToken()) && range.right.compareTo(dk.token) < 0)
break outer;
- if (!range.contains(dk.token))
+ if (!range.contains(dk.token) || dataKey.equals(lastDataKey))
continue;
// get the row columns requested, and additional columns for the expressions if necessary
@@ -1534,7 +1539,8 @@ public class ColumnFamilyStore implement
}
if (n < clause.count || startKey.equals(dataKey))
break;
- startKey = dataKey;
+
+ lastDataKey = startKey = dataKey;
}
return rows;
Modified: cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java Tue Apr 19 17:13:19 2011
@@ -279,13 +279,13 @@ public class HintedHandOffManager implem
{
try
{
- logger_.info("Checking remote schema before delivering hints");
+ logger_.debug("Checking remote schema before delivering hints");
int waited = waitForSchemaAgreement(endpoint);
// sleep a random amount to stagger handoff delivery from different replicas.
// (if we had to wait, then gossiper randomness took care of that for us already.)
if (waited == 0) {
int sleep = new Random().nextInt(60000);
- logger_.info("Sleeping {}ms to stagger hint delivery", sleep);
+ logger_.debug("Sleeping {}ms to stagger hint delivery", sleep);
Thread.sleep(sleep);
}
if (!Gossiper.instance.getEndpointStateForEndpoint(endpoint).isAlive())
Modified: cassandra/trunk/src/java/org/apache/cassandra/db/MeteredFlusher.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/MeteredFlusher.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/MeteredFlusher.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/MeteredFlusher.java Tue Apr 19 17:13:19 2011
@@ -1,4 +1,25 @@
package org.apache.cassandra.db;
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+
import java.util.ArrayList;
import java.util.Collections;
Modified: cassandra/trunk/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordWriter.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordWriter.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordWriter.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordWriter.java Tue Apr 19 17:13:19 2011
@@ -206,7 +206,7 @@ implements org.apache.hadoop.mapred.Reco
private Column avroToThrift(org.apache.cassandra.hadoop.avro.Column acol)
{
- return new Column(acol.name, acol.value, acol.timestamp);
+ return new Column(acol.name).setValue(acol.value).setTimestamp(acol.timestamp);
}
/**
Modified: cassandra/trunk/src/java/org/apache/cassandra/io/CompactionType.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/CompactionType.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/CompactionType.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/CompactionType.java Tue Apr 19 17:13:19 2011
@@ -1,4 +1,25 @@
package org.apache.cassandra.io;
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+
public enum CompactionType
{
Modified: cassandra/trunk/src/java/org/apache/cassandra/io/ICompactSerializer3.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/ICompactSerializer3.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/ICompactSerializer3.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/ICompactSerializer3.java Tue Apr 19 17:13:19 2011
@@ -1,4 +1,25 @@
package org.apache.cassandra.io;
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+
public interface ICompactSerializer3<T> extends ICompactSerializer2<T>
{
Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java Tue Apr 19 17:13:19 2011
@@ -500,8 +500,9 @@ public class SSTableReader extends SSTab
public void cacheKey(DecoratedKey key, Long info)
{
+ assert key.key != null;
// avoid keeping a permanent reference to the original key buffer
- DecoratedKey copiedKey = new DecoratedKey(key.token, key.key == null ? null : ByteBufferUtil.clone(key.key));
+ DecoratedKey copiedKey = new DecoratedKey(key.token, ByteBufferUtil.clone(key.key));
keyCache.put(new Pair<Descriptor, DecoratedKey>(descriptor, copiedKey), info);
}
@@ -570,7 +571,8 @@ public class SSTableReader extends SSTab
if (op == Operator.EQ)
bloomFilterTracker.addTruePositive();
// store exact match for the key
- cacheKey(decoratedKey, dataPosition);
+ if (decoratedKey.key != null)
+ cacheKey(decoratedKey, dataPosition);
}
return dataPosition;
}
Modified: cassandra/trunk/src/java/org/apache/cassandra/io/util/MemoryInputStream.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/util/MemoryInputStream.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/util/MemoryInputStream.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/util/MemoryInputStream.java Tue Apr 19 17:13:19 2011
@@ -1,4 +1,25 @@
package org.apache.cassandra.io.util;
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+
import java.io.Closeable;
import java.io.DataInput;
@@ -42,4 +63,4 @@ public class MemoryInputStream extends A
{
// do nothing.
}
-}
\ No newline at end of file
+}
Modified: cassandra/trunk/src/java/org/apache/cassandra/io/util/MemoryOutputStream.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/util/MemoryOutputStream.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/util/MemoryOutputStream.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/util/MemoryOutputStream.java Tue Apr 19 17:13:19 2011
@@ -1,4 +1,25 @@
package org.apache.cassandra.io.util;
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+
import java.io.OutputStream;
Modified: cassandra/trunk/src/java/org/apache/cassandra/net/OutboundTcpConnection.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/net/OutboundTcpConnection.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/net/OutboundTcpConnection.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/net/OutboundTcpConnection.java Tue Apr 19 17:13:19 2011
@@ -116,8 +116,8 @@ public class OutboundTcpConnection exten
}
catch (IOException e)
{
- logger.info("error writing to " + endpoint);
- logger.debug("error was ", e);
+ if (logger.isDebugEnabled())
+ logger.debug("error writing to " + endpoint, e);
disconnect();
}
}
Modified: cassandra/trunk/src/java/org/apache/cassandra/service/AntiEntropyService.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/AntiEntropyService.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/AntiEntropyService.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/AntiEntropyService.java Tue Apr 19 17:13:19 2011
@@ -286,6 +286,7 @@ public class AntiEntropyService
private transient long validated;
private transient MerkleTree.TreeRange range;
private transient MerkleTree.TreeRangeIterator ranges;
+ private transient DecoratedKey lastKey;
public final static MerkleTree.RowHash EMPTY_ROW = new MerkleTree.RowHash(null, new byte[0]);
@@ -361,6 +362,9 @@ public class AntiEntropyService
public void add(AbstractCompactedRow row)
{
assert request.range.contains(row.key.token) : row.key.token + " is not contained in " + request.range;
+ assert lastKey == null || lastKey.compareTo(row.key) < 0
+ : "row " + row.key + " received out of order wrt " + lastKey;
+ lastKey = row.key;
if (range == null)
range = ranges.next();
Modified: cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java Tue Apr 19 17:13:19 2011
@@ -24,7 +24,6 @@ import java.io.UnsupportedEncodingExcept
import java.nio.ByteBuffer;
import java.nio.charset.CharacterCodingException;
import java.util.*;
-import java.util.Map.Entry;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
@@ -55,7 +54,6 @@ import org.apache.cassandra.service.Clie
import org.apache.cassandra.service.StorageProxy;
import org.apache.cassandra.service.StorageService;
import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.utils.FBUtilities;
import org.apache.thrift.TException;
public class CassandraServer implements Cassandra.Iface
@@ -146,7 +144,7 @@ public class CassandraServer implements
{
continue;
}
- Column thrift_column = new Column(column.name(), column.value(), column.timestamp());
+ Column thrift_column = new Column(column.name()).setValue(column.value()).setTimestamp(column.timestamp());
if (column instanceof ExpiringColumn)
{
thrift_column.setTtl(((ExpiringColumn) column).getTimeToLive());
@@ -195,7 +193,7 @@ public class CassandraServer implements
}
else
{
- Column thrift_column = new Column(column.name(), column.value(), column.timestamp());
+ Column thrift_column = new Column(column.name()).setValue(column.value()).setTimestamp(column.timestamp());
if (column instanceof ExpiringColumn)
{
thrift_column.setTtl(((ExpiringColumn) column).getTimeToLive());
@@ -858,21 +856,10 @@ public class CassandraServer implements
cfDefs.add(CFMetaData.convertToCFMetaData(cfDef));
}
- // Attempt to instantiate the ARS, which will throw a ConfigException if
- // the strategy_options aren't fully formed or if the ARS Classname is invalid.
- TokenMetadata tmd = StorageService.instance.getTokenMetadata();
- IEndpointSnitch eps = DatabaseDescriptor.getEndpointSnitch();
- Class<? extends AbstractReplicationStrategy> cls = AbstractReplicationStrategy.getClass(ks_def.strategy_class);
- AbstractReplicationStrategy strat = AbstractReplicationStrategy
- .createReplicationStrategy(ks_def.name,
- cls,
- tmd,
- eps,
- ks_def.strategy_options);
-
+ ThriftValidation.validateKsDef(ks_def);
KSMetaData ksm = new KSMetaData(ks_def.name,
AbstractReplicationStrategy.getClass(ks_def.strategy_class),
- ks_def.strategy_options,
+ KSMetaData.backwardsCompatibleOptions(ks_def),
cfDefs.toArray(new CFMetaData[cfDefs.size()]));
applyMigrationOnStage(new AddKeyspace(ksm));
@@ -891,7 +878,7 @@ public class CassandraServer implements
throw ex;
}
}
-
+
public synchronized String system_drop_keyspace(String keyspace)
throws InvalidRequestException, SchemaDisagreementException, TException
{
@@ -932,9 +919,10 @@ public class CassandraServer implements
try
{
+ ThriftValidation.validateKsDef(ks_def);
KSMetaData ksm = new KSMetaData(ks_def.name,
AbstractReplicationStrategy.getClass(ks_def.strategy_class),
- ks_def.strategy_options);
+ KSMetaData.backwardsCompatibleOptions(ks_def));
applyMigrationOnStage(new UpdateKeyspace(ksm));
return DatabaseDescriptor.getDefsVersion().toString();
}
Modified: cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java Tue Apr 19 17:13:19 2011
@@ -23,16 +23,16 @@ package org.apache.cassandra.thrift;
import java.nio.ByteBuffer;
import java.util.*;
-import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.ConfigurationException;
-import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.config.ColumnDefinition;
+import org.apache.cassandra.config.*;
import org.apache.cassandra.db.*;
import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.MarshalException;
import org.apache.cassandra.dht.IPartitioner;
import org.apache.cassandra.dht.RandomPartitioner;
import org.apache.cassandra.dht.Token;
+import org.apache.cassandra.locator.AbstractReplicationStrategy;
+import org.apache.cassandra.locator.IEndpointSnitch;
+import org.apache.cassandra.locator.TokenMetadata;
import org.apache.cassandra.service.StorageService;
import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.cassandra.utils.FBUtilities;
@@ -379,6 +379,10 @@ public class ThriftValidation
public static void validateColumnData(CFMetaData metadata, Column column) throws InvalidRequestException
{
validateTtl(column);
+ if (!column.isSetValue())
+ throw new InvalidRequestException("Column value is required");
+ if (!column.isSetTimestamp())
+ throw new InvalidRequestException("Column timestamp is required");
try
{
AbstractType validator = metadata.getValueValidator(column.name);
@@ -550,4 +554,15 @@ public class ThriftValidation
throw new InvalidRequestException("cannot achieve CL > CL.ONE without replicate_on_write on columnfamily " + metadata.cfName);
}
}
+
+ static void validateKsDef(KsDef ks_def) throws ConfigurationException
+ {
+ // Attempt to instantiate the ARS, which will throw a ConfigException if
+ // the strategy_options aren't fully formed or if the ARS Classname is invalid.
+ Map<String, String> options = KSMetaData.backwardsCompatibleOptions(ks_def);
+ TokenMetadata tmd = StorageService.instance.getTokenMetadata();
+ IEndpointSnitch eps = DatabaseDescriptor.getEndpointSnitch();
+ Class<? extends AbstractReplicationStrategy> cls = AbstractReplicationStrategy.getClass(ks_def.strategy_class);
+ AbstractReplicationStrategy.createReplicationStrategy(ks_def.name, cls, tmd, eps, options);
+ }
}
Modified: cassandra/trunk/src/resources/org/apache/cassandra/cli/CliHelp.yaml
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/resources/org/apache/cassandra/cli/CliHelp.yaml?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/src/resources/org/apache/cassandra/cli/CliHelp.yaml (original)
+++ cassandra/trunk/src/resources/org/apache/cassandra/cli/CliHelp.yaml Tue Apr 19 17:13:19 2011
@@ -1,3 +1,20 @@
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
# Help file for online commands in Yaml.
banner: |
@@ -1147,4 +1164,4 @@ commands:
- EACH_QUORUM
- ANY
- Note: Consistency level ANY can only be used for write operations.
\ No newline at end of file
+ Note: Consistency level ANY can only be used for write operations.
Modified: cassandra/trunk/test/long/org/apache/cassandra/db/MeteredFlusherTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/long/org/apache/cassandra/db/MeteredFlusherTest.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/test/long/org/apache/cassandra/db/MeteredFlusherTest.java (original)
+++ cassandra/trunk/test/long/org/apache/cassandra/db/MeteredFlusherTest.java Tue Apr 19 17:13:19 2011
@@ -1,4 +1,25 @@
package org.apache.cassandra.db;
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+
import java.io.IOException;
import java.nio.ByteBuffer;
Modified: cassandra/trunk/test/system/__init__.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/system/__init__.py?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/test/system/__init__.py (original)
+++ cassandra/trunk/test/system/__init__.py Tue Apr 19 17:13:19 2011
@@ -33,7 +33,7 @@ import Cassandra
def get_thrift_client(host='127.0.0.1', port=9170):
socket = TSocket.TSocket(host, port)
transport = TTransport.TFramedTransport(socket)
- protocol = TBinaryProtocol.TBinaryProtocolAccelerated(transport)
+ protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = Cassandra.Client(protocol)
client.transport = transport
return client
@@ -149,7 +149,7 @@ class ThriftTester(BaseTester):
def define_schema(self):
keyspace1 = Cassandra.KsDef('Keyspace1', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'},
- [
+ cf_defs=[
Cassandra.CfDef('Keyspace1', 'Standard1'),
Cassandra.CfDef('Keyspace1', 'Standard2'),
Cassandra.CfDef('Keyspace1', 'StandardLong1', comparator_type='LongType'),
@@ -168,7 +168,7 @@ class ThriftTester(BaseTester):
])
keyspace2 = Cassandra.KsDef('Keyspace2', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'},
- [
+ cf_defs=[
Cassandra.CfDef('Keyspace2', 'Standard1'),
Cassandra.CfDef('Keyspace2', 'Standard3'),
Cassandra.CfDef('Keyspace2', 'Super3', column_type='Super', subcomparator_type='BytesType'),
Modified: cassandra/trunk/test/system/test_cql.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/system/test_cql.py?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/test/system/test_cql.py (original)
+++ cassandra/trunk/test/system/test_cql.py Tue Apr 19 17:13:19 2011
@@ -136,13 +136,16 @@ class TestCql(ThriftTester):
def test_select_columns(self):
"retrieve multiple columns"
cursor = init()
+ # we deliberately request columns in non-comparator order
cursor.execute("""
- SELECT 'cd1', 'col' FROM StandardString1 WHERE KEY = 'kd'
+ SELECT ca1, col, cd1 FROM StandardString1 WHERE KEY = 'kd'
""")
d = cursor.description
- assert "cd1" in [col_dscptn[0] for col_dscptn in d]
- assert "col" in [col_dscptn[0] for col_dscptn in d]
+ assert ['Row Key', 'ca1', 'col', 'cd1'] == [col_dscptn[0] for col_dscptn in d], d
+ row = cursor.fetchone()
+ # check that the column that didn't exist in the row comes back as null
+ assert ['kd', None, 'val', 'vd1'] == row, row
def test_select_row_range(self):
"retrieve a range of rows with columns"
@@ -307,9 +310,8 @@ class TestCql(ThriftTester):
cursor.execute("""
SELECT 'cd1', 'col' FROM StandardString1 WHERE KEY = 'kd'
""")
- colnames = [col_d[0] for col_d in cursor.description]
- assert "cd1" in colnames
- assert "col" in colnames
+ assert ['Row Key', 'cd1', 'col'] == [col_d[0] for col_d in cursor.description]
+
cursor.execute("""
DELETE 'cd1', 'col' FROM StandardString1 WHERE KEY = 'kd'
""")
@@ -317,7 +319,7 @@ class TestCql(ThriftTester):
SELECT 'cd1', 'col' FROM StandardString1 WHERE KEY = 'kd'
""")
r = cursor.fetchone()
- assert len(r) == 1
+ assert ['kd', None, None] == r, r
def test_delete_columns_multi_rows(self):
"delete columns from multiple rows"
@@ -325,22 +327,22 @@ class TestCql(ThriftTester):
cursor.execute("SELECT 'col' FROM StandardString1 WHERE KEY = 'kc'")
r = cursor.fetchone()
- assert len(r) == 2
+ assert ['kc', 'val'] == r, r
cursor.execute("SELECT 'col' FROM StandardString1 WHERE KEY = 'kd'")
r = cursor.fetchone()
- assert len(r) == 2
+ assert ['kd', 'val'] == r, r
cursor.execute("""
DELETE 'col' FROM StandardString1 WHERE KEY IN ('kc', 'kd')
""")
cursor.execute("SELECT 'col' FROM StandardString1 WHERE KEY = 'kc'")
r = cursor.fetchone()
- assert len(r) == 1
+ assert ['kc', None] == r, r
cursor.execute("SELECT 'col' FROM StandardString1 WHERE KEY = 'kd'")
r = cursor.fetchone()
- assert len(r) == 1
+ assert ['kd', None] == r, r
def test_delete_rows(self):
"delete entire rows"
@@ -348,15 +350,13 @@ class TestCql(ThriftTester):
cursor.execute("""
SELECT 'cd1', 'col' FROM StandardString1 WHERE KEY = 'kd'
""")
- colnames = [col_d[0] for col_d in cursor.description]
- assert "cd1" in colnames
- assert "col" in colnames
+ assert ['Row Key', 'cd1', 'col'] == [col_d[0] for col_d in cursor.description]
cursor.execute("DELETE FROM StandardString1 WHERE KEY = 'kd'")
cursor.execute("""
SELECT 'cd1', 'col' FROM StandardString1 WHERE KEY = 'kd'
""")
r = cursor.fetchone()
- assert len(r) == 1
+ assert ['kd', None, None] == r, r
def test_create_keyspace(self):
"create a new keyspace"
Modified: cassandra/trunk/test/system/test_thrift_server.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/system/test_thrift_server.py?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/test/system/test_thrift_server.py (original)
+++ cassandra/trunk/test/system/test_thrift_server.py Tue Apr 19 17:13:19 2011
@@ -1192,20 +1192,20 @@ class TestMutations(ThriftTester):
def test_invalid_ks_names(self):
def invalid_keyspace():
- client.system_add_keyspace(KsDef('in-valid', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, []))
+ client.system_add_keyspace(KsDef('in-valid', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, cf_defs=[]))
_expect_exception(invalid_keyspace, InvalidRequestException)
def test_invalid_strategy_class(self):
def add_invalid_keyspace():
- client.system_add_keyspace(KsDef('ValidKs', 'InvalidStrategyClass', {}, []))
+ client.system_add_keyspace(KsDef('ValidKs', 'InvalidStrategyClass', {}, cf_defs=[]))
exc = _expect_exception(add_invalid_keyspace, InvalidRequestException)
s = str(exc)
assert s.find("InvalidStrategyClass") > -1, s
assert s.find("Unable to find replication strategy") > -1, s
def update_invalid_keyspace():
- client.system_add_keyspace(KsDef('ValidKsForUpdate', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, []))
- client.system_update_keyspace(KsDef('ValidKsForUpdate', 'InvalidStrategyClass', {}, []))
+ client.system_add_keyspace(KsDef('ValidKsForUpdate', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, cf_defs=[]))
+ client.system_update_keyspace(KsDef('ValidKsForUpdate', 'InvalidStrategyClass', {}, cf_defs=[]))
exc = _expect_exception(update_invalid_keyspace, InvalidRequestException)
s = str(exc)
@@ -1222,7 +1222,7 @@ class TestMutations(ThriftTester):
def invalid_cf_inside_new_ks():
cf = CfDef('ValidKsName_invalid_cf', 'in-valid')
_set_keyspace('system')
- client.system_add_keyspace(KsDef('ValidKsName_invalid_cf', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor': '1'}, [cf]))
+ client.system_add_keyspace(KsDef('ValidKsName_invalid_cf', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor': '1'}, cf_defs=[cf]))
_expect_exception(invalid_cf_inside_new_ks, InvalidRequestException)
def test_system_cf_recreate(self):
@@ -1234,7 +1234,7 @@ class TestMutations(ThriftTester):
# create
newcf = CfDef(keyspace, cf_name)
- newks = KsDef(keyspace, 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, [newcf])
+ newks = KsDef(keyspace, 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, cf_defs=[newcf])
client.system_add_keyspace(newks)
_set_keyspace(keyspace)
@@ -1261,7 +1261,7 @@ class TestMutations(ThriftTester):
keyspace = KsDef('CreateKeyspace',
'org.apache.cassandra.locator.SimpleStrategy',
{'replication_factor': '10'},
- [CfDef('CreateKeyspace', 'CreateKsCf')])
+ cf_defs=[CfDef('CreateKeyspace', 'CreateKsCf')])
client.system_add_keyspace(keyspace)
newks = client.describe_keyspace('CreateKeyspace')
assert 'CreateKsCf' in [x.name for x in newks.cf_defs]
@@ -1272,7 +1272,7 @@ class TestMutations(ThriftTester):
modified_keyspace = KsDef('CreateKeyspace',
'org.apache.cassandra.locator.OldNetworkTopologyStrategy',
{'replication_factor': '1'},
- [])
+ cf_defs=[])
client.system_update_keyspace(modified_keyspace)
modks = client.describe_keyspace('CreateKeyspace')
assert modks.strategy_class == modified_keyspace.strategy_class
Modified: cassandra/trunk/test/unit/org/apache/cassandra/cache/CacheProviderTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/cache/CacheProviderTest.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/cache/CacheProviderTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/cache/CacheProviderTest.java Tue Apr 19 17:13:19 2011
@@ -1,4 +1,25 @@
package org.apache.cassandra.cache;
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+
import java.util.ArrayList;
import java.util.List;
Modified: cassandra/trunk/test/unit/org/apache/cassandra/client/TestRingCache.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/client/TestRingCache.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/client/TestRingCache.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/client/TestRingCache.java Tue Apr 19 17:13:19 2011
@@ -103,7 +103,7 @@ public class TestRingCache
// now, read the row back directly from the host owning the row locally
tester.setup(firstEndpoint.getHostAddress(), DatabaseDescriptor.getRpcPort());
tester.thriftClient.set_keyspace(keyspace);
- tester.thriftClient.insert(row, parent, new Column(ByteBufferUtil.bytes("col1"), ByteBufferUtil.bytes("val1"), 1), ConsistencyLevel.ONE);
+ tester.thriftClient.insert(row, parent, new Column(ByteBufferUtil.bytes("col1")).setValue(ByteBufferUtil.bytes("val1")).setTimestamp(1), ConsistencyLevel.ONE);
Column column = tester.thriftClient.get(row, col, ConsistencyLevel.ONE).column;
System.out.println("read row " + new String(row.array()) + " " + new String(column.name.array()) + ":" + new String(column.value.array()) + ":" + column.timestamp);
}
Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java Tue Apr 19 17:13:19 2011
@@ -211,6 +211,35 @@ public class ColumnFamilyStoreTest exten
}
@Test
+ public void testLargeScan() throws IOException
+ {
+ RowMutation rm;
+ for (int i = 0; i < 100; i++)
+ {
+ rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("key" + i));
+ rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(34L), 0);
+ rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("notbirthdate")), ByteBufferUtil.bytes((long) (i % 2)), 0);
+ rm.applyUnsafe();
+ }
+
+ IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ, ByteBufferUtil.bytes(34L));
+ IndexExpression expr2 = new IndexExpression(ByteBufferUtil.bytes("notbirthdate"), IndexOperator.EQ, ByteBufferUtil.bytes(1L));
+ IndexClause clause = new IndexClause(Arrays.asList(expr, expr2), ByteBufferUtil.EMPTY_BYTE_BUFFER, 100);
+ IFilter filter = new IdentityQueryFilter();
+ IPartitioner p = StorageService.getPartitioner();
+ Range range = new Range(p.getMinimumToken(), p.getMinimumToken());
+ List<Row> rows = Table.open("Keyspace1").getColumnFamilyStore("Indexed1").scan(clause, range, filter);
+
+ assert rows != null;
+ assert rows.size() == 50 : rows.size();
+ Set<DecoratedKey> keys = new HashSet<DecoratedKey>();
+ // extra check that there are no duplicate results -- see https://issues.apache.org/jira/browse/CASSANDRA-2406
+ for (Row row : rows)
+ keys.add(row.key);
+ assert rows.size() == keys.size();
+ }
+
+ @Test
public void testIndexDeletions() throws IOException
{
ColumnFamilyStore cfs = Table.open("Keyspace3").getColumnFamilyStore("Indexed1");
Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/SystemTableTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/SystemTableTest.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/SystemTableTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/SystemTableTest.java Tue Apr 19 17:13:19 2011
@@ -1,4 +1,25 @@
package org.apache.cassandra.db;
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+
import java.net.InetAddress;
import java.net.UnknownHostException;
Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/marshal/UUIDTypeTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/marshal/UUIDTypeTest.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/marshal/UUIDTypeTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/marshal/UUIDTypeTest.java Tue Apr 19 17:13:19 2011
@@ -1,4 +1,25 @@
package org.apache.cassandra.db.marshal;
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+
import static org.junit.Assert.assertEquals;
Modified: cassandra/trunk/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java Tue Apr 19 17:13:19 2011
@@ -84,8 +84,10 @@ public class EmbeddedCassandraServiceTes
cp.column = ByteBufferUtil.bytes("name");
// insert
- client.insert(key_user_id, par, new Column(ByteBufferUtil.bytes("name"),
- ByteBufferUtil.bytes("Ran"), timestamp), ConsistencyLevel.ONE);
+ client.insert(key_user_id,
+ par,
+ new Column(ByteBufferUtil.bytes("name")).setValue(ByteBufferUtil.bytes("Ran")).setTimestamp(timestamp),
+ ConsistencyLevel.ONE);
// read
ColumnOrSuperColumn got = client.get(key_user_id, cp, ConsistencyLevel.ONE);
Modified: cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/Session.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/Session.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/Session.java (original)
+++ cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/Session.java Tue Apr 19 17:13:19 2011
@@ -73,6 +73,7 @@ public class Session
availableOptions.addOption("R", "replication-strategy", true, "Replication strategy to use (only on insert if keyspace does not exist), default:org.apache.cassandra.locator.SimpleStrategy");
availableOptions.addOption("O", "strategy-properties", true, "Replication strategy properties in the following format <dc_name>:<num>,<dc_name>:<num>,...");
availableOptions.addOption("W", "no-replicate-on-write",false, "Set replicate_on_write to false for counters. Only counter add with CL=ONE will work");
+ availableOptions.addOption("V", "average-size-values", false, "Generate column values of average rather than specific size");
}
private int numKeys = 1000 * 1000;
@@ -103,6 +104,7 @@ public class Session
private String replicationStrategy = "org.apache.cassandra.locator.SimpleStrategy";
private Map<String, String> replicationStrategyOptions = new HashMap<String, String>();
+ public final boolean averageSizeValues;
// required by Gaussian distribution.
protected int mean;
@@ -260,6 +262,8 @@ public class Session
if (cmd.hasOption("W"))
replicateOnWrite = false;
+
+ averageSizeValues = cmd.hasOption("V");
}
catch (ParseException e)
{
Modified: cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/operations/IndexedRangeSlicer.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/operations/IndexedRangeSlicer.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/operations/IndexedRangeSlicer.java (original)
+++ cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/operations/IndexedRangeSlicer.java Tue Apr 19 17:13:19 2011
@@ -48,8 +48,8 @@ public class IndexedRangeSlicer extends
int received = 0;
- String startOffset = "0";
- ByteBuffer value = values.get(index % values.size());
+ String startOffset = String.format(format, 0);
+ ByteBuffer value = values.get(1); // only C1 column is indexed
IndexExpression expression = new IndexExpression(columnName, IndexOperator.EQ, value);
Modified: cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/util/Operation.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/util/Operation.java?rev=1095139&r1=1095138&r2=1095139&view=diff
==============================================================================
--- cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/util/Operation.java (original)
+++ cassandra/trunk/tools/stress/src/org/apache/cassandra/stress/util/Operation.java Tue Apr 19 17:13:19 2011
@@ -55,11 +55,33 @@ public abstract class Operation
// Utility methods
+ protected List<ByteBuffer> generateValues()
+ {
+ if (session.averageSizeValues)
+ {
+ return generateRandomizedValues();
+ }
+
+ List<ByteBuffer> values = new ArrayList<ByteBuffer>();
+
+ for (int i = 0; i < session.getCardinality(); i++)
+ {
+ String hash = getMD5(Integer.toString(i));
+ int times = session.getColumnSize() / hash.length();
+ int sumReminder = session.getColumnSize() % hash.length();
+
+ String value = new StringBuilder(multiplyString(hash, times)).append(hash.substring(0, sumReminder)).toString();
+ values.add(ByteBuffer.wrap(value.getBytes()));
+ }
+
+ return values;
+ }
+
/**
* Generate values of average size specified by -S, up to cardinality specified by -C
* @return Collection of the values
*/
- protected List<ByteBuffer> generateValues()
+ protected List<ByteBuffer> generateRandomizedValues()
{
List<ByteBuffer> values = new ArrayList<ByteBuffer>();