Skip to content

Commit

Permalink
merge from 0.8
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@1163255 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
tjake committed Aug 30, 2011
2 parents 16d7385 + 51d20ba commit 2ec8621
Show file tree
Hide file tree
Showing 11 changed files with 290 additions and 107 deletions.
11 changes: 10 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,16 @@
* allow sstable2json to work on index sstable files (CASSANDRA-3059)
* always hint counters (CASSANDRA-3099)
* fix log4j initialization in EmbeddedCassandraService (CASSANDRA-2857)

* remove gossip state when a new IP takes over a token (CASSANDRA-3071)
* work around native memory leak in com.sun.management.GarbageCollectorMXBean
(CASSANDRA-2868)
* fix UnavailableException with writes at CL.EACH_QUORM (CASSANDRA-3084)
* fix parsing of the Keyspace and ColumnFamily names in numeric
and string representations in CLI (CASSANDRA-3075)
* fix corner cases in Range.differenceToFetch (CASSANDRA-3084)
* fix ip address String representation in the ring cache (CASSANDRA-3044)
* fix ring cache compatibility when mixing pre-0.8.4 nodes with post-
in the same cluster (CASSANDRA-3023)

0.8.4
* include files-to-be-streamed in StreamInSession.getSources (CASSANDRA-2972)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ Upgrading
- The loadbalance command has been removed from nodetool. For similar
behavior, decommission then rebootstrap with empty initial_token.
- Thrift unframed mode has been removed.
- The addition of key_validation_class means the cli will assume keys
are bytes, instead of strings, in the absence of other information.
See http://wiki.apache.org/cassandra/FAQ#cli_keys for more details.


Features
--------
Expand Down
46 changes: 19 additions & 27 deletions src/java/org/apache/cassandra/cli/Cli.g
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ useKeyspace


keyValuePairExpr
: objectName ( (AND | WITH) keyValuePair )*
-> ^(NODE_NEW_KEYSPACE_ACCESS objectName ( keyValuePair )* )
: entityName ( (AND | WITH) keyValuePair )*
-> ^(NODE_NEW_KEYSPACE_ACCESS entityName ( keyValuePair )* )
;

keyValuePair
Expand Down Expand Up @@ -424,13 +424,13 @@ columnFamilyExpr
;

keyRangeExpr
: '[' ( startKey? ':' endKey? )? ']'
-> ^(NODE_KEY_RANGE startKey? endKey?)
: '[' ( startKey=entityName? ':' endKey=entityName? )? ']'
-> ^(NODE_KEY_RANGE $startKey? $endKey?)
;

columnName
: (StringLiteral | Identifier | IntegerPositiveLiteral | IntegerNegativeLiteral)
;
: entityName
;

attr_name
: Identifier
Expand All @@ -449,21 +449,17 @@ attrValueDouble
: DoubleLiteral
;

objectName
: Identifier
;

keyspace
: Identifier
;
: entityName
;

replica_placement_strategy
: StringLiteral
;

keyspaceNewName
: Identifier
;
: entityName
;

comparator
: StringLiteral
Expand All @@ -473,8 +469,8 @@ command : Identifier
;

newColumnFamily
: Identifier
;
: entityName
;

username: Identifier
;
Expand All @@ -483,10 +479,14 @@ password: StringLiteral
;

columnFamily
: Identifier
;
: entityName
;

entityName
: (Identifier | StringLiteral | IntegerPositiveLiteral | IntegerNegativeLiteral)
;

rowKey
rowKey
: (Identifier | StringLiteral | IntegerPositiveLiteral | IntegerNegativeLiteral | functionCall)
;

Expand All @@ -507,14 +507,6 @@ functionArgument
: Identifier | StringLiteral | IntegerPositiveLiteral | IntegerNegativeLiteral
;

startKey
: (Identifier | StringLiteral)
;

endKey
: (Identifier | StringLiteral)
;

columnOrSuperColumn
: (Identifier | IntegerPositiveLiteral | IntegerNegativeLiteral | StringLiteral | functionCall)
;
Expand Down
2 changes: 1 addition & 1 deletion src/java/org/apache/cassandra/cli/CliCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static Tree compileQuery(String query)

public static String getColumnFamily(Tree astNode, List<CfDef> cfDefs)
{
return getColumnFamily(astNode.getChild(0).getText(), cfDefs);
return getColumnFamily(CliUtils.unescapeSQLString(astNode.getChild(0).getText()), cfDefs);
}

public static String getColumnFamily(String cfName, List<CfDef> cfDefs)
Expand Down
62 changes: 41 additions & 21 deletions src/java/org/apache/cassandra/dht/Range.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,24 @@ public int compareTo(Range rhs)
return compare(right,rhs.right);
}

