Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
Snappy-Java Source Code
Snappy-Java is a Java port of the "snappy", a fast C++ compresser/decompresser developed by Google.
Snappy-Java Source Code files are provided in the source packge (snappy-java-1.1.8.4-sources.jar). You can download it at Snappy Maven Website.
You can also browse Snappy-Java Source Code below:
✍: FYIcenter.com
⏎ org/xerial/snappy/buffer/CachedBufferAllocator.java
package org.xerial.snappy.buffer;
import java.lang.ref.SoftReference;
import java.util.*;
/**
* Cached buffer
*/
public class CachedBufferAllocator
implements BufferAllocator
{
private static BufferAllocatorFactory factory = new BufferAllocatorFactory()
{
@Override
public BufferAllocator getBufferAllocator(int bufferSize)
{
return CachedBufferAllocator.getAllocator(bufferSize);
}
};
public static void setBufferAllocatorFactory(BufferAllocatorFactory factory)
{
assert (factory != null);
CachedBufferAllocator.factory = factory;
}
public static BufferAllocatorFactory getBufferAllocatorFactory()
{
return factory;
}
/**
* Use SoftReference so that having this queueTable does not prevent the GC of CachedBufferAllocator instances
*/
private static final Map<Integer, SoftReference<CachedBufferAllocator>> queueTable = new HashMap<Integer, SoftReference<CachedBufferAllocator>>();
private final int bufferSize;
private final Deque<byte[]> bufferQueue;
public CachedBufferAllocator(int bufferSize)
{
this.bufferSize = bufferSize;
this.bufferQueue = new ArrayDeque<byte[]>();
}
public static synchronized CachedBufferAllocator getAllocator(int bufferSize)
{
CachedBufferAllocator result = null;
if (queueTable.containsKey(bufferSize)) {
result = queueTable.get(bufferSize).get();
}
if (result == null) {
result = new CachedBufferAllocator(bufferSize);
queueTable.put(bufferSize, new SoftReference<CachedBufferAllocator>(result));
}
return result;
}
@Override
public byte[] allocate(int size)
{
synchronized (this) {
if (bufferQueue.isEmpty()) {
return new byte[size];
}
else {
return bufferQueue.pollFirst();
}
}
}
@Override
public void release(byte[] buffer)
{
synchronized (this) {
bufferQueue.addLast(buffer);
}
}
}
⏎ org/xerial/snappy/buffer/CachedBufferAllocator.java
Or download all of them as a single archive file:
File name: snappy-java-1.1.8.4-sources.jar File size: 1962098 bytes Release date: 2021-01-25 Download
⇒ Download and Install Snappy-Java Binary Package
2021-07-13, ≈35🔥, 0💬
Popular Posts:
Where to get the Java source code for Connector/J 8.0 User API module? Java source code files for Co...
JDK 17 jdk.xml.dom.jmod is the JMOD file for JDK 17 XML DOM module. JDK 17 XML DOM module compiled c...
JDK 17 jdk.dynalink.jmod is the JMOD file for JDK 17 Dynamic Linking module. JDK 17 Dynamic Linking ...
JDK 11 java.security.jgss.jmod is the JMOD file for JDK 11 Security JGSS (Java Generic Security Serv...
How to run "jarsigner" command from JDK tools.jar file? "jarsigner" command allows you to digitally ...