Fix compilation issues and buffer expansions
This commit is contained in:
parent
47de651c94
commit
154086dee2
@ -660,7 +660,7 @@ public class LLLocalDictionary implements LLDictionary {
|
|||||||
prevData = null;
|
prevData = null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var obtainedPrevData = dbGet(cfh, null, key.send(), existsAlmostCertainly);
|
var obtainedPrevData = dbGet(cfh, null, key.copy().send(), existsAlmostCertainly);
|
||||||
if (obtainedPrevData == null) {
|
if (obtainedPrevData == null) {
|
||||||
prevData = null;
|
prevData = null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -96,10 +96,10 @@ public class BufferDataInput implements DataInput, SafeCloseable {
|
|||||||
@Override
|
@Override
|
||||||
public String readUTF() {
|
public String readUTF() {
|
||||||
var len = buf.readUnsignedShort();
|
var len = buf.readUnsignedShort();
|
||||||
try (var copiedBuf = buf.copy(buf.readerOffset(), len)) {
|
byte[] bytes = new byte[len];
|
||||||
var off = copiedBuf.readerOffset();
|
buf.copyInto(buf.readerOffset(), bytes, 0, len);
|
||||||
return LLUtils.deserializeString(copiedBuf.send(), off, len, StandardCharsets.UTF_8);
|
buf.readerOffset(buf.readerOffset() + len);
|
||||||
}
|
return new String(bytes, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,72 +19,90 @@ public class BufferDataOutput implements DataOutput {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(int b) {
|
public void write(int b) {
|
||||||
|
buf.ensureWritable(Integer.BYTES);
|
||||||
buf.writeUnsignedByte(b);
|
buf.writeUnsignedByte(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(byte @NotNull [] b) {
|
public void write(byte @NotNull [] b) {
|
||||||
|
buf.ensureWritable(Byte.BYTES * b.length);
|
||||||
buf.writeBytes(b);
|
buf.writeBytes(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(byte @NotNull [] b, int off, int len) {
|
public void write(byte @NotNull [] b, int off, int len) {
|
||||||
|
buf.ensureWritable(len);
|
||||||
buf.writeBytes(b, off, len);
|
buf.writeBytes(b, off, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeBoolean(boolean v) {
|
public void writeBoolean(boolean v) {
|
||||||
|
buf.ensureWritable(Byte.BYTES);
|
||||||
buf.writeUnsignedByte(v ? 1 : 0);
|
buf.writeUnsignedByte(v ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeByte(int v) {
|
public void writeByte(int v) {
|
||||||
|
buf.ensureWritable(Byte.BYTES);
|
||||||
buf.writeByte((byte) v);
|
buf.writeByte((byte) v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeShort(int v) {
|
public void writeShort(int v) {
|
||||||
|
buf.ensureWritable(Short.BYTES);
|
||||||
buf.writeShort((short) v);
|
buf.writeShort((short) v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeChar(int v) {
|
public void writeChar(int v) {
|
||||||
|
buf.ensureWritable(Character.BYTES);
|
||||||
buf.writeChar((char) v);
|
buf.writeChar((char) v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeInt(int v) {
|
public void writeInt(int v) {
|
||||||
|
buf.ensureWritable(Integer.BYTES);
|
||||||
buf.writeInt(v);
|
buf.writeInt(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeLong(long v) {
|
public void writeLong(long v) {
|
||||||
|
buf.ensureWritable(Long.BYTES);
|
||||||
buf.writeLong(v);
|
buf.writeLong(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeFloat(float v) {
|
public void writeFloat(float v) {
|
||||||
|
buf.ensureWritable(Float.BYTES);
|
||||||
buf.writeFloat(v);
|
buf.writeFloat(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeDouble(double v) {
|
public void writeDouble(double v) {
|
||||||
|
buf.ensureWritable(Double.BYTES);
|
||||||
buf.writeDouble(v);
|
buf.writeDouble(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeBytes(@NotNull String s) {
|
public void writeBytes(@NotNull String s) {
|
||||||
buf.writeBytes(s.getBytes());
|
var b= s.getBytes(StandardCharsets.UTF_8);
|
||||||
|
buf.ensureWritable(Byte.BYTES * b.length);
|
||||||
|
buf.writeBytes(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeChars(@NotNull String s) {
|
public void writeChars(@NotNull String s) {
|
||||||
s.chars().forEach(c -> buf.writeChar((char) c));
|
var chars = s.toCharArray();
|
||||||
|
buf.ensureWritable(Character.BYTES * chars.length);
|
||||||
|
for (char c : chars) {
|
||||||
|
buf.writeChar(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeUTF(@NotNull String s) {
|
public void writeUTF(@NotNull String s) {
|
||||||
var bytes = s.getBytes(StandardCharsets.UTF_8);
|
var bytes = s.getBytes(StandardCharsets.UTF_8);
|
||||||
|
buf.ensureWritable(Short.BYTES + Byte.BYTES * bytes.length);
|
||||||
buf.writeUnsignedShort(bytes.length);
|
buf.writeUnsignedShort(bytes.length);
|
||||||
buf.writeBytes(bytes);
|
buf.writeBytes(bytes);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public class RandomFieldComparator extends FieldComparator<Float> implements Lea
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!(scorer instanceof ScoreCachingWrappingScorer)) {
|
if (!(scorer instanceof ScoreCachingWrappingScorer)) {
|
||||||
this.scorer = ScoreCachingWrappingScorer.wrap(randomizedScorer);
|
this.scorer = new ScoreCachingWrappingScorer(randomizedScorer);
|
||||||
} else {
|
} else {
|
||||||
this.scorer = randomizedScorer;
|
this.scorer = randomizedScorer;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user