-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support EXPANSION and NONSCALING options (#54)
* Support EXPANSION and NONSCALING options * edit * Placed BF tests contiguously * add tests and modify source * address review and further changes
- Loading branch information
Showing
5 changed files
with
181 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package io.rebloom.client; | ||
|
||
import static io.rebloom.client.Keywords.EXPANSION; | ||
import static io.rebloom.client.Keywords.NONSCALING; | ||
import static redis.clients.jedis.Protocol.toByteArray; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* To be used by both BF.RESERVE and BR.INSERT commands. | ||
* <p> | ||
* Supported arguments: | ||
* <ul><li>EXPANSION</li><li>NONSCALING</li></ul> | ||
*/ | ||
public class ReserveParams { | ||
|
||
private int expansion = 0; | ||
private boolean nonScaling = false; | ||
|
||
public ReserveParams() { | ||
} | ||
|
||
/** | ||
* @return ReserveParams | ||
* @see ReserveParams | ||
*/ | ||
public static ReserveParams reserveParams() { | ||
return new ReserveParams(); | ||
} | ||
|
||
public ReserveParams expansion(int expansion) { | ||
this.expansion = expansion; | ||
return this; | ||
} | ||
|
||
public ReserveParams nonScaling() { | ||
this.nonScaling = true; | ||
return this; | ||
} | ||
|
||
public List<byte[]> getParams() { | ||
List<byte[]> args = new ArrayList<>(); | ||
if (expansion > 0) { | ||
args.add(EXPANSION.getRaw()); | ||
args.add(toByteArray(expansion)); | ||
} | ||
if (nonScaling) { | ||
args.add(NONSCALING.getRaw()); | ||
} | ||
return args; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters