
package org.apache.cassandra.db.rows;

import org.apache.cassandra.db.Digest;
import org.apache.cassandra.schema.TableMetadata;
import org.apache.cassandra.db.Clusterable;

/**
 * Unfiltered is the common class for the main constituent of an unfiltered partition.
 * <p>
 * In practice, an Unfiltered is either a row or a range tombstone marker. Unfiltereds
 * are uniquely identified by their clustering information and can be sorted according
 * to those.
 */
public interface Unfiltered extends Clusterable
{
    public enum Kind { ROW, RANGE_TOMBSTONE_MARKER };

    /**
     * The kind of the atom: either row or range tombstone marker.
     */
    public Kind kind();

    /**
     * Digest the atom using the provided {@link Digest}.
     *
     * @param digest the {@see Digest} to use.
     */
    public void digest(Digest digest);

    /**
     * Validate the data of this atom.
     *
     * @param metadata the metadata for the table this atom is part of.
     * @throws org.apache.cassandra.serializers.MarshalException if some of the data in this atom is
     * invalid (some value is invalid for its column type, or some field
     * is nonsensical).
     */
    public void validateData(TableMetadata metadata);

    /**
     * Do a quick validation of the deletions of the unfiltered (if any)
     *
     * @return true if any deletion is invalid
     */
    public boolean hasInvalidDeletions();
    public boolean isEmpty();

    public String toString(TableMetadata metadata);
    public String toString(TableMetadata metadata, boolean fullDetails);
    public String toString(TableMetadata metadata, boolean includeClusterKeys, boolean fullDetails);

    default boolean isRow()
    {
        return kind() == Kind.ROW;
    }

    default boolean isRangeTombstoneMarker()
    {
        return kind() == Kind.RANGE_TOMBSTONE_MARKER;
    }
}
