blerer commented on a change in pull request #1368:
URL: https://github.com/apache/cassandra/pull/1368#discussion_r772140067
##########
File path: src/java/org/apache/cassandra/cql3/functions/OperationFcts.java
##########
@@ -105,6 +106,22 @@ protected ByteBuffer executeOnNumerics(NumberType<?>
resultType,
{
return resultType.mod(leftType, left, rightType, right);
}
+ },
+ CONCATENATION('+', "_concat")
Review comment:
There is no need to add a new enum. You should simply implemente the
`excuteOnStrings` method in `ADD`. The internal name is hidden and does not
play any important role.
##########
File path: src/java/org/apache/cassandra/db/marshal/StringType.java
##########
@@ -18,10 +18,29 @@
package org.apache.cassandra.db.marshal;
+import org.apache.cassandra.utils.ByteBufferUtil;
+
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
public abstract class StringType extends AbstractType<String>
{
protected StringType(ComparisonType comparisonType)
{
super(comparisonType);
}
+
+ public abstract String charsetName();
+
+ public ByteBuffer concat(StringType leftType,
+ ByteBuffer left,
+ StringType rightType,
+ ByteBuffer right) throws
UnsupportedEncodingException
+ {
+ String leftS = new String(left.array(), leftType.charsetName());
+ String rightS = new String(right.array(), rightType.charsetName());
+
+ return ByteBufferUtil.bytes(leftS + rightS);
+ }
Review comment:
{{ByteBuffer}} do not necessarily have array. If they direct buffer that
code will not work. To get the `String` value from the `ByteBuffer` you should
use: `leftType.compose(left)` to convert a `String` back into a `ByteBuffer`
you should use the `decompose` method. ` return decompose(leftS + rightS);`
--
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]