text:
package com.amazonaws.services.dynamodbv2.model;

import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;

/**
 *

 * For the UpdateItem operation, represents the attributes to be modified, the action to perform on each,
 * and the new value for each.
 *

 * <note>
 *

 * You cannot use UpdateItem to update any primary key attributes. Instead, you will need to delete the
 * item, and then use PutItem to create a new item with new attributes.
 *

 * </note>
 *

 * Attribute values cannot be null; string and binary type attributes must have lengths greater than zero; and set type
 * attributes must not be empty. Requests with empty values will be rejected with a ValidationException
 * exception.
 *

 *
 * @see AWS API
 *      Documentation
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AttributeValueUpdate implements Serializable, Cloneable, StructuredPojo {

    /**
     *

     * Represents the data for an attribute.
     *

     *

     * Each attribute value is described as a name-value pair. The name is the data type, and the value is the data
     * itself.
     *

     *

     * For more information, see Data Types in the Amazon DynamoDB Developer Guide.
     *

     */
    private AttributeValue value;
    /**
     *

     * Specifies how to perform the update. Valid values are PUT (default), DELETE, and
     * ADD. The behavior depends on whether the specified primary key already exists in the table.
     *

     *

     * If an item with the specified Key is found in the table:
     *

     *

     *

     *

     * PUT - Adds the specified attribute to the item. If the attribute already exists, it is replaced by
     * the new value.
     *

     *

     *

     *

     * DELETE - If no value is specified, the attribute and its value are removed from the item. The data
     * type of the specified value must match the existing value's data type.
     *

     *

     * If a set of values is specified, then those values are subtracted from the old set. For example, if the
     * attribute value was the set [a,b,c] and the DELETE action specified [a,c],
     * then the final attribute value would be [b]. Specifying an empty set is an error.
     *

     *

     *

     *

     * ADD - If the attribute does not already exist, then the attribute and its values are added to the
     * item. If the attribute does exist, then the behavior of ADD depends on the data type of the
     * attribute:
     *

     *

     *

     *

     * If the existing attribute is a number, and if Value is also a number, then the Value is
     * mathematically added to the existing attribute. If Value is a negative number, then it is subtracted
     * from the existing attribute.
     *

     * <note>
     *

     * If you use ADD to increment or decrement a number value for an item that doesn't exist before the
     * update, DynamoDB uses 0 as the initial value.
     *

     *

     * In addition, if you use ADD to update an existing item, and intend to increment or decrement an
     * attribute value which does not yet exist, DynamoDB uses 0 as the initial value. For example, suppose
     * that the item you want to update does not yet have an attribute named itemcount, but you decide to
     * ADD the number 3 to this attribute anyway, even though it currently does not exist.
     * DynamoDB will create the itemcount attribute, set its initial value to 0, and finally add
     * 3 to it. The result will be a new itemcount attribute in the item, with a value of
     * 3.
     *

     * </note>

     *

     *

     * If the existing data type is a set, and if the Value is also a set, then the Value is
     * added to the existing set. (This is a set operation, not mathematical addition.) For example, if the
     * attribute value was the set [1,2], and the ADD action specified [3], then
     * the final attribute value would be [1,2,3]. An error occurs if an Add action is specified for a set
     * attribute and the attribute type specified does not match the existing set type.
     *

     *

     * Both sets must have the same primitive data type. For example, if the existing data type is a set of strings, the
     * Value must also be a set of strings. The same holds true for number sets and binary sets.
     *

     *

     *

     *

     * This action is only valid for an existing attribute whose data type is number or is a set. Do not use
     * ADD for any other data types.
     *

     *

     *

     *

     * If no item with the specified Key is found:
     *

     *

     *

     *

     * PUT - DynamoDB creates a new item with the specified primary key, and then adds the attribute.
     *

     *

     *

     *

     * DELETE - Nothing happens; there is no attribute to delete.
     *

     *

     *

     *

     * ADD - DynamoDB creates a new item with the supplied primary key and number (or set) for the
     * attribute value. The only data types allowed are number, number set, string set or binary set.
     *

     *

     *

     */
    private String action;

    /**
     * Default constructor for AttributeValueUpdate object. Callers should use the setter or fluent setter (with...)
     * methods to initialize the object after creating it.
     */
    public AttributeValueUpdate() {
    }

    /**
     * Constructs a new AttributeValueUpdate object. Callers should use the setter or fluent setter (with...) methods to
     * initialize any additional object members.
     *
     * @param value
     *        Represents the data for an attribute.

     *

     *        Each attribute value is described as a name-value pair. The name is the data type, and the value is the
     *        data itself.
     *

     *

     *        For more information, see Data Types in the Amazon DynamoDB Developer Guide.
     * @param action
     *        Specifies how to perform the update. Valid values are PUT (default), DELETE, and
     *        ADD. The behavior depends on whether the specified primary key already exists in the table.
     *

     *

     *        If an item with the specified Key is found in the table:
     *

     *

     *

     *

     *        PUT - Adds the specified attribute to the item. If the attribute already exists, it is
     *        replaced by the new value.
     *

     *

     *

     *

     *        DELETE - If no value is specified, the attribute and its value are removed from the item. The
     *        data type of the specified value must match the existing value's data type.
     *

     *

     *        If a set of values is specified, then those values are subtracted from the old set. For example, if
     *        the attribute value was the set [a,b,c] and the DELETE action specified
     *        [a,c], then the final attribute value would be [b]. Specifying an empty set is
     *        an error.
     *

     *

     *

     *

     *        ADD - If the attribute does not already exist, then the attribute and its values are added to
     *        the item. If the attribute does exist, then the behavior of ADD depends on the data type of
     *        the attribute:
     *

     *

     *

     *

     *        If the existing attribute is a number, and if Value is also a number, then the
     *        Value is mathematically added to the existing attribute. If Value is a negative
     *        number, then it is subtracted from the existing attribute.
     *

     *        <note>
     *

     *        If you use ADD to increment or decrement a number value for an item that doesn't exist before
     *        the update, DynamoDB uses 0 as the initial value.
     *

     *

     *        In addition, if you use ADD to update an existing item, and intend to increment or decrement
     *        an attribute value which does not yet exist, DynamoDB uses 0 as the initial value. For
     *        example, suppose that the item you want to update does not yet have an attribute named itemcount,
     *        but you decide to ADD the number 3 to this attribute anyway, even though it
     *        currently does not exist. DynamoDB will create the itemcount attribute, set its initial value to
     *        0, and finally add 3 to it. The result will be a new itemcount attribute
     *        in the item, with a value of 3.
     *

     *        </note>

     *

     *

     *        If the existing data type is a set, and if the Value is also a set, then the
     *        Value is added to the existing set. (This is a set operation, not mathematical
     *        addition.) For example, if the attribute value was the set [1,2], and the ADD
     *        action specified [3], then the final attribute value would be [1,2,3]. An error
     *        occurs if an Add action is specified for a set attribute and the attribute type specified does not match
     *        the existing set type.
     *

     *

     *        Both sets must have the same primitive data type. For example, if the existing data type is a set of
     *        strings, the Value must also be a set of strings. The same holds true for number sets and
     *        binary sets.
     *

     *

     *

     *

     *        This action is only valid for an existing attribute whose data type is number or is a set. Do not use
     *        ADD for any other data types.
     *

     *

     *

     *

     *        If no item with the specified Key is found:
     *

     *

     *

     *

     *        PUT - DynamoDB creates a new item with the specified primary key, and then adds the
     *        attribute.
     *

     *

     *

     *

     *        DELETE - Nothing happens; there is no attribute to delete.
     *

     *

     *

     *

     *        ADD - DynamoDB creates a new item with the supplied primary key and number (or set) for the
     *        attribute value. The only data types allowed are number, number set, string set or binary set.
     *

     *

     */
    public AttributeValueUpdate(AttributeValue value, String action) {
        setValue(value);
        setAction(action);
    }

    /**
     * Constructs a new AttributeValueUpdate object. Callers should use the setter or fluent setter (with...) methods to
     * initialize any additional object members.
     *
     * @param value
     *        Represents the data for an attribute.

     *

     *        Each attribute value is described as a name-value pair. The name is the data type, and the value is the
     *        data itself.
     *

     *

     *        For more information, see Data Types in the Amazon DynamoDB Developer Guide.
     * @param action
     *        Specifies how to perform the update. Valid values are PUT (default), DELETE, and
     *        ADD. The behavior depends on whether the specified primary key already exists in the table.
     *

     *

     *        If an item with the specified Key is found in the table:
     *

     *

     *

     *

     *        PUT - Adds the specified attribute to the item. If the attribute already exists, it is
     *        replaced by the new value.
     *

     *

     *

     *

     *        DELETE - If no value is specified, the attribute and its value are removed from the item. The
     *        data type of the specified value must match the existing value's data type.
     *

     *

     *        If a set of values is specified, then those values are subtracted from the old set. For example, if
     *        the attribute value was the set [a,b,c] and the DELETE action specified
     *        [a,c], then the final attribute value would be [b]. Specifying an empty set is
     *        an error.
     *

     *

     *

     *

     *        ADD - If the attribute does not already exist, then the attribute and its values are added to
     *        the item. If the attribute does exist, then the behavior of ADD depends on the data type of
     *        the attribute:
     *

     *

     *

     *

     *        If the existing attribute is a number, and if Value is also a number, then the
     *        Value is mathematically added to the existing attribute. If Value is a negative
     *        number, then it is subtracted from the existing attribute.
     *

     *        <note>
     *

     *        If you use ADD to increment or decrement a number value for an item that doesn't exist before
     *        the update, DynamoDB uses 0 as the initial value.
     *

     *

     *        In addition, if you use ADD to update an existing item, and intend to increment or decrement
     *        an attribute value which does not yet exist, DynamoDB uses 0 as the initial value. For
     *        example, suppose that the item you want to update does not yet have an attribute named itemcount,
     *        but you decide to ADD the number 3 to this attribute anyway, even though it
     *        currently does not exist. DynamoDB will create the itemcount attribute, set its initial value to
     *        0, and finally add 3 to it. The result will be a new itemcount attribute
     *        in the item, with a value of 3.
     *

     *        </note>

     *

     *

     *        If the existing data type is a set, and if the Value is also a set, then the
     *        Value is added to the existing set. (This is a set operation, not mathematical
     *        addition.) For example, if the attribute value was the set [1,2], and the ADD
     *        action specified [3], then the final attribute value would be [1,2,3]. An error
     *        occurs if an Add action is specified for a set attribute and the attribute type specified does not match
     *        the existing set type.
     *

     *

     *        Both sets must have the same primitive data type. For example, if the existing data type is a set of
     *        strings, the Value must also be a set of strings. The same holds true for number sets and
     *        binary sets.
     *

     *

     *

     *

     *        This action is only valid for an existing attribute whose data type is number or is a set. Do not use
     *        ADD for any other data types.
     *

     *

     *

     *

     *        If no item with the specified Key is found:
     *

     *

     *

     *

     *        PUT - DynamoDB creates a new item with the specified primary key, and then adds the
     *        attribute.
     *

     *

     *

     *

     *        DELETE - Nothing happens; there is no attribute to delete.
     *

     *

     *

     *

     *        ADD - DynamoDB creates a new item with the supplied primary key and number (or set) for the
     *        attribute value. The only data types allowed are number, number set, string set or binary set.
     *

     *

     */
    public AttributeValueUpdate(AttributeValue value, AttributeAction action) {
        setValue(value);
        setAction(action.toString());
    }

    /**
     *

     * Represents the data for an attribute.
     *

     *

     * Each attribute value is described as a name-value pair. The name is the data type, and the value is the data
     * itself.
     *

     *

     * For more information, see Data Types in the Amazon DynamoDB Developer Guide.
     *

     *
     * @param value
     *        Represents the data for an attribute.

     *

     *        Each attribute value is described as a name-value pair. The name is the data type, and the value is the
     *        data itself.
     *

     *

     *        For more information, see Data Types in the Amazon DynamoDB Developer Guide.
     */

    public void setValue(AttributeValue value) {
        this.value = value;
    }

    /**
     *

     * Represents the data for an attribute.
     *

     *

     * Each attribute value is described as a name-value pair. The name is the data type, and the value is the data
     * itself.
     *

     *

     * For more information, see Data Types in the Amazon DynamoDB Developer Guide.
     *

     *
     * @return Represents the data for an attribute.

     *

     *         Each attribute value is described as a name-value pair. The name is the data type, and the value is the
     *         data itself.
     *

     *

     *         For more information, see Data Types in the Amazon DynamoDB Developer Guide.
     */

    public AttributeValue getValue() {
        return this.value;
    }

    /**
     *

     * Represents the data for an attribute.
     *

     *

     * Each attribute value is described as a name-value pair. The name is the data type, and the value is the data
     * itself.
     *

     *

     * For more information, see Data Types in the Amazon DynamoDB Developer Guide.
     *

     *
     * @param value
     *        Represents the data for an attribute.

     *

     *        Each attribute value is described as a name-value pair. The name is the data type, and the value is the
     *        data itself.
     *

     *

     *        For more information, see Data Types in the Amazon DynamoDB Developer Guide.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public AttributeValueUpdate withValue(AttributeValue value) {
        setValue(value);
        return this;
    }

    /**
     *

     * Specifies how to perform the update. Valid values are PUT (default), DELETE, and
     * ADD. The behavior depends on whether the specified primary key already exists in the table.
     *

     *

     * If an item with the specified Key is found in the table:
     *

     *

     *

     *

     * PUT - Adds the specified attribute to the item. If the attribute already exists, it is replaced by
     * the new value.
     *

     *

     *

     *

     * DELETE - If no value is specified, the attribute and its value are removed from the item. The data
     * type of the specified value must match the existing value's data type.
     *

     *

     * If a set of values is specified, then those values are subtracted from the old set. For example, if the
     * attribute value was the set [a,b,c] and the DELETE action specified [a,c],
     * then the final attribute value would be [b]. Specifying an empty set is an error.
     *

     *

     *

     *

     * ADD - If the attribute does not already exist, then the attribute and its values are added to the
     * item. If the attribute does exist, then the behavior of ADD depends on the data type of the
     * attribute:
     *

     *

     *

     *

     * If the existing attribute is a number, and if Value is also a number, then the Value is
     * mathematically added to the existing attribute. If Value is a negative number, then it is subtracted
     * from the existing attribute.
     *

     * <note>
     *

     * If you use ADD to increment or decrement a number value for an item that doesn't exist before the
     * update, DynamoDB uses 0 as the initial value.
     *

     *

     * In addition, if you use ADD to update an existing item, and intend to increment or decrement an
     * attribute value which does not yet exist, DynamoDB uses 0 as the initial value. For example, suppose
     * that the item you want to update does not yet have an attribute named itemcount, but you decide to
     * ADD the number 3 to this attribute anyway, even though it currently does not exist.
     * DynamoDB will create the itemcount attribute, set its initial value to 0, and finally add
     * 3 to it. The result will be a new itemcount attribute in the item, with a value of
     * 3.
     *

     * </note>

     *

     *

     * If the existing data type is a set, and if the Value is also a set, then the Value is
     * added to the existing set. (This is a set operation, not mathematical addition.) For example, if the
     * attribute value was the set [1,2], and the ADD action specified [3], then
     * the final attribute value would be [1,2,3]. An error occurs if an Add action is specified for a set
     * attribute and the attribute type specified does not match the existing set type.
     *

     *

     * Both sets must have the same primitive data type. For example, if the existing data type is a set of strings, the
     * Value must also be a set of strings. The same holds true for number sets and binary sets.
     *

     *

     *

     *

     * This action is only valid for an existing attribute whose data type is number or is a set. Do not use
     * ADD for any other data types.
     *

     *

     *

     *

     * If no item with the specified Key is found:
     *

     *

     *

     *

     * PUT - DynamoDB creates a new item with the specified primary key, and then adds the attribute.
     *

     *

     *

     *

     * DELETE - Nothing happens; there is no attribute to delete.
     *

     *

     *

     *

     * ADD - DynamoDB creates a new item with the supplied primary key and number (or set) for the
     * attribute value. The only data types allowed are number, number set, string set or binary set.
     *

     *

     *

     *
     * @param action
     *        Specifies how to perform the update. Valid values are PUT (default), DELETE, and
     *        ADD. The behavior depends on whether the specified primary key already exists in the
     *        table.

     *

     *        If an item with the specified Key is found in the table:
     *

     *

     *

     *

     *        PUT - Adds the specified attribute to the item. If the attribute already exists, it is
     *        replaced by the new value.
     *

     *

     *

     *

     *        DELETE - If no value is specified, the attribute and its value are removed from the item. The
     *        data type of the specified value must match the existing value's data type.
     *

     *

     *        If a set of values is specified, then those values are subtracted from the old set. For example, if
     *        the attribute value was the set [a,b,c] and the DELETE action specified
     *        [a,c], then the final attribute value would be [b]. Specifying an empty set is
     *        an error.
     *

     *

     *

     *

     *        ADD - If the attribute does not already exist, then the attribute and its values are added to
     *        the item. If the attribute does exist, then the behavior of ADD depends on the data type of
     *        the attribute:
     *

     *

     *

     *

     *        If the existing attribute is a number, and if Value is also a number, then the
     *        Value is mathematically added to the existing attribute. If Value is a negative
     *        number, then it is subtracted from the existing attribute.
     *

     *        <note>
     *

     *        If you use ADD to increment or decrement a number value for an item that doesn't exist before
     *        the update, DynamoDB uses 0 as the initial value.
     *

     *

     *        In addition, if you use ADD to update an existing item, and intend to increment or decrement
     *        an attribute value which does not yet exist, DynamoDB uses 0 as the initial value. For
     *        example, suppose that the item you want to update does not yet have an attribute named itemcount,
     *        but you decide to ADD the number 3 to this attribute anyway, even though it
     *        currently does not exist. DynamoDB will create the itemcount attribute, set its initial value to
     *        0, and finally add 3 to it. The result will be a new itemcount attribute
     *        in the item, with a value of 3.
     *

     *        </note>

     *

     *

     *        If the existing data type is a set, and if the Value is also a set, then the
     *        Value is added to the existing set. (This is a set operation, not mathematical
     *        addition.) For example, if the attribute value was the set [1,2], and the ADD
     *        action specified [3], then the final attribute value would be [1,2,3]. An error
     *        occurs if an Add action is specified for a set attribute and the attribute type specified does not match
     *        the existing set type.
     *

     *

     *        Both sets must have the same primitive data type. For example, if the existing data type is a set of
     *        strings, the Value must also be a set of strings. The same holds true for number sets and
     *        binary sets.
     *

     *

     *

     *

     *        This action is only valid for an existing attribute whose data type is number or is a set. Do not use
     *        ADD for any other data types.
     *

     *

     *

     *

     *        If no item with the specified Key is found:
     *

     *

     *

     *

     *        PUT - DynamoDB creates a new item with the specified primary key, and then adds the
     *        attribute.
     *

     *

     *

     *

     *        DELETE - Nothing happens; there is no attribute to delete.
     *

     *

     *

     *

     *        ADD - DynamoDB creates a new item with the supplied primary key and number (or set) for the
     *        attribute value. The only data types allowed are number, number set, string set or binary set.
     *

     *

     * @see AttributeAction
     */

    public void setAction(String action) {
        this.action = action;
    }

    /**
     *

     * Specifies how to perform the update. Valid values are PUT (default), DELETE, and
     * ADD. The behavior depends on whether the specified primary key already exists in the table.
     *

     *

     * If an item with the specified Key is found in the table:
     *

     *

     *

     *

     * PUT - Adds the specified attribute to the item. If the attribute already exists, it is replaced by
     * the new value.
     *

     *

     *

     *

     * DELETE - If no value is specified, the attribute and its value are removed from the item. The data
     * type of the specified value must match the existing value's data type.
     *

     *

     * If a set of values is specified, then those values are subtracted from the old set. For example, if the
     * attribute value was the set [a,b,c] and the DELETE action specified [a,c],
     * then the final attribute value would be [b]. Specifying an empty set is an error.
     *

     *

     *

     *

     * ADD - If the attribute does not already exist, then the attribute and its values are added to the
     * item. If the attribute does exist, then the behavior of ADD depends on the data type of the
     * attribute:
     *

     *

     *

     *

     * If the existing attribute is a number, and if Value is also a number, then the Value is
     * mathematically added to the existing attribute. If Value is a negative number, then it is subtracted
     * from the existing attribute.
     *

     * <note>
     *

     * If you use ADD to increment or decrement a number value for an item that doesn't exist before the
     * update, DynamoDB uses 0 as the initial value.
     *

     *

     * In addition, if you use ADD to update an existing item, and intend to increment or decrement an
     * attribute value which does not yet exist, DynamoDB uses 0 as the initial value. For example, suppose
     * that the item you want to update does not yet have an attribute named itemcount, but you decide to
     * ADD the number 3 to this attribute anyway, even though it currently does not exist.
     * DynamoDB will create the itemcount attribute, set its initial value to 0, and finally add
     * 3 to it. The result will be a new itemcount attribute in the item, with a value of
     * 3.
     *

     * </note>

     *

     *

     * If the existing data type is a set, and if the Value is also a set, then the Value is
     * added to the existing set. (This is a set operation, not mathematical addition.) For example, if the
     * attribute value was the set [1,2], and the ADD action specified [3], then
     * the final attribute value would be [1,2,3]. An error occurs if an Add action is specified for a set
     * attribute and the attribute type specified does not match the existing set type.
     *

     *

     * Both sets must have the same primitive data type. For example, if the existing data type is a set of strings, the
     * Value must also be a set of strings. The same holds true for number sets and binary sets.
     *

     *

     *

     *

     * This action is only valid for an existing attribute whose data type is number or is a set. Do not use
     * ADD for any other data types.
     *

     *

     *

     *

     * If no item with the specified Key is found:
     *

     *

     *

     *

     * PUT - DynamoDB creates a new item with the specified primary key, and then adds the attribute.
     *

     *

     *

     *

     * DELETE - Nothing happens; there is no attribute to delete.
     *

     *

     *

     *

     * ADD - DynamoDB creates a new item with the supplied primary key and number (or set) for the
     * attribute value. The only data types allowed are number, number set, string set or binary set.
     *

     *

     *

     *
     * @return Specifies how to perform the update. Valid values are PUT (default), DELETE,
     *         and ADD. The behavior depends on whether the specified primary key already exists in the
     *         table.

     *

     *         If an item with the specified Key is found in the table:
     *

     *

     *

     *

     *         PUT - Adds the specified attribute to the item. If the attribute already exists, it is
     *         replaced by the new value.
     *

     *

     *

     *

     *         DELETE - If no value is specified, the attribute and its value are removed from the item.
     *         The data type of the specified value must match the existing value's data type.
     *

     *

     *         If a set of values is specified, then those values are subtracted from the old set. For example,
     *         if the attribute value was the set [a,b,c] and the DELETE action specified
     *         [a,c], then the final attribute value would be [b]. Specifying an empty set is
     *         an error.
     *

     *

     *

     *

     *         ADD - If the attribute does not already exist, then the attribute and its values are added
     *         to the item. If the attribute does exist, then the behavior of ADD depends on the data type
     *         of the attribute:
     *

     *

     *

     *

     *         If the existing attribute is a number, and if Value is also a number, then the
     *         Value is mathematically added to the existing attribute. If Value is a negative
     *         number, then it is subtracted from the existing attribute.
     *

     *         <note>
     *

     *         If you use ADD to increment or decrement a number value for an item that doesn't exist
     *         before the update, DynamoDB uses 0 as the initial value.
     *

     *

     *         In addition, if you use ADD to update an existing item, and intend to increment or decrement
     *         an attribute value which does not yet exist, DynamoDB uses 0 as the initial value. For
     *         example, suppose that the item you want to update does not yet have an attribute named itemcount,
     *         but you decide to ADD the number 3 to this attribute anyway, even though it
     *         currently does not exist. DynamoDB will create the itemcount attribute, set its initial value to
     *         0, and finally add 3 to it. The result will be a new itemcount attribute
     *         in the item, with a value of 3.
     *

     *         </note>

     *

     *

     *         If the existing data type is a set, and if the Value is also a set, then the
     *         Value is added to the existing set. (This is a set operation, not mathematical
     *         addition.) For example, if the attribute value was the set [1,2], and the ADD
     *         action specified [3], then the final attribute value would be [1,2,3]. An error
     *         occurs if an Add action is specified for a set attribute and the attribute type specified does not match
     *         the existing set type.
     *

     *

     *         Both sets must have the same primitive data type. For example, if the existing data type is a set of
     *         strings, the Value must also be a set of strings. The same holds true for number sets and
     *         binary sets.
     *

     *

     *

     *

     *         This action is only valid for an existing attribute whose data type is number or is a set. Do not use
     *         ADD for any other data types.
     *

     *

     *

     *

     *         If no item with the specified Key is found:
     *

     *

     *

     *

     *         PUT - DynamoDB creates a new item with the specified primary key, and then adds the
     *         attribute.
     *

     *

     *

     *

     *         DELETE - Nothing happens; there is no attribute to delete.
     *

     *

     *

     *

     *         ADD - DynamoDB creates a new item with the supplied primary key and number (or set) for the
     *         attribute value. The only data types allowed are number, number set, string set or binary set.
     *

     *

     * @see AttributeAction
     */

    public String getAction() {
        return this.action;
    }

    /**
     *

     * Specifies how to perform the update. Valid values are PUT (default), DELETE, and
     * ADD. The behavior depends on whether the specified primary key already exists in the table.
     *

     *

     * If an item with the specified Key is found in the table:
     *

     *

     *

     *

     * PUT - Adds the specified attribute to the item. If the attribute already exists, it is replaced by
     * the new value.
     *

     *

     *

     *

     * DELETE - If no value is specified, the attribute and its value are removed from the item. The data
     * type of the specified value must match the existing value's data type.
     *

     *

     * If a set of values is specified, then those values are subtracted from the old set. For example, if the
     * attribute value was the set [a,b,c] and the DELETE action specified [a,c],
     * then the final attribute value would be [b]. Specifying an empty set is an error.
     *

     *

     *

     *

     * ADD - If the attribute does not already exist, then the attribute and its values are added to the
     * item. If the attribute does exist, then the behavior of ADD depends on the data type of the
     * attribute:
     *

     *

     *

     *

     * If the existing attribute is a number, and if Value is also a number, then the Value is
     * mathematically added to the existing attribute. If Value is a negative number, then it is subtracted
     * from the existing attribute.
     *

     * <note>
     *

     * If you use ADD to increment or decrement a number value for an item that doesn't exist before the
     * update, DynamoDB uses 0 as the initial value.
     *

     *

     * In addition, if you use ADD to update an existing item, and intend to increment or decrement an
     * attribute value which does not yet exist, DynamoDB uses 0 as the initial value. For example, suppose
     * that the item you want to update does not yet have an attribute named itemcount, but you decide to
     * ADD the number 3 to this attribute anyway, even though it currently does not exist.
     * DynamoDB will create the itemcount attribute, set its initial value to 0, and finally add
     * 3 to it. The result will be a new itemcount attribute in the item, with a value of
     * 3.
     *

     * </note>

     *

     *

     * If the existing data type is a set, and if the Value is also a set, then the Value is
     * added to the existing set. (This is a set operation, not mathematical addition.) For example, if the
     * attribute value was the set [1,2], and the ADD action specified [3], then
     * the final attribute value would be [1,2,3]. An error occurs if an Add action is specified for a set
     * attribute and the attribute type specified does not match the existing set type.
     *

     *

     * Both sets must have the same primitive data type. For example, if the existing data type is a set of strings, the
     * Value must also be a set of strings. The same holds true for number sets and binary sets.
     *

     *

     *

     *

     * This action is only valid for an existing attribute whose data type is number or is a set. Do not use
     * ADD for any other data types.
     *

     *

     *

     *

     * If no item with the specified Key is found:
     *

     *

     *

     *

     * PUT - DynamoDB creates a new item with the specified primary key, and then adds the attribute.
     *

     *

     *

     *

     * DELETE - Nothing happens; there is no attribute to delete.
     *

     *

     *

     *

     * ADD - DynamoDB creates a new item with the supplied primary key and number (or set) for the
     * attribute value. The only data types allowed are number, number set, string set or binary set.
     *

     *

     *

     *
     * @param action
     *        Specifies how to perform the update. Valid values are PUT (default), DELETE, and
     *        ADD. The behavior depends on whether the specified primary key already exists in the
     *        table.

     *

     *        If an item with the specified Key is found in the table:
     *

     *

     *

     *

     *        PUT - Adds the specified attribute to the item. If the attribute already exists, it is
     *        replaced by the new value.
     *

     *

     *

     *

     *        DELETE - If no value is specified, the attribute and its value are removed from the item. The
     *        data type of the specified value must match the existing value's data type.
     *

     *

     *        If a set of values is specified, then those values are subtracted from the old set. For example, if
     *        the attribute value was the set [a,b,c] and the DELETE action specified
     *        [a,c], then the final attribute value would be [b]. Specifying an empty set is
     *        an error.
     *

     *

     *

     *

     *        ADD - If the attribute does not already exist, then the attribute and its values are added to
     *        the item. If the attribute does exist, then the behavior of ADD depends on the data type of
     *        the attribute:
     *

     *

     *

     *

     *        If the existing attribute is a number, and if Value is also a number, then the
     *        Value is mathematically added to the existing attribute. If Value is a negative
     *        number, then it is subtracted from the existing attribute.
     *

     *        <note>
     *

     *        If you use ADD to increment or decrement a number value for an item that doesn't exist before
     *        the update, DynamoDB uses 0 as the initial value.
     *

     *

     *        In addition, if you use ADD to update an existing item, and intend to increment or decrement
     *        an attribute value which does not yet exist, DynamoDB uses 0 as the initial value. For
     *        example, suppose that the item you want to update does not yet have an attribute named itemcount,
     *        but you decide to ADD the number 3 to this attribute anyway, even though it
     *        currently does not exist. DynamoDB will create the itemcount attribute, set its initial value to
     *        0, and finally add 3 to it. The result will be a new itemcount attribute
     *        in the item, with a value of 3.
     *

     *        </note>

     *

     *

     *        If the existing data type is a set, and if the Value is also a set, then the
     *        Value is added to the existing set. (This is a set operation, not mathematical
     *        addition.) For example, if the attribute value was the set [1,2], and the ADD
     *        action specified [3], then the final attribute value would be [1,2,3]. An error
     *        occurs if an Add action is specified for a set attribute and the attribute type specified does not match
     *        the existing set type.
     *

     *

     *        Both sets must have the same primitive data type. For example, if the existing data type is a set of
     *        strings, the Value must also be a set of strings. The same holds true for number sets and
     *        binary sets.
     *

     *

     *

     *

     *        This action is only valid for an existing attribute whose data type is number or is a set. Do not use
     *        ADD for any other data types.
     *

     *

     *

     *

     *        If no item with the specified Key is found:
     *

     *

     *

     *

     *        PUT - DynamoDB creates a new item with the specified primary key, and then adds the
     *        attribute.
     *

     *

     *

     *

     *        DELETE - Nothing happens; there is no attribute to delete.
     *

     *

     *

     *

     *        ADD - DynamoDB creates a new item with the supplied primary key and number (or set) for the
     *        attribute value. The only data types allowed are number, number set, string set or binary set.
     *

     *

     * @return Returns a reference to this object so that method calls can be chained together.
     * @see AttributeAction
     */

    public AttributeValueUpdate withAction(String action) {
        setAction(action);
        return this;
    }

    /**
     *

     * Specifies how to perform the update. Valid values are PUT (default), DELETE, and
     * ADD. The behavior depends on whether the specified primary key already exists in the table.
     *

     *

     * If an item with the specified Key is found in the table:
     *

     *

     *

     *

     * PUT - Adds the specified attribute to the item. If the attribute already exists, it is replaced by
     * the new value.
     *

     *

     *

     *

     * DELETE - If no value is specified, the attribute and its value are removed from the item. The data
     * type of the specified value must match the existing value's data type.
     *

     *

     * If a set of values is specified, then those values are subtracted from the old set. For example, if the
     * attribute value was the set [a,b,c] and the DELETE action specified [a,c],
     * then the final attribute value would be [b]. Specifying an empty set is an error.
     *

     *

     *

     *

     * ADD - If the attribute does not already exist, then the attribute and its values are added to the
     * item. If the attribute does exist, then the behavior of ADD depends on the data type of the
     * attribute:
     *

     *

     *

     *

     * If the existing attribute is a number, and if Value is also a number, then the Value is
     * mathematically added to the existing attribute. If Value is a negative number, then it is subtracted
     * from the existing attribute.
     *

     * <note>
     *

     * If you use ADD to increment or decrement a number value for an item that doesn't exist before the
     * update, DynamoDB uses 0 as the initial value.
     *

     *

     * In addition, if you use ADD to update an existing item, and intend to increment or decrement an
     * attribute value which does not yet exist, DynamoDB uses 0 as the initial value. For example, suppose
     * that the item you want to update does not yet have an attribute named itemcount, but you decide to
     * ADD the number 3 to this attribute anyway, even though it currently does not exist.
     * DynamoDB will create the itemcount attribute, set its initial value to 0, and finally add
     * 3 to it. The result will be a new itemcount attribute in the item, with a value of
     * 3.
     *

     * </note>

     *

     *

     * If the existing data type is a set, and if the Value is also a set, then the Value is
     * added to the existing set. (This is a set operation, not mathematical addition.) For example, if the
     * attribute value was the set [1,2], and the ADD action specified [3], then
     * the final attribute value would be [1,2,3]. An error occurs if an Add action is specified for a set
     * attribute and the attribute type specified does not match the existing set type.
     *

     *

     * Both sets must have the same primitive data type. For example, if the existing data type is a set of strings, the
     * Value must also be a set of strings. The same holds true for number sets and binary sets.
     *

     *

     *

     *

     * This action is only valid for an existing attribute whose data type is number or is a set. Do not use
     * ADD for any other data types.
     *

     *

     *

     *

     * If no item with the specified Key is found:
     *

     *

     *

     *

     * PUT - DynamoDB creates a new item with the specified primary key, and then adds the attribute.
     *

     *

     *

     *

     * DELETE - Nothing happens; there is no attribute to delete.
     *

     *

     *

     *

     * ADD - DynamoDB creates a new item with the supplied primary key and number (or set) for the
     * attribute value. The only data types allowed are number, number set, string set or binary set.
     *

     *

     *

     *
     * @param action
     *        Specifies how to perform the update. Valid values are PUT (default), DELETE, and
     *        ADD. The behavior depends on whether the specified primary key already exists in the
     *        table.

     *

     *        If an item with the specified Key is found in the table:
     *

     *

     *

     *

     *        PUT - Adds the specified attribute to the item. If the attribute already exists, it is
     *        replaced by the new value.
     *

     *

     *

     *

     *        DELETE - If no value is specified, the attribute and its value are removed from the item. The
     *        data type of the specified value must match the existing value's data type.
     *

     *

     *        If a set of values is specified, then those values are subtracted from the old set. For example, if
     *        the attribute value was the set [a,b,c] and the DELETE action specified
     *        [a,c], then the final attribute value would be [b]. Specifying an empty set is
     *        an error.
     *

     *

     *

     *

     *        ADD - If the attribute does not already exist, then the attribute and its values are added to
     *        the item. If the attribute does exist, then the behavior of ADD depends on the data type of
     *        the attribute:
     *

     *

     *

     *

     *        If the existing attribute is a number, and if Value is also a number, then the
     *        Value is mathematically added to the existing attribute. If Value is a negative
     *        number, then it is subtracted from the existing attribute.
     *

     *        <note>
     *

     *        If you use ADD to increment or decrement a number value for an item that doesn't exist before
     *        the update, DynamoDB uses 0 as the initial value.
     *

     *

     *        In addition, if you use ADD to update an existing item, and intend to increment or decrement
     *        an attribute value which does not yet exist, DynamoDB uses 0 as the initial value. For
     *        example, suppose that the item you want to update does not yet have an attribute named itemcount,
     *        but you decide to ADD the number 3 to this attribute anyway, even though it
     *        currently does not exist. DynamoDB will create the itemcount attribute, set its initial value to
     *        0, and finally add 3 to it. The result will be a new itemcount attribute
     *        in the item, with a value of 3.
     *

     *        </note>

     *

     *

     *        If the existing data type is a set, and if the Value is also a set, then the
     *        Value is added to the existing set. (This is a set operation, not mathematical
     *        addition.) For example, if the attribute value was the set [1,2], and the ADD
     *        action specified [3], then the final attribute value would be [1,2,3]. An error
     *        occurs if an Add action is specified for a set attribute and the attribute type specified does not match
     *        the existing set type.
     *

     *

     *        Both sets must have the same primitive data type. For example, if the existing data type is a set of
     *        strings, the Value must also be a set of strings. The same holds true for number sets and
     *        binary sets.
     *

     *

     *

     *

     *        This action is only valid for an existing attribute whose data type is number or is a set. Do not use
     *        ADD for any other data types.
     *

     *

     *

     *

     *        If no item with the specified Key is found:
     *

     *

     *

     *

     *        PUT - DynamoDB creates a new item with the specified primary key, and then adds the
     *        attribute.
     *

     *

     *

     *

     *        DELETE - Nothing happens; there is no attribute to delete.
     *

     *

     *

     *

     *        ADD - DynamoDB creates a new item with the supplied primary key and number (or set) for the
     *        attribute value. The only data types allowed are number, number set, string set or binary set.
     *

     *

     * @see AttributeAction
     */

    public void setAction(AttributeAction action) {
        withAction(action);
    }

    /**
     *

     * Specifies how to perform the update. Valid values are PUT (default), DELETE, and
     * ADD. The behavior depends on whether the specified primary key already exists in the table.
     *

     *

     * If an item with the specified Key is found in the table:
     *

     *

     *

     *

     * PUT - Adds the specified attribute to the item. If the attribute already exists, it is replaced by
     * the new value.
     *

     *

     *

     *

     * DELETE - If no value is specified, the attribute and its value are removed from the item. The data
     * type of the specified value must match the existing value's data type.
     *

     *

     * If a set of values is specified, then those values are subtracted from the old set. For example, if the
     * attribute value was the set [a,b,c] and the DELETE action specified [a,c],
     * then the final attribute value would be [b]. Specifying an empty set is an error.
     *

     *

     *

     *

     * ADD - If the attribute does not already exist, then the attribute and its values are added to the
     * item. If the attribute does exist, then the behavior of ADD depends on the data type of the
     * attribute:
     *

     *

     *

     *

     * If the existing attribute is a number, and if Value is also a number, then the Value is
     * mathematically added to the existing attribute. If Value is a negative number, then it is subtracted
     * from the existing attribute.
     *

     * <note>
     *

     * If you use ADD to increment or decrement a number value for an item that doesn't exist before the
     * update, DynamoDB uses 0 as the initial value.
     *

     *

     * In addition, if you use ADD to update an existing item, and intend to increment or decrement an
     * attribute value which does not yet exist, DynamoDB uses 0 as the initial value. For example, suppose
     * that the item you want to update does not yet have an attribute named itemcount, but you decide to
     * ADD the number 3 to this attribute anyway, even though it currently does not exist.
     * DynamoDB will create the itemcount attribute, set its initial value to 0, and finally add
     * 3 to it. The result will be a new itemcount attribute in the item, with a value of
     * 3.
     *

     * </note>

     *

     *

     * If the existing data type is a set, and if the Value is also a set, then the Value is
     * added to the existing set. (This is a set operation, not mathematical addition.) For example, if the
     * attribute value was the set [1,2], and the ADD action specified [3], then
     * the final attribute value would be [1,2,3]. An error occurs if an Add action is specified for a set
     * attribute and the attribute type specified does not match the existing set type.
     *

     *

     * Both sets must have the same primitive data type. For example, if the existing data type is a set of strings, the
     * Value must also be a set of strings. The same holds true for number sets and binary sets.
     *

     *

     *

     *

     * This action is only valid for an existing attribute whose data type is number or is a set. Do not use
     * ADD for any other data types.
     *

     *

     *

     *

     * If no item with the specified Key is found:
     *

     *

     *

     *

     * PUT - DynamoDB creates a new item with the specified primary key, and then adds the attribute.
     *

     *

     *

     *

     * DELETE - Nothing happens; there is no attribute to delete.
     *

     *

     *

     *

     * ADD - DynamoDB creates a new item with the supplied primary key and number (or set) for the
     * attribute value. The only data types allowed are number, number set, string set or binary set.
     *

     *

     *

     *
     * @param action
     *        Specifies how to perform the update. Valid values are PUT (default), DELETE, and
     *        ADD. The behavior depends on whether the specified primary key already exists in the
     *        table.

     *

     *        If an item with the specified Key is found in the table:
     *

     *

     *

     *

     *        PUT - Adds the specified attribute to the item. If the attribute already exists, it is
     *        replaced by the new value.
     *

     *

     *

     *

     *        DELETE - If no value is specified, the attribute and its value are removed from the item. The
     *        data type of the specified value must match the existing value's data type.
     *

     *

     *        If a set of values is specified, then those values are subtracted from the old set. For example, if
     *        the attribute value was the set [a,b,c] and the DELETE action specified
     *        [a,c], then the final attribute value would be [b]. Specifying an empty set is
     *        an error.
     *

     *

     *

     *

     *        ADD - If the attribute does not already exist, then the attribute and its values are added to
     *        the item. If the attribute does exist, then the behavior of ADD depends on the data type of
     *        the attribute:
     *

     *

     *

     *

     *        If the existing attribute is a number, and if Value is also a number, then the
     *        Value is mathematically added to the existing attribute. If Value is a negative
     *        number, then it is subtracted from the existing attribute.
     *

     *        <note>
     *

     *        If you use ADD to increment or decrement a number value for an item that doesn't exist before
     *        the update, DynamoDB uses 0 as the initial value.
     *

     *

     *        In addition, if you use ADD to update an existing item, and intend to increment or decrement
     *        an attribute value which does not yet exist, DynamoDB uses 0 as the initial value. For
     *        example, suppose that the item you want to update does not yet have an attribute named itemcount,
     *        but you decide to ADD the number 3 to this attribute anyway, even though it
     *        currently does not exist. DynamoDB will create the itemcount attribute, set its initial value to
     *        0, and finally add 3 to it. The result will be a new itemcount attribute
     *        in the item, with a value of 3.
     *

     *        </note>

     *

     *

     *        If the existing data type is a set, and if the Value is also a set, then the
     *        Value is added to the existing set. (This is a set operation, not mathematical
     *        addition.) For example, if the attribute value was the set [1,2], and the ADD
     *        action specified [3], then the final attribute value would be [1,2,3]. An error
     *        occurs if an Add action is specified for a set attribute and the attribute type specified does not match
     *        the existing set type.
     *

     *

     *        Both sets must have the same primitive data type. For example, if the existing data type is a set of
     *        strings, the Value must also be a set of strings. The same holds true for number sets and
     *        binary sets.
     *

     *

     *

     *

     *        This action is only valid for an existing attribute whose data type is number or is a set. Do not use
     *        ADD for any other data types.
     *

     *

     *

     *

     *        If no item with the specified Key is found:
     *

     *

     *

     *

     *        PUT - DynamoDB creates a new item with the specified primary key, and then adds the
     *        attribute.
     *

     *

     *

     *

     *        DELETE - Nothing happens; there is no attribute to delete.
     *

     *

     *

     *

     *        ADD - DynamoDB creates a new item with the supplied primary key and number (or set) for the
     *        attribute value. The only data types allowed are number, number set, string set or binary set.
     *

     *

     * @return Returns a reference to this object so that method calls can be chained together.
     * @see AttributeAction
     */

    public AttributeValueUpdate withAction(AttributeAction action) {
        this.action = action.toString();
        return this;
    }

    /**
     * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
     * redacted from this string using a placeholder value.
     *
     * @return A string representation of this object.
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getValue() != null)
            sb.append("Value: ").append(getValue()).append(",");
        if (getAction() != null)
            sb.append("Action: ").append(getAction());
        sb.append("}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;

        if (obj instanceof AttributeValueUpdate == false)
            return false;
        AttributeValueUpdate other = (AttributeValueUpdate) obj;
        if (other.getValue() == null ^ this.getValue() == null)
            return false;
        if (other.getValue() != null && other.getValue().equals(this.getValue()) == false)
            return false;
        if (other.getAction() == null ^ this.getAction() == null)
            return false;
        if (other.getAction() != null && other.getAction().equals(this.getAction()) == false)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;

        hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode());
        hashCode = prime * hashCode + ((getAction() == null) ? 0 : getAction().hashCode());
        return hashCode;
    }

    @Override
    public AttributeValueUpdate clone() {
        try {
            return (AttributeValueUpdate) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
        }
    }

    @com.amazonaws.annotation.SdkInternalApi
    @Override
    public void marshall(ProtocolMarshaller protocolMarshaller) {
        com.amazonaws.services.dynamodbv2.model.transform.AttributeValueUpdateMarshaller.getInstance().marshall(this, protocolMarshaller);
    }
}


text:
'use strict';

/**
 * Collection of runs.
 */
class RunListResult extends Array {
  /**
   * Create a RunListResult.
   * @property {string} [nextLink] The URI that can be used to request the next
   * set of paged results.
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of RunListResult
   *
   * @returns {object} metadata of RunListResult
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'RunListResult',
      type: {
        name: 'Composite',
        className: 'RunListResult',
        modelProperties: {
          value: {
            required: false,
            serializedName: '',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'RunElementType',
                  type: {
                    name: 'Composite',
                    className: 'Run'
                  }
              }
            }
          },
          nextLink: {
            required: false,
            serializedName: 'nextLink',
            type: {
              name: 'String'
            }
          }
        }
      }
    };
  }
}

module.exports = RunListResult;

redpajama_set_name: RedPajamaGithub


text:
void mark_pending_event_invalid(void *sptr)
{
	int i;
	for (i = 0; i < event_count; i++) {
		if (cur_events[i].data.ptr == sptr)
			cur_events[i].events = 0;
	}
}

int read_event_handler(server_info_t *server, int efd)
{
	struct sockaddr_in c_addr;
	int c_len, read_len;
	int accepted_fd;
	server_info_t *client_info;
	server->read_events++;
	switch (server->server_flags) {
		case LB_SERVER:
		{
			c_len = sizeof(c_addr);
			if (0 > (accepted_fd = accept(server->fd, (struct sockaddr *)&c_addr, &c_len)))
				ASSERT(0);
			if (client_info = create_client_info(efd, accepted_fd)) {
				insert_client_info(client_info);
			}
			break;
		}
		case STATS_SERVER:
		{
			c_len = sizeof(c_addr);
			if (0 > (accepted_fd = accept(server->fd, (struct sockaddr *)&c_addr, &c_len)))
				ASSERT(0);
			if (client_info = create_client_info(efd, accepted_fd))
				client_info->server_flags |= STATS_CONN;
			break;
		}
		default:
		{
			if (!(server->server_flags & STATS_CONN) &&
			    NULL == server->session->server) {
				if (0 > attach_backend_lbserver(efd, server)) {
					close_client_pconn(server);
					lb_server->tot_unhandled_conn++;
					return -1;
				} else {
					lb_server->cur_conn++;
				}
			}
			ASSERT(server->session->buf_len <= BUF_LEN);
			if (BUF_LEN == server->session->buf_size)
				break;
			int start, end;
			if (BUF_LEN == server->session->buf_len)
				server->session->buf_len = 0;
			if (server->session->buf_len >= server->session->buf_read) {
				start = server->session->buf_len;
				end = BUF_LEN;
			} else {
				start = server->session->buf_len;
				end = server->session->buf_read;
			}
			if (0 > (read_len = read(server->fd, server->session->buf + start, end - start)))
				ASSERT(0);
			if (read_len > 0) {
				server->session->buf_len += read_len;
				server->session->buf_size += read_len;
			} else {
				ASSERT(!(server->server_flags & LB_SERVER));
				printf("closing connection data read = %d\n", server->session->buf_len);
				close_conn(efd, server);
				return 0;
			}
			if (server->server_flags & STATS_CONN)
				stats_read_req(server, efd);
		}
	}
	return 0;
}

int write_event_handler(server_info_t *server)
{
	server->write_events++;
	if (server->server_flags & STATS_CONN) {
		stats_server->write_events++;
		stats_write_res(server);
	} else {
		ASSERT(server->session->buf_read <= BUF_LEN);
		int start, end, write_len;
		server_info_t *rserver = server->session->server;
		if (BUF_LEN == rserver->session->buf_read &&
		    rserver->session->buf_size > 0)
			rserver->session->buf_read = 0;
		if (rserver->session->buf_len >= rserver->session->buf_read) {
			start = rserver->session->buf_read;
			end = rserver->session->buf_len;
		} else {
			start = rserver->session->buf_read;
			end = BUF_LEN;
		}
		if (start == end)
			return -1;

		if (0 > (write_len = write(server->fd, rserver->session->buf + start, end - start))) {
			perror("write");
			return -1;
		}
		rserver->session->buf_read += write_len;
		rserver->session->buf_size -= write_len;

		if (!(server->server_flags & BACKEND_SERVER) &&
			(rserver->session->buf_len == rserver->session->buf_read) &&
			(rserver->server_flags & CONN_CLOSED)) {
			close_client_conn(server);
		}
	}
}


text:
feature 'Manage candidates', :devise do
#   As a manager
#   I want to be able to add, edit and find candidates
#   So I can easily walk through the whole application process

  scenario 'create new candidate' do
    sign_in_as_manager

    click_on 'Bewerber*innen'
    click_on 'Neu'
    click_on 'Speichern'
    expect(page).to have_content('Bewerber*in konnte nicht gespeichert werden')

    click_on 'Bewerber*in'
    expect do
      create_candidate Vorname: 'Frank', Nachname: 'Meyer', Anrede: 'Herr'
    end.to change { page.all('tbody tr[data-url]').count }.by(1)
    expect(page).to have_content 'Frank'
    expect(page).to have_content 'Meyer'
  end

  scenario 'edit person data' do
    sign_in_as_manager

    create_candidate Vorname: 'Frank', Nachname: 'Meyer', Anrede: 'Herr'
    click_row_with 'Frank'
    within('.panel.person') { click_on 'Bearbeiten' }
    select 'Herr',            from: 'Anrede'
    fill_in 'Vorname',        with: ''
    fill_in 'Geburtsdatum',   with: '1.1.1996'
    fill_in 'PLZ',            with: '12345'
    fill_in 'E-Mail-Adresse', with: 'a@b.c'
    fill_in 'Telefon',        with: '09876'
    fill_in 'Mobiltelefon',   with: '01234567'
    click_on 'Speichern'
    expect(page).to have_content 'Bewerber*in konnte nicht gespeichert werden'
    fill_in 'Vorname', with: 'Rodriges'
    fill_in 'Nachname', with: 'Gonzales'
    click_on 'Speichern'
    expect(page).to have_content 'Bewerber*in gespeichert'
    expect(page).to have_content 'Rodriges Gonzales'
  end

  scenario 'edit documents' do
    sign_in_as_manager

    create_candidate Vorname: 'Frank', Nachname: 'Meyer', Anrede: 'Herr'
    click_row_with 'Frank'
    within('.panel.documents') { click_on 'Bearbeiten' }
    within('.panel.candidation') do
      fill_in :Eingangsdatum, with: '01.02.2017'
      select Date.current.year, from: :Jahr
    end
    within('.panel.education-graduate') do
      check 'Beglaubigte Kopie liegt vor'
      select 'Grade1', from: 'Schulabschluss'
    end
    within('.panel.police-certificate') do
      check 'Beglaubigte Kopie liegt vor'
    end
    within('.panel.internships') do
      fill_in 'candidate[internships]', with: 'Internship1'
      check 'Beglaubigte Kopien liegen vor'
    end
    click_on 'Speichern'
    expect(page).to have_content 'Bewerber*in gespeichert'
  end

  scenario 'edit interview' do
    sign_in_as_manager

    create_candidate Vorname: 'Frank', Nachname: 'Meyer', Anrede: 'Herr'
    click_row_with 'Frank'
    within('.panel.interview') { click_on 'Bearbeiten' }
    fill_in 'Datum', with: '01.07.2016'
    check 'eingeladen'
    select 'Zusage', from: 'Rückmeldung'
    select 'Wiederholen', from: 'Ergebnis'
    click_on 'Speichern'
    expect(page).to have_content 'Bewerber*in gespeichert'
    expect(page).to have_content '01.07.2016'
  end

  scenario 'edit contracts' do
    sign_in_as_manager

    create_candidate Vorname: 'Frank', Nachname: 'Meyer', Anrede: 'Herr'
    click_row_with 'Frank'
    within('.panel.contracts') { click_on 'Bearbeiten' }
    within('.panel.education-contract') do
      fill_in 'Versand am', with: '01.08.2016'
      fill_in 'zurück',     with: '03.08.2016'
    end
    within('.panel.internship-contract') do
      fill_in 'Versand am', with: '01.09.2016'
      fill_in 'zurück',     with: '03.09.2016'
    end
    within('.panel.debit-mandate') do
      check 'Einzugsermächtigung'
      fill_in 'Notizen', with: 'Contract notes'
    end
    click_on 'Speichern'
    expect(page).to have_content 'Bewerber*in gespeichert'
    expect(page).to have_content '01.08.2016'
    expect(page).to have_content '03.08.2016'
    expect(page).to have_content '01.09.2016'
    expect(page).to have_content '03.09.2016'
    expect(page).to have_content 'Contract notes'
  end

  scenario 'delete candidate' do
    sign_in_as_manager

    create_candidate Vorname: 'Frank', Nachname: 'Meyer', Anrede: 'Herr'
    expect do
      click_row_with 'Frank'
      click_on 'Löschen'
    end.to change { page.all('tbody tr[data-url]').count }.by(-1)
    expect(page).to have_content 'gelöscht'
  end

  scenario 'accept candidate' do
    sign_in_as_manager

    create_candidate Vorname: 'Frank', Nachname: 'Meyer', Anrede: 'Herr'
    click_row_with 'Frank'
    click_on 'Zulassen'
    expect(page).to have_content 'Bewerber*in aufgenommen'
    expect(page).to have_content 'Bewerber*in ist zugelassen'
  end

  scenario 'reject candidate' do
    sign_in_as_manager

    create_candidate Vorname: 'Frank', Nachname: 'Meyer', Anrede: 'Herr'
    click_row_with 'Frank'
    click_on 'Absagen'
    fill_in :Datum, with: '6.7.2015'
    select 'Schule', from: 'Absage durch'
    click_on :Absagen
    expect(page).to have_content 'Bewerber*in gespeichert'
    expect(page).to have_content '06.07.2015'
    expect(page).to have_content 'Absage durch'
    expect(page).to have_content 'Schule'
  end

end


text:
#include "network/CCDownloader-android.h"

#include "network/CCDownloader.h"
#include "platform/android/jni/JniHelper.h"

#include <mutex>

#define JCLS_DOWNLOADER "org/cocos2dx/lib/Cocos2dxDownloader"
#define JCLS_TASK       "com/loopj/android/http/RequestHandle"
#define JARG_STR        "Ljava/lang/String;"
#define JARG_DOWNLOADER "L" JCLS_DOWNLOADER ";"
#define JARG_TASK       "L" JCLS_TASK ";"

using namespace std;

static bool _registerNativeMethods(JNIEnv* env);

unordered_map<int, cocos2d::network::DownloaderAndroid*> sDownloaderMap;
std::mutex sDownloaderMutex;

static void _insertDownloaderAndroid(int id, cocos2d::network::DownloaderAndroid* downloaderPtr)
{
    std::lock_guard<std::mutex> guard(sDownloaderMutex);
    sDownloaderMap.insert(make_pair(id, downloaderPtr));
}

static void _eraseDownloaderAndroid(int id)
{
    std::lock_guard<std::mutex> guard(sDownloaderMutex);
    sDownloaderMap.erase(id);
}

/**
 * If not found, return nullptr, otherwise return the Downloader
 */
static cocos2d::network::DownloaderAndroid* _findDownloaderAndroid(int id)
{
    std::lock_guard<std::mutex> guard(sDownloaderMutex);
    auto iter = sDownloaderMap.find(id);
    if (sDownloaderMap.end() == iter) {
        return nullptr;
    } else {
        return iter->second;
    }
}

namespace cocos2d { namespace network {

