Permalink
Browse files

handle larger db returns

  • Loading branch information...
erh committed Sep 19, 2009
1 parent a23a54f commit 3d0dea03b7fc4d3ec36b146e7654a94f671a3767
@@ -65,7 +65,7 @@ public ByteDecoder( ByteBuffer buf ){
}
private ByteDecoder(){
- _buf = ByteBuffer.allocateDirect( BUF_SIZE );
+ _buf = ByteBuffer.allocateDirect( 1024 + ( MAX_OBJECT_SIZE * 2 ) );
_private = true;
reset();
}
@@ -106,15 +106,15 @@ protected ByteEncoder createNew(){
}
protected long memSize( ByteEncoder d ){
- return BUF_SIZE + ( 2 * MAX_STRING ) + 1024;
+ return d._buf.capacity() + ( 2 * MAX_STRING ) + 1024;
}
};
// ----
private ByteEncoder(){
- _buf = ByteBuffer.allocateDirect( BUF_SIZE );
+ _buf = ByteBuffer.allocateDirect( MAX_OBJECT_SIZE + 2048 );
_buf.order( Bytes.ORDER );
}
@@ -32,14 +32,15 @@
/** Little-endian */
public static final ByteOrder ORDER = ByteOrder.LITTLE_ENDIAN;
-
- static final int BUF_SIZE = 1024 * 1024 * 5;
+
+ static final int MAX_OBJECT_SIZE = 1024 * 1024 * 4;
+
static final int CONNECTIONS_PER_HOST = Integer.parseInt( System.getProperty( "MONGO.POOLSIZE" , "10" ) );
static final int NUM_ENCODERS;
static {
Runtime r = Runtime.getRuntime();
- int numBufs = (int)(r.maxMemory() / BUF_SIZE);
+ int numBufs = (int)(r.maxMemory() / MAX_OBJECT_SIZE);
numBufs = numBufs / 5;
if ( numBufs > CONNECTIONS_PER_HOST ){
numBufs = CONNECTIONS_PER_HOST;

0 comments on commit 3d0dea0

Please sign in to comment.