idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
156,900 | public static ZContext shadow ( ZContext ctx ) { ZContext context = new ZContext ( ctx . context , false , ctx . ioThreads ) ; context . linger = ctx . linger ; context . sndhwm = ctx . sndhwm ; context . rcvhwm = ctx . rcvhwm ; context . pipehwm = ctx . pipehwm ; return context ; } | Creates new shadow context . Shares same underlying org . zeromq . Context instance but has own list of managed sockets io thread count etc . |
156,901 | public Socket fork ( ZThread . IAttachedRunnable runnable , Object ... args ) { return ZThread . fork ( this , runnable , args ) ; } | Create an attached thread An attached thread gets a ctx and a PAIR pipe back to its parent . It must monitor its pipe and exit if the pipe becomes unreadable |
156,902 | public static ByteBuffer putUInt64 ( ByteBuffer buf , long value ) { buf . put ( ( byte ) ( ( value >>> 56 ) & 0xff ) ) ; buf . put ( ( byte ) ( ( value >>> 48 ) & 0xff ) ) ; buf . put ( ( byte ) ( ( value >>> 40 ) & 0xff ) ) ; buf . put ( ( byte ) ( ( value >>> 32 ) & 0xff ) ) ; buf . put ( ( byte ) ( ( value >>> 24 )... | 8 bytes value |
156,903 | public static Socket fork ( ZContext ctx , IAttachedRunnable runnable , Object ... args ) { Socket pipe = ctx . createSocket ( SocketType . PAIR ) ; if ( pipe != null ) { pipe . bind ( String . format ( "inproc://zctx-pipe-%d" , pipe . hashCode ( ) ) ) ; } else { return null ; } ZContext ccontext = ZContext . shadow ( ... | pipe becomes unreadable . Returns pipe or null if there was an error . |
156,904 | private void startConnecting ( ) { try { boolean rc = open ( ) ; if ( rc ) { handle = ioObject . addFd ( fd ) ; connectEvent ( ) ; } else { handle = ioObject . addFd ( fd ) ; ioObject . setPollConnect ( handle ) ; socket . eventConnectDelayed ( addr . toString ( ) , - 1 ) ; } } catch ( RuntimeException | IOException e ... | Internal function to start the actual connection establishment . |
156,905 | private void addReconnectTimer ( ) { int rcIvl = getNewReconnectIvl ( ) ; ioObject . addTimer ( rcIvl , RECONNECT_TIMER_ID ) ; try { addr . resolve ( options . ipv6 ) ; } catch ( Exception ignored ) { } socket . eventConnectRetried ( addr . toString ( ) , rcIvl ) ; timerStarted = true ; } | Internal function to add a reconnect timer |
156,906 | private int getNewReconnectIvl ( ) { int interval = currentReconnectIvl + ( Utils . randomInt ( ) % options . reconnectIvl ) ; if ( options . reconnectIvlMax > 0 && options . reconnectIvlMax > options . reconnectIvl ) { currentReconnectIvl = Math . min ( currentReconnectIvl * 2 , options . reconnectIvlMax ) ; } return ... | Returns the currently used interval |
156,907 | private boolean open ( ) throws IOException { assert ( fd == null ) ; if ( addr == null ) { throw new IOException ( "Null address" ) ; } addr . resolve ( options . ipv6 ) ; Address . IZAddress resolved = addr . resolved ( ) ; if ( resolved == null ) { throw new IOException ( "Address not resolved" ) ; } SocketAddress s... | Returns false if async connect was launched . |
156,908 | private SocketChannel connect ( ) { try { boolean finished = fd . finishConnect ( ) ; assert ( finished ) ; return fd ; } catch ( IOException e ) { return null ; } } | null if the connection was unsuccessful . |
156,909 | protected void close ( ) { assert ( fd != null ) ; try { fd . close ( ) ; socket . eventClosed ( addr . toString ( ) , fd ) ; } catch ( IOException e ) { socket . eventCloseFailed ( addr . toString ( ) , ZError . exccode ( e ) ) ; } fd = null ; } | Close the connecting socket . |
156,910 | public boolean setInterval ( Timer timer , long interval ) { assert ( timer . parent == this ) ; return timer . setInterval ( interval ) ; } | Changes the interval of the timer . This method is slow canceling existing and adding a new timer yield better performance . |
156,911 | public long timeout ( ) { final long now = now ( ) ; for ( Entry < Timer , Long > entry : entries ( ) ) { final Timer timer = entry . getKey ( ) ; final Long expiration = entry . getValue ( ) ; if ( timer . alive ) { if ( expiration - now > 0 ) { return expiration - now ; } else { return 0 ; } } timers . remove ( expir... | Returns the time in millisecond until the next timer . |
156,912 | public int execute ( ) { int executed = 0 ; final long now = now ( ) ; for ( Entry < Timer , Long > entry : entries ( ) ) { final Timer timer = entry . getKey ( ) ; final Long expiration = entry . getValue ( ) ; if ( ! timer . alive ) { timers . remove ( expiration , timer ) ; continue ; } if ( expiration - now > 0 ) {... | Execute the timers . |
156,913 | public static ZProxy newProxy ( ZContext ctx , String name , Proxy sockets , String motdelafin , Object ... args ) { return new ZProxy ( ctx , name , sockets , new ZmqPump ( ) , motdelafin , args ) ; } | Creates a new low - level proxy for better performances . |
156,914 | public String restart ( ZMsg hot ) { ZMsg msg = new ZMsg ( ) ; msg . add ( RESTART ) ; final boolean cold = hot == null ; if ( cold ) { msg . add ( Boolean . toString ( false ) ) ; } else { msg . add ( Boolean . toString ( true ) ) ; msg . append ( hot ) ; } String status = EXITED ; if ( agent . send ( msg ) ) { status... | Restarts the proxy . Stays alive . |
156,915 | public String exit ( ) { agent . send ( EXIT ) ; exit . awaitSilent ( ) ; agent . close ( ) ; return EXITED ; } | Stops the proxy and exits . The call is synchronous . |
156,916 | public String status ( boolean sync ) { if ( exit . isExited ( ) ) { return EXITED ; } try { String status = recvStatus ( ) ; if ( agent . send ( STATUS ) && sync ) { status = recvStatus ( ) ; if ( EXITED . equals ( status ) || ! agent . send ( STATUS ) ) { return EXITED ; } } return status ; } catch ( ZMQException e )... | Inquires for the status of the proxy . |
156,917 | private String recvStatus ( ) { if ( ! agent . sign ( ) ) { return EXITED ; } final ZMsg msg = agent . recv ( ) ; if ( msg == null ) { return EXITED ; } String status = msg . popString ( ) ; msg . destroy ( ) ; return status ; } | receives the last known state of the proxy |
156,918 | public boolean containsPublicKey ( byte [ ] publicKey ) { Utils . checkArgument ( publicKey . length == 32 , "publickey needs to have a size of 32 bytes. got only " + publicKey . length ) ; return containsPublicKey ( ZMQ . Curve . z85Encode ( publicKey ) ) ; } | Check if a public key is in the certificate store . |
156,919 | public boolean containsPublicKey ( String publicKey ) { Utils . checkArgument ( publicKey . length ( ) == 40 , "z85 publickeys should have a length of 40 bytes but got " + publicKey . length ( ) ) ; reloadIfNecessary ( ) ; return publicKeys . containsKey ( publicKey ) ; } | check if a z85 - based public key is in the certificate store . This method will scan the folder for changes on every call |
156,920 | boolean checkForChanges ( ) { final Map < File , byte [ ] > presents = new HashMap < > ( fingerprints ) ; boolean modified = traverseDirectory ( location , new IFileVisitor ( ) { public boolean visitFile ( File file ) { return modified ( presents . remove ( file ) , file ) ; } public boolean visitDir ( File dir ) { ret... | Check if files in the certificate folders have been added or removed . |
156,921 | public ZAuth configureCurve ( String location ) { Objects . requireNonNull ( location , "Location has to be supplied" ) ; return send ( Mechanism . CURVE . name ( ) , location ) ; } | Configure CURVE authentication |
156,922 | public ZapReply nextReply ( boolean wait ) { if ( ! repliesEnabled ) { System . out . println ( "ZAuth: replies are disabled. Please use replies(true);" ) ; return null ; } return ZapReply . recv ( replies , wait ) ; } | Retrieves the next ZAP reply . |
156,923 | public static int send ( SocketBase s , String str , int flags ) { byte [ ] data = str . getBytes ( CHARSET ) ; return send ( s , data , data . length , flags ) ; } | Sending functions . |
156,924 | public static Msg recv ( SocketBase s , int flags ) { checkSocket ( s ) ; Msg msg = recvMsg ( s , flags ) ; if ( msg == null ) { return null ; } return msg ; } | Receiving functions . |
156,925 | public static String getMessageMetadata ( Msg msg , String property ) { String data = null ; Metadata metadata = msg . getMetadata ( ) ; if ( metadata != null ) { data = metadata . get ( property ) ; } return data ; } | Get message metadata string |
156,926 | public static boolean proxy ( SocketBase frontend , SocketBase backend , SocketBase capture ) { Utils . checkArgument ( frontend != null , "Frontend socket has to be present for proxy" ) ; Utils . checkArgument ( backend != null , "Backend socket has to be present for proxy" ) ; return Proxy . proxy ( frontend , backen... | The proxy functionality |
156,927 | public final ZMonitor start ( ) { if ( started ) { System . out . println ( "ZMonitor: Unable to start while already started." ) ; return this ; } agent . send ( START ) ; agent . recv ( ) ; started = true ; return this ; } | Starts the monitoring . Event types have to be added before the start or they will take no effect . |
156,928 | public final ZMonitor verbose ( boolean verbose ) { if ( started ) { System . out . println ( "ZMonitor: Unable to change verbosity while already started." ) ; return this ; } agent . send ( VERBOSE , true ) ; agent . send ( Boolean . toString ( verbose ) ) ; agent . recv ( ) ; return this ; } | Sets verbosity of the monitor . |
156,929 | public final ZMonitor add ( Event ... events ) { if ( started ) { System . out . println ( "ZMonitor: Unable to add events while already started." ) ; return this ; } ZMsg msg = new ZMsg ( ) ; msg . add ( ADD_EVENTS ) ; for ( Event evt : events ) { msg . add ( evt . name ( ) ) ; } agent . send ( msg ) ; agent . recv ( ... | Adds event types to monitor . |
156,930 | public final ZEvent nextEvent ( boolean wait ) { if ( ! started ) { System . out . println ( "ZMonitor: Start before getting events." ) ; return null ; } ZMsg msg = agent . recv ( wait ) ; if ( msg == null ) { return null ; } return new ZEvent ( msg ) ; } | Gets the next event blocking for it until available if requested . |
156,931 | public boolean sendFrame ( ZFrame frame , int flags ) { final byte [ ] data = frame . getData ( ) ; final Msg msg = new Msg ( data ) ; if ( socketBase . send ( msg , flags ) ) { return true ; } mayRaise ( ) ; return false ; } | Send a frame |
156,932 | public static Pipe [ ] pair ( ZObject [ ] parents , int [ ] hwms , boolean [ ] conflates ) { Pipe [ ] pipes = new Pipe [ 2 ] ; YPipeBase < Msg > upipe1 = conflates [ 0 ] ? new YPipeConflate < > ( ) : new YPipe < Msg > ( Config . MESSAGE_PIPE_GRANULARITY . getValue ( ) ) ; YPipeBase < Msg > upipe2 = conflates [ 1 ] ? ne... | terminates straight away . |
156,933 | public boolean checkRead ( ) { if ( ! inActive ) { return false ; } if ( state != State . ACTIVE && state != State . WAITING_FOR_DELIMITER ) { return false ; } if ( ! inpipe . checkRead ( ) ) { inActive = false ; return false ; } if ( isDelimiter ( inpipe . probe ( ) ) ) { Msg msg = inpipe . read ( ) ; assert ( msg != ... | Returns true if there is at least one message to read in the pipe . |
156,934 | public Msg read ( ) { if ( ! inActive ) { return null ; } if ( state != State . ACTIVE && state != State . WAITING_FOR_DELIMITER ) { return null ; } while ( true ) { Msg msg = inpipe . read ( ) ; if ( msg == null ) { inActive = false ; return null ; } if ( msg . isCredential ( ) ) { credential = Blob . createBlob ( msg... | Reads a message to the underlying pipe . |
156,935 | public boolean checkWrite ( ) { if ( ! outActive || state != State . ACTIVE ) { return false ; } boolean full = ! checkHwm ( ) ; if ( full ) { outActive = false ; return false ; } return true ; } | the message would cause high watermark the function returns false . |
156,936 | public boolean write ( Msg msg ) { if ( ! checkWrite ( ) ) { return false ; } boolean more = msg . hasMore ( ) ; boolean identity = msg . isIdentity ( ) ; outpipe . write ( msg , more ) ; if ( ! more && ! identity ) { msgsWritten ++ ; } return true ; } | message cannot be written because high watermark was reached . |
156,937 | public void rollback ( ) { Msg msg ; if ( outpipe != null ) { while ( ( msg = outpipe . unwrite ( ) ) != null ) { assert ( msg . hasMore ( ) ) ; } } } | Remove unfinished parts of the outbound message from the pipe . |
156,938 | public void flush ( ) { if ( state == State . TERM_ACK_SENT ) { return ; } if ( outpipe != null && ! outpipe . flush ( ) ) { sendActivateRead ( peer ) ; } } | Flush the messages downstream . |
156,939 | public void terminate ( boolean delay ) { this . delay = delay ; if ( state == State . TERM_REQ_SENT_1 || state == State . TERM_REQ_SENT_2 ) { return ; } else if ( state == State . TERM_ACK_SENT ) { return ; } else if ( state == State . ACTIVE ) { sendPipeTerm ( peer ) ; state = State . TERM_REQ_SENT_1 ; } else if ( st... | before actual shutdown . |
156,940 | private void processDelimiter ( ) { assert ( state == State . ACTIVE || state == State . WAITING_FOR_DELIMITER ) ; if ( state == State . ACTIVE ) { state = State . DELIMITER_RECEIVED ; } else { outpipe = null ; sendPipeTermAck ( peer ) ; state = State . TERM_ACK_SENT ; } } | Handler for delimiter read from the pipe . |
156,941 | public void hiccup ( ) { if ( state != State . ACTIVE ) { return ; } inpipe = null ; if ( conflate ) { inpipe = new YPipeConflate < > ( ) ; } else { inpipe = new YPipe < > ( Config . MESSAGE_PIPE_GRANULARITY . getValue ( ) ) ; } inActive = true ; sendHiccup ( peer , inpipe ) ; } | in the peer . |
156,942 | protected boolean rollback ( ) { if ( currentOut != null ) { currentOut . rollback ( ) ; currentOut = null ; moreOut = false ; } return true ; } | Rollback any message parts that were sent but not yet flushed . |
156,943 | public final int encode ( ValueReference < ByteBuffer > data , int size ) { int bufferSize = size ; ByteBuffer buf = data . get ( ) ; if ( buf == null ) { buf = this . buffer ; bufferSize = this . bufferSize ; buffer . clear ( ) ; } if ( inProgress == null ) { return 0 ; } int pos = 0 ; buf . limit ( buf . capacity ( )... | is NULL ) encoder will provide buffer of its own . |
156,944 | private void nextStep ( byte [ ] buf , int toWrite , Runnable next , boolean newMsgFlag ) { if ( buf != null ) { writeBuf = ByteBuffer . wrap ( buf ) ; writeBuf . limit ( toWrite ) ; } else { writeBuf = null ; } this . toWrite = toWrite ; this . next = next ; this . newMsgFlag = newMsgFlag ; } | to the buffer and schedule next state machine action . |
156,945 | public void addTimer ( long timeout , IPollEvents sink , int id ) { assert ( Thread . currentThread ( ) == worker ) ; final long expiration = clock ( ) + timeout ; TimerInfo info = new TimerInfo ( sink , id ) ; timers . insert ( expiration , info ) ; changed = true ; } | argument set to id_ . |
156,946 | public void cancelTimer ( IPollEvents sink , int id ) { assert ( Thread . currentThread ( ) == worker ) ; TimerInfo copy = new TimerInfo ( sink , id ) ; TimerInfo timerInfo = timers . find ( copy ) ; if ( timerInfo != null ) { timerInfo . cancelled = true ; } } | Cancel the timer created by sink_ object with ID equal to id_ . |
156,947 | protected long executeTimers ( ) { assert ( Thread . currentThread ( ) == worker ) ; changed = false ; if ( timers . isEmpty ( ) ) { return 0L ; } long current = clock ( ) ; for ( Entry < TimerInfo , Long > entry : timers . entries ( ) ) { final TimerInfo timerInfo = entry . getKey ( ) ; if ( timerInfo . cancelled ) { ... | to wait to match the next timer or 0 meaning no timers . |
156,948 | protected void processTerm ( int linger ) { assert ( ! terminating ) ; for ( Own it : owned ) { sendTerm ( it , linger ) ; } registerTermAcks ( owned . size ( ) ) ; owned . clear ( ) ; terminating = true ; checkTermAcks ( ) ; } | steps to the beginning of the termination process . |
156,949 | public boolean rm ( Pipe pipe , IMtrieHandler func , XPub pub ) { assert ( pipe != null ) ; assert ( func != null ) ; return rmHelper ( pipe , new byte [ 0 ] , 0 , 0 , func , pub ) ; } | supplied callback function . |
156,950 | public boolean rm ( Msg msg , Pipe pipe ) { assert ( msg != null ) ; assert ( pipe != null ) ; return rmHelper ( msg , 1 , msg . size ( ) - 1 , pipe ) ; } | actually removed rather than de - duplicated . |
156,951 | public void match ( ByteBuffer data , int size , IMtrieHandler func , XPub pub ) { assert ( data != null ) ; assert ( func != null ) ; assert ( pub != null ) ; Mtrie current = this ; int idx = 0 ; while ( true ) { if ( current . pipes != null ) { for ( Pipe it : current . pipes ) { func . invoke ( it , null , 0 , pub )... | Signal all the matching pipes . |
156,952 | private void close ( ) { assert ( fd != null ) ; try { fd . close ( ) ; socket . eventClosed ( endpoint , fd ) ; } catch ( IOException e ) { socket . eventCloseFailed ( endpoint , ZError . exccode ( e ) ) ; } fd = null ; } | Close the listening socket . |
156,953 | private SocketChannel accept ( ) throws IOException { assert ( fd != null ) ; SocketChannel sock = fd . accept ( ) ; if ( ! options . tcpAcceptFilters . isEmpty ( ) ) { boolean matched = false ; for ( TcpAddress . TcpAddressMask am : options . tcpAcceptFilters ) { if ( am . matchAddress ( address . address ( ) ) ) { ma... | or was denied because of accept filters . |
156,954 | public void attach ( Pipe pipe ) { if ( more ) { pipes . add ( pipe ) ; Collections . swap ( pipes , eligible , pipes . size ( ) - 1 ) ; eligible ++ ; } else { pipes . add ( pipe ) ; Collections . swap ( pipes , active , pipes . size ( ) - 1 ) ; active ++ ; eligible ++ ; } } | Adds the pipe to the distributor object . |
156,955 | public void match ( Pipe pipe ) { int idx = pipes . indexOf ( pipe ) ; if ( idx < matching ) { return ; } if ( idx >= eligible ) { return ; } Collections . swap ( pipes , idx , matching ) ; matching ++ ; } | will send message also to this pipe . |
156,956 | public void terminated ( Pipe pipe ) { if ( pipes . indexOf ( pipe ) < matching ) { Collections . swap ( pipes , pipes . indexOf ( pipe ) , matching - 1 ) ; matching -- ; } if ( pipes . indexOf ( pipe ) < active ) { Collections . swap ( pipes , pipes . indexOf ( pipe ) , active - 1 ) ; active -- ; } if ( pipes . indexO... | Removes the pipe from the distributor object . |
156,957 | public void activated ( Pipe pipe ) { Collections . swap ( pipes , pipes . indexOf ( pipe ) , eligible ) ; eligible ++ ; if ( ! more ) { Collections . swap ( pipes , eligible - 1 , active ) ; active ++ ; } } | Activates pipe that have previously reached high watermark . |
156,958 | public boolean sendToMatching ( Msg msg ) { boolean msgMore = msg . hasMore ( ) ; distribute ( msg ) ; if ( ! msgMore ) { active = eligible ; } more = msgMore ; return true ; } | Send the message to the matching outbound pipes . |
156,959 | private void distribute ( Msg msg ) { if ( matching == 0 ) { return ; } for ( int idx = 0 ; idx < matching ; ++ idx ) { if ( ! write ( pipes . get ( idx ) , msg ) ) { -- idx ; } } } | Put the message to all active pipes . |
156,960 | private boolean write ( Pipe pipe , Msg msg ) { if ( ! pipe . write ( msg ) ) { Collections . swap ( pipes , pipes . indexOf ( pipe ) , matching - 1 ) ; matching -- ; Collections . swap ( pipes , pipes . indexOf ( pipe ) , active - 1 ) ; active -- ; Collections . swap ( pipes , active , eligible - 1 ) ; eligible -- ; r... | fails . In such a case false is returned . |
156,961 | public final boolean register ( final SelectableChannel channel , final EventsHandler handler ) { return register ( channel , handler , IN | OUT | ERR ) ; } | Registers a SelectableChannel for polling on all events . |
156,962 | public final boolean unregister ( final Object socketOrChannel ) { if ( socketOrChannel == null ) { return false ; } CompositePollItem items = this . items . remove ( socketOrChannel ) ; boolean rc = items != null ; if ( rc ) { all . remove ( items ) ; } return rc ; } | Unregister a Socket or SelectableChannel for polling on the specified events . |
156,963 | protected int poll ( final long timeout , final boolean dispatchEvents ) { final Set < PollItem > pollItems = new HashSet < > ( ) ; for ( CompositePollItem it : all ) { pollItems . add ( it . item ( ) ) ; } final int rc = poll ( selector , timeout , pollItems ) ; if ( ! dispatchEvents ) { return rc ; } if ( dispatch ( ... | Issue a poll call using the specified timeout value . |
156,964 | protected int poll ( final Selector selector , final long tout , final Collection < zmq . poll . PollItem > items ) { final int size = items . size ( ) ; return zmq . ZMQ . poll ( selector , items . toArray ( new PollItem [ size ] ) , size , tout ) ; } | does the effective polling |
156,965 | protected boolean dispatch ( final Collection < ? extends ItemHolder > all , int size ) { ItemHolder [ ] array = all . toArray ( new ItemHolder [ all . size ( ) ] ) ; for ( ItemHolder holder : array ) { EventsHandler handler = holder . handler ( ) ; if ( handler == null ) { handler = globalHandler ; } if ( handler == n... | Dispatches the polled events . |
156,966 | public boolean readable ( final Object socketOrChannel ) { final PollItem it = filter ( socketOrChannel , READABLE ) ; if ( it == null ) { return false ; } return it . isReadable ( ) ; } | checks for read event |
156,967 | public boolean writable ( final Object socketOrChannel ) { final PollItem it = filter ( socketOrChannel , WRITABLE ) ; if ( it == null ) { return false ; } return it . isWritable ( ) ; } | checks for write event |
156,968 | public boolean error ( final Object socketOrChannel ) { final PollItem it = filter ( socketOrChannel , ERR ) ; if ( it == null ) { return false ; } return it . isError ( ) ; } | checks for error event |
156,969 | protected boolean add ( Object socketOrChannel , final ItemHolder holder ) { if ( socketOrChannel == null ) { Socket socket = holder . socket ( ) ; SelectableChannel ch = holder . item ( ) . getRawSocket ( ) ; if ( ch == null ) { assert ( socket != null ) ; socketOrChannel = socket ; } else if ( socket == null ) { sock... | add an item to this poller |
156,970 | protected Collection < ? extends ItemHolder > items ( ) { for ( CompositePollItem item : all ) { item . handler ( globalHandler ) ; } return all ; } | gets all the items of this poller |
156,971 | protected Iterable < ItemHolder > items ( final Object socketOrChannel ) { final CompositePollItem aggregate = items . get ( socketOrChannel ) ; if ( aggregate == null ) { return Collections . emptySet ( ) ; } return aggregate . holders ; } | gets all the items of this poller regarding the given input |
156,972 | protected PollItem filter ( final Object socketOrChannel , int events ) { if ( socketOrChannel == null ) { return null ; } CompositePollItem item = items . get ( socketOrChannel ) ; if ( item == null ) { return null ; } PollItem pollItem = item . item ( ) ; if ( pollItem == null ) { return null ; } if ( pollItem . hasE... | filters items to get the first one matching the criteria or null if none found |
156,973 | public String getShortString ( ) { String value = Wire . getShortString ( needle , needle . position ( ) ) ; forward ( value . length ( ) + 1 ) ; return value ; } | Get a string from the frame |
156,974 | public String getLongString ( ) { String value = Wire . getLongString ( needle , needle . position ( ) ) ; forward ( value . length ( ) + 4 ) ; return value ; } | Get a long string from the frame |
156,975 | public void putList ( Collection < String > elements ) { if ( elements == null ) { putNumber1 ( 0 ) ; } else { Utils . checkArgument ( elements . size ( ) < 256 , "Collection has to be smaller than 256 elements" ) ; putNumber1 ( elements . size ( ) ) ; for ( String string : elements ) { putString ( string ) ; } } } | Put a collection of strings to the frame |
156,976 | public void putMap ( Map < String , String > map ) { if ( map == null ) { putNumber1 ( 0 ) ; } else { Utils . checkArgument ( map . size ( ) < 256 , "Map has to be smaller than 256 elements" ) ; putNumber1 ( map . size ( ) ) ; for ( Entry < String , String > entry : map . entrySet ( ) ) { if ( entry . getKey ( ) . cont... | Put a map of strings to the frame |
156,977 | public void push ( T val ) { backChunk . values [ backPos ] = val ; backChunk = endChunk ; backPos = endPos ; if ( ++ endPos != size ) { return ; } Chunk < T > sc = spareChunk ; if ( sc != beginChunk ) { spareChunk = spareChunk . next ; endChunk . next = sc ; sc . prev = endChunk ; } else { endChunk . next = new Chunk ... | Adds an element to the back end of the queue . |
156,978 | public void unpush ( ) { if ( backPos > 0 ) { -- backPos ; } else { backPos = size - 1 ; backChunk = backChunk . prev ; } if ( endPos > 0 ) { -- endPos ; } else { endPos = size - 1 ; endChunk = endChunk . prev ; endChunk . next = null ; } } | unsynchronised thread . |
156,979 | public T pop ( ) { T val = beginChunk . values [ beginPos ] ; beginChunk . values [ beginPos ] = null ; beginPos ++ ; if ( beginPos == size ) { beginChunk = beginChunk . next ; beginChunk . prev = null ; beginPos = 0 ; } return val ; } | Removes an element from the front end of the queue . |
156,980 | private void rebuild ( ) { pollact = null ; pollSize = pollers . size ( ) ; if ( pollset != null ) { pollset . close ( ) ; } pollset = context . poller ( pollSize ) ; assert ( pollset != null ) ; pollact = new SPoller [ pollSize ] ; int itemNbr = 0 ; for ( SPoller poller : pollers ) { pollset . register ( poller . item... | activity on pollers . Returns 0 on success - 1 on failure . |
156,981 | public int addPoller ( PollItem pollItem , IZLoopHandler handler , Object arg ) { if ( pollItem . getRawSocket ( ) == null && pollItem . getSocket ( ) == null ) { return - 1 ; } SPoller poller = new SPoller ( pollItem , handler , arg ) ; pollers . add ( poller ) ; dirty = true ; if ( verbose ) { System . out . printf (... | corresponding handler . |
156,982 | public int removeTimer ( Object arg ) { Objects . requireNonNull ( arg , "Argument has to be supplied" ) ; zombies . add ( arg ) ; if ( verbose ) { System . out . printf ( "I: zloop: cancel timer\n" ) ; } return 0 ; } | Returns 0 on success . |
156,983 | public ANRWatchDog setANRListener ( ANRListener listener ) { if ( listener == null ) { _anrListener = DEFAULT_ANR_LISTENER ; } else { _anrListener = listener ; } return this ; } | Sets an interface for when an ANR is detected . If not set the default behavior is to throw an error and crash the application . |
156,984 | public ANRWatchDog setANRInterceptor ( ANRInterceptor interceptor ) { if ( interceptor == null ) { _anrInterceptor = DEFAULT_ANR_INTERCEPTOR ; } else { _anrInterceptor = interceptor ; } return this ; } | Sets an interface to intercept ANRs before they are reported . If set you can define if given the current duration of the detected ANR and external context it is necessary to report the ANR . |
156,985 | public ANRWatchDog setInterruptionListener ( InterruptionListener listener ) { if ( listener == null ) { _interruptionListener = DEFAULT_INTERRUPTION_LISTENER ; } else { _interruptionListener = listener ; } return this ; } | Sets an interface for when the watchdog thread is interrupted . If not set the default behavior is to just log the interruption message . |
156,986 | private static Type processTypeForDescendantLookup ( Type type ) { if ( type instanceof ParameterizedType ) { return ( ( ParameterizedType ) type ) . getRawType ( ) ; } else { return type ; } } | Given a type returns the type that should be used for the purpose of looking up implementations of that type . |
156,987 | private static < T > Stream < T > generateStream ( T seed , Predicate < ? super T > hasNext , UnaryOperator < T > next ) { final Spliterator < T > spliterator = Spliterators . spliteratorUnknownSize ( new Iterator < T > ( ) { private T last = seed ; public boolean hasNext ( ) { return hasNext . test ( last ) ; } public... | remove on Java 9 and replace with Stream . iterate |
156,988 | private static Set < TsBeanModel > writeBeanAndParentsFieldSpecs ( Writer writer , Settings settings , TsModel model , Set < TsBeanModel > emittedSoFar , TsBeanModel bean ) { if ( emittedSoFar . contains ( bean ) ) { return new HashSet < > ( ) ; } final TsBeanModel parentBean = getBeanModelByType ( model , bean . getPa... | Emits a bean and its parent beans before if needed . Returns the list of beans that were emitted . |
156,989 | private static boolean isOriginalTsType ( TsType type ) { if ( type instanceof TsType . BasicType ) { TsType . BasicType basicType = ( TsType . BasicType ) type ; return ! ( basicType . name . equals ( "null" ) || basicType . name . equals ( "undefined" ) ) ; } return true ; } | is this type an original TS type or a contextual information? null undefined and optional info are not original types everything else is original |
156,990 | private static TsType extractOriginalTsType ( TsType type ) { if ( type instanceof TsType . OptionalType ) { return extractOriginalTsType ( ( ( TsType . OptionalType ) type ) . type ) ; } if ( type instanceof TsType . UnionType ) { TsType . UnionType union = ( TsType . UnionType ) type ; List < TsType > originalTypes =... | If the type is optional of number|null|undefined or list of of integer we want to be able to recognize it as number to link the member to another class . = > extract the original type while ignoring the |null|undefined and optional informations . |
156,991 | public static int findUnlinked ( int pos , int end , DBIDArrayIter ix , PointerHierarchyRepresentationBuilder builder ) { while ( pos < end ) { if ( ! builder . isLinked ( ix . seek ( pos ) ) ) { return pos ; } ++ pos ; } return - 1 ; } | Find an unlinked object . |
156,992 | private DoubleObjPair < Polygon > buildHullsRecursively ( Cluster < Model > clu , Hierarchy < Cluster < Model > > hier , Map < Object , DoubleObjPair < Polygon > > hulls , Relation < ? extends NumberVector > coords ) { final DBIDs ids = clu . getIDs ( ) ; FilteredConvexHull2D hull = new FilteredConvexHull2D ( ) ; for (... | Recursively step through the clusters to build the hulls . |
156,993 | public static final Color getColorForValue ( double val ) { double [ ] pos = new double [ ] { 0.0 , 0.6 , 0.8 , 1.0 } ; Color [ ] cols = new Color [ ] { new Color ( 0.0f , 0.0f , 0.0f , 0.6f ) , new Color ( 0.0f , 0.0f , 1.0f , 0.8f ) , new Color ( 1.0f , 0.0f , 0.0f , 0.9f ) , new Color ( 1.0f , 1.0f , 0.0f , 1.0f ) }... | Get color from a simple heatmap . |
156,994 | public static int showSaveDialog ( SVGPlot plot , int width , int height ) { JFileChooser fc = new JFileChooser ( new File ( "." ) ) ; fc . setDialogTitle ( DEFAULT_TITLE ) ; SaveOptionsPanel optionsPanel = new SaveOptionsPanel ( fc , width , height ) ; fc . setAccessory ( optionsPanel ) ; int ret = fc . showSaveDialog... | Show a Save as dialog . |
156,995 | public static String guessFormat ( String name ) { String ext = FileUtil . getFilenameExtension ( name ) ; for ( String format : FORMATS ) { if ( format . equalsIgnoreCase ( ext ) ) { return ext ; } } return null ; } | Guess a supported format from the file name . For auto format handling . |
156,996 | @ SuppressWarnings ( "unchecked" ) public static < F > FeatureVectorAdapter < F > featureVectorAdapter ( FeatureVector < F > prototype ) { return ( FeatureVectorAdapter < F > ) FEATUREVECTORADAPTER ; } | Get the static instance . |
156,997 | public static < A > int getIndexOfMaximum ( A array , NumberArrayAdapter < ? , A > adapter ) throws IndexOutOfBoundsException { final int size = adapter . size ( array ) ; int index = 0 ; double max = adapter . getDouble ( array , 0 ) ; for ( int i = 1 ; i < size ; i ++ ) { double val = adapter . getDouble ( array , i ... | Returns the index of the maximum of the given values . If no value is bigger than the first the index of the first entry is returned . |
156,998 | public byte [ ] asByteArray ( NumberVector vector ) { final long [ ] longValueList = new long [ dimensionality ] ; for ( int dim = 0 ; dim < dimensionality ; ++ dim ) { final double minValue = minValues [ dim ] ; final double maxValue = maxValues [ dim ] ; double dimValue = vector . doubleValue ( dim ) ; dimValue = ( d... | Transform a single vector . |
156,999 | public OutlierResult run ( Relation < V > relation ) { SimilarityQuery < V > snnInstance = similarityFunction . instantiate ( relation ) ; FiniteProgress progress = LOG . isVerbose ( ) ? new FiniteProgress ( "Assigning Subspace Outlier Degree" , relation . size ( ) , LOG ) : null ; WritableDoubleDataStore sod_scores = ... | Performs the SOD algorithm on the given database . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.