        static int sTaskCounter;
        static int sDownloaderCounter;
        static bool _registered = false;

        struct DownloadTaskAndroid : public IDownloadTask
        {
            DownloadTaskAndroid()
            :id(++sTaskCounter)
            {
                DLLOG("Construct DownloadTaskAndroid: %p", this);
            }
            virtual  ~DownloadTaskAndroid()
            {
                DLLOG("Destruct DownloadTaskAndroid: %p", this);
            }

            int id;
            shared_ptr<const DownloadTask> task;    // reference to DownloadTask, when task finish, release
        };

        DownloaderAndroid::DownloaderAndroid(const DownloaderHints& hints)
        : _id(++sDownloaderCounter)
        , _impl(nullptr)
        {
            DLLOG("Construct DownloaderAndroid: %p", this);
            JniMethodInfo methodInfo;
            if (JniHelper::getStaticMethodInfo(methodInfo,
                                               JCLS_DOWNLOADER,
                                               "createDownloader",
                                               "(II" JARG_STR "I)" JARG_DOWNLOADER))
            {
                jobject jStr = methodInfo.env->NewStringUTF(hints.tempFileNameSuffix.c_str());
                jobject jObj = methodInfo.env->CallStaticObjectMethod(
                        methodInfo.classID,
                        methodInfo.methodID,
                        _id,
                        hints.timeoutInSeconds,
                        jStr,
                        hints.countOfMaxProcessingTasks
                );
                _impl = methodInfo.env->NewGlobalRef(jObj);
                DLLOG("android downloader: jObj: %p, _impl: %p", jObj, _impl);
                //It's not thread-safe here, use thread-safe method instead
                //sDownloaderMap.insert(make_pair(_id, this));
                _insertDownloaderAndroid(_id, this);
                methodInfo.env->DeleteLocalRef(jStr);
                methodInfo.env->DeleteLocalRef(jObj);
                methodInfo.env->DeleteLocalRef(methodInfo.classID);
            }
        }

