idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
22,100 | protected void handleMultiformPost ( final HttpServletRequest req , final HttpServletResponse resp , final Map < String , Object > multipart , final Session session ) throws ServletException , IOException { } | The post request is handed off to the implementor after the user is logged in . |
22,101 | public void gracefulShutdown ( final ExecutorService service , final Duration timeout ) throws InterruptedException { service . shutdown ( ) ; final long timeout_in_unit_of_miliseconds = timeout . toMillis ( ) ; if ( ! service . awaitTermination ( timeout_in_unit_of_miliseconds , MILLI_SECONDS_TIME_UNIT ) ) { service . shutdownNow ( ) ; if ( ! service . awaitTermination ( timeout_in_unit_of_miliseconds , MILLI_SECONDS_TIME_UNIT ) ) { logger . error ( "The executor service did not terminate." ) ; } } } | Gracefully shuts down the given executor service . |
22,102 | private static UserGroupInformation createSecurityEnabledProxyUser ( String userToProxy , String fileLocation , Logger log ) throws IOException { if ( ! new File ( fileLocation ) . exists ( ) ) { throw new RuntimeException ( "hadoop token file doesn't exist." ) ; } log . info ( "Found token file. Setting " + HadoopSecurityManager . MAPREDUCE_JOB_CREDENTIALS_BINARY + " to " + fileLocation ) ; System . setProperty ( HadoopSecurityManager . MAPREDUCE_JOB_CREDENTIALS_BINARY , fileLocation ) ; UserGroupInformation loginUser = null ; loginUser = UserGroupInformation . getLoginUser ( ) ; log . info ( "Current logged in user is " + loginUser . getUserName ( ) ) ; UserGroupInformation proxyUser = UserGroupInformation . createProxyUser ( userToProxy , loginUser ) ; for ( Token < ? > token : loginUser . getTokens ( ) ) { proxyUser . addToken ( token ) ; } proxyUser . addCredentials ( loginUser . getCredentials ( ) ) ; return proxyUser ; } | Perform all the magic required to get the proxyUser in a securitized grid |
22,103 | public static UserGroupInformation setupProxyUser ( Properties jobProps , String tokenFile , Logger log ) { UserGroupInformation proxyUser = null ; if ( ! HadoopSecureWrapperUtils . shouldProxy ( jobProps ) ) { log . info ( "submitting job as original submitter, not proxying" ) ; return proxyUser ; } final Configuration conf = new Configuration ( ) ; UserGroupInformation . setConfiguration ( conf ) ; boolean securityEnabled = UserGroupInformation . isSecurityEnabled ( ) ; try { String userToProxy = null ; userToProxy = jobProps . getProperty ( HadoopSecurityManager . USER_TO_PROXY ) ; if ( securityEnabled ) { proxyUser = HadoopSecureWrapperUtils . createSecurityEnabledProxyUser ( userToProxy , tokenFile , log ) ; log . info ( "security enabled, proxying as user " + userToProxy ) ; } else { proxyUser = UserGroupInformation . createRemoteUser ( userToProxy ) ; log . info ( "security not enabled, proxying as user " + userToProxy ) ; } } catch ( IOException e ) { log . error ( "HadoopSecureWrapperUtils.setupProxyUser threw an IOException" , e ) ; } return proxyUser ; } | Sets up the UserGroupInformation proxyUser object so that calling code can do doAs returns null if the jobProps does not call for a proxyUser |
22,104 | @ SuppressWarnings ( "DefaultCharset" ) public static Properties loadAzkabanProps ( ) throws IOException { String propsFile = System . getenv ( ProcessJob . JOB_PROP_ENV ) ; Properties props = new Properties ( ) ; props . load ( new BufferedReader ( new FileReader ( propsFile ) ) ) ; return props ; } | Loading the properties file which is a combination of the jobProps file and sysProps file |
22,105 | public static boolean shouldProxy ( Properties props ) { String shouldProxy = props . getProperty ( HadoopSecurityManager . ENABLE_PROXYING ) ; return shouldProxy != null && shouldProxy . equals ( "true" ) ; } | Looks for particular properties inside the Properties object passed in and determines whether proxying should happen or not |
22,106 | private TimerTask getTimerTask ( ) { final TimeBasedReportingMetric < T > lockObject = this ; final TimerTask recurringReporting = new TimerTask ( ) { public void run ( ) { synchronized ( lockObject ) { preTrackingEventMethod ( ) ; notifyManager ( ) ; postTrackingEventMethod ( ) ; } } } ; return recurringReporting ; } | Get a TimerTask to reschedule Timer |
22,107 | public void updateInterval ( final long interval ) throws MetricException { if ( ! isValidInterval ( interval ) ) { throw new MetricException ( "Invalid interval: Cannot update timer" ) ; } logger . debug ( String . format ( "Updating tracking interval to %d milisecond for %s metric" , interval , getName ( ) ) ) ; this . timer . cancel ( ) ; this . timer = new Timer ( ) ; this . timer . schedule ( getTimerTask ( ) , interval , interval ) ; } | Method to change tracking interval |
22,108 | public Pair < ExecutionReference , ExecutableFlow > fetchHead ( ) throws InterruptedException { final Pair < ExecutionReference , ExecutableFlow > pair = this . queuedFlowList . take ( ) ; if ( pair != null && pair . getFirst ( ) != null ) { this . queuedFlowMap . remove ( pair . getFirst ( ) . getExecId ( ) ) ; } return pair ; } | Wraps BoundedQueue Take method to have a corresponding update in queuedFlowMap lookup table |
22,109 | public void dequeue ( final int executionId ) { if ( this . queuedFlowMap . containsKey ( executionId ) ) { this . queuedFlowList . remove ( this . queuedFlowMap . get ( executionId ) ) ; this . queuedFlowMap . remove ( executionId ) ; } } | Helper method to have a single point of deletion in the queued flows |
22,110 | public ExecutableFlow getFlow ( final int executionId ) { if ( hasExecution ( executionId ) ) { return this . queuedFlowMap . get ( executionId ) . getSecond ( ) ; } return null ; } | Fetch flow for an execution . Returns null if execution not in queue |
22,111 | public ExecutionReference getReference ( final int executionId ) { if ( hasExecution ( executionId ) ) { return this . queuedFlowMap . get ( executionId ) . getFirst ( ) ; } return null ; } | Fetch Activereference for an execution . Returns null if execution not in queue |
22,112 | public void clear ( ) { for ( final Pair < ExecutionReference , ExecutableFlow > pair : this . queuedFlowMap . values ( ) ) { dequeue ( pair . getFirst ( ) . getExecId ( ) ) ; } } | Empties queue by dequeuing all the elements |
22,113 | protected static < T extends Serializable > T asT ( final Object service , final Class < T > type ) { return type . cast ( service ) ; } | Cast the object to the original one with the type . The object must extend Serializable . |
22,114 | public synchronized Project createNewProject ( final String name , final String description , final User creator ) throws ProjectManagerException { final ProjectResultHandler handler = new ProjectResultHandler ( ) ; try { final List < Project > projects = this . dbOperator . query ( ProjectResultHandler . SELECT_ACTIVE_PROJECT_BY_NAME , handler , name ) ; if ( ! projects . isEmpty ( ) ) { throw new ProjectManagerException ( "Active project with name " + name + " already exists in db." ) ; } } catch ( final SQLException ex ) { logger . error ( ex ) ; throw new ProjectManagerException ( "Checking for existing project failed. " + name , ex ) ; } final String INSERT_PROJECT = "INSERT INTO projects ( name, active, modified_time, create_time, version, last_modified_by, description, enc_type, settings_blob) values (?,?,?,?,?,?,?,?,?)" ; final SQLTransaction < Integer > insertProject = transOperator -> { final long time = System . currentTimeMillis ( ) ; return transOperator . update ( INSERT_PROJECT , name , true , time , time , null , creator . getUserId ( ) , description , this . defaultEncodingType . getNumVal ( ) , null ) ; } ; try { final int numRowsInserted = this . dbOperator . transaction ( insertProject ) ; if ( numRowsInserted == 0 ) { throw new ProjectManagerException ( "No projects have been inserted." ) ; } } catch ( final SQLException ex ) { logger . error ( INSERT_PROJECT + " failed." , ex ) ; throw new ProjectManagerException ( "Insert project" + name + " for existing project failed. " , ex ) ; } return fetchProjectByName ( name ) ; } | Creates a Project in the db . |
22,115 | private void addProjectToProjectVersions ( final DatabaseTransOperator transOperator , final int projectId , final int version , final File localFile , final String uploader , final byte [ ] md5 , final String resourceId ) throws ProjectManagerException { final long updateTime = System . currentTimeMillis ( ) ; final String INSERT_PROJECT_VERSION = "INSERT INTO project_versions " + "(project_id, version, upload_time, uploader, file_type, file_name, md5, num_chunks, resource_id) values " + "(?,?,?,?,?,?,?,?,?)" ; try { transOperator . update ( INSERT_PROJECT_VERSION , projectId , version , updateTime , uploader , Files . getFileExtension ( localFile . getName ( ) ) , localFile . getName ( ) , md5 , 0 , resourceId ) ; } catch ( final SQLException e ) { final String msg = String . format ( "Error initializing project id: %d version: %d " , projectId , version ) ; logger . error ( msg , e ) ; throw new ProjectManagerException ( msg , e ) ; } } | Insert a new version record to TABLE project_versions before uploading files . |
22,116 | private void updateChunksInProjectVersions ( final DatabaseTransOperator transOperator , final int projectId , final int version , final int chunk ) throws ProjectManagerException { final String UPDATE_PROJECT_NUM_CHUNKS = "UPDATE project_versions SET num_chunks=? WHERE project_id=? AND version=?" ; try { transOperator . update ( UPDATE_PROJECT_NUM_CHUNKS , chunk , projectId , version ) ; transOperator . getConnection ( ) . commit ( ) ; } catch ( final SQLException e ) { logger . error ( "Error updating project " + projectId + " : chunk_num " + chunk , e ) ; throw new ProjectManagerException ( "Error updating project " + projectId + " : chunk_num " + chunk , e ) ; } } | we update num_chunks s actual number to db here . |
22,117 | public OtpErlangObject [ ] elements ( ) { if ( arity ( ) == 0 ) { return NO_ELEMENTS ; } final OtpErlangObject [ ] res = new OtpErlangObject [ arity ( ) ] ; System . arraycopy ( elems , 0 , res , 0 , res . length ) ; return res ; } | Get all the elements from the list as an array . |
22,118 | public String stringValue ( ) throws OtpErlangException { if ( ! isProper ( ) ) { throw new OtpErlangException ( "Non-proper list: " + this ) ; } final int [ ] values = new int [ arity ( ) ] ; for ( int i = 0 ; i < values . length ; ++ i ) { final OtpErlangObject o = elementAt ( i ) ; if ( ! ( o instanceof OtpErlangLong ) ) { throw new OtpErlangException ( "Non-integer term: " + o ) ; } final OtpErlangLong l = ( OtpErlangLong ) o ; values [ i ] = l . intValue ( ) ; } return new String ( values , 0 , values . length ) ; } | Convert a list of integers into a Unicode string interpreting each integer as a Unicode code point value . |
22,119 | public synchronized void put ( final Object o ) { final Bucket b = new Bucket ( o ) ; if ( tail != null ) { tail . setNext ( b ) ; tail = b ; } else { head = tail = b ; } count ++ ; notify ( ) ; } | Add an object to the tail of the queue . |
22,120 | public synchronized Object get ( ) { Object o = null ; while ( ( o = tryGet ( ) ) == null ) { try { this . wait ( ) ; } catch ( final InterruptedException e ) { } } return o ; } | Retrieve an object from the head of the queue or block until one arrives . |
22,121 | public synchronized Object get ( final long timeout ) throws InterruptedException { if ( status == closed ) { return null ; } long currentTime = System . currentTimeMillis ( ) ; final long stopTime = currentTime + timeout ; Object o = null ; while ( true ) { if ( ( o = tryGet ( ) ) != null ) { return o ; } currentTime = System . currentTimeMillis ( ) ; if ( stopTime <= currentTime ) { throw new InterruptedException ( "Get operation timed out" ) ; } try { this . wait ( stopTime - currentTime ) ; } catch ( final InterruptedException e ) { } } } | Retrieve an object from the head of the queue blocking until one arrives or until timeout occurs . |
22,122 | public Object tryGet ( ) { Object o = null ; if ( head != null ) { o = head . getContents ( ) ; head = head . getNext ( ) ; count -- ; if ( head == null ) { tail = null ; count = 0 ; } } return o ; } | attempt to retrieve message from queue head |
22,123 | public int size ( ) { if ( pad_bits == 0 ) { return bin . length ; } if ( bin . length == 0 ) { throw new java . lang . IllegalStateException ( "Impossible length" ) ; } return bin . length - 1 ; } | Get the size in whole bytes of the bitstr rest bits in the last byte not counted . |
22,124 | public void unPublishPort ( ) { OtpEpmd . unPublishPort ( this ) ; try { if ( super . epmd != null ) { super . epmd . close ( ) ; } } catch ( final IOException e ) { } super . epmd = null ; } | Unregister the server node s name and port number from the Erlang port mapper thus preventing any new connections from remote nodes . |
22,125 | public OtpConnection accept ( ) throws IOException , OtpAuthException { OtpTransport newsock = null ; while ( true ) { try { newsock = sock . accept ( ) ; return new OtpConnection ( this , newsock ) ; } catch ( final IOException e ) { try { if ( newsock != null ) { newsock . close ( ) ; } } catch ( final IOException f ) { } throw e ; } } } | Accept an incoming connection from a remote node . A call to this method will block until an incoming connection is at least attempted . |
22,126 | public OtpConnection connect ( final OtpSelf self ) throws IOException , UnknownHostException , OtpAuthException { return new OtpConnection ( self , this ) ; } | Create a connection to a remote node . |
22,127 | public void write4BE ( final long n ) { write ( ( byte ) ( ( n & 0xff000000 ) >> 24 ) ) ; write ( ( byte ) ( ( n & 0xff0000 ) >> 16 ) ) ; write ( ( byte ) ( ( n & 0xff00 ) >> 8 ) ) ; write ( ( byte ) ( n & 0xff ) ) ; } | Write the low four bytes of a value to the stream in big endian order . |
22,128 | public void writeLE ( final long n , final int b ) { long v = n ; for ( int i = 0 ; i < b ; i ++ ) { write ( ( byte ) ( v & 0xff ) ) ; v >>= 8 ; } } | Write any number of bytes in little endian format . |
22,129 | public void write4LE ( final long n ) { write ( ( byte ) ( n & 0xff ) ) ; write ( ( byte ) ( ( n & 0xff00 ) >> 8 ) ) ; write ( ( byte ) ( ( n & 0xff0000 ) >> 16 ) ) ; write ( ( byte ) ( ( n & 0xff000000 ) >> 24 ) ) ; } | Write the low four bytes of a value to the stream in little endian order . |
22,130 | public void write8LE ( final long n ) { write ( ( byte ) ( n & 0xff ) ) ; write ( ( byte ) ( n >> 8 & 0xff ) ) ; write ( ( byte ) ( n >> 16 & 0xff ) ) ; write ( ( byte ) ( n >> 24 & 0xff ) ) ; write ( ( byte ) ( n >> 32 & 0xff ) ) ; write ( ( byte ) ( n >> 40 & 0xff ) ) ; write ( ( byte ) ( n >> 48 & 0xff ) ) ; write ( ( byte ) ( n >> 56 & 0xff ) ) ; } | Write the low eight bytes of a value to the stream in little endian order . |
22,131 | public void poke4BE ( final int offset , final long n ) { if ( offset < super . count ) { buf [ offset + 0 ] = ( byte ) ( ( n & 0xff000000 ) >> 24 ) ; buf [ offset + 1 ] = ( byte ) ( ( n & 0xff0000 ) >> 16 ) ; buf [ offset + 2 ] = ( byte ) ( ( n & 0xff00 ) >> 8 ) ; buf [ offset + 3 ] = ( byte ) ( n & 0xff ) ; } } | Write the low four bytes of a value to the stream in bif endian order at the specified position . If the position specified is beyond the end of the stream this method will have no effect . |
22,132 | public void write_atom ( final String atom ) { String enc_atom ; byte [ ] bytes ; if ( atom . codePointCount ( 0 , atom . length ( ) ) <= OtpExternal . maxAtomLength ) { enc_atom = atom ; } else { enc_atom = new String ( OtpErlangString . stringToCodePoints ( atom ) , 0 , OtpExternal . maxAtomLength ) ; } try { bytes = enc_atom . getBytes ( "UTF-8" ) ; final int length = bytes . length ; if ( length < 256 ) { write1 ( OtpExternal . smallAtomUtf8Tag ) ; write1 ( length ) ; } else { write1 ( OtpExternal . atomUtf8Tag ) ; write2BE ( length ) ; } writeN ( bytes ) ; } catch ( final java . io . UnsupportedEncodingException e ) { write1 ( OtpExternal . smallAtomUtf8Tag ) ; write1 ( 2 ) ; write2BE ( 0xffff ) ; } } | Write a string to the stream as an Erlang atom . |
22,133 | public void write_binary ( final byte [ ] bin ) { write1 ( OtpExternal . binTag ) ; write4BE ( bin . length ) ; writeN ( bin ) ; } | Write an array of bytes to the stream as an Erlang binary . |
22,134 | public void write_bitstr ( final byte [ ] bin , final int pad_bits ) { if ( pad_bits == 0 ) { write_binary ( bin ) ; return ; } write1 ( OtpExternal . bitBinTag ) ; write4BE ( bin . length ) ; write1 ( 8 - pad_bits ) ; writeN ( bin ) ; } | Write an array of bytes to the stream as an Erlang bitstr . |
22,135 | public void write_tuple_head ( final int arity ) { if ( arity < 0xff ) { write1 ( OtpExternal . smallTupleTag ) ; write1 ( arity ) ; } else { write1 ( OtpExternal . largeTupleTag ) ; write4BE ( arity ) ; } } | Write an Erlang tuple header to the stream . After calling this method you must write arity elements to the stream or it will not be possible to decode it later . |
22,136 | public void write_ref ( final String node , final int id , final int creation ) { int ids [ ] = new int [ 1 ] ; ids [ 0 ] = id ; write_ref ( node , ids , creation ) ; } | Write an old style Erlang ref to the stream . |
22,137 | public void write_string ( final String s ) { final int len = s . length ( ) ; switch ( len ) { case 0 : write_nil ( ) ; break ; default : if ( len <= 65535 && is8bitString ( s ) ) { try { final byte [ ] bytebuf = s . getBytes ( "ISO-8859-1" ) ; write1 ( OtpExternal . stringTag ) ; write2BE ( len ) ; writeN ( bytebuf ) ; } catch ( final UnsupportedEncodingException e ) { write_nil ( ) ; } } else { final int [ ] codePoints = OtpErlangString . stringToCodePoints ( s ) ; write_list_head ( codePoints . length ) ; for ( final int codePoint : codePoints ) { write_int ( codePoint ) ; } write_nil ( ) ; } } } | Write a string to the stream . |
22,138 | public void write_compressed ( final OtpErlangObject o , final int level ) { @ SuppressWarnings ( "resource" ) final OtpOutputStream oos = new OtpOutputStream ( o ) ; if ( oos . size ( ) < 5 ) { try { oos . writeToAndFlush ( this ) ; close ( ) ; } catch ( final IOException e ) { throw new java . lang . IllegalArgumentException ( "Intermediate stream failed for Erlang object " + o ) ; } } else { final int startCount = super . count ; final int destCount = startCount + oos . size ( ) ; fixedSize = destCount ; final Deflater def = new Deflater ( level ) ; final java . util . zip . DeflaterOutputStream dos = new java . util . zip . DeflaterOutputStream ( this , def ) ; try { write1 ( OtpExternal . compressedTag ) ; write4BE ( oos . size ( ) ) ; oos . writeTo ( dos ) ; dos . close ( ) ; } catch ( final IllegalArgumentException e ) { def . end ( ) ; super . count = startCount ; try { oos . writeTo ( this ) ; close ( ) ; } catch ( final IOException e2 ) { throw new java . lang . IllegalArgumentException ( "Intermediate stream failed for Erlang object " + o ) ; } } catch ( final IOException e ) { throw new java . lang . IllegalArgumentException ( "Intermediate stream failed for Erlang object " + o ) ; } finally { fixedSize = Integer . MAX_VALUE ; } } } | Write an arbitrary Erlang term to the stream in compressed format . |
22,139 | public String setCookie ( final String cookie ) { final String prev = this . cookie ; this . cookie = cookie ; return prev ; } | Set the authorization cookie used by this node . |
22,140 | protected int doHashCode ( ) { final OtpErlangObject . Hash hash = new OtpErlangObject . Hash ( 7 ) ; hash . combine ( creation , ids [ 0 ] ) ; if ( isNewRef ( ) ) { hash . combine ( ids [ 1 ] , ids [ 2 ] ) ; } return hash . valueOf ( ) ; } | Compute the hashCode value for a given ref . This function is compatible with equal . |
22,141 | public OtpErlangObject receive ( ) throws IOException , OtpErlangExit , OtpAuthException { try { return receiveMsg ( ) . getMsg ( ) ; } catch ( final OtpErlangDecodeException e ) { close ( ) ; throw new IOException ( e . getMessage ( ) ) ; } } | Receive a message from a remote process . This method blocks until a valid message is received or an exception is raised . |
22,142 | public OtpMsg receiveMsg ( ) throws IOException , OtpErlangExit , OtpAuthException { final Object o = queue . get ( ) ; if ( o instanceof OtpMsg ) { return ( OtpMsg ) o ; } else if ( o instanceof IOException ) { throw ( IOException ) o ; } else if ( o instanceof OtpErlangExit ) { throw ( OtpErlangExit ) o ; } else if ( o instanceof OtpAuthException ) { throw ( OtpAuthException ) o ; } return null ; } | Receive a messge complete with sender and recipient information . |
22,143 | @ SuppressWarnings ( "resource" ) public void send ( final OtpErlangPid dest , final OtpErlangObject msg ) throws IOException { super . sendBuf ( self . pid ( ) , dest , new OtpOutputStream ( msg ) ) ; } | Send a message to a process on a remote node . |
22,144 | public void sendBuf ( final OtpErlangPid dest , final OtpOutputStream payload ) throws IOException { super . sendBuf ( self . pid ( ) , dest , payload ) ; } | Send a pre - encoded message to a process on a remote node . |
22,145 | public int bitLength ( ) { if ( bigVal != null ) { return bigVal . bitLength ( ) ; } if ( val == 0 || val == - 1 ) { return 0 ; } int i = 32 ; long m = ( 1L << i ) - 1 ; if ( val < 0 ) { m = ~ m ; for ( int j = i >> 1 ; j > 0 ; j >>= 1 ) { if ( ( val | m ) == val ) { i -= j ; m >>= j ; } else { i += j ; m <<= j ; } } if ( ( val | m ) != val ) { i ++ ; } } else { for ( int j = i >> 1 ; j > 0 ; j >>= 1 ) { if ( ( val & m ) == val ) { i -= j ; m >>= j ; } else { i += j ; m = m << j | m ; } } if ( ( val & m ) != val ) { i ++ ; } } return i ; } | Returns the number of bits in the minimal two s - complement representation of this BigInteger excluding a sign bit . |
22,146 | public int intValue ( ) throws OtpErlangRangeException { final long l = longValue ( ) ; final int i = ( int ) l ; if ( i != l ) { throw new OtpErlangRangeException ( "Value too large for int: " + val ) ; } return i ; } | Get this number as an int . |
22,147 | public int uIntValue ( ) throws OtpErlangRangeException { final long l = longValue ( ) ; final int i = ( int ) l ; if ( i != l ) { throw new OtpErlangRangeException ( "Value too large for int: " + val ) ; } else if ( i < 0 ) { throw new OtpErlangRangeException ( "Value not positive: " + val ) ; } return i ; } | Get this number as a non - negative int . |
22,148 | public short shortValue ( ) throws OtpErlangRangeException { final long l = longValue ( ) ; final short i = ( short ) l ; if ( i != l ) { throw new OtpErlangRangeException ( "Value too large for short: " + val ) ; } return i ; } | Get this number as a short . |
22,149 | public short uShortValue ( ) throws OtpErlangRangeException { final long l = longValue ( ) ; final short i = ( short ) l ; if ( i != l ) { throw new OtpErlangRangeException ( "Value too large for short: " + val ) ; } else if ( i < 0 ) { throw new OtpErlangRangeException ( "Value not positive: " + val ) ; } return i ; } | Get this number as a non - negative short . |
22,150 | public char charValue ( ) throws OtpErlangRangeException { final long l = longValue ( ) ; final char i = ( char ) l ; if ( i != l ) { throw new OtpErlangRangeException ( "Value too large for char: " + val ) ; } return i ; } | Get this number as a char . |
22,151 | public byte byteValue ( ) throws OtpErlangRangeException { final long l = longValue ( ) ; final byte i = ( byte ) l ; if ( i != l ) { throw new OtpErlangRangeException ( "Value too large for byte: " + val ) ; } return i ; } | Get this number as a byte . |
22,152 | public void encode ( final OtpOutputStream buf ) { if ( bigVal != null ) { buf . write_big_integer ( bigVal ) ; } else { buf . write_long ( val ) ; } } | Convert this number to the equivalent Erlang external representation . |
22,153 | public void closeMbox ( final OtpMbox mbox , final OtpErlangObject reason ) { if ( mbox != null ) { mboxes . remove ( mbox ) ; mbox . name = null ; mbox . breakLinks ( reason ) ; } } | Close the specified mailbox with the given reason . |
22,154 | private boolean atomNeedsQuoting ( final String s ) { char c ; if ( s . length ( ) == 0 ) { return true ; } if ( ! isErlangLower ( s . charAt ( 0 ) ) ) { return true ; } final int len = s . length ( ) ; for ( int i = 1 ; i < len ; i ++ ) { c = s . charAt ( i ) ; if ( ! isErlangLetter ( c ) && ! isErlangDigit ( c ) && c != '@' ) { return true ; } } return false ; } | true if the atom should be displayed with quotation marks |
22,155 | public void encode ( final OtpOutputStream buf ) { final int arity = elems . length ; buf . write_tuple_head ( arity ) ; for ( int i = 0 ; i < arity ; i ++ ) { buf . write_any ( elems [ i ] ) ; } } | Convert this tuple to the equivalent Erlang external representation . |
22,156 | public static int [ ] stringToCodePoints ( final String s ) { final int m = s . codePointCount ( 0 , s . length ( ) ) ; final int [ ] codePoints = new int [ m ] ; int j = 0 ; for ( int offset = 0 ; offset < s . length ( ) ; ) { final int codepoint = s . codePointAt ( offset ) ; codePoints [ j ++ ] = codepoint ; offset += Character . charCount ( codepoint ) ; } return codePoints ; } | Create Unicode code points from a String . |
22,157 | public void encode ( final OtpOutputStream buf ) { final int arity = arity ( ) ; buf . write_map_head ( arity ) ; for ( final Map . Entry < OtpErlangObject , OtpErlangObject > e : entrySet ( ) ) { buf . write_any ( e . getKey ( ) ) ; buf . write_any ( e . getValue ( ) ) ; } } | Convert this map to the equivalent Erlang external representation . |
22,158 | public void close ( ) { done = true ; connected = false ; synchronized ( this ) { try { if ( socket != null ) { if ( traceLevel >= ctrlThreshold ) { System . out . println ( "-> CLOSE" ) ; } socket . close ( ) ; } } catch ( final IOException e ) { } finally { socket = null ; } } } | Close the connection to the remote node . |
22,159 | protected synchronized void do_send ( final OtpOutputStream header ) throws IOException { try { if ( traceLevel >= ctrlThreshold ) { try { final OtpErlangObject h = header . getOtpInputStream ( 5 ) . read_any ( ) ; System . out . println ( "-> " + headerType ( h ) + " " + h ) ; } catch ( final OtpErlangDecodeException e ) { System . out . println ( " " + "can't decode output buffer: " + e ) ; } } header . writeToAndFlush ( socket . getOutputStream ( ) ) ; } catch ( final IOException e ) { close ( ) ; throw e ; } } | used by the other message types |
22,160 | static String hex0 ( final byte x ) { final char tab [ ] = { '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' } ; int uint ; if ( x < 0 ) { uint = x & 0x7F ; uint |= 1 << 7 ; } else { uint = x ; } return "" + tab [ uint >>> 4 ] + tab [ uint & 0xF ] ; } | Used to debug print a message digest |
22,161 | private boolean digests_equals ( final byte [ ] a , final byte [ ] b ) { int i ; for ( i = 0 ; i < 16 ; ++ i ) { if ( a [ i ] != b [ i ] ) { return false ; } } return true ; } | Would use Array . equals in newer JDK ... |
22,162 | public int setPos ( final int pos ) { final int oldpos = super . pos ; int apos = pos ; if ( pos > super . count ) { apos = super . count ; } else if ( pos < 0 ) { apos = 0 ; } super . pos = apos ; return oldpos ; } | Set the current position in the stream . |
22,163 | public int readN ( final byte [ ] abuf , final int off , final int len ) throws OtpErlangDecodeException { if ( len == 0 && available ( ) == 0 ) { return 0 ; } final int i = super . read ( abuf , off , len ) ; if ( i < 0 ) { throw new OtpErlangDecodeException ( "Cannot read from input stream" ) ; } return i ; } | Read an array of bytes from the stream . The method reads at most len bytes from the input stream into offset off of the buffer . |
22,164 | public int peek1 ( ) throws OtpErlangDecodeException { int i ; try { i = super . buf [ super . pos ] ; if ( i < 0 ) { i += 256 ; } return i ; } catch ( final Exception e ) { throw new OtpErlangDecodeException ( "Cannot read from input stream" ) ; } } | Look ahead one position in the stream without consuming the byte found there . |
22,165 | public int read2BE ( ) throws OtpErlangDecodeException { final byte [ ] b = new byte [ 2 ] ; try { super . read ( b ) ; } catch ( final IOException e ) { throw new OtpErlangDecodeException ( "Cannot read from input stream" ) ; } return ( b [ 0 ] << 8 & 0xff00 ) + ( b [ 1 ] & 0xff ) ; } | Read a two byte big endian integer from the stream . |
22,166 | public int read4BE ( ) throws OtpErlangDecodeException { final byte [ ] b = new byte [ 4 ] ; try { super . read ( b ) ; } catch ( final IOException e ) { throw new OtpErlangDecodeException ( "Cannot read from input stream" ) ; } return ( b [ 0 ] << 24 & 0xff000000 ) + ( b [ 1 ] << 16 & 0xff0000 ) + ( b [ 2 ] << 8 & 0xff00 ) + ( b [ 3 ] & 0xff ) ; } | Read a four byte big endian integer from the stream . |
22,167 | public int read2LE ( ) throws OtpErlangDecodeException { final byte [ ] b = new byte [ 2 ] ; try { super . read ( b ) ; } catch ( final IOException e ) { throw new OtpErlangDecodeException ( "Cannot read from input stream" ) ; } return ( b [ 1 ] << 8 & 0xff00 ) + ( b [ 0 ] & 0xff ) ; } | Read a two byte little endian integer from the stream . |
22,168 | public int read4LE ( ) throws OtpErlangDecodeException { final byte [ ] b = new byte [ 4 ] ; try { super . read ( b ) ; } catch ( final IOException e ) { throw new OtpErlangDecodeException ( "Cannot read from input stream" ) ; } return ( b [ 3 ] << 24 & 0xff000000 ) + ( b [ 2 ] << 16 & 0xff0000 ) + ( b [ 1 ] << 8 & 0xff00 ) + ( b [ 0 ] & 0xff ) ; } | Read a four byte little endian integer from the stream . |
22,169 | public long readLE ( final int n ) throws OtpErlangDecodeException { final byte [ ] b = new byte [ n ] ; try { super . read ( b ) ; } catch ( final IOException e ) { throw new OtpErlangDecodeException ( "Cannot read from input stream" ) ; } long v = 0 ; int i = n ; while ( i -- > 0 ) { v = v << 8 | ( long ) b [ i ] & 0xff ; } return v ; } | Read a little endian integer from the stream . |
22,170 | @ SuppressWarnings ( "fallthrough" ) public String read_atom ( ) throws OtpErlangDecodeException { int tag ; int len = - 1 ; byte [ ] strbuf ; String atom ; tag = read1skip_version ( ) ; switch ( tag ) { case OtpExternal . atomTag : len = read2BE ( ) ; strbuf = new byte [ len ] ; this . readN ( strbuf ) ; try { atom = new String ( strbuf , "ISO-8859-1" ) ; } catch ( final java . io . UnsupportedEncodingException e ) { throw new OtpErlangDecodeException ( "Failed to decode ISO-8859-1 atom" ) ; } if ( atom . length ( ) > OtpExternal . maxAtomLength ) { atom = atom . substring ( 0 , OtpExternal . maxAtomLength ) ; } break ; case OtpExternal . smallAtomUtf8Tag : len = read1 ( ) ; case OtpExternal . atomUtf8Tag : if ( len < 0 ) { len = read2BE ( ) ; } strbuf = new byte [ len ] ; this . readN ( strbuf ) ; try { atom = new String ( strbuf , "UTF-8" ) ; } catch ( final java . io . UnsupportedEncodingException e ) { throw new OtpErlangDecodeException ( "Failed to decode UTF-8 atom" ) ; } if ( atom . codePointCount ( 0 , atom . length ( ) ) > OtpExternal . maxAtomLength ) { final int [ ] cps = OtpErlangString . stringToCodePoints ( atom ) ; atom = new String ( cps , 0 , OtpExternal . maxAtomLength ) ; } break ; default : throw new OtpErlangDecodeException ( "wrong tag encountered, expected " + OtpExternal . atomTag + ", or " + OtpExternal . atomUtf8Tag + ", got " + tag ) ; } return atom ; } | Read an Erlang atom from the stream . |
22,171 | public byte [ ] read_binary ( ) throws OtpErlangDecodeException { int tag ; int len ; byte [ ] bin ; tag = read1skip_version ( ) ; if ( tag != OtpExternal . binTag ) { throw new OtpErlangDecodeException ( "Wrong tag encountered, expected " + OtpExternal . binTag + ", got " + tag ) ; } len = read4BE ( ) ; bin = new byte [ len ] ; this . readN ( bin ) ; return bin ; } | Read an Erlang binary from the stream . |
22,172 | public byte [ ] read_bitstr ( final int pad_bits [ ] ) throws OtpErlangDecodeException { int tag ; int len ; byte [ ] bin ; tag = read1skip_version ( ) ; if ( tag != OtpExternal . bitBinTag ) { throw new OtpErlangDecodeException ( "Wrong tag encountered, expected " + OtpExternal . bitBinTag + ", got " + tag ) ; } len = read4BE ( ) ; bin = new byte [ len ] ; final int tail_bits = read1 ( ) ; if ( tail_bits < 0 || 7 < tail_bits ) { throw new OtpErlangDecodeException ( "Wrong tail bit count in bitstr: " + tail_bits ) ; } if ( len == 0 && tail_bits != 0 ) { throw new OtpErlangDecodeException ( "Length 0 on bitstr with tail bit count: " + tail_bits ) ; } this . readN ( bin ) ; pad_bits [ 0 ] = 8 - tail_bits ; return bin ; } | Read an Erlang bitstr from the stream . |
22,173 | public double read_double ( ) throws OtpErlangDecodeException { int tag ; tag = read1skip_version ( ) ; switch ( tag ) { case OtpExternal . newFloatTag : { return Double . longBitsToDouble ( readBE ( 8 ) ) ; } case OtpExternal . floatTag : { BigDecimal val ; int epos ; int exp ; final byte [ ] strbuf = new byte [ 31 ] ; String str ; this . readN ( strbuf ) ; str = OtpErlangString . newString ( strbuf ) ; epos = str . indexOf ( 'e' , 0 ) ; if ( epos < 0 ) { throw new OtpErlangDecodeException ( "Invalid float format: '" + str + "'" ) ; } String estr = str . substring ( epos + 1 ) . trim ( ) ; if ( estr . substring ( 0 , 1 ) . equals ( "+" ) ) { estr = estr . substring ( 1 ) ; } exp = Integer . valueOf ( estr ) . intValue ( ) ; val = new BigDecimal ( str . substring ( 0 , epos ) ) . movePointRight ( exp ) ; return val . doubleValue ( ) ; } default : throw new OtpErlangDecodeException ( "Wrong tag encountered, expected " + OtpExternal . newFloatTag + ", got " + tag ) ; } } | Read an Erlang float from the stream . |
22,174 | public byte read_byte ( ) throws OtpErlangDecodeException { final long l = this . read_long ( false ) ; final byte i = ( byte ) l ; if ( l != i ) { throw new OtpErlangDecodeException ( "Value does not fit in byte: " + l ) ; } return i ; } | Read one byte from the stream . |
22,175 | public char read_char ( ) throws OtpErlangDecodeException { final long l = this . read_long ( true ) ; final char i = ( char ) l ; if ( l != ( i & 0xffffL ) ) { throw new OtpErlangDecodeException ( "Value does not fit in char: " + l ) ; } return i ; } | Read a character from the stream . |
22,176 | public int read_uint ( ) throws OtpErlangDecodeException { final long l = this . read_long ( true ) ; final int i = ( int ) l ; if ( l != ( i & 0xFFFFffffL ) ) { throw new OtpErlangDecodeException ( "Value does not fit in uint: " + l ) ; } return i ; } | Read an unsigned integer from the stream . |
22,177 | public short read_ushort ( ) throws OtpErlangDecodeException { final long l = this . read_long ( true ) ; final short i = ( short ) l ; if ( l != ( i & 0xffffL ) ) { throw new OtpErlangDecodeException ( "Value does not fit in ushort: " + l ) ; } return i ; } | Read an unsigned short from the stream . |
22,178 | public short read_short ( ) throws OtpErlangDecodeException { final long l = this . read_long ( false ) ; final short i = ( short ) l ; if ( l != i ) { throw new OtpErlangDecodeException ( "Value does not fit in short: " + l ) ; } return i ; } | Read a short from the stream . |
22,179 | public int read_list_head ( ) throws OtpErlangDecodeException { int arity = 0 ; final int tag = read1skip_version ( ) ; switch ( tag ) { case OtpExternal . nilTag : arity = 0 ; break ; case OtpExternal . stringTag : arity = read2BE ( ) ; break ; case OtpExternal . listTag : arity = read4BE ( ) ; break ; default : throw new OtpErlangDecodeException ( "Not valid list tag: " + tag ) ; } return arity ; } | Read a list header from the stream . |
22,180 | public int read_tuple_head ( ) throws OtpErlangDecodeException { int arity = 0 ; final int tag = read1skip_version ( ) ; switch ( tag ) { case OtpExternal . smallTupleTag : arity = read1 ( ) ; break ; case OtpExternal . largeTupleTag : arity = read4BE ( ) ; break ; default : throw new OtpErlangDecodeException ( "Not valid tuple tag: " + tag ) ; } return arity ; } | Read a tuple header from the stream . |
22,181 | public int read_nil ( ) throws OtpErlangDecodeException { int arity = 0 ; final int tag = read1skip_version ( ) ; switch ( tag ) { case OtpExternal . nilTag : arity = 0 ; break ; default : throw new OtpErlangDecodeException ( "Not valid nil tag: " + tag ) ; } return arity ; } | Read an empty list from the stream . |
22,182 | public OtpErlangPid read_pid ( ) throws OtpErlangDecodeException { String node ; int id ; int serial ; int creation ; int tag ; tag = read1skip_version ( ) ; if ( tag != OtpExternal . pidTag && tag != OtpExternal . newPidTag ) { throw new OtpErlangDecodeException ( "Wrong tag encountered, expected " + OtpExternal . pidTag + " or " + OtpExternal . newPidTag + ", got " + tag ) ; } node = read_atom ( ) ; id = read4BE ( ) ; serial = read4BE ( ) ; if ( tag == OtpExternal . pidTag ) creation = read1 ( ) ; else creation = read4BE ( ) ; return new OtpErlangPid ( tag , node , id , serial , creation ) ; } | Read an Erlang PID from the stream . |
22,183 | public OtpErlangPort read_port ( ) throws OtpErlangDecodeException { String node ; int id ; int creation ; int tag ; tag = read1skip_version ( ) ; if ( tag != OtpExternal . portTag && tag != OtpExternal . newPortTag ) { throw new OtpErlangDecodeException ( "Wrong tag encountered, expected " + OtpExternal . portTag + " or " + OtpExternal . newPortTag + ", got " + tag ) ; } node = read_atom ( ) ; id = read4BE ( ) ; if ( tag == OtpExternal . portTag ) creation = read1 ( ) ; else creation = read4BE ( ) ; return new OtpErlangPort ( tag , node , id , creation ) ; } | Read an Erlang port from the stream . |
22,184 | public OtpErlangRef read_ref ( ) throws OtpErlangDecodeException { String node ; int id ; int creation ; int tag ; tag = read1skip_version ( ) ; switch ( tag ) { case OtpExternal . refTag : node = read_atom ( ) ; id = read4BE ( ) & 0x3ffff ; creation = read1 ( ) & 0x03 ; return new OtpErlangRef ( node , id , creation ) ; case OtpExternal . newRefTag : case OtpExternal . newerRefTag : final int arity = read2BE ( ) ; if ( arity > 3 ) { throw new OtpErlangDecodeException ( "Ref arity " + arity + " too large " ) ; } node = read_atom ( ) ; if ( tag == OtpExternal . newRefTag ) creation = read1 ( ) ; else creation = read4BE ( ) ; final int [ ] ids = new int [ arity ] ; for ( int i = 0 ; i < arity ; i ++ ) { ids [ i ] = read4BE ( ) ; } return new OtpErlangRef ( tag , node , ids , creation ) ; default : throw new OtpErlangDecodeException ( "Wrong tag encountered, expected ref, got " + tag ) ; } } | Read an Erlang reference from the stream . |
22,185 | public String read_string ( ) throws OtpErlangDecodeException { int tag ; int len ; byte [ ] strbuf ; int [ ] intbuf ; tag = read1skip_version ( ) ; switch ( tag ) { case OtpExternal . stringTag : len = read2BE ( ) ; strbuf = new byte [ len ] ; this . readN ( strbuf ) ; return OtpErlangString . newString ( strbuf ) ; case OtpExternal . nilTag : return "" ; case OtpExternal . listTag : len = read4BE ( ) ; intbuf = new int [ len ] ; for ( int i = 0 ; i < len ; i ++ ) { intbuf [ i ] = read_int ( ) ; if ( ! OtpErlangString . isValidCodePoint ( intbuf [ i ] ) ) { throw new OtpErlangDecodeException ( "Invalid CodePoint: " + intbuf [ i ] ) ; } } read_nil ( ) ; return new String ( intbuf , 0 , intbuf . length ) ; default : throw new OtpErlangDecodeException ( "Wrong tag encountered, expected " + OtpExternal . stringTag + " or " + OtpExternal . listTag + ", got " + tag ) ; } } | Read a string from the stream . |
22,186 | public OtpErlangObject read_compressed ( ) throws OtpErlangDecodeException { final int tag = read1skip_version ( ) ; if ( tag != OtpExternal . compressedTag ) { throw new OtpErlangDecodeException ( "Wrong tag encountered, expected " + OtpExternal . compressedTag + ", got " + tag ) ; } final int size = read4BE ( ) ; final byte [ ] abuf = new byte [ size ] ; final java . util . zip . InflaterInputStream is = new java . util . zip . InflaterInputStream ( this , new java . util . zip . Inflater ( ) , size ) ; int curPos = 0 ; try { int curRead ; while ( curPos < size && ( curRead = is . read ( abuf , curPos , size - curPos ) ) != - 1 ) { curPos += curRead ; } if ( curPos != size ) { throw new OtpErlangDecodeException ( "Decompression gave " + curPos + " bytes, not " + size ) ; } } catch ( final IOException e ) { throw new OtpErlangDecodeException ( "Cannot read from input stream" ) ; } @ SuppressWarnings ( "resource" ) final OtpInputStream ois = new OtpInputStream ( abuf , flags ) ; return ois . read_any ( ) ; } | Read a compressed term from the stream |
22,187 | public OtpErlangObject read_any ( ) throws OtpErlangDecodeException { final int tag = peek1skip_version ( ) ; switch ( tag ) { case OtpExternal . smallIntTag : case OtpExternal . intTag : case OtpExternal . smallBigTag : case OtpExternal . largeBigTag : return new OtpErlangLong ( this ) ; case OtpExternal . atomTag : case OtpExternal . smallAtomUtf8Tag : case OtpExternal . atomUtf8Tag : return new OtpErlangAtom ( this ) ; case OtpExternal . floatTag : case OtpExternal . newFloatTag : return new OtpErlangDouble ( this ) ; case OtpExternal . refTag : case OtpExternal . newRefTag : case OtpExternal . newerRefTag : return new OtpErlangRef ( this ) ; case OtpExternal . mapTag : return new OtpErlangMap ( this ) ; case OtpExternal . portTag : case OtpExternal . newPortTag : return new OtpErlangPort ( this ) ; case OtpExternal . pidTag : case OtpExternal . newPidTag : return new OtpErlangPid ( this ) ; case OtpExternal . stringTag : return new OtpErlangString ( this ) ; case OtpExternal . listTag : case OtpExternal . nilTag : if ( ( flags & DECODE_INT_LISTS_AS_STRINGS ) != 0 ) { final int savePos = getPos ( ) ; try { return new OtpErlangString ( this ) ; } catch ( final OtpErlangDecodeException e ) { } setPos ( savePos ) ; } return new OtpErlangList ( this ) ; case OtpExternal . smallTupleTag : case OtpExternal . largeTupleTag : return new OtpErlangTuple ( this ) ; case OtpExternal . binTag : return new OtpErlangBinary ( this ) ; case OtpExternal . bitBinTag : return new OtpErlangBitstr ( this ) ; case OtpExternal . compressedTag : return read_compressed ( ) ; case OtpExternal . newFunTag : case OtpExternal . funTag : return new OtpErlangFun ( this ) ; case OtpExternal . externalFunTag : return new OtpErlangExternalFun ( this ) ; default : throw new OtpErlangDecodeException ( "Uknown data type: " + tag ) ; } } | Read an arbitrary Erlang term from the stream . |
22,188 | public static boolean publishPort ( final OtpLocalNode node ) throws IOException { OtpTransport s = null ; s = r4_publish ( node ) ; node . setEpmd ( s ) ; return s != null ; } | Register with Epmd so that other nodes are able to find and connect to it . |
22,189 | public static void unPublishPort ( final OtpLocalNode node ) { OtpTransport s = null ; try { s = node . createTransport ( ( String ) null , EpmdPort . get ( ) ) ; @ SuppressWarnings ( "resource" ) final OtpOutputStream obuf = new OtpOutputStream ( ) ; obuf . write2BE ( node . alive ( ) . length ( ) + 1 ) ; obuf . write1 ( stopReq ) ; obuf . writeN ( node . alive ( ) . getBytes ( ) ) ; obuf . writeToAndFlush ( s . getOutputStream ( ) ) ; if ( traceLevel >= traceThreshold ) { System . out . println ( "-> UNPUBLISH " + node + " port=" + node . port ( ) ) ; System . out . println ( "<- OK (assumed)" ) ; } } catch ( final Exception e ) { } finally { try { if ( s != null ) { s . close ( ) ; } } catch ( final IOException e ) { } s = null ; } } | Unregister from Epmd . Other nodes wishing to connect will no longer be able to . |
22,190 | public void send ( final String aname , final OtpErlangObject msg ) { home . deliver ( new OtpMsg ( self , aname , ( OtpErlangObject ) msg . clone ( ) ) ) ; } | Send a message to a named mailbox created from the same node as this mailbox . |
22,191 | public void send ( final String aname , final String node , final OtpErlangObject msg ) { try { final String currentNode = home . node ( ) ; if ( node . equals ( currentNode ) ) { send ( aname , msg ) ; } else if ( node . indexOf ( '@' , 0 ) < 0 && node . equals ( currentNode . substring ( 0 , currentNode . indexOf ( '@' , 0 ) ) ) ) { send ( aname , msg ) ; } else { final OtpCookedConnection conn = home . getConnection ( node ) ; if ( conn == null ) { return ; } conn . send ( self , aname , msg ) ; } } catch ( final Exception e ) { } } | Send a message to a named mailbox created from another node . |
22,192 | void breakLinks ( final OtpErlangObject reason ) { final Link [ ] l = links . clearLinks ( ) ; if ( l != null ) { final int len = l . length ; for ( int i = 0 ; i < len ; i ++ ) { exit ( 1 , l [ i ] . remote ( ) , reason ) ; } } } | used to break all known links to this mbox |
22,193 | public void read_lock_frames ( Job job ) { Frame tr = train ( ) ; if ( tr != null ) tr . read_lock ( job . _key ) ; if ( _valid != null && ! _train . equals ( _valid ) ) _valid . get ( ) . read_lock ( job . _key ) ; } | Read - Lock both training and validation User frames . |
22,194 | public void read_unlock_frames ( Job job ) { Frame tr = train ( ) ; if ( tr != null ) tr . unlock ( job . _key , false ) ; if ( _valid != null && ! _train . equals ( _valid ) ) valid ( ) . unlock ( job . _key , false ) ; } | Read - UnLock both training and validation User frames . This method is called on crashing cleanup pathes so handles the case where the frames are not actually locked . |
22,195 | public Frame reorderColumns ( Frame f ) { if ( ( _interactionsOnly == null ) || ( f == null ) ) return f ; Vec [ ] interOnlyVecs = f . vecs ( _interactionsOnly ) ; f . remove ( _interactionsOnly ) ; for ( int i = 0 ; i < _interactionsOnly . length ; i ++ ) { if ( isUsed ( _interactionsOnly [ i ] ) ) { f . add ( _interactionsOnly [ i ] , interOnlyVecs [ i ] ) ; } else if ( ! isIgnored ( _interactionsOnly [ i ] ) ) { Log . warn ( "Column '" + _interactionsOnly [ i ] + "' was marked to be used for interactions only " + "but it is not actually required in any interaction." ) ; } } return f ; } | Reorders columns of a Frame so that columns that only used to make interactions are at the end of the Frame . Only Vecs that will actually be used are kept in the frame . |
22,196 | public String [ ] classNames ( ) { if ( _domains == null || _domains . length == 0 || ! isSupervised ( ) ) return null ; return _domains [ _domains . length - 1 ] ; } | Names of levels for a categorical response column . |
22,197 | private void validateS3Credentials ( final PersistS3CredentialsV3 s3Credentials ) { Objects . requireNonNull ( s3Credentials ) ; if ( s3Credentials . secret_key_id == null ) throw new IllegalArgumentException ( "The field 'S3_SECRET_KEY_ID' may not be null." ) ; if ( s3Credentials . secret_access_key == null ) throw new IllegalArgumentException ( "The field 'S3_SECRET_ACCESS_KEY' may not be null." ) ; s3Credentials . secret_key_id = s3Credentials . secret_key_id . trim ( ) ; s3Credentials . secret_access_key = s3Credentials . secret_access_key . trim ( ) ; if ( s3Credentials . secret_key_id . isEmpty ( ) ) throw new IllegalArgumentException ( "The field 'S3_SECRET_KEY_ID' may not be empty." ) ; if ( s3Credentials . secret_access_key . isEmpty ( ) ) throw new IllegalArgumentException ( "The field 'S3_SECRET_ACCESS_KEY' may not be empty." ) ; } | Checks for basic mistakes users might make when providing S3 credentials . |
22,198 | private Vec [ ] [ ] makeTemplates ( Frame dataset , double [ ] ratios ) { Vec anyVec = dataset . anyVec ( ) ; final long [ ] [ ] espcPerSplit = computeEspcPerSplit ( anyVec . espc ( ) , anyVec . length ( ) , ratios ) ; final int num = dataset . numCols ( ) ; final int nsplits = espcPerSplit . length ; final String [ ] [ ] domains = dataset . domains ( ) ; final byte [ ] types = new byte [ num ] ; int j = 0 ; for ( Vec v : dataset . vecs ( ) ) types [ j ++ ] = v . get_type ( ) ; Vec [ ] [ ] t = new Vec [ nsplits ] [ ] ; for ( int i = 0 ; i < nsplits ; i ++ ) { Key vkey = Vec . newKey ( ) ; int rowLayout = Vec . ESPC . rowLayout ( vkey , espcPerSplit [ i ] ) ; t [ i ] = new Vec ( vkey , rowLayout ) . makeCons ( num , 0 , domains , types ) ; } return t ; } | Make vector templates for all output frame vectors |
22,199 | static long [ ] [ ] computeEspcPerSplit ( long [ ] espc , long len , double [ ] ratios ) { assert espc . length > 0 && espc [ 0 ] == 0 ; assert espc [ espc . length - 1 ] == len ; long [ ] partSizes = partitione ( len , ratios ) ; int nparts = ratios . length + 1 ; long [ ] [ ] r = new long [ nparts ] [ espc . length ] ; long nrows = 0 ; long start = 0 ; for ( int p = 0 , c = 0 ; p < nparts ; p ++ ) { int nc = 0 ; for ( ; c < espc . length - 1 && ( espc [ c + 1 ] - start ) <= partSizes [ p ] ; c ++ ) r [ p ] [ ++ nc ] = espc [ c + 1 ] - start ; if ( r [ p ] [ nc ] < partSizes [ p ] ) r [ p ] [ ++ nc ] = partSizes [ p ] ; r [ p ] = Arrays . copyOf ( r [ p ] , nc + 1 ) ; nrows = nrows - partSizes [ p ] ; start += partSizes [ p ] ; } return r ; } | The task computes ESPC per split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.