Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access Reducer attributes #3637

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/redis/clients/jedis/search/aggr/Reducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ public final Reducer as(String alias) {
return this;
}

public final String getName() {
return name;
}

public final String getField() {
return field;
}

public final String getAlias() {
return alias;
}

protected abstract List<Object> getOwnArgs();

public final void addArgs(List<Object> args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package redis.clients.jedis.modules.search;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import org.junit.Test;

import redis.clients.jedis.search.aggr.Reducer;
import redis.clients.jedis.search.aggr.Reducers;

public class AggregationBuilderTest {

@Test
public void reducerObject() {
Reducer reducer = Reducers.sum("@count").as("total");
assertEquals("SUM", reducer.getName());
assertEquals("@count", reducer.getField());
assertEquals("total", reducer.getAlias());
}

@Test
public void countObject() {
Reducer count = Reducers.count();
assertEquals("COUNT", count.getName());
assertNull(count.getField());
assertNull(count.getAlias());
}
}
Loading