        DownloaderAndroid::~DownloaderAndroid()
        {
            if(_impl != nullptr)
            {
                JniMethodInfo methodInfo;
                if (JniHelper::getStaticMethodInfo(methodInfo,
                                                   JCLS_DOWNLOADER,
                                                   "cancelAllRequests",
                                                   "(" JARG_DOWNLOADER ")V"))
                {
                    methodInfo.env->CallStaticVoidMethod(
                            methodInfo.classID,
                            methodInfo.methodID,
                            _impl
                    );
                    methodInfo.env->DeleteLocalRef(methodInfo.classID);
                }
                //It's not thread-safe here, use thread-safe method instead
                //sDownloaderMap.erase(_id);
                _eraseDownloaderAndroid(_id);
                JniHelper::getEnv()->DeleteGlobalRef(_impl);
            }
            DLLOG("Destruct DownloaderAndroid: %p", this);
        }

        IDownloadTask *DownloaderAndroid::createCoTask(std::shared_ptr<const DownloadTask>& task)
        {
            DownloadTaskAndroid *coTask = new DownloadTaskAndroid;
            coTask->task = task;

            JniMethodInfo methodInfo;
            if (JniHelper::getStaticMethodInfo(methodInfo,
                                               JCLS_DOWNLOADER,
                                               "createTask",
                                               "(" JARG_DOWNLOADER "I" JARG_STR JARG_STR")V"))
            {
                jstring jstrURL = methodInfo.env->NewStringUTF(task->requestURL.c_str());
                jstring jstrPath= methodInfo.env->NewStringUTF(task->storagePath.c_str());
                methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, _impl, coTask->id, jstrURL, jstrPath);
                methodInfo.env->DeleteLocalRef(jstrURL);
                methodInfo.env->DeleteLocalRef(jstrPath);
                methodInfo.env->DeleteLocalRef(methodInfo.classID);
            }

