remove bytes caching for stream copy
This commit is contained in:
parent
32294a4d4f
commit
9eb9e738ac
|
@ -34,7 +34,6 @@ public class CacheRecycler {
|
|||
|
||||
public static void clear() {
|
||||
BufferRecycler.clean();
|
||||
bytes.remove();
|
||||
doubleObjectHashMap.remove();
|
||||
longObjectHashMap.remove();
|
||||
longLongHashMap.remove();
|
||||
|
@ -47,27 +46,6 @@ public class CacheRecycler {
|
|||
intArray.remove();
|
||||
}
|
||||
|
||||
// Bytes
|
||||
private static ThreadLocal<SoftReference<byte[]>> bytes = new ThreadLocal<SoftReference<byte[]>>();
|
||||
|
||||
public static byte[] popBytes() {
|
||||
SoftReference<byte[]> ref = bytes.get();
|
||||
byte[] bb = ref == null ? null : ref.get();
|
||||
if (bb == null) {
|
||||
bb = new byte[1024];
|
||||
bytes.set(new SoftReference<byte[]>(bb));
|
||||
}
|
||||
return bb;
|
||||
}
|
||||
|
||||
public static void pushBytes(byte[] bb) {
|
||||
SoftReference<byte[]> ref = bytes.get();
|
||||
byte[] bb1 = ref == null ? null : ref.get();
|
||||
if (bb1 != null && bb1.length < bb.length) {
|
||||
bytes.set(new SoftReference<byte[]>(bb));
|
||||
}
|
||||
}
|
||||
|
||||
// ----- ExtTHashMap -----
|
||||
|
||||
private static ThreadLocal<SoftReference<Deque<ExtTHashMap>>> hashMap = new ThreadLocal<SoftReference<Deque<ExtTHashMap>>>();
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.common.xcontent.json;
|
||||
|
||||
import org.elasticsearch.common.CacheRecycler;
|
||||
import org.elasticsearch.common.io.Streams;
|
||||
import org.elasticsearch.common.jackson.JsonGenerator;
|
||||
import org.elasticsearch.common.xcontent.*;
|
||||
|
@ -214,8 +213,7 @@ public class JsonXContentGenerator implements XContentGenerator {
|
|||
generator.writeRaw(fieldName);
|
||||
generator.writeRaw("\" : ");
|
||||
flush();
|
||||
byte[] bytes = CacheRecycler.popBytes();
|
||||
Streams.copy(content, bos, bytes);
|
||||
Streams.copy(content, bos);
|
||||
}
|
||||
|
||||
@Override public void copyCurrentStructure(XContentParser parser) throws IOException {
|
||||
|
|
Loading…
Reference in New Issue