Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion client/src/com/aerospike/client/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,8 @@ public int hashCode() {
* HyperLogLog value.
*/
public static final class HLLValue extends Value {
private volatile LuaBytes cachedLuaValue;

private final byte[] bytes;

public HLLValue(byte[] bytes) {
Expand Down Expand Up @@ -1399,7 +1401,16 @@ public byte[] getBytes() {

@Override
public LuaValue getLuaValue(LuaInstance instance) {
return new LuaBytes(instance, bytes);
LuaBytes result = cachedLuaValue;
if (result == null) {
synchronized (this) {
result = cachedLuaValue;
if (result == null) {
cachedLuaValue = result = new LuaBytes(instance, bytes);
}
}
}
return result;
}

@Override
Expand Down