            DLLOG("DownloaderAndroid::createCoTask id: %d", coTask->id);
            _taskMap.insert(make_pair(coTask->id, coTask));
            return coTask;
        }

        void DownloaderAndroid::_onProcess(int taskId, int64_t dl, int64_t dlNow, int64_t dlTotal)
        {
            DLLOG("DownloaderAndroid::onProgress(taskId: %d, dl: %lld, dlnow: %lld, dltotal: %lld)", taskId, dl, dlNow, dlTotal);
            auto iter = _taskMap.find(taskId);
            if (_taskMap.end() == iter)
            {
                DLLOG("DownloaderAndroid::onProgress can't find task with id: %d", taskId);
                return;
            }
            DownloadTaskAndroid *coTask = iter->second;
            function<int64_t(void*, int64_t)> transferDataToBuffer;
            onTaskProgress(*coTask->task, dl, dlNow, dlTotal, transferDataToBuffer);
        }

        void DownloaderAndroid::_onFinish(int taskId, int errCode, const char *errStr, vector<unsigned char>& data)
        {
            DLLOG("DownloaderAndroid::_onFinish(taskId: %d, errCode: %d, errStr: %s)", taskId, errCode, (errStr)?errStr:"null");
            auto iter = _taskMap.find(taskId);
            if (_taskMap.end() == iter)
            {
                DLLOG("DownloaderAndroid::_onFinish can't find task with id: %d", taskId);
                return;
            }
            DownloadTaskAndroid *coTask = iter->second;
            string str = (errStr ? errStr : "");
            _taskMap.erase(iter);
            onTaskFinish(*coTask->task,
                         errStr ? DownloadTask::ERROR_IMPL_INTERNAL : DownloadTask::ERROR_NO_ERROR,
                         errCode,
                         str,
                         data
            );
            coTask->task.reset();
        }

