Skip to content

Commit

Permalink
PUBDEV-2133: Speed up Enum mapping between train/test from O(N^2) to …
Browse files Browse the repository at this point in the history
…O(N*log(N))
  • Loading branch information
arnocandel committed Sep 22, 2015
1 parent f265d1b commit fe94591
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions h2o-core/src/main/java/water/fvec/EnumWrappedVec.java
Expand Up @@ -120,16 +120,20 @@ void computeMap( String[] from, String[] to, boolean fromIsBad ) {
for( int i=0; i<to.length; i++ ) h.put(to[i],i);
String[] ss = to;
int extra = to.length;
int actualLen = extra;
for( int j=0; j<from.length; j++ ) {
Integer x = h.get(from[j]);
if( x!=null ) _map[j] = x;
else {
_map[j] = extra++;
ss = Arrays.copyOf(ss,extra);
if (extra > ss.length) {
ss = Arrays.copyOf(ss, 2*ss.length);
}
ss[extra-1] = from[j];
actualLen = extra;
}
}
setDomain(ss);
setDomain(Arrays.copyOf(ss, actualLen));
}


Expand Down

0 comments on commit fe94591

Please sign in to comment.