/**
* Subtracts a portion of this range.
* @param contained The range to subtract from this. It must be totally
* contained by this range.
* @return An ArrayList of the Ranges left after subtracting contained
* from this.
*/
private ArrayList<Range> subtractContained(Range contained)
{
ArrayList<Range> difference = new ArrayList<Range>();

if (!left.equals(contained.left))
difference.add(new Range(left, contained.left));
if (!right.equals(contained.right))
difference.add(new Range(contained.right, right));
return difference;
}

/**
* Calculate set of the difference ranges of given two ranges
* (as current (A, B] and rhs is (C, D])
Expand All @@ -270,33 +288,35 @@ public int compareTo(Range rhs)
*/
public Set<Range> differenceToFetch(Range rhs)
{
Set<Range> difference = new HashSet<Range>();

int comparisonAC = Range.compare(left, rhs.left);

if (comparisonAC == 0) // (A, B] & (A, C]
Set<Range> result;
Set<Range> intersectionSet = this.intersectionWith(rhs);
if (intersectionSet.isEmpty())
{
if (Range.compare(right, rhs.right) < 0) // B < C
{
difference.add(new Range(right, rhs.right));
}
result = new HashSet<Range>();
result.add(rhs);
}
else if (comparisonAC > 0) // (A, B] & (C, D] where C < A (A > C)
else
{
difference.add(new Range(rhs.left, left)); // first interval will be (C, A]

if (Range.compare(rhs.right, right) > 0) // D > B
Range[] intersections = new Range[intersectionSet.size()];
intersectionSet.toArray(intersections);
if (intersections.length == 1)
{
difference.add(new Range(rhs.right, right)); // (D, B]
result = new HashSet<Range>(rhs.subtractContained(intersections[0]));
}
else
{
// intersections.length must be 2
Range first = intersections[0];
Range second = intersections[1];
ArrayList<Range> temp = rhs.subtractContained(first);

// Because there are two intersections, subtracting only one of them
// will yield a single Range.
Range single = temp.get(0);
result = new HashSet<Range>(single.subtractContained(second));
}
}
else // (A, B] & (C, D] where C > A (mean that comparisonAC < 0)
{
Token newLeft = (Range.compare(rhs.left, right) > 0) ? rhs.left : right; // C > B ? (C, D] : (B, D]
difference.add(new Range(newLeft, rhs.right));
}

return difference;
return result;
}

public static boolean isTokenInRanges(Token token, Iterable<Range> ranges)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void assureSufficientLiveNodes() throws UnavailableException
// Throw exception if any of the DC doesn't have livenodes to accept write.
for (String dc: strategy.getDatacenters())
{
if (dcEndpoints.get(dc).get() != responses.get(dc).get())
if (dcEndpoints.get(dc).get() < responses.get(dc).get())
throw new UnavailableException();
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/java/org/apache/cassandra/service/GCInspector.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ private void logGCResults()

Long previousCount = gccounts.get(gc.getName());
Long count = gc.getCollectionCount();

if (count == 0)
continue;

if (previousCount == null)
previousCount = 0L;
gccounts.put(gc.getName(), count);
Expand Down
11 changes: 9 additions & 2 deletions src/java/org/apache/cassandra/utils/BloomCalculations.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,21 @@ public static BloomSpecification computeBloomSpec(int bucketsPerElement)
* A wrapper class that holds two key parameters for a Bloom Filter: the
* number of hash functions used, and the number of buckets per element used.
*/
public static class BloomSpecification {
public static class BloomSpecification
{
final int K; // number of hash functions.
final int bucketsPerElement;

public BloomSpecification(int k, int bucketsPerElement) {
public BloomSpecification(int k, int bucketsPerElement)
{
K = k;
this.bucketsPerElement = bucketsPerElement;
}

public String toString()
{
return String.format("BloomSpecification(K=%d, bucketsPerElement=%d)", K, bucketsPerElement);
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/java/org/apache/cassandra/utils/BloomFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public static BloomFilter getFilter(long numElements, int targetBucketsPerElem)
numElements, bucketsPerElement, targetBucketsPerElem));
}
BloomCalculations.BloomSpecification spec = BloomCalculations.computeBloomSpec(bucketsPerElement);
logger.debug("Creating bloom filter for {} elements and spec {}", numElements, spec);
return new BloomFilter(spec.K, bucketsFor(numElements, spec.bucketsPerElement));
}

Expand Down
Loading

0 comments on commit 2ec8621

Please sign in to comment.