        void _preloadJavaDownloaderClass()
        {
            if(!_registered)
            {
                _registered = _registerNativeMethods(JniHelper::getEnv());
            }
        }
    }
}  // namespace cocos2d::network

static void _nativeOnProgress(JNIEnv *env, jclass clazz, jint id, jint taskId, jlong dl, jlong dlnow, jlong dltotal)
{
    DLLOG("_nativeOnProgress(id: %d, taskId: %d, dl: %lld, dlnow: %lld, dltotal: %lld)", id, taskId, dl, dlnow, dltotal);
    //It's not thread-safe here, use thread-safe method instead
    cocos2d::network::DownloaderAndroid *downloader = _findDownloaderAndroid(id);
    if (nullptr == downloader)
    {
        DLLOG("_nativeOnProgress can't find downloader by key: %p for task: %d", clazz, id);
        return;
    }
    downloader->_onProcess((int)taskId, (int64_t)dl, (int64_t)dlnow, (int64_t)dltotal);
}

static void _nativeOnFinish(JNIEnv *env, jclass clazz, jint id, jint taskId, jint errCode, jstring errStr, jbyteArray data)
{
    DLLOG("_nativeOnFinish(id: %d, taskId: %d)", id, taskId);
    //It's not thread-safe here, use thread-safe method instead
    cocos2d::network::DownloaderAndroid *downloader = _findDownloaderAndroid(id);
    if (nullptr == downloader)
    {
        DLLOG("_nativeOnFinish can't find downloader id: %d for task: %d", id, taskId);
        return;
    }
    vector<unsigned char> buf;
    if (errStr)
    {
        // failure
        const char *nativeErrStr = env->GetStringUTFChars(errStr, JNI_FALSE);
        downloader->_onFinish((int)taskId, (int)errCode, nativeErrStr, buf);
        env->ReleaseStringUTFChars(errStr, nativeErrStr);
        return;
    }

    // success
    if (data)
    {
        int len = env->GetArrayLength(data);
        if (len)
        {
            buf.reserve(len);
            buf.resize(len);
            env->GetByteArrayRegion(data, 0, len, reinterpret_cast<jbyte*>(buf.data()));
        }
    }
    downloader->_onFinish((int)taskId, (int)errCode, nullptr, buf);
}

