-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this will end poorly, but maybe it will be fast af
- Loading branch information
1 parent
39f2320
commit c489fa2
Showing
4 changed files
with
75 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/ByteArrayFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.processing;import org.apache.commons.pool2.BasePooledObjectFactory; | ||
import org.apache.commons.pool2.PooledObject; | ||
import org.apache.commons.pool2.impl.DefaultPooledObject; | ||
|
||
|
||
|
||
public class ByteArrayFactory extends BasePooledObjectFactory<byte[]> { | ||
|
||
private final int size; | ||
|
||
public ByteArrayFactory(int size) { | ||
this.size = size; | ||
} | ||
|
||
@Override | ||
public byte[] create() { | ||
return new byte[1]; | ||
} | ||
|
||
/** | ||
* Use the default PooledObject implementation. | ||
*/ | ||
@Override | ||
public PooledObject<byte[]> wrap(byte[] buffer) { | ||
return new DefaultPooledObject<byte[]>(buffer); | ||
} | ||
|
||
/** | ||
* When an object is returned to the pool, clear the buffer. | ||
*/ | ||
@Override | ||
public void passivateObject(PooledObject<byte[]> pooledObject) { | ||
// pooledObject.getObject().setLength(0); | ||
// noop | ||
} | ||
|
||
// for all other methods, the no-op implementation | ||
// in BasePooledObjectFactory will suffice | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters