Search in sources :

Example 1 with ExistenceCondition

use of org.apache.ignite.internal.metastorage.server.ExistenceCondition in project ignite-3 by apache.

the class MetaStorageListener method toCondition.

private static Condition toCondition(ConditionInfo info) {
    if (info instanceof SimpleConditionInfo) {
        SimpleConditionInfo inf = (SimpleConditionInfo) info;
        byte[] key = inf.key();
        ConditionType type = inf.type();
        if (type == ConditionType.KEY_EXISTS) {
            return new ExistenceCondition(ExistenceCondition.Type.EXISTS, key);
        } else if (type == ConditionType.KEY_NOT_EXISTS) {
            return new ExistenceCondition(ExistenceCondition.Type.NOT_EXISTS, key);
        } else if (type == ConditionType.TOMBSTONE) {
            return new TombstoneCondition(key);
        } else if (type == ConditionType.VAL_EQUAL) {
            return new ValueCondition(ValueCondition.Type.EQUAL, key, inf.value());
        } else if (type == ConditionType.VAL_NOT_EQUAL) {
            return new ValueCondition(ValueCondition.Type.NOT_EQUAL, key, inf.value());
        } else if (type == ConditionType.VAL_GREATER) {
            return new ValueCondition(ValueCondition.Type.GREATER, key, inf.value());
        } else if (type == ConditionType.VAL_GREATER_OR_EQUAL) {
            return new ValueCondition(ValueCondition.Type.GREATER_OR_EQUAL, key, inf.value());
        } else if (type == ConditionType.VAL_LESS) {
            return new ValueCondition(ValueCondition.Type.LESS, key, inf.value());
        } else if (type == ConditionType.VAL_LESS_OR_EQUAL) {
            return new ValueCondition(ValueCondition.Type.LESS_OR_EQUAL, key, inf.value());
        } else if (type == ConditionType.REV_EQUAL) {
            return new RevisionCondition(RevisionCondition.Type.EQUAL, key, inf.revision());
        } else if (type == ConditionType.REV_NOT_EQUAL) {
            return new RevisionCondition(RevisionCondition.Type.NOT_EQUAL, key, inf.revision());
        } else if (type == ConditionType.REV_GREATER) {
            return new RevisionCondition(RevisionCondition.Type.GREATER, key, inf.revision());
        } else if (type == ConditionType.REV_GREATER_OR_EQUAL) {
            return new RevisionCondition(RevisionCondition.Type.GREATER_OR_EQUAL, key, inf.revision());
        } else if (type == ConditionType.REV_LESS) {
            return new RevisionCondition(RevisionCondition.Type.LESS, key, inf.revision());
        } else if (type == ConditionType.REV_LESS_OR_EQUAL) {
            return new RevisionCondition(RevisionCondition.Type.LESS_OR_EQUAL, key, inf.revision());
        } else {
            throw new IllegalArgumentException("Unknown condition type: " + type);
        }
    } else if (info instanceof CompoundConditionInfo) {
        CompoundConditionInfo inf = (CompoundConditionInfo) info;
        if (inf.type() == CompoundConditionType.AND) {
            return new AndCondition(toCondition(inf.leftConditionInfo()), toCondition(inf.rightConditionInfo()));
        } else if (inf.type() == CompoundConditionType.OR) {
            return new OrCondition(toCondition(inf.leftConditionInfo()), toCondition(inf.rightConditionInfo()));
        } else {
            throw new IllegalArgumentException("Unknown compound condition " + inf.type());
        }
    } else {
        throw new IllegalArgumentException("Unknown condition info type " + info);
    }
}
Also used : SimpleConditionInfo(org.apache.ignite.internal.metastorage.common.command.SimpleConditionInfo) TombstoneCondition(org.apache.ignite.internal.metastorage.server.TombstoneCondition) CompoundConditionInfo(org.apache.ignite.internal.metastorage.common.command.CompoundConditionInfo) ValueCondition(org.apache.ignite.internal.metastorage.server.ValueCondition) ExistenceCondition(org.apache.ignite.internal.metastorage.server.ExistenceCondition) CompoundConditionType(org.apache.ignite.internal.metastorage.common.command.CompoundConditionType) ConditionType(org.apache.ignite.internal.metastorage.common.ConditionType) OrCondition(org.apache.ignite.internal.metastorage.server.OrCondition) RevisionCondition(org.apache.ignite.internal.metastorage.server.RevisionCondition) AndCondition(org.apache.ignite.internal.metastorage.server.AndCondition)

Aggregations

ConditionType (org.apache.ignite.internal.metastorage.common.ConditionType)1 CompoundConditionInfo (org.apache.ignite.internal.metastorage.common.command.CompoundConditionInfo)1 CompoundConditionType (org.apache.ignite.internal.metastorage.common.command.CompoundConditionType)1 SimpleConditionInfo (org.apache.ignite.internal.metastorage.common.command.SimpleConditionInfo)1 AndCondition (org.apache.ignite.internal.metastorage.server.AndCondition)1 ExistenceCondition (org.apache.ignite.internal.metastorage.server.ExistenceCondition)1 OrCondition (org.apache.ignite.internal.metastorage.server.OrCondition)1 RevisionCondition (org.apache.ignite.internal.metastorage.server.RevisionCondition)1 TombstoneCondition (org.apache.ignite.internal.metastorage.server.TombstoneCondition)1 ValueCondition (org.apache.ignite.internal.metastorage.server.ValueCondition)1