static JNINativeMethod sMethodTable[] = {
        { "nativeOnProgress", "(IIJJJ)V", (void*)_nativeOnProgress },
        { "nativeOnFinish", "(III" JARG_STR "[B)V", (void*)_nativeOnFinish },
};

static bool _registerNativeMethods(JNIEnv* env)
{
    jclass clazz = env->FindClass(JCLS_DOWNLOADER);
    if (clazz == NULL)
    {
        DLLOG("_registerNativeMethods: can't find java class:%s", JARG_DOWNLOADER);
        return false;
    }
    if (JNI_OK != env->RegisterNatives(clazz, sMethodTable, sizeof(sMethodTable) / sizeof(sMethodTable[0])))
    {
        DLLOG("_registerNativeMethods: failed");
        if (env->ExceptionCheck())
        {
            env->ExceptionClear();
        }
        return false;
    }
    return true;
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>Uses of Class javax.xml.ws.spi.http.HttpHandler (Java Platform SE 7 )</title>
<meta name="date" content="2014-12-18">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Java™ Platform
Standard Ed. 7

Prev

Next

Frames

No Frames

All Classes

Uses of Class
javax.xml.ws.spi.http.HttpHandler

Packages that use HttpHandler

Package
Description

javax.xml.ws.spi.http

Provides HTTP SPI that is used for portable deployment of JAX-WS
  web services in containers(for e.g.

Uses of HttpHandler in javax.xml.ws.spi.http

Fields in javax.xml.ws.spi.http declared as HttpHandler

Modifier and Type
Field and Description

protected HttpHandler
HttpContext.handler

Methods in javax.xml.ws.spi.http with parameters of type HttpHandler

Modifier and Type
Method and Description

void
HttpContext.setHandler(HttpHandler handler)

JAX-WS runtime sets its handler during
 Endpoint.publish(HttpContext) to handle
 HTTP requests for this context.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Java™ Platform
Standard Ed. 7

Prev

Next

Frames

No Frames

All Classes

 Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2015, Oracle and/or its affiliates.  All rights reserved.


text:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Buffers.Operations;

namespace System.Buffers
{
    public static class MemoryListExtensions
    {
        // span creation helpers:
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static long IndexOf(this ReadOnlySequenceSegment<byte> list, ReadOnlySpan<byte> value)
        {
            var first = list.Memory.Span;
            var index = first.IndexOf(value);
            if (index != -1) return index;

            var rest = list.Next;
            if (rest == null) return -1;

            return IndexOfStraddling(first, list.Next, value);
        }

        public static int CopyTo(this ReadOnlySequenceSegment<byte> list, Span<byte> destination)
        {
            var current = list.Memory.Span;
            int copied = 0;

            while (destination.Length > 0)
            {
                if (current.Length >= destination.Length)
                {
                    current.Slice(0, destination.Length).CopyTo(destination);
                    copied += destination.Length;
                    return copied;
                }
                else
                {
                    current.CopyTo(destination);
                    copied += current.Length;
                    destination = destination.Slice(current.Length);
                }
            }
            return copied;
        }

        public static SequencePosition? PositionOf(this ReadOnlySequenceSegment<byte> list, byte value)
        {
            while (list != null)
            {
                var current = list.Memory.Span;
                var index = current.IndexOf(value);
                if (index != -1) return new SequencePosition(list, index);
                list = list.Next;
            }
            return null;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static (T segment, int index) Get<T>(this SequencePosition position)
        {
            var segment = position.GetObject() == null ? default : (T)position.GetObject();
            return (segment, position.GetInteger());
        }

        // TODO (pri 3): I am pretty sure this whole routine can be written much better

        // searches values that potentially straddle between first and rest
        internal static long IndexOfStraddling(this ReadOnlySpan<byte> first, ReadOnlySequenceSegment<byte> rest, ReadOnlySpan<byte> value)
        {
            Debug.Assert(first.IndexOf(value) == -1);
            if (rest == null) return -1;

            // we only need to search the end of the first buffer. More precisely, only up to value.Length - 1 bytes in the first buffer
            // The other bytes in first, were already search and presumably did not match
            int bytesToSkipFromFirst = 0;
            if (first.Length > value.Length - 1)
            {
                bytesToSkipFromFirst = first.Length - value.Length - 1;
            }

            // now that we know how many bytes we need to skip, create slice of first buffer with bytes that need to be searched.
            ReadOnlySpan<byte> bytesToSearchAgain;
            if (bytesToSkipFromFirst > 0)
            {
                bytesToSearchAgain = first.Slice(bytesToSkipFromFirst);
            }
            else
            {
                bytesToSearchAgain = first;
            }

            long index;

            // now combine the bytes from the end of the first buffer with bytes in the rest, and serarch the combined buffer
            // this check is a small optimization: if the first byte from the value does not exist in the bytesToSearchAgain, there is no reason to combine
            if (bytesToSearchAgain.IndexOf(value[0]) != -1)
            {
                var combinedBufferLength = value.Length << 1;
                var combined = combinedBufferLength < 128 ?
                                        stackalloc byte[combinedBufferLength] :
                                        // TODO (pri 3): I think this could be eliminated by chunking values
                                        new byte[combinedBufferLength];

                bytesToSearchAgain.CopyTo(combined);
                int combinedLength = bytesToSearchAgain.Length + rest.CopyTo(combined.Slice(bytesToSearchAgain.Length));
                combined = combined.Slice(0, combinedLength);

                if (combined.Length < value.Length) return -1;

                index = combined.IndexOf(value);
                if (index != -1)
                {
                    return index + bytesToSkipFromFirst;
                }
            }

            // try to find the bytes in _rest
            index = rest.IndexOf(value);
            if (index != -1) return first.Length + index;

            return -1;
        }
    }

    public static class BufferExtensions
    {
        const int stackLength = 32;

        public static void Pipe(this IBufferOperation transformation, ReadOnlySequence<byte> source, IBufferWriter<byte> destination)
        {
            int afterMergeSlice = 0;

            // Assign 'remainder' to something formally stack-referring.
            // The default classification is "returnable, not referring to stack", we want the opposite in this case.
            ReadOnlySpan<byte> remainder = stackalloc byte[0];
            Span<byte> stackSpan = stackalloc byte[stackLength];

            SequencePosition poisition = default;
            while (source.TryGet(ref poisition, out var sourceBuffer))
            {
                Span<byte> outputSpan = destination.GetSpan();
                ReadOnlySpan<byte> sourceSpan = sourceBuffer.Span;

                if (!remainder.IsEmpty)
                {
                    int leftOverBytes = remainder.Length;
                    remainder.CopyTo(stackSpan);
                    int amountToCopy = Math.Min(sourceSpan.Length, stackSpan.Length - leftOverBytes);
                    sourceSpan.Slice(0, amountToCopy).CopyTo(stackSpan.Slice(leftOverBytes));
                    int amountOfData = leftOverBytes + amountToCopy;

                    Span<byte> spanToTransform = stackSpan.Slice(0, amountOfData);

                    TryTransformWithRemainder:
                    OperationStatus status = transformation.Execute(spanToTransform, outputSpan, out int bytesConsumed, out int bytesWritten);
                    if (status != OperationStatus.Done)
                    {
                        destination.Advance(bytesWritten);
                        spanToTransform = spanToTransform.Slice(bytesConsumed);

                        if (status == OperationStatus.DestinationTooSmall)
                        {
                            outputSpan = destination.GetSpan();

                            if (outputSpan.Length - bytesWritten < 3)
                            {
                                return; // no more output space, user decides what to do.
                            }
                            goto TryTransformWithRemainder;
                        }
                        else
                        {
                            if (status == OperationStatus.InvalidData)
                            {
                                continue; // source buffer contains invalid bytes, user decides what to do for fallback
                            }

                            // at this point, status = TransformationStatus.NeedMoreSourceData
                            // left over bytes in stack span
                            remainder = spanToTransform;
                        }
                        continue;
                    }
                    else    // success
                    {
                        afterMergeSlice = bytesConsumed - remainder.Length;
                        remainder = Span<byte>.Empty;
                        destination.Advance(bytesWritten);
                        outputSpan = destination.GetSpan();
                    }
                }

                TryTransform:
                OperationStatus result = transformation.Execute(sourceSpan.Slice(afterMergeSlice), outputSpan, out int consumed, out int written);
                afterMergeSlice = 0;
                destination.Advance(written);
                sourceSpan = sourceSpan.Slice(consumed);

                if (result == OperationStatus.Done) continue;

                // Not successful
                if (result == OperationStatus.DestinationTooSmall)
                {
                    destination.GetMemory();  // output buffer is too small
                    outputSpan = destination.GetSpan();
                    if (outputSpan.Length - written < 3)
                    {
                        return; // no more output space, user decides what to do.
                    }
                    goto TryTransform;
                }
                else
                {
                    if (result == OperationStatus.InvalidData)
                    {
                        continue; // source buffer contains invalid bytes, user decides what to do for fallback
                    }

                    // at this point, result = TransformationStatus.NeedMoreSourceData
                    // left over bytes in source span
                    remainder = sourceSpan;
                }
            }
            return;
        }

        public static bool SequenceEqual<T>(this Memory<T> first, Memory<T> second) where T : struct, IEquatable<T>
        {
            return first.Span.SequenceEqual(second.Span);
        }

        public static bool SequenceEqual<T>(this ReadOnlyMemory<T> first, ReadOnlyMemory<T> second) where T : struct, IEquatable<T>
        {
            return first.Span.SequenceEqual(second.Span);
        }

        public static int SequenceCompareTo(this Span<byte> left, ReadOnlySpan<byte> right)
        {
            return SequenceCompareTo((ReadOnlySpan<byte>)left, right);
        }

        public static int SequenceCompareTo(this ReadOnlySpan<byte> left, ReadOnlySpan<byte> right)
        {
            var minLength = left.Length;
            if (minLength > right.Length) minLength = right.Length;
            for (int i = 0; i < minLength; i++)
            {
                var result = left[i].CompareTo(right[i]);
                if (result != 0) return result;
            }
            return left.Length.CompareTo(right.Length);
        }

        public static bool TryIndicesOf(this Span<byte> buffer, byte value, Span<int> indices, out int numberOfIndices)
        {
            var length = buffer.Length;
            if (length == 0 || indices.Length == 0)
            {
                numberOfIndices = 0;
                return false;
            }

            return TryIndicesOf(ref MemoryMarshal.GetReference(buffer), value, length, indices, out numberOfIndices);
        }

        public static bool TryIndicesOf(this ReadOnlySpan<byte> buffer, byte value, Span<int> indices, out int numberOfIndices)
        {
            var length = buffer.Length;
            if (length == 0 || indices.Length == 0)
            {
                numberOfIndices = 0;
                return false;
            }

            return TryIndicesOf(ref MemoryMarshal.GetReference(buffer), value, length, indices, out numberOfIndices);
        }

        private unsafe static bool TryIndicesOf(ref byte searchSpace, byte value, int length, Span<int> indices, out int numberOfIndices)
        {
            var result = false;
            numberOfIndices = 0;

            fixed (byte* pSearchSpace = &searchSpace)
            {
                var searchStart = pSearchSpace;
                var offset = 0;

                while (true)
                {
                    if (Vector.IsHardwareAccelerated)
                    {
                        // Check Vector lengths
                        if (length - Vector<byte>.Count >= offset)
                        {
                            Vector<byte> values = GetVector(value);
                            do
                            {
                                var vFlaggedMatches = Vector.Equals(Unsafe.Read<Vector<byte>>(searchStart + offset), values);
                                if (!vFlaggedMatches.Equals(Vector<byte>.Zero))
                                {
                                    // Found match, reuse Vector values to keep register pressure low
                                    values = vFlaggedMatches;
                                    break;
                                }

                                offset += Vector<byte>.Count;
                            } while (length - Vector<byte>.Count >= offset);

                            // Found match? Perform secondary search outside out of loop, so above loop body is small
                            if (length - Vector<byte>.Count >= offset)
                            {
                                // Find offset of first match
                                offset += LocateFirstFoundByte(values);
                                // goto rather than inline return to keep function smaller
                                goto exitFixed;
                            }
                        }
                    }

                    ulong flaggedMatches = 0;
                    // Check ulong length
                    while (length - sizeof(ulong) >= offset)
                    {
                        flaggedMatches = SetLowBitsForByteMatch(*(ulong*)(searchStart + offset), value);
                        if (flaggedMatches != 0)
                        {
                            // Found match
                            break;
                        }

                        offset += sizeof(ulong);
                    }

                    // Found match? Perform secondary search outside out of loop, so above loop body is small
                    if (length - sizeof(ulong) >= offset)
                    {
                        // Find offset of first match
                        offset += LocateFirstFoundByte(flaggedMatches);
                        // goto rather than inline return to keep function smaller
                        goto exitFixed;
                    }

                    // Haven't found match, scan through remaining
                    for (; offset < length; offset++)
                    {
                        if (*(searchStart + offset) == value)
                        {
                            // goto rather than inline return to keep loop body small
                            goto exitFixed;
                        }
                    }

                    // No Matches
                    result = true;
                    break;

                    exitFixed:;
                    indices[numberOfIndices++] = offset++;
                    if (numberOfIndices >= indices.Length)
                        break;
                }
            }

            return result && numberOfIndices < indices.Length;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static int LocateFirstFoundByte(Vector<byte> match)
        {
            var vector64 = Vector.AsVectorUInt64(match);
            ulong candidate = 0;
            var i = 0;
            // Pattern unrolled by jit https://github.com/dotnet/coreclr/pull/8001
            for (; i < Vector<ulong>.Count; i++)
            {
                candidate = vector64[i];
                if (candidate != 0)
                {
                    break;
                }
            }

            // Single LEA instruction with jitted const (using function result)
            return i * 8 + LocateFirstFoundByte(candidate);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static int LocateFirstFoundByte(ulong match)
        {
            unchecked
            {
                // Flag least significant power of two bit
                var powerOfTwoFlag = match ^ (match - 1);
                // Shift all powers of two into the high byte and extract
                return (int)((powerOfTwoFlag * xorPowerOfTwoToHighByte) >> 57);
            }
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static ulong SetLowBitsForByteMatch(ulong potentialMatch, byte search)
        {
            unchecked
            {
                var flaggedValue = potentialMatch ^ (byteBroadcastToUlong * search);
                return (
                        (flaggedValue - byteBroadcastToUlong) &
                        ~(flaggedValue) &
                        filterByteHighBitsInUlong
                       ) >> 7;
            }
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static Vector<byte> GetVector(byte vectorByte)
        {
#if !NETCOREAPP
            // Vector<byte> .ctor doesn't become an intrinsic due to detection issue
            // However this does cause it to become an intrinsic (with additional multiply and reg->reg copy)
            // https://github.com/dotnet/coreclr/issues/7459#issuecomment-253965670
            return Vector.AsVectorByte(new Vector<uint>(vectorByte * 0x01010101u));
#else
            return new Vector<byte>(vectorByte);
#endif
        }

        private const ulong xorPowerOfTwoToHighByte = (0x07ul |
                                                       0x06ul << 8 |
                                                       0x05ul << 16 |
                                                       0x04ul << 24 |
                                                       0x03ul << 32 |
                                                       0x02ul << 40 |
                                                       0x01ul << 48) + 1;
        private const ulong byteBroadcastToUlong = ~0UL / Byte.MaxValue;
        private const ulong filterByteHighBitsInUlong = (byteBroadcastToUlong >> 1) | (byteBroadcastToUlong << (sizeof(ulong) * 8 - 1));
    }
}