use of org.apache.ignite.internal.metastorage.common.command.SimpleConditionInfo 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);
}
}
use of org.apache.ignite.internal.metastorage.common.command.SimpleConditionInfo in project ignite-3 by apache.
the class MetaStorageServiceImpl method toConditionInfo.
private static ConditionInfo toConditionInfo(@NotNull Condition condition) {
ConditionInfo cnd = null;
if (condition instanceof SimpleCondition) {
Object obj = ((SimpleCondition) condition).inner();
if (obj instanceof SimpleCondition.ExistenceCondition) {
SimpleCondition.ExistenceCondition inner = (SimpleCondition.ExistenceCondition) obj;
cnd = new SimpleConditionInfo(inner.key(), inner.type(), null, 0);
} else if (obj instanceof SimpleCondition.TombstoneCondition) {
SimpleCondition.TombstoneCondition inner = (SimpleCondition.TombstoneCondition) obj;
cnd = new SimpleConditionInfo(inner.key(), inner.type(), null, 0);
} else if (obj instanceof SimpleCondition.RevisionCondition) {
SimpleCondition.RevisionCondition inner = (SimpleCondition.RevisionCondition) obj;
cnd = new SimpleConditionInfo(inner.key(), inner.type(), null, inner.revision());
} else if (obj instanceof SimpleCondition.ValueCondition) {
SimpleCondition.ValueCondition inner = (SimpleCondition.ValueCondition) obj;
cnd = new SimpleConditionInfo(inner.key(), inner.type(), inner.value(), 0);
} else {
assert false : "Unknown condition type: " + obj.getClass().getSimpleName();
}
} else if (condition instanceof CompoundCondition) {
CompoundCondition cond = (CompoundCondition) condition;
cnd = new CompoundConditionInfo(toConditionInfo(cond.leftCondition()), toConditionInfo(cond.rightCondition()), cond.compoundConditionType());
} else {
assert false : "Unknown condition type: " + condition.getClass().getSimpleName();
}
return cnd;
}
Aggregations