kadirozde commented on code in PR #1906:
URL: https://github.com/apache/phoenix/pull/1906#discussion_r1708282571


##########
phoenix-core-client/src/main/java/org/apache/phoenix/expression/util/bson/UpdateExpressionUtils.java:
##########
@@ -0,0 +1,949 @@
+/*
+ * 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.
+ */
+
+package org.apache.phoenix.expression.util.bson;
+
+import java.math.BigDecimal;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.bson.BsonArray;
+import org.bson.BsonDecimal128;
+import org.bson.BsonDocument;
+import org.bson.BsonDouble;
+import org.bson.BsonInt32;
+import org.bson.BsonInt64;
+import org.bson.BsonNumber;
+import org.bson.BsonString;
+import org.bson.BsonValue;
+import org.bson.types.Decimal128;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * BSON Update Expression Utility to perform the Document updates. All update 
expressions
+ * provided by this utility supports operations on nested document fields. The 
field key can
+ * represent any top level or nested fields within the document. The caller 
should use "."
+ * notation for accessing nested document elements and "[n]" notation for 
accessing nested array
+ * elements. Top level fields do not require any additional character.
+ */
+public class UpdateExpressionUtils {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(UpdateExpressionUtils.class);
+
+  /**
+   * Updates the given document based on the update expression.
+   * <p/>
+   * {
+   *    "$SET": { &lt;field1&gt;: &lt;value1>, &lt;field2&gt;: &lt;value2&gt;, 
.... },
+   *    "$UNSET": { &lt;field1&gt;: null, &lt;field2&gt;: null, ... },
+   *    "$ADD": { &lt;field1&gt;: &lt;value1&gt;, &lt;field2&gt;: 
&lt;value2&gt;, .... },
+   *    "$DELETE_FROM_SET": { &lt;field1&gt;: &lt;value1&gt;, &lt;field2&gt;: 
&lt;value2&gt;, .... }
+   * }
+   * <p/>
+   * "$SET": Use the SET action in an update expression to add one or more 
fields to a BSON
+   * Document. If any of these fields already exists, they are overwritten by 
the new values.
+   * To perform multiple SET actions, provide multiple fields key-value 
entries within nested
+   * document under $SET field key.
+   * "$UNSET": Use the REMOVE action in an update expression to remove one or 
more fields from a

Review Comment:
   Both the document and PR makes references to keyword "REMOVE" which does not 
exist. Should we replace REMOVE with UNSET? Or is REMOVE a better choice than 
UNSET as a keyword here?



-- 
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]

Reply via email to