mirror of https://github.com/apache/cassandra
merge from 0.8.1
git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@1124795 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
259f06eff5
commit
e23fff1d73
|
|
@ -235,10 +235,10 @@ exitStatement
|
|||
;
|
||||
|
||||
getStatement
|
||||
: GET columnFamilyExpr ('AS' typeIdentifier)?
|
||||
-> ^(NODE_THRIFT_GET columnFamilyExpr ( ^(CONVERT_TO_TYPE typeIdentifier) )? )
|
||||
| GET columnFamily 'WHERE' getCondition ('AND' getCondition)* ('LIMIT' limit=IntegerPositiveLiteral)*
|
||||
-> ^(NODE_THRIFT_GET_WITH_CONDITIONS columnFamily ^(CONDITIONS getCondition+) ^(NODE_LIMIT $limit)*)
|
||||
: GET columnFamilyExpr ('AS' typeIdentifier)? ('LIMIT' limit=IntegerPositiveLiteral)?
|
||||
-> ^(NODE_THRIFT_GET columnFamilyExpr ( ^(CONVERT_TO_TYPE typeIdentifier) )? ^(NODE_LIMIT $limit)?)
|
||||
| GET columnFamily 'WHERE' getCondition ('AND' getCondition)* ('LIMIT' limit=IntegerPositiveLiteral)?
|
||||
-> ^(NODE_THRIFT_GET_WITH_CONDITIONS columnFamily ^(CONDITIONS getCondition+) ^(NODE_LIMIT $limit)?)
|
||||
;
|
||||
|
||||
getCondition
|
||||
|
|
|
|||
|
|
@ -412,7 +412,7 @@ public class CliClient
|
|||
sessionState.out.println(String.format("%s removed.", (columnSpecCnt == 0) ? "row" : "column"));
|
||||
}
|
||||
|
||||
private void doSlice(String keyspace, ByteBuffer key, String columnFamily, byte[] superColumnName)
|
||||
private void doSlice(String keyspace, ByteBuffer key, String columnFamily, byte[] superColumnName, int limit)
|
||||
throws InvalidRequestException, UnavailableException, TimedOutException, TException, IllegalAccessException, NotFoundException, InstantiationException, NoSuchFieldException
|
||||
{
|
||||
|
||||
|
|
@ -420,7 +420,7 @@ public class CliClient
|
|||
if(superColumnName != null)
|
||||
parent.setSuper_column(superColumnName);
|
||||
|
||||
SliceRange range = new SliceRange(ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, 1000000);
|
||||
SliceRange range = new SliceRange(ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, limit);
|
||||
SlicePredicate predicate = new SlicePredicate().setColumn_names(null).setSlice_range(range);
|
||||
|
||||
CfDef cfDef = getCfDef(columnFamily);
|
||||
|
|
@ -529,10 +529,39 @@ public class CliClient
|
|||
byte[] superColumnName = null;
|
||||
ByteBuffer columnName;
|
||||
|
||||
Tree typeTree = null;
|
||||
Tree limitTree = null;
|
||||
|
||||
int limit = 1000000;
|
||||
|
||||
if (statement.getChildCount() >= 2)
|
||||
{
|
||||
if (statement.getChild(1).getType() == CliParser.CONVERT_TO_TYPE)
|
||||
{
|
||||
typeTree = statement.getChild(1).getChild(0);
|
||||
if (statement.getChildCount() == 3)
|
||||
limitTree = statement.getChild(2).getChild(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
limitTree = statement.getChild(1).getChild(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (limitTree != null)
|
||||
{
|
||||
limit = Integer.parseInt(limitTree.getText());
|
||||
|
||||
if (limit == 0)
|
||||
{
|
||||
throw new IllegalArgumentException("LIMIT should be greater than zero.");
|
||||
}
|
||||
}
|
||||
|
||||
// table.cf['key'] -- row slice
|
||||
if (columnSpecCnt == 0)
|
||||
{
|
||||
doSlice(keySpace, key, columnFamily, superColumnName);
|
||||
doSlice(keySpace, key, columnFamily, superColumnName, limit);
|
||||
return;
|
||||
}
|
||||
// table.cf['key']['column'] -- slice of a super, or get of a standard
|
||||
|
|
@ -543,7 +572,7 @@ public class CliClient
|
|||
if (isSuper)
|
||||
{
|
||||
superColumnName = columnName.array();
|
||||
doSlice(keySpace, key, columnFamily, superColumnName);
|
||||
doSlice(keySpace, key, columnFamily, superColumnName, limit);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -586,14 +615,12 @@ public class CliClient
|
|||
|
||||
byte[] columnValue = column.getValue();
|
||||
String valueAsString;
|
||||
|
||||
|
||||
// we have ^(CONVERT_TO_TYPE <type>) inside of GET statement
|
||||
// which means that we should try to represent byte[] value according
|
||||
// to specified type
|
||||
if (statement.getChildCount() == 2)
|
||||
if (typeTree != null)
|
||||
{
|
||||
// getting ^(CONVERT_TO_TYPE <type>) tree
|
||||
Tree typeTree = statement.getChild(1).getChild(0);
|
||||
// .getText() will give us <type>
|
||||
String typeName = CliUtils.unescapeSQLString(typeTree.getText());
|
||||
// building AbstractType from <type>
|
||||
|
|
|
|||
Loading…
Reference in New Issue