return this;
}
public Object execute(final Map<Object, Object> iArgs) {
if (query == null && indexName == null)
throw new OCommandExecutionException("Can't execute the command because it hasn't been parsed yet");
if (query != null) {
// AGAINST CLUSTERS AND CLASSES
query.execute(iArgs);
return recordCount;
} else {
// AGAINST INDEXES
final OIndex index = database.getMetadata().getIndexManager().getIndex(indexName);
if (index == null)
throw new OCommandExecutionException("Target index '" + indexName + "' not found");
Object key = null;
Object value = VALUE_NOT_FOUND;
if (compiledFilter.getRootCondition() == null) {
final long total = index.getSize();
index.clear();
return total;
} else {
if (KEYWORD_KEY.equalsIgnoreCase(compiledFilter.getRootCondition().getLeft().toString()))
// FOUND KEY ONLY
key = compiledFilter.getRootCondition().getRight();
else if (compiledFilter.getRootCondition().getLeft() instanceof OSQLFilterCondition) {
// KEY AND VALUE
final OSQLFilterCondition leftCondition = (OSQLFilterCondition) compiledFilter.getRootCondition().getLeft();
if (KEYWORD_KEY.equalsIgnoreCase(leftCondition.getLeft().toString()))
key = leftCondition.getRight();
final OSQLFilterCondition rightCondition = (OSQLFilterCondition) compiledFilter.getRootCondition().getRight();
if (KEYWORD_RID.equalsIgnoreCase(rightCondition.getLeft().toString()))
value = rightCondition.getRight();
}
if (key == null)
throw new OCommandExecutionException("'Key' field is required for queries against indexes");
final boolean result;
if (value != VALUE_NOT_FOUND)
result = index.remove(key, (OIdentifiable) value);
else