Coder Social home page Coder Social logo

redisbloom / jredisbloom Goto Github PK

View Code? Open in Web Editor NEW
154.0 10.0 33.0 1.13 MB

Java Client for RedisBloom probabilistic module

Home Page: https://redisbloom.io

License: BSD 2-Clause "Simplified" License

Java 100.00%
bloom-filter java-client redis-client redisbloom redis

jredisbloom's Issues

java.lang.NoClassDefFoundError: redis/clients/jedis/util/Pool

I got an Error like this:
java.lang.NoClassDefFoundError: redis/clients/jedis/util/Pool

my jrebloom version is 2.1.0, jedis version is 2.9.3
Client.class in io.rebloom.client like this:
import redis.clients.jedis.util.Pool . But my jedis folder is redis.clients.util, so it cannot find path(redis.clients.jedis.util.Pool)
should i change my jrebloom or jedis to a suitable version?

Issue with createFilter

Hello,

I am following the example on how to create a filter, but I am running into the error below:

redis.clients.jedis.exceptions.JedisDataException: ERR unknown command `BF.RESERVE`, with args beginning with: `specialBloom`, `0.01`, `500000`, 
	at redis.clients.jedis.Protocol.processError(Protocol.java:132)
	at redis.clients.jedis.Protocol.process(Protocol.java:166)
	at redis.clients.jedis.Protocol.read(Protocol.java:220)

Looking at the documentation here: https://oss.redislabs.com/redisbloom/Bloom_Commands/
it seems that it should work with those args --> BF.RESERVE {key} {error_rate} {capacity}

Here is how I am initializing it (I have my local redis instance on port 6379):

       redisClient = new Client("localhost", 6379);
       redisClient.createFilter("specialBloom", 500000, 0.01);

Any help would be appreciated!

Support for T-Digest data structure

Given RedisBloom/RedisBloom#285 there is the following set of commands we should enable:

  • TDIGEST.CREATE: Allocate a new histogram
  • TDIGEST.RESET: Empty out a histogram and re-initialize it
  • TDIGEST.ADD: Add a value to the t-Digest with the specified count
  • TDIGEST.MERGE: Merge one t-Digest into another
  • TDIGEST.CDF: Returns the fraction of all points added which are ≤ x.
  • TDIGEST.QUANTILE: Returns an estimate of the cutoff such that a specified fraction of the data added to the t-Digest would be less than or equal to the cutoff.
  • TDIGEST.MIN: Get the minimum value from the histogram. Will return DBL_MAX if the histogram is empty
  • TDIGEST.MAX: Get the maximum value from the histogram. Will return DBL_MIN if the histogram is empty
  • TDIGEST.INFO : Returns compression, capacity, total merged and unmerged nodes, the total compressions
    made up to date on that key, and merged and unmerged weight.

With the in-depth params in https://oss.redislabs.com/redisbloom/master/TDigest_Commands/

run cfScanDump method result :WRONGTYPE Operation against a key holding the wrong kind of value

package com.ghy.www.test9;

import com.ghy.www.f.F;
import io.rebloom.client.Client;
import io.rebloom.client.ReserveParams;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class Bloom_6 {
private static JedisPool pool = new JedisPool(new JedisPoolConfig(), F.IP_1, F.PORT_1, F.TIMEOUT_1, F.PASSWORD_1);

public static void main(String[] args) {
    Jedis jedis = null;
    Client client = null;
    try {
        jedis = pool.getResource();
        jedis.flushDB();

        client = new Client(pool);

        ReserveParams params = new ReserveParams();
        client.bfReserve("mykey", 0.001, 10, params);
        client.add("mykey", "a");
        client.add("mykey", "b");
        client.add("mykey", "c");
        client.add("mykey", "d");
        client.add("mykey", "e");

        Map backupMap = new HashMap();

        Map.Entry<Long, byte[]> mykey = client.cfScanDump("mykey", 0);
        while (mykey.getKey() != 0) {
            long cursor = mykey.getKey();
            byte[] dataArray = mykey.getValue();
            backupMap.put(cursor, dataArray);
            mykey = client.cfScanDump("mykey", cursor);
        }

        jedis.flushDB();

        Set<Map.Entry> set = backupMap.entrySet();
        Iterator<Map.Entry> iterator = set.iterator();
        while (iterator.hasNext()) {
            client.cfLoadChunk("mykey", iterator.next());
        }

        System.out.println();
        Map<String, Object> mykeyInfo = client.info("mykey");
        for (String eachKey : mykeyInfo.keySet()) {
            System.out.println("key=" + eachKey + " value=" + mykeyInfo.get(eachKey));
        }

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (jedis != null) {
            jedis.close();
        }
        if (client != null) {
            client.close();
        }
    }
}

}

redis.clients.jedis.exceptions.JedisDataException: WRONGTYPE Operation against a key holding the wrong kind of value

why add 3, return boolean[] length is 4 ???

package com.ghy.www.test9;

import com.ghy.www.f.F;
import io.rebloom.client.Client;
import io.rebloom.client.InsertOptions;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import java.util.Map;

public class Bloom_3 {
    private static JedisPool pool = new JedisPool(new JedisPoolConfig(), F.IP_1, F.PORT_1, F.TIMEOUT_1, F.PASSWORD_1);

    public static void main(String[] args) {

        Jedis jedis = null;
        Client client = null;
        try {
            jedis = pool.getResource();
            jedis.flushDB();

            client = new Client(pool);
            {
                InsertOptions insertOptions = new InsertOptions();
                boolean[] insert = client.insert("mykey", insertOptions, "a", "b", "c");
                for (int i = 0; i < insert.length; i++) {
                    System.out.println(insert[i]);
                }
                System.out.println();
                Map<String, Object> mykey = client.info("mykey");
                for (String eachKey : mykey.keySet()) {
                    System.out.println("key=" + eachKey + " value=" + mykey.get(eachKey));
                }
            }
            System.out.println();
            System.out.println();
            {
                InsertOptions insertOptions = new InsertOptions();
                boolean[] insert = client.insert("mykey", insertOptions, "x", "y", "z");
                for (int i = 0; i < insert.length; i++) {
                    System.out.println(insert[i]);
                }
                System.out.println();
                Map<String, Object> mykey = client.info("mykey");
                for (String eachKey : mykey.keySet()) {
                    System.out.println("key=" + eachKey + " value=" + mykey.get(eachKey));
                }
            }
            System.out.println();
            System.out.println();
            {
                InsertOptions insertOptions = new InsertOptions();
                insertOptions.nocreate();
                client.insert("nononokey", insertOptions, "x", "y", "z");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (jedis != null) {
                jedis.close();
            }
            if (client != null) {
                client.close();
            }
        }
    }
}

true
true
true
false

key=Expansion rate value=2
key=Number of filters value=1
key=Capacity value=100
key=Number of items inserted value=3
key=Size value=290


true
true
true
false

key=Expansion rate value=2
key=Number of filters value=1
key=Capacity value=100
key=Number of items inserted value=6
key=Size value=290


redis.clients.jedis.exceptions.JedisDataException: ERR not found

Issue: connect pool

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Failed connecting to host

what is the version of jedis ?

In the Client class, i get that you import redis.clients.jedis.util.Pool;but my project occour this Exception:java.lang.ClassNotFoundException: redis.clients.jedis.util.Pool;I am sure it's the version of jedis(2.9.0) in my project cause this problem .So,what is your version of jedis? Thx.

return type bug

  String rep = sendCommand(conn, Command.RESERVE, name, errorRate + "", initCapacity + "").getStatusCodeReply();

will casue Byte caste long error

Unable to delete rebloom key

I am building a daily bloom filter where I make a new bloom-filter and remove the old filter via scheduler, but the delete command doesn't seem to be able to remove key.
Eg:

Client client1 = new Client("127.0.0.1", 6379);
String[] bloomFilterKeyList = {"a", "b"};
client1.addMulti("testBloom", bloomFilterKeyList);
client1.delete("testBloom");

Even after running the command testBloom key/filter still doesn't get deleted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.