Class SimpleDateType

All Implemented Interfaces:
Comparator<ByteBuffer>, AssignmentTestable

public class SimpleDateType extends TemporalType<Integer>
  • Field Details

  • Method Details

    • asComparableBytes

      public <V> ByteSource asComparableBytes(ValueAccessor<V> accessor, V data, ByteComparable.Version version)
      Description copied from class: AbstractType
      Produce a byte-comparable representation of the given value, i.e. a sequence of bytes that compares the same way using lexicographical unsigned byte comparison as the original value using the type's comparator. We use a slightly stronger requirement to be able to use the types in tuples. Precisely, for any pair x, y of non-equal valid values of this type and any bytes b1, b2 between 0x10 and 0xEF, (+ stands for concatenation) compare(x, y) == compareLexicographicallyUnsigned(asByteComparable(x)+b1, asByteComparable(y)+b2) (i.e. the values compare like the original type, and an added 0x10-0xEF byte at the end does not change that) and: asByteComparable(x)+b1 is not a prefix of asByteComparable(y) (weakly prefix free) (i.e. a valid representation of a value may be a prefix of another valid representation of a value only if the following byte in the latter is smaller than 0x10 or larger than 0xEF). These properties are trivially true if the encoding compares correctly and is prefix free, but also permits a little more freedom that enables somewhat more efficient encoding of arbitrary-length byte-comparable blobs. Depending on the type, this method can be called for null or empty input, in which case the output is allowed to be null (the clustering/tuple encoding will accept and handle it).
      Overrides:
      asComparableBytes in class AbstractType<Integer>
    • fromComparableBytes

      public <V> V fromComparableBytes(ValueAccessor<V> accessor, ByteSource.Peekable comparableBytes, ByteComparable.Version version)
      Description copied from class: AbstractType
      Translates the given byte-ordered representation to the common, non-byte-ordered binary representation of a payload for this abstract type (the latter, common binary representation is what we mostly work with in the storage engine internals). If the given bytes don't correspond to the encoding of some payload value for this abstract type, an IllegalArgumentException may be thrown.
      Overrides:
      fromComparableBytes in class AbstractType<Integer>
      Parameters:
      accessor - value accessor used to construct the value.
      comparableBytes - A byte-ordered representation (presumably of a payload for this abstract type).
      version - The byte-comparable version used to construct the representation.
      Returns:
      A of a payload for this abstract type, corresponding to the given byte-ordered representation, constructed using the supplied value accessor.
      See Also:
    • fromString

      public ByteBuffer fromString(String source) throws MarshalException
      Description copied from class: AbstractType
      get a byte representation of the given string.
      Specified by:
      fromString in class AbstractType<Integer>
      Throws:
      MarshalException
    • fromTimeInMillis

      public ByteBuffer fromTimeInMillis(long millis) throws MarshalException
      Description copied from class: TemporalType
      Returns the temporal value corresponding to the specified UNIX timestamp.
      Overrides:
      fromTimeInMillis in class TemporalType<Integer>
      Parameters:
      millis - the UNIX timestamp to convert
      Returns:
      the temporal value corresponding to the specified UNIX timestamp
      Throws:
      MarshalException
    • toTimeInMillis

      public long toTimeInMillis(ByteBuffer buffer) throws MarshalException
      Description copied from class: TemporalType
      Converts this temporal in UNIX timestamp.
      Overrides:
      toTimeInMillis in class TemporalType<Integer>
      Parameters:
      buffer - the temporal value.
      Returns:
      the UNIX timestamp corresponding to this temporal.
      Throws:
      MarshalException
    • isValueCompatibleWithInternal

      public boolean isValueCompatibleWithInternal(AbstractType<?> otherType)
      Description copied from class: AbstractType
      Needed to handle ReversedType in value-compatibility checks. Subclasses should implement this instead of isValueCompatibleWith().
      Overrides:
      isValueCompatibleWithInternal in class AbstractType<Integer>
    • fromJSONObject

      public Term fromJSONObject(Object parsed) throws MarshalException
      Description copied from class: AbstractType
      Given a parsed JSON string, return a byte representation of the object.
      Specified by:
      fromJSONObject in class AbstractType<Integer>
      Parameters:
      parsed - the result of parsing a json string
      Throws:
      MarshalException
    • toJSONString

      public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion)
      Description copied from class: AbstractType
      Converts the specified value into its JSON representation.

      The buffer position will stay the same.

      Overrides:
      toJSONString in class AbstractType<Integer>
      Parameters:
      buffer - the value to convert
      protocolVersion - the protocol version to use for the conversion
      Returns:
      a JSON string representing the specified value
    • asCQL3Type

      public CQL3Type asCQL3Type()
      Overrides:
      asCQL3Type in class AbstractType<Integer>
    • getSerializer

      public TypeSerializer<Integer> getSerializer()
      Specified by:
      getSerializer in class AbstractType<Integer>
    • validateDuration

      protected void validateDuration(Duration duration)
      Description copied from class: TemporalType
      Validates that the duration has the correct precision.
      Overrides:
      validateDuration in class TemporalType<Integer>
      Parameters:
      duration - the duration to validate.
    • getMaskedValue

      public ByteBuffer getMaskedValue()
      Overrides:
      getMaskedValue in class AbstractType<Integer>
      Returns:
      A fixed, serialized value to be used when the column is masked, to be returned instead of the real value.