simerplaha / SwayDB

Persistent and in-memory key-value storage engine for JVM that scales on a single machine.

Home Page:https://swaydb.simer.au

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve Java Slice API's usability

simerplaha opened this issue · comments

commented

Accessing Slice from Java requires input ByteOps for each API call which is repetitive and no fun.

Slice
  .ofBytesJava(50) 
  .addInt(data.getInteger(), ByteOps.Java())
  .addLong(data.getLongVal(), ByteOps.Java())
  .addStringUTF8(data.getString(), ByteOps.Java())
  .close(); 

See example.

Solution

Maybe implement a Java singleton instance in Slice which makes the above simpler. For example:

Slice.Java // .java or SliceJava or SliceJ ?
  .ofBytes(50)
  .addInt(data.getInteger())
  .addLong(data.getLongVal())
  .addStringUTF8(data.getString())
  .close();

With a dedicated Java implementation we could possibly remove ByteOps all together as long as there are no boxing issues.

Reference code

See SliceTest.java. The end goal is to improve this API.

Hi , can I have a go

commented

Sure! Go for it!

commented

I've moved all Slice related to code into a single project called slice and all Java related code into single project swaydb-java.

This should make things easier.

commented

Related task #319 requires @specialized(Byte) applied to Slice which in my IntelliJ setup does not register breakpoints.

To make debugging/breakpoints work remove @specialized(Byte) from Slice.scala.

commented

@hemantgs sorry I've had to attempt at this task because I'm running some benchmarks and ByteOps needs to be removed. This commit is preview only.

Progress

All Java APIs in Slice will be prefixed j. So in our IDE we can just hit j to filter out java relevant functions.

image

If prefix java_ or j_ feel better. We can change this based on whatever is preferred but this naming convention should be consistent for all APIs.

commented

The prefixes for Java APIs is inconvenient. There is a better way of doing this so Java APIs are seamless.

I'm going to remove "good first issue" label and work on core tasks. Will visit Java APIs before the release.

Hello sir ,
I am new to open source contribution.
I already know java , my tech stacks & tools includes C, C++ , Python , Java, JavaScript , HTML , CSS , SQL , Bootstrap, ReactJS, ExpressJS, NodeJS & Git . I need a little help from your side to contribute to these amazing projects.

commented

Hey! Welcome to the project :)

That's a wealth of knowledge you have there. That's awesome!

A great Java API is very important. Other than the issues labelled java I'd suggest just browsing through the Java code and see where you'd want to improve things.

SwayDB.java.examples is another project that is entirely Java which gets cloned a bit.

If there is anything specific you'd like to work on please go ahead and let me know how I can help.

But make sure to read the project status. As you can tell by the commit frequency SwayDB is not under active development right now. I hope to resume someday.

@simerplaha Need a little help , There are lots of functions i saw was new to me . in this product . what are the prerequired know we require about the project .
Am i missing something about this project

commented

Other than Scala there is no other prerequisite. SwayDB has no external core dependency so you'd just need to know Scala.

The Java API is written in Scala with the goal to have a nicer Java & Scala interop and minimum or no extra memory allocation. So it does not use anything from Scala's type-system that does not interop easily with Java.