We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Sequence 的incr 里面建议换成BigDecimal 这样可以支持几乎无限位自增
public class Sequence { public final static String HEAD = KeyEnum.SEQ.getKey(); private final static byte[] HEAD_B = HEAD.getBytes(); private final byte[] key_b; private DB db; private BigDecimal version; public synchronized String incr(String increments) throws RocksDBException { BigDecimal increment = new BigDecimal(increments); if (version == null) { byte[] value = db.rocksDB().get(key_b); if (value == null) { version = BigDecimal.ZERO; } else { version = new BigDecimal(ArrayKits.bytesToString(value)); } } version = version.add(increment); db.rocksDB().put(key_b, ArrayKits.convertStringToBytes(version.toPlainString())); return version.toPlainString(); } public String get() { return version.toPlainString(); } public Sequence(DB db, byte[] key) { this.db = db; this.key_b = ArrayKits.addAll(HEAD_B, key); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Sequence 的incr 里面建议换成BigDecimal 这样可以支持几乎无限位自增
The text was updated successfully, but these errors were encountered: