idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
22,200
protected Parser parser ( Key jobKey ) { ParserProvider pp = ParserService . INSTANCE . getByInfo ( _parse_type ) ; if ( pp != null ) { return pp . createParser ( this , jobKey ) ; } throw new H2OIllegalArgumentException ( "Unknown file type. Parse cannot be completed." , "Attempted to invoke a parser for ParseType:" ...
This is a single entry - point to create a parser .
22,201
public final ParseSetup getFinalSetup ( Key [ ] inputKeys , ParseSetup demandedSetup ) { ParserProvider pp = ParserService . INSTANCE . getByInfo ( _parse_type ) ; if ( pp != null ) { ParseSetup ps = pp . createParserSetup ( inputKeys , demandedSetup ) ; if ( demandedSetup . _decrypt_tool != null ) ps . _decrypt_tool =...
Return create a final parser - specific setup for this configuration .
22,202
HashSet < String > checkDupColumnNames ( ) { HashSet < String > conflictingNames = new HashSet < > ( ) ; if ( null == _column_names ) return conflictingNames ; HashSet < String > uniqueNames = new HashSet < > ( ) ; for ( String n : _column_names ) if ( ! uniqueNames . add ( n ) ) conflictingNames . add ( n ) ; return c...
Set of duplicated column names
22,203
public static ParseSetup guessSetup ( Key [ ] fkeys , boolean singleQuote , int checkHeader ) { return guessSetup ( fkeys , new ParseSetup ( GUESS_INFO , GUESS_SEP , singleQuote , checkHeader , GUESS_COL_CNT , null , new ParseWriter . ParseErr [ 0 ] ) ) ; }
Used by test harnesses for simple parsing of test data . Presumes auto - detection for file and separator types .
22,204
public static ParseSetup guessSetup ( Key [ ] fkeys , ParseSetup userSetup ) { GuessSetupTsk t = new GuessSetupTsk ( userSetup ) ; t . doAll ( fkeys ) . getResult ( ) ; Iced ice = DKV . getGet ( fkeys [ 0 ] ) ; if ( ice instanceof Frame && ( ( Frame ) ice ) . vec ( 0 ) instanceof UploadFileVec ) { t . _gblSetup . _chun...
Discover the parse setup needed to correctly parse all files . This takes a ParseSetup as guidance . Each file is examined individually and then results merged . If a conflict exists between any results all files are re - examined using the best guess from the first examination .
22,205
private static int [ ] createMapping ( final MojoModel model , final String [ ] reference , final String modelName ) { int [ ] mapping = new int [ reference . length ] ; if ( model . _names . length != reference . length ) { throw new IllegalStateException ( String . format ( "Model '%s' is expected to have has non-sta...
Creates an array of integers with mapping of referential column name space into model - specific column name space .
22,206
public long size ( ) { long res = 0 ; if ( _network != null ) res += _network . length ; if ( _modelparams != null ) res += _modelparams . length ; return res ; }
momenta are not counted here but they are needed for model building
22,207
private void javaToNative ( byte [ ] network , byte [ ] parameters ) { long now = System . currentTimeMillis ( ) ; if ( _backend != null && ( network == null || Arrays . equals ( network , _network ) ) && ( parameters == null || Arrays . equals ( parameters , _modelparams ) ) ) { Log . warn ( "No need to move the state...
Internal helper to create a native backend and fill its state
22,208
TwoDimTable createSummaryTable ( ) { TwoDimTable table = new TwoDimTable ( "Status of Deep Learning Model" , ( get_params ( ) . _network == null ? ( "MLP: " + Arrays . toString ( get_params ( ) . _hidden ) ) : get_params ( ) . _network . toString ( ) ) + ", " + PrettyPrint . bytes ( size ( ) ) + ", " + ( ! get_params (...
Create a summary table
22,209
private final void print ( Object [ ] kvs ) { for ( int i = 0 ; i < len ( kvs ) ; i ++ ) { Object K = key ( kvs , i ) ; if ( K != null ) { String KS = ( K == TOMBSTONE ) ? "XXX" : K . toString ( ) ; Object V = val ( kvs , i ) ; Object U = Prime . unbox ( V ) ; String p = ( V == U ) ? "" : "prime_" ; String US = ( U == ...
print the entire state of the table
22,210
private final void print2 ( Object [ ] kvs ) { for ( int i = 0 ; i < len ( kvs ) ; i ++ ) { Object key = key ( kvs , i ) ; Object val = val ( kvs , i ) ; Object U = Prime . unbox ( val ) ; if ( key != null && key != TOMBSTONE && val != null && U != TOMBSTONE ) { String p = ( val == U ) ? "" : "prime_" ; System . out . ...
print only the live values broken down by the table they are in
22,211
private int setCompletion ( int completion ) { for ( int s ; ; ) { if ( ( s = status ) < 0 ) return s ; if ( U . compareAndSwapInt ( this , STATUS , s , s | completion ) ) { if ( ( s >>> 16 ) != 0 ) synchronized ( this ) { notifyAll ( ) ; } return completion ; } } }
Marks completion and wakes up threads waiting to join this task .
22,212
final int doExec ( ) { int s ; boolean completed ; if ( ( s = status ) >= 0 ) { try { completed = exec ( ) ; } catch ( Throwable rex ) { return setExceptionalCompletion ( rex ) ; } if ( completed ) s = setCompletion ( NORMAL ) ; } return s ; }
Primary execution method for stolen tasks . Unless done calls exec and records status if completed but doesn t wait for completion otherwise .
22,213
final boolean trySetSignal ( ) { int s = status ; return s >= 0 && U . compareAndSwapInt ( this , STATUS , s , s | SIGNAL ) ; }
Tries to set SIGNAL status unless already completed . Used by ForkJoinPool . Other variants are directly incorporated into externalAwaitDone etc .
22,214
private int doJoin ( ) { int s ; Thread t ; ForkJoinWorkerThread wt ; ForkJoinPool . WorkQueue w ; if ( ( s = status ) >= 0 ) { if ( ( ( t = Thread . currentThread ( ) ) instanceof ForkJoinWorkerThread ) ) { if ( ! ( w = ( wt = ( ForkJoinWorkerThread ) t ) . workQueue ) . tryUnpush ( this ) || ( s = doExec ( ) ) >= 0 )...
Implementation for join get quietlyJoin . Directly handles only cases of already - completed external wait and unfork + exec . Others are relayed to ForkJoinPool . awaitJoin .
22,215
private int doInvoke ( ) { int s ; Thread t ; ForkJoinWorkerThread wt ; if ( ( s = doExec ( ) ) >= 0 ) { if ( ( t = Thread . currentThread ( ) ) instanceof ForkJoinWorkerThread ) s = ( wt = ( ForkJoinWorkerThread ) t ) . pool . awaitJoin ( wt . workQueue , this ) ; else s = externalAwaitDone ( ) ; } return s ; }
Implementation for invoke quietlyInvoke .
22,216
final int recordExceptionalCompletion ( Throwable ex ) { int s ; if ( ( s = status ) >= 0 ) { int h = System . identityHashCode ( this ) ; final ReentrantLock lock = exceptionTableLock ; lock . lock ( ) ; try { expungeStaleExceptions ( ) ; ExceptionNode [ ] t = exceptionTable ; int i = h & ( t . length - 1 ) ; for ( Ex...
Records exception and sets status .
22,217
private int setExceptionalCompletion ( Throwable ex ) { int s = recordExceptionalCompletion ( ex ) ; if ( ( s & DONE_MASK ) == EXCEPTIONAL ) internalPropagateException ( ex ) ; return s ; }
Records exception and possibly propagates
22,218
static final void cancelIgnoringExceptions ( ForkJoinTask < ? > t ) { if ( t != null && t . status >= 0 ) { try { t . cancel ( false ) ; } catch ( Throwable ignore ) { } } }
Cancels ignoring any exceptions thrown by cancel . Used during worker and pool shutdown . Cancel is spec ed not to throw any exceptions but if it does anyway we have no recourse during shutdown so guard against this case .
22,219
private void clearExceptionalCompletion ( ) { int h = System . identityHashCode ( this ) ; final ReentrantLock lock = exceptionTableLock ; lock . lock ( ) ; try { ExceptionNode [ ] t = exceptionTable ; int i = h & ( t . length - 1 ) ; ExceptionNode e = t [ i ] ; ExceptionNode pred = null ; while ( e != null ) { Excepti...
Removes exception node and clears status
22,220
private static void expungeStaleExceptions ( ) { for ( Object x ; ( x = exceptionTableRefQueue . poll ( ) ) != null ; ) { if ( x instanceof ExceptionNode ) { ForkJoinTask < ? > key = ( ( ExceptionNode ) x ) . get ( ) ; ExceptionNode [ ] t = exceptionTable ; int i = System . identityHashCode ( key ) & ( t . length - 1 )...
Poll stale refs and remove them . Call only while holding lock .
22,221
private void reportException ( int s ) { Throwable ex = ( ( s == CANCELLED ) ? new CancellationException ( ) : ( s == EXCEPTIONAL ) ? getThrowableException ( ) : null ) ; if ( ex != null ) U . throwException ( ex ) ; }
Throws exception if any associated with the given status .
22,222
public static ForkJoinPool getPool ( ) { Thread t = Thread . currentThread ( ) ; return ( t instanceof ForkJoinWorkerThread ) ? ( ( ForkJoinWorkerThread ) t ) . pool : null ; }
Returns the pool hosting the current task execution or null if this task is executing outside of any ForkJoinPool .
22,223
public final short setForkJoinTaskTag ( short tag ) { for ( int s ; ; ) { if ( U . compareAndSwapInt ( this , STATUS , s = status , ( s & ~ SMASK ) | ( tag & SMASK ) ) ) return ( short ) s ; } }
Atomically sets the tag value for this task .
22,224
protected final boolean isNA2 ( int idx ) { if ( isString ( ) ) return _is [ idx ] == - 1 ; if ( isUUID ( ) || _ds == null ) return _missing != null && _missing . get ( idx ) ; return Double . isNaN ( _ds [ idx ] ) ; }
what about sparse reps?
22,225
private void append2slowstr ( ) { if ( _xs != null ) { _xs = null ; _ms = null ; alloc_str_indices ( _sparseLen ) ; Arrays . fill ( _is , - 1 ) ; } if ( _is != null && _is . length > 0 ) { if ( _id == null ) { int nzs = 0 ; for ( int i : _is ) if ( i != - 1 ) ++ nzs ; if ( ( nzs + 1 ) * _sparseRatio < _len ) set_sparse...
Slow - path append string
22,226
public Chunk compress ( ) { Chunk res = compress2 ( ) ; byte type = type ( ) ; assert _vec == null || type == _vec . _type || type == Vec . T_BAD || ( type == Vec . T_NUM && _vec . _type == Vec . T_CAT ) || ( type == Vec . T_NUM && _vec . _type == Vec . T_TIME && ! res . hasFloat ( ) ) : "NewChunk has type " + Vec . TY...
Return the data so compressed .
22,227
public static String escapeNewlines ( String str ) { final int len = str . length ( ) ; StringWriter out = new StringWriter ( len * 2 ) ; for ( int i = 0 ; i < len ; i ++ ) { char c = str . charAt ( i ) ; switch ( c ) { case '\\' : out . write ( '\\' ) ; out . write ( '\\' ) ; break ; case '\n' : out . write ( '\\' ) ;...
Escapes new line characters of a given string . It also escapes the forward slash characters .
22,228
public Val exec ( AstRoot ast , AstFunction scope ) { sanity_check_refs ( null ) ; Env env = new Env ( this ) ; env . _scope = scope ; Val val = ast . exec ( env ) ; assert env . sp ( ) == 0 ; sanity_check_refs ( val ) ; return val ; }
Execute an AstRoot in the current Session with much assertion - checking
22,229
public RuntimeException endQuietly ( Throwable ex ) { try { GLOBALS . clear ( ) ; Futures fs = new Futures ( ) ; for ( Frame fr : FRAMES . values ( ) ) { for ( Key < Vec > vec : fr . keys ( ) ) { Integer I = REFCNTS . get ( vec ) ; int i = ( I == null ? 0 : I ) - 1 ; if ( i > 0 ) REFCNTS . put ( vec , i ) ; else { REFC...
The Rapids call threw an exception . Best - effort cleanup no more exceptions
22,230
private int _addRefCnt ( Key < Vec > vec , int i ) { return _putRefCnt ( vec , _getRefCnt ( vec ) + i ) ; }
Bump internal count not counting globals
22,231
private int addRefCnt ( Key < Vec > vec , int i ) { return _addRefCnt ( vec , i ) + ( GLOBALS . contains ( vec ) ? 1 : 0 ) ; }
RefCnt + i this Vec ; Global Refs can be alive with zero internal counts
22,232
public void exec ( Frame fr , Random rng ) { if ( p > 0 ) new InsertNAs ( p , rng ) . doAll ( fr ) ; }
Execute this post - processing step .
22,233
private static InetAddress getInetAddress ( String ip ) { if ( ip == null ) return null ; InetAddress addr = null ; try { addr = InetAddress . getByName ( ip ) ; } catch ( UnknownHostException e ) { Log . err ( e ) ; H2O . exit ( - 1 ) ; } return addr ; }
Get address for given IP .
22,234
protected Frame predictScoreImpl ( Frame fr , Frame adaptFrm , String destination_key , Job j , boolean computeMetrics , CFuncRef customMetricFunc ) { Frame levelOneFrame = new Frame ( Key . < Frame > make ( "preds_levelone_" + this . _key . toString ( ) + fr . _key ) ) ; for ( Key < Model > baseKey : this . _parms . _...
For StackedEnsemble we call score on all the base_models and then combine the results with the metalearner to create the final predictions frame .
22,235
private static void write2frame ( GenericRecord gr , String [ ] columnNames , Schema . Field [ ] inSchema , byte [ ] columnTypes , ParseWriter dout ) { assert inSchema . length == columnTypes . length : "AVRO field flatenized schema has to match to parser setup" ; BufferedString bs = new BufferedString ( ) ; for ( int ...
The main method transforming Avro record into a row in H2O frame .
22,236
@ SuppressWarnings ( "unused" ) public water . automl . api . schemas3 . LeaderboardsV99 list ( int version , water . automl . api . schemas3 . LeaderboardsV99 s ) { Leaderboards m = s . createAndFillImpl ( ) ; m . leaderboards = Leaderboards . fetchAll ( ) ; return s . fillFromImpl ( m ) ; }
Return all the Leaderboards .
22,237
public float [ ] train ( BackendModel m , float [ ] data , float [ ] label ) { ( ( DeepwaterCaffeModel ) m ) . train ( data , label ) ; return null ; }
given a mini - batch worth of data and labels train
22,238
public final void print ( ) { System . out . println ( "=========" ) ; print_impl ( - 99 , NO_KEY , _val_1 ) ; _chm . print ( ) ; System . out . println ( "=========" ) ; }
Verbose printout of table internals useful for debugging .
22,239
public long [ ] keySetLong ( ) { long [ ] dom = new long [ size ( ) ] ; IteratorLong i = ( IteratorLong ) keySet ( ) . iterator ( ) ; int j = 0 ; while ( j < dom . length && i . hasNext ( ) ) dom [ j ++ ] = i . nextLong ( ) ; return dom ; }
Keys as a long array . Array may be zero - padded if keys are concurrently deleted .
22,240
public void set ( final int row , final int col , final Object o ) { if ( o == null ) cellValues [ row ] [ col ] = new IcedWrapper ( null ) ; else if ( o instanceof Double && Double . isNaN ( ( double ) o ) ) cellValues [ row ] [ col ] = new IcedWrapper ( Double . NaN ) ; else if ( o instanceof int [ ] ) cellValues [ r...
Setter for table cells
22,241
static void parseArguments ( String [ ] args ) { for ( AbstractH2OExtension e : extManager . getCoreExtensions ( ) ) { args = e . parseArguments ( args ) ; } parseH2OArgumentsTo ( args , ARGS ) ; }
Dead stupid argument parser .
22,242
public static void notifyAboutCloudSize ( InetAddress ip , int port , InetAddress leaderIp , int leaderPort , int size ) { if ( ARGS . notify_local != null && ! ARGS . notify_local . trim ( ) . isEmpty ( ) ) { final File notifyFile = new File ( ARGS . notify_local ) ; final File parentDir = notifyFile . getParentFile (...
Tell the embedding software that this H2O instance belongs to a cloud of a certain size . This may be non - blocking .
22,243
public static void exit ( int status ) { if ( embeddedH2OConfig != null ) embeddedH2OConfig . exit ( status ) ; Log . flushStdout ( ) ; System . exit ( status ) ; }
Notify embedding software instance H2O wants to exit . Shuts down a single Node .
22,244
public static void shutdown ( int status ) { if ( status == 0 ) H2O . orderlyShutdown ( ) ; UDPRebooted . T . error . send ( H2O . SELF ) ; H2O . exit ( status ) ; }
Cluster shutdown itself by sending a shutdown UDP packet .
22,245
public static long getIdleTimeMillis ( ) { long latestEndTimeMillis = - 1 ; if ( activeRapidsExecs . get ( ) > 0 ) { updateNotIdle ( ) ; } else { Job [ ] jobs = Job . jobs ( ) ; for ( int i = jobs . length - 1 ; i >= 0 ; i -- ) { Job j = jobs [ i ] ; if ( j . isRunning ( ) ) { updateNotIdle ( ) ; break ; } if ( j . end...
Get the number of milliseconds the H2O cluster has been idle .
22,246
public static String getSysProperty ( String name , String def ) { return System . getProperty ( H2O . OptArgs . SYSTEM_PROP_PREFIX + name , def ) ; }
Retrieves a value of an H2O system property
22,247
public static String technote ( int [ ] numbers , String message ) { StringBuilder sb = new StringBuilder ( ) . append ( message ) . append ( "\n" ) . append ( "\n" ) . append ( "For more information visit:\n" ) ; for ( int number : numbers ) { sb . append ( " http://jira.h2o.ai/browse/TN-" ) . append ( Integer . toSt...
Return an error message with an accompanying list of URLs to help the user get more detailed information .
22,248
public static < T extends H2OCountedCompleter > T submitTask ( T task ) { int priority = task . priority ( ) ; if ( priority < LOW_PRIORITY_API_WORK ) LOW_PRIORITY_API_WORK_CLASS = task . getClass ( ) . toString ( ) ; assert MIN_PRIORITY <= priority && priority <= MAX_PRIORITY : "priority " + priority + " is out of ran...
Submit to the correct priority queue
22,249
static < T extends RemoteRunnable > T runOnH2ONode ( H2ONode node , T runnable ) { if ( node == H2O . SELF ) { runnable . run ( ) ; return runnable ; } else { RunnableWrapperTask < T > task = new RunnableWrapperTask < > ( runnable ) ; try { return new RPC < > ( node , task ) . call ( ) . get ( ) . _runnable ; } catch (...
package - private for unit tests
22,250
public static String DEFAULT_FLOW_DIR ( ) { String flow_dir = null ; try { if ( ARGS . ga_hadoop_ver != null ) { PersistManager pm = getPM ( ) ; if ( pm != null ) { String s = pm . getHdfsHomeDirectory ( ) ; if ( pm . exists ( s ) ) { flow_dir = s ; } } if ( flow_dir != null ) { flow_dir = flow_dir + "/h2oflows" ; } } ...
Place to store flows
22,251
private static void printAndLogVersion ( String [ ] arguments ) { Log . init ( ARGS . log_level , ARGS . quiet ) ; Log . info ( "----- H2O started " + ( ARGS . client ? "(client)" : "" ) + " -----" ) ; Log . info ( "Build git branch: " + ABV . branchName ( ) ) ; Log . info ( "Build git hash: " + ABV . lastCommitHash ( ...
If logging has not been setup yet then Log . info will only print to stdout . This allows for early processing of the - version option without unpacking the jar file and other startup stuff .
22,252
private static void startLocalNode ( ) { NetworkInit . initializeNetworkSockets ( ) ; if ( ! ARGS . client && H2O . isFlatfileEnabled ( ) && ! H2O . isNodeInFlatfile ( SELF ) ) { Log . warn ( "Flatfile configuration does not include self: " + SELF + ", but contains " + H2O . getFlatfile ( ) ) ; H2O . addNodeToFlatfile ...
Initializes the local node and the local cloud with itself as the only member .
22,253
private static void startNetworkServices ( ) { UDPRebooted . T . reboot . broadcast ( ) ; new MultiReceiverThread ( ) . start ( ) ; Cleaner . THE_CLEANER . start ( ) ; new TCPReceiverThread ( NetworkInit . _tcpSocket ) . start ( ) ; }
Starts the worker threads receiver threads heartbeats and all other network related services .
22,254
void set_next_Cloud ( H2ONode [ ] h2os , int hash ) { synchronized ( this ) { int idx = _idx + 1 ; if ( idx == 256 ) idx = 1 ; CLOUDS [ idx ] = CLOUD = new H2O ( h2os , hash , idx ) ; } SELF . _heartbeat . _cloud_size = ( char ) CLOUD . size ( ) ; H2O . CLOUD . _node_ip_to_index = new HashMap < > ( ) ; for ( H2ONode no...
member list .
22,255
public long free_mem ( ) { long memsz = 0 ; for ( H2ONode h2o : CLOUD . _memary ) memsz += h2o . _heartbeat . get_free_mem ( ) ; return memsz ; }
Cluster free memory
22,256
public boolean healthy ( ) { long now = System . currentTimeMillis ( ) ; for ( H2ONode node : H2O . CLOUD . members ( ) ) if ( ! node . isHealthy ( now ) ) return false ; return true ; }
Quick health check ; no reason given for bad health
22,257
public static void joinOthers ( ) { long start = System . currentTimeMillis ( ) ; while ( System . currentTimeMillis ( ) - start < 2000 ) { if ( CLOUD . size ( ) > 1 && Paxos . _commonKnowledge ) break ; try { Thread . sleep ( 100 ) ; } catch ( InterruptedException ignore ) { } } }
- If nobody else is found not an error .
22,258
public static void raw_remove ( Key key ) { Value v = STORE . remove ( key ) ; if ( v != null ) v . removePersist ( ) ; }
Get the value from the store
22,259
public static String STOREtoString ( ) { int [ ] cnts = new int [ 1 ] ; Object [ ] kvs = H2O . STORE . raw_array ( ) ; for ( int i = 2 ; i < kvs . length ; i += 2 ) { Object ov = kvs [ i + 1 ] ; if ( ! ( ov instanceof Value ) ) continue ; Value val = ( Value ) ov ; if ( val . isNull ( ) ) { Value . STORE_get ( val . _k...
Nice local - STORE only debugging summary
22,260
public static boolean checkUnsupportedJava ( ) { if ( Boolean . getBoolean ( H2O . OptArgs . SYSTEM_PROP_PREFIX + "debug.noJavaVersionCheck" ) ) { return false ; } if ( JAVA_VERSION . isKnown ( ) && ! isUserEnabledJavaVersion ( ) && ( JAVA_VERSION . getMajor ( ) < 7 || JAVA_VERSION . getMajor ( ) > 12 ) ) { System . er...
Check if the Java version is not supported
22,261
private static long getCurrentPID ( ) { try { String n = ManagementFactory . getRuntimeMXBean ( ) . getName ( ) ; int i = n . indexOf ( '@' ) ; if ( i != - 1 ) { return Long . parseLong ( n . substring ( 0 , i ) ) ; } else { return - 1L ; } } catch ( Throwable ignore ) { return - 1L ; } }
Find PID of the current process use - 1 if we can t find the value .
22,262
public static void setFlatfile ( Set < H2ONode > nodes ) { if ( nodes == null ) { STATIC_H2OS = null ; } else { STATIC_H2OS = Collections . newSetFromMap ( new ConcurrentHashMap < H2ONode , Boolean > ( ) ) ; STATIC_H2OS . addAll ( nodes ) ; } }
Setup a set of nodes which should be contacted during manual multicast
22,263
public void onAck ( ) { if ( _dontCache && ! _xval . isPersisted ( ) ) H2O . putIfMatch ( _xkey , null , _xval ) ; if ( _xval != null ) _xval . completeRemotePut ( ) ; }
Received an ACK
22,264
public static String UUID ( long lo , long hi ) { long lo0 = ( lo >> 32 ) & 0xFFFFFFFFL ; long lo1 = ( lo >> 16 ) & 0xFFFFL ; long lo2 = ( lo >> 0 ) & 0xFFFFL ; long hi0 = ( hi >> 48 ) & 0xFFFFL ; long hi1 = ( hi >> 0 ) & 0xFFFFFFFFFFFFL ; return String . format ( "%08X-%04X-%04X-%04X-%012X" , lo0 , lo1 , lo2 , hi0 , h...
About as clumsy and random as a blaster ...
22,265
public KeySnapshot filter ( KVFilter kvf ) { ArrayList < KeyInfo > res = new ArrayList < > ( ) ; for ( KeyInfo kinfo : _keyInfos ) if ( kvf . filter ( kinfo ) ) res . add ( kinfo ) ; return new KeySnapshot ( res . toArray ( new KeyInfo [ res . size ( ) ] ) ) ; }
Filter the snapshot providing custom filter . Only the keys for which filter returns true will be present in the new snapshot .
22,266
public static Key [ ] globalKeysOfClass ( final Class clz ) { return KeySnapshot . globalSnapshot ( ) . filter ( new KeySnapshot . KVFilter ( ) { public boolean filter ( KeySnapshot . KeyInfo k ) { return Value . isSubclassOf ( k . _type , clz ) ; } } ) . keys ( ) ; }
Return all the keys of the given class .
22,267
public static KeySnapshot localSnapshot ( boolean homeOnly ) { Object [ ] kvs = H2O . STORE . raw_array ( ) ; ArrayList < KeyInfo > res = new ArrayList < > ( ) ; for ( int i = 2 ; i < kvs . length ; i += 2 ) { Object ok = kvs [ i ] ; if ( ! ( ok instanceof Key ) ) continue ; Key key = ( Key ) ok ; if ( ! key . user_all...
Get the user keys from this node only .
22,268
public static KeySnapshot globalSnapshot ( long timeTolerance ) { KeySnapshot res = _cache ; final long t = System . currentTimeMillis ( ) ; if ( res == null || ( t - res . timestamp ) > timeTolerance ) res = new KeySnapshot ( ( new GlobalUKeySetTask ( ) . doAllNodes ( ) . _res ) ) ; else if ( t - res . timestamp > _up...
Cache - enabled call to get global key snapshot . User can provide time tolerance to indicate a how old the snapshot can be .
22,269
public static void start ( String [ ] args , String relativeResourcePath , boolean finalizeRestRegistration ) { long time0 = System . currentTimeMillis ( ) ; H2O . main ( args ) ; H2O . registerResourceRoot ( new File ( relativeResourcePath + File . separator + "h2o-web/src/main/resources/www" ) ) ; H2O . registerResou...
Start H2O node .
22,270
private Icer < D > icer ( ) { int id = _ice_id ; int tyid ; if ( id != 0 ) assert id == ( tyid = TypeMap . onIce ( this ) ) : "incorrectly cashed id " + id + ", typemap has " + tyid + ", type = " + getClass ( ) . getName ( ) ; return TypeMap . getIcer ( id != 0 ? id : ( _ice_id = ( short ) TypeMap . onIce ( this ) ) , ...
Return the icer for this instance + class . Will set on 1st use .
22,271
public void readExternal ( ObjectInput ois ) throws IOException , ClassNotFoundException { int x = ois . readInt ( ) ; byte [ ] buf = MemoryManager . malloc1 ( x ) ; ois . readFully ( buf ) ; read ( new AutoBuffer ( buf ) ) ; }
Java serializers use H2Os Icing
22,272
static String buildSelectSingleRowSql ( String databaseType , String table , String columns ) { switch ( databaseType ) { case SQL_SERVER_DB_TYPE : return "SELECT TOP(1) " + columns + " FROM " + table ; case ORACLE_DB_TYPE : return "SELECT " + columns + " FROM " + table + " FETCH NEXT 1 ROWS ONLY" ; case TERADATA_DB_TY...
Builds SQL SELECT to retrieve single row from a table based on type of database
22,273
static String buildSelectChunkSql ( String databaseType , String table , long start , int length , String columns , String [ ] columnNames ) { String sqlText = "SELECT " + columns + " FROM " + table ; switch ( databaseType ) { case SQL_SERVER_DB_TYPE : sqlText += " ORDER BY ROW_NUMBER() OVER (ORDER BY (SELECT 0))" ; sq...
Builds SQL SELECT to retrieve chunk of rows from a table based on row offset and number of rows in a chunk .
22,274
static void initializeDatabaseDriver ( String databaseType ) { String driverClass = System . getProperty ( JDBC_DRIVER_CLASS_KEY_PREFIX + databaseType ) ; if ( driverClass != null ) { Log . debug ( "Loading " + driverClass + " to initialize database of type " + databaseType ) ; try { Class . forName ( driverClass ) ; }...
Initializes database driver for databases with JDBC driver version lower than 4 . 0
22,275
synchronized public List < ParserProvider > getAllProviders ( boolean sort ) { List < ParserProvider > providers = new ArrayList < > ( ) ; for ( ParserProvider pp : loader ) { providers . add ( pp ) ; } if ( sort ) { Collections . sort ( providers , PARSER_PROVIDER_COMPARATOR ) ; } return providers ; }
Returns all parser providers sorted based on priority if required .
22,276
public static long getTotalPhysicalMemory ( ) { long memory = - 1 ; try { MBeanServer mBeanServer = ManagementFactory . getPlatformMBeanServer ( ) ; Object attribute = mBeanServer . getAttribute ( new ObjectName ( "java.lang" , "type" , "OperatingSystem" ) , "TotalPhysicalMemorySize" ) ; return ( Long ) attribute ; } c...
Safe call to obtain size of total physical memory .
22,277
private ValFrame rowwise ( Env env , Frame fr , final AstPrimitive fun ) { final String [ ] names = fr . _names ; final AstFunction scope = env . _scope ; double [ ] ds = new double [ fr . numCols ( ) ] ; for ( int col = 0 ; col < fr . numCols ( ) ; ++ col ) ds [ col ] = fr . vec ( col ) . at ( 0 ) ; int noutputs = fun...
1 argument . All rows are independent and run in parallel
22,278
public final AutoBuffer write_impl ( AutoBuffer ab ) { _write_lock = true ; try { if ( map ( ) . size ( ) == 0 ) return ab . put1 ( 0 ) ; Entry < K , V > entry = map ( ) . entrySet ( ) . iterator ( ) . next ( ) ; K key = entry . getKey ( ) ; V val = entry . getValue ( ) ; assert key != null && val != null ; int mode ; ...
random Value is written .
22,279
static double computeQuantile ( double lo , double hi , double row , double nrows , double prob , QuantileModel . CombineMethod method ) { if ( lo == hi ) return lo ; if ( method == null ) method = QuantileModel . CombineMethod . INTERPOLATE ; switch ( method ) { case INTERPOLATE : return linearInterpolate ( lo , hi , ...
Compute the correct final quantile from these 4 values . If the lo and hi elements are equal use them . However if they differ then there is no single value which exactly matches the desired quantile . There are several well - accepted definitions in this case - including picking either the lo or the hi or averaging th...
22,280
public static void diagnose ( String applicationId , String queueName , int numNodes , int nodeMemoryMb , int numNodesStarted ) throws Exception { H2OYarnDiagnostic client = new H2OYarnDiagnostic ( ) ; client . applicationId = applicationId ; client . queueName = queueName ; client . numNodes = numNodes ; client . node...
The assumption is this method doesn t get called unless a problem occurred .
22,281
private int calcCountSubstringsWords ( String str , HashSet < String > words ) { int wordCount = 0 ; int N = str . length ( ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) for ( int j = i + 2 ; j < N + 1 ; j ++ ) { if ( words . contains ( str . substring ( i , j ) ) ) wordCount += 1 ; } return wordCount ; }
count all substrings > = 2 chars that are in words
22,282
public double str_op ( BufferedString l , BufferedString r ) { if ( StringUtils . isNullOrEmpty ( l ) ) return StringUtils . isNullOrEmpty ( r ) ? 0 : 1 ; else return l . equals ( r ) ? 0 : 1 ; }
Make sense to run this OP on an enm?
22,283
public ParseSetup guessInitSetup ( ByteVec v , byte [ ] bits , ParseSetup userSetup ) { return guessSetup ( v , bits , userSetup . _separator , userSetup . _number_columns , userSetup . _single_quotes , userSetup . _check_header , userSetup . _column_names , userSetup . _column_types , userSetup . _domains , userSetup ...
Constructs initial ParseSetup from a given user setup
22,284
public ParseSetup guessSetup ( ByteVec v , byte [ ] bits , byte sep , int ncols , boolean singleQuotes , int checkHeader , String [ ] columnNames , byte [ ] columnTypes , String [ ] [ ] domains , String [ ] [ ] naStrings ) { throw new UnsupportedOperationException ( "Not implemented. This method is kept only for backwa...
Returns parser setup of throws exception if input is not recognized
22,285
private static RowData parseDataRow ( String line , GenMunger munger ) { if ( line . isEmpty ( ) || line . equals ( "" ) ) return null ; String [ ] inputData = line . split ( ",(?=([^\"]*\"[^\"]*\")*[^\"]*$)|(,)" , - 1 ) ; for ( int i = 0 ; i < inputData . length ; ++ i ) inputData [ i ] = inputData [ i ] == null ? "" ...
This CSV parser is as bare bones as it gets . Our test data doesn t have funny quoting spacing or other issues . Can t handle cases where the number of data columns is less than the number of header columns .
22,286
public static void main ( String [ ] args ) throws Exception { parseArgs ( args ) ; GenMunger rawMunger ; rawMunger = ( hex . genmodel . GenMunger ) Class . forName ( assemblyClassName ) . newInstance ( ) ; BufferedReader input = new BufferedReader ( new FileReader ( inputCSVFileName ) ) ; BufferedWriter output = new B...
CSV reader and predictor test program .
22,287
public S fillWithDefaults ( ) { HyperSpaceSearchCriteria defaults = null ; if ( HyperSpaceSearchCriteria . Strategy . Cartesian == strategy ) { defaults = new HyperSpaceSearchCriteria . CartesianSearchCriteria ( ) ; } else if ( HyperSpaceSearchCriteria . Strategy . RandomDiscrete == strategy ) { defaults = new HyperSpa...
Fill with the default values from the corresponding Iced object .
22,288
protected final void registerModelBuilder ( RestApiContext context , ModelBuilder mbProto , int version ) { Class < ? extends water . api . Handler > handlerClass = water . api . ModelBuilderHandler . class ; if ( H2O . ARGS . features_level . compareTo ( mbProto . builderVisibility ( ) ) > 0 ) { return ; } String base...
Register algorithm common REST interface .
22,289
long checkRangeSupport ( URI uri ) throws IOException { HttpRequestBase req = createReq ( uri , true ) ; try ( CloseableHttpClient client = HttpClientBuilder . create ( ) . build ( ) ; CloseableHttpResponse response = client . execute ( req ) ) { Header acceptRangesHeader = response . getFirstHeader ( HttpHeaders . ACC...
Tests whether a given URI can be accessed using range - requests .
22,290
private Chunk [ ] getScoringChunks ( Chunk [ ] allChunks ) { if ( _preds == null ) return allChunks ; Chunk [ ] chks = new Chunk [ allChunks . length - _preds . numCols ( ) ] ; System . arraycopy ( allChunks , 0 , chks , 0 , chks . length ) ; return chks ; }
scoring chunks are those chunks that make the input to one of the scoring functions
22,291
private ModelMetrics makeModelMetrics ( SharedTreeModel model , Frame fr , Frame adaptedFr , Frame preds ) { ModelMetrics mm ; if ( model . _output . nclasses ( ) == 2 && _computeGainsLift ) { assert preds != null : "Predictions were pre-created" ; mm = _mb . makeModelMetrics ( model , fr , adaptedFr , preds ) ; } else...
Run after the doAll scoring to convert the MetricsBuilder to a ModelMetrics
22,292
public void createChunks ( String frameKey , byte [ ] expectedTypes , int chunkId , int totalNumRows , int [ ] maxVecSizes ) throws IOException { ab . put1 ( ExternalFrameHandler . INIT_BYTE ) ; ab . put1 ( ExternalFrameHandler . CREATE_FRAME ) ; ab . putStr ( frameKey ) ; this . expectedTypes = expectedTypes ; ab . pu...
Create chunks on the h2o backend . This method creates chunk in en empty frame .
22,293
public void waitUntilAllWritten ( int timeout ) throws ExternalFrameConfirmationException { final AutoBuffer confirmAb = new AutoBuffer ( channel ) ; try { byte flag = ExternalFrameConfirmationCheck . getConfirmation ( confirmAb , timeout ) ; assert ( flag == ExternalFrameHandler . CONFIRM_WRITING_DONE ) ; } catch ( Ti...
This method ensures the application waits for all bytes to be written before continuing in the control flow .
22,294
public static ValueSetter createValueSetter ( Vec v , Object value ) { if ( value == null ) { return new NAValueSetter ( ) ; } switch ( v . get_type ( ) ) { case Vec . T_CAT : return new CatValueSetter ( v . domain ( ) , value ) ; case Vec . T_NUM : case Vec . T_TIME : return new NumValueSetter ( value ) ; case Vec . T...
Create an instance of ValueSetter for a given scalar value . It creates setter of the appropriate type based on the type of the underlying Vec .
22,295
Map < Integer , Pair < Integer , Integer > > constructRingMap ( Map < Integer , List < Integer > > treeMap , Map < Integer , Integer > parentMap ) { assert parentMap . get ( 0 ) == - 1 ; List < Integer > sharedRing = constructShareRing ( treeMap , parentMap , 0 ) ; assert sharedRing . size ( ) == treeMap . size ( ) ; M...
Returns for each node with rank the previous and next node in DFS order . For the root the previous entry will be the last element which will create a ring type structure .
22,296
private final ByteVec getUploadedMojo ( final Key < Frame > key ) throws IllegalArgumentException { Objects . requireNonNull ( key ) ; Frame mojoFrame = key . get ( ) ; if ( mojoFrame . numCols ( ) > 1 ) throw new IllegalArgumentException ( String . format ( "Given MOJO frame with key '%s' should contain only 1 column ...
Retrieves pre - uploaded MOJO archive and performs basic verifications if present .
22,297
public static void closeSilently ( Closeable ... closeable ) { for ( Closeable c : closeable ) try { if ( c != null ) c . close ( ) ; } catch ( IOException xe ) { } }
Silently close given files .
22,298
public static void close ( Closeable ... closeable ) { for ( Closeable c : closeable ) try { if ( c != null ) c . close ( ) ; } catch ( IOException ex ) { Log . err ( ex ) ; } }
Closes given files logging exceptions thrown during the process of closing .
22,299
public static File locateFile ( String fname ) { File file = new File ( fname ) ; if ( ! file . exists ( ) ) file = new File ( "target/" + fname ) ; if ( ! file . exists ( ) ) file = new File ( "../" + fname ) ; if ( ! file . exists ( ) ) file = new File ( "../../" + fname ) ; if ( ! file . exists ( ) ) file = new File...
Hunt for files in likely places . Null if cannot find .