forked from h2oai/h2o-2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not print giant Java models by default
Big Tree models (e.g. 50 trees x 2 classes x 10000 leaves per tree) make for Big Java - which we were printing to the browser with each progress-bar update. Move SB to its own file, so others can use it. Peel out the Java generation from the API, into its own methods.
- Loading branch information
1 parent
b713887
commit d879439
Showing
10 changed files
with
76 additions
and
38 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
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
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
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
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
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,43 @@ | ||
package water.util; | ||
|
||
// Tight/tiny StringBuilder wrapper. | ||
// Short short names on purpose; so they don't obscure the printing. | ||
// Can't believe this wasn't done long long ago. | ||
public class SB { | ||
public final StringBuilder _sb; | ||
public SB( ) { _sb = new StringBuilder( ); } | ||
public SB(String s) { _sb = new StringBuilder(s); } | ||
public SB p( String s ) { _sb.append(s); return this; } | ||
public SB p( float s ) { _sb.append(s); return this; } | ||
public SB p( char s ) { _sb.append(s); return this; } | ||
public SB p( int s ) { _sb.append(s); return this; } | ||
public SB p( Object s ) { _sb.append(s.toString()); return this; } | ||
public SB indent( int d ) { for( int i=0; i<d; i++ ) p(" "); return this; } | ||
// Convert a String[] into a valid Java String initializer | ||
public SB toJavaStringInit( String[] ss ) { | ||
p('{'); | ||
for( int i=0; i<ss.length-1; i++ ) p('"').p(ss[i]).p("\","); | ||
if( ss.length > 0 ) p('"').p(ss[ss.length-1]).p('"'); | ||
return p('}'); | ||
} | ||
public SB toJSArray(float[] nums) { | ||
p('['); | ||
for (int i=0; i<nums.length; i++) { | ||
if (i>0) p(','); | ||
p(nums[i]); | ||
} | ||
return p(']'); | ||
} | ||
public SB toJSArray(String[] ss) { | ||
p('['); | ||
for (int i=0; i<ss.length; i++) { | ||
if (i>0) p(','); | ||
p('"').p(ss[i]).p('"'); | ||
} | ||
return p(']'); | ||
} | ||
|
||
// Mostly a fail, since we should just dump into the same SB. | ||
public SB p( SB sb ) { _sb.append(sb._sb); return this; } | ||
@Override public String toString() { return _sb.toString(); } | ||
} |