GithubHelp home page GithubHelp logo

Comments (5)

adamretter avatar adamretter commented on April 28, 2024

If you want to explicitly use Column Families, you should pass the descriptors when you open the db, in return you will get back a set of handles that you can reuse for get/put.

Otherwise, if you don't want to explicitly use Column Families, you can just call -

byte[] value = db.get(KEY);

...

db.put(KEY, value);

from rocksdb.

vsrivatsan89 avatar vsrivatsan89 commented on April 28, 2024

I thought that was the case, but I recall receiving exception saying that column family can’t be null when using the get (KEY) API. Let me try again.

from rocksdb.

vsrivatsan89 avatar vsrivatsan89 commented on April 28, 2024

@adamretter I updated the code as per your suggestion to

try {
      byte[] value = db.get(KEY);
      if (value == null) {
        value = ByteBuffer.allocate(4).putInt(1).array();
      } else {
        value = ByteBuffer.allocate(4).putInt(ByteBuffer.wrap(value).getInt() + 1).array();
      }
      db.put(KEY, value);
      return "SUCCESS";
    } catch (RocksDBException e) {
      throw new RuntimeException(e);
    }

I still get SIGSEGV. If i'm not using column families explicitly in my API calls, do I still need to register the default column family upon DB open?

from rocksdb.

adamretter avatar adamretter commented on April 28, 2024

@vsrivatsan89 I just took a closer look at your earlier code:

try (final Options options = new Options().setCreateIfMissing(true)) {
      try (final RocksDB db = RocksDB.open(options, "/mnt/test")) {
        log.info("Successfully loaded RocksDB");
        return db;
      } catch (RocksDBException e) {
        log.info("Exception in loading RocksDB");
        throw new RuntimeException(e);
      }
}

This is invalid! Your code will call db.close() and then options.close() before returning the db object.

from rocksdb.

vsrivatsan89 avatar vsrivatsan89 commented on April 28, 2024

@adamretter Bah! Sorry about the silly mistake and wasting your time. Thank you for your patience.

from rocksdb.

Related Issues (20)

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.