Maxwell-Guo commented on code in PR #2118:
URL: https://github.com/apache/cassandra/pull/2118#discussion_r1093225924
##########
src/java/org/apache/cassandra/db/marshal/TypeParser.java:
##########
@@ -131,6 +138,59 @@ public AbstractType<?> parse() throws SyntaxException,
ConfigurationException
return getAbstractType(name);
}
+ /**
+ * parse PartitionOrdering from old version of PartitionOrdering' string
format
+ * */
+ private static AbstractType<?> defaultParsePartitionOrdering(TypeParser
typeParser)
+ {
+ IPartitioner partitioner = DatabaseDescriptor.getPartitioner();
+ Iterator<String> argIterator =
typeParser.getKeyValueParameters().keySet().iterator();
+ if (argIterator.hasNext())
+ {
+ partitioner = FBUtilities.newPartitioner(argIterator.next());
+ assert !argIterator.hasNext();
+ }
+ return partitioner.partitionOrdering();
+ }
+
+ /**
+ * parse and return the real PartitionerDefinedOrder from the string
variable str
+ * the str format can be like PartitionerDefinedOrder(<partitioner>) or
+ * PartitionerDefinedOrder(<partitioner>:<baseType>)
+ * */
+ public AbstractType<?> getPartitionerDefinedOrder()
+ {
+ int initIdx = idx;
+ skipBlank();
+ if (isEOS())
+ return defaultParsePartitionOrdering(this);
+ if (str.charAt(idx) != '(')
+ throw new IllegalStateException();
+
+ ++idx; // skipping '('
+ skipBlank();
+
+ String k = readNextIdentifier();
+ IPartitioner partitioner = FBUtilities.newPartitioner(k);
+ skipBlank();
+ if (str.charAt(idx) == ':')
+ {
+ ++idx;
+ skipBlank();
+ // must be PartitionerDefinedOrder
+ PartitionerDefinedOrder tmp = (PartitionerDefinedOrder)
partitioner.partitionOrdering();
+ return tmp.withBaseType(parse());
+ }
+ else if (str.charAt(idx) == ')')
+ {
+ idx = initIdx;
+ // if PartitionerDefinedOrder(<partitioner>) then use the original
way of parse partitioner Order
+ // for may exist some place we do not know ? or we can just return
partitioner.partitionOrdering() here with not initIdx set
+ return defaultParsePartitionOrdering(this);
Review Comment:
yes I agree, as ths comment I left above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]