idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
2,900 | static String toPattern ( String pos1 , String rel , String pos2 ) { return pos1 + ":" + rel + ":" + pos2 ; } | Returns the pattern string for the provided parts of speech and relation . |
2,901 | private int computePk1Measure ( double [ ] objectiveScores , double pk1Threshold ) { LOGGER . fine ( "Computing the PK1 measure" ) ; double average = 0 ; for ( int k = 0 ; k < objectiveScores . length ; ++ k ) average += objectiveScores [ k ] ; average /= objectiveScores . length ; double stdev = 0 ; for ( int k = 0 ; ... | Compute the smallest k that satisfies the Pk1 method . |
2,902 | private int computePk2Measure ( double [ ] objectiveScores ) { LOGGER . fine ( "Computing the PK2 measure" ) ; double average = 0 ; for ( int k = objectiveScores . length - 1 ; k > 0 ; -- k ) { objectiveScores [ k ] /= objectiveScores [ k - 1 ] ; average += objectiveScores [ k ] ; } average /= ( objectiveScores . lengt... | Compute the smallest k that satisfies the Pk3 method . |
2,903 | private double extractScore ( String clutoOutput ) throws IOException { double score = 0 ; BufferedReader reader = new BufferedReader ( new StringReader ( clutoOutput ) ) ; String line = null ; while ( ( line = reader . readLine ( ) ) != null ) { if ( line . contains ( "[I2=" ) ) { String [ ] split = line . split ( "="... | Extracts the score of the objective function for a given set of clustering assignments . This requires scraping the output from Cluto to find the line specifiying the score . |
2,904 | protected ArgOptions setupOptions ( ) { ArgOptions options = new ArgOptions ( ) ; options . addOption ( 'c' , "corpusDir" , "the directory of the corpus" , true , "DIR" , "Required" ) ; options . addOption ( 'a' , "analogyFile" , "the file containing list of word pairs" , true , "FILE" , "Required" ) ; options . addOpt... | Adds the default options for running semantic space algorithms from the command line . Subclasses should override this method and return a different instance if the default options need to be different . |
2,905 | public static synchronized DependencyExtractor getExtractor ( String name ) { DependencyExtractor e = nameToExtractor . get ( name ) ; if ( e == null ) throw new IllegalArgumentException ( "No extactor with name " + name ) ; return e ; } | Returns the extractor with the specified name . The name typically refers to the parser that generated the output files that the extractor can read . |
2,906 | public double count ( T obj ) { double count = counts . get ( obj ) ; count ++ ; counts . put ( obj , count ) ; sum ++ ; return count ; } | Counts the object increasing its total count by 1 . |
2,907 | public Iterator < Map . Entry < T , Double > > iterator ( ) { return Collections . unmodifiableSet ( TDecorators . wrap ( counts ) . entrySet ( ) ) . iterator ( ) ; } | Returns an interator over the elements that have been counted thusfar and their respective counts . |
2,908 | private static double distanceSum ( double [ ] distances ) { double sum = 0 ; for ( double distance : distances ) sum += Math . pow ( distance , 2 ) ; return sum ; } | Returns the sum of distances squared . |
2,909 | private boolean advance ( int tokens ) { while ( buffer . size ( ) < tokens && tokenizer . hasNext ( ) ) buffer . add ( tokenizer . next ( ) ) ; return buffer . size ( ) >= tokens ; } | Advances the specified number of tokens in the stream and places them in the buffer . |
2,910 | public static void initializeIndex ( String indexDir , String dataDir ) { File indexDir_f = new File ( indexDir ) ; File dataDir_f = new File ( dataDir ) ; long start = new Date ( ) . getTime ( ) ; try { int numIndexed = index ( indexDir_f , dataDir_f ) ; long end = new Date ( ) . getTime ( ) ; System . err . println (... | Initializes an index given the index directory and data directory . |
2,911 | private static int index ( File indexDir , File dataDir ) throws IOException { if ( ! dataDir . exists ( ) || ! dataDir . isDirectory ( ) ) { throw new IOException ( dataDir + " does not exist or is not a directory" ) ; } IndexWriter writer = new IndexWriter ( indexDir , new StandardAnalyzer ( ) , true , IndexWriter . ... | creates the index files |
2,912 | private static HashSet < String > searchDirectoryForPattern ( File dir , String A , String B ) throws Exception { File [ ] files = dir . listFiles ( ) ; HashSet < String > pattern_set = new HashSet < String > ( ) ; for ( int i = 0 ; i < files . length ; i ++ ) { File f = files [ i ] ; if ( f . isDirectory ( ) ) { patte... | recursive method that finds interleving patterns between A and B in all files within a given directory |
2,913 | private static void indexDirectory ( IndexWriter writer , File dir ) throws IOException { File [ ] files = dir . listFiles ( ) ; for ( int i = 0 ; i < files . length ; i ++ ) { File f = files [ i ] ; if ( f . isDirectory ( ) ) { indexDirectory ( writer , f ) ; } else if ( f . getName ( ) . endsWith ( ".txt" ) ) { index... | recursive method that calls itself when it finds a directory or indexes if it is at a file ending in . txt |
2,914 | private static void indexFile ( IndexWriter writer , File f ) throws IOException { if ( f . isHidden ( ) || ! f . exists ( ) || ! f . canRead ( ) ) { System . err . println ( "Could not write " + f . getName ( ) ) ; return ; } System . err . println ( "Indexing " + f . getCanonicalPath ( ) ) ; Document doc = new Docume... | method to actually index a file using Lucene adds a document onto the index writer |
2,915 | public static float countPhraseFrequencies ( String indexDir , String A , String B ) { File indexDir_f = new File ( indexDir ) ; if ( ! indexDir_f . exists ( ) || ! indexDir_f . isDirectory ( ) ) { System . err . println ( "Search failed: index directory does not exist" ) ; } else { try { return searchPhrase ( indexDir... | Searches an index given the index directory and counts up the frequncy of the two words used in a phrase . |
2,916 | private static float searchPhrase ( File indexDir , String A , String B ) throws Exception { Directory fsDir = FSDirectory . getDirectory ( indexDir ) ; IndexSearcher searcher = new IndexSearcher ( fsDir ) ; long start = new Date ( ) . getTime ( ) ; QueryParser parser = new QueryParser ( "contents" , new StandardAnalyz... | method that actually does the searching |
2,917 | private static String combinatorialPatternMaker ( String [ ] str , int str_size , int c ) { String comb_pattern = "" ; int curr_comb = 1 ; for ( int i = 0 ; i < str_size ; i ++ ) { if ( ( c & curr_comb ) != 0 ) { comb_pattern += str [ i ] + "\\s" ; } else { comb_pattern += "[\\w]+\\s" ; } curr_comb = curr_comb << 1 ; }... | Makes patterns by replacing words in str with wildcards based on the binary value of c . |
2,918 | private static int countWildcardPhraseFrequencies ( File dir , String pattern ) throws Exception { File [ ] files = dir . listFiles ( ) ; int total = 0 ; for ( int i = 0 ; i < files . length ; i ++ ) { File f = files [ i ] ; if ( f . isDirectory ( ) ) { total += countWildcardPhraseFrequencies ( f , pattern ) ; } else i... | Searches through all the . txt files in a directory and returns the total number of occurrences of a pattern . |
2,919 | private static int getIndexOfPair ( String value , Map < Integer , String > row_data ) { for ( Integer i : row_data . keySet ( ) ) { if ( row_data . get ( i ) . equals ( value ) ) { return i . intValue ( ) ; } } return - 1 ; } | returns the index of the String in the HashMap or - 1 if value was not found . |
2,920 | public Matrix computeSVD ( Matrix sparse_matrix , int dimensions ) { try { File rawTermDocMatrix = File . createTempFile ( "lra-term-document-matrix" , ".dat" ) ; MatrixIO . writeMatrix ( sparse_matrix , rawTermDocMatrix , MatrixIO . Format . SVDLIBC_SPARSE_TEXT ) ; MatrixFile mFile = new MatrixFile ( rawTermDocMatrix ... | Does the Singular Value Decomposition using the generated sparse matrix . The dimensions used cannot exceed the number of columns in the original matrix . |
2,921 | public void evaluateAnalogies ( Matrix projection , String inputFileName , String outputFileName ) { try { Scanner sc = new Scanner ( new File ( inputFileName ) ) ; PrintStream out = new PrintStream ( new FileOutputStream ( outputFileName ) ) ; while ( sc . hasNext ( ) ) { String analogy = sc . next ( ) ; if ( ! isAnal... | Reads analogies from file and outputs their cosine similarities to another file . |
2,922 | public void evaluateAnalogies ( Matrix projection ) { try { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { String analogy = sc . next ( ) ; if ( ! isAnalogyFormat ( analogy , true ) ) { System . err . println ( "\"" + analogy + "\" not in proper format." ) ; continue ; } double cosineVal = comp... | Reads analogies from Standard In and outputs their cosine similarities to Standard Out . |
2,923 | private void loadOffsetsFromFormat ( File file , SSpaceFormat format ) throws IOException { this . format = format ; spaceName = file . getName ( ) ; termToOffset = new LinkedHashMap < String , Long > ( ) ; long start = System . currentTimeMillis ( ) ; int dims = - 1 ; RandomAccessFile raf = null ; RandomAccessBuffered... | Loads the words and offets for each word s vector in the semantic space file using the format as a guide to how the semantic space data is stored in the file . |
2,924 | private < E extends WeightedEdge > SparseDoubleVector getVertexWeightVector ( WeightedGraph < E > g , int vertex ) { if ( keepWeightVectors ) { SparseDoubleVector weightVec = vertexToWeightVector . get ( vertex ) ; if ( weightVec == null ) { synchronized ( this ) { weightVec = vertexToWeightVector . get ( vertex ) ; if... | Returns the normalized weight vector for the specified row to be used in edge comparisons . The weight vector is normalized by the number of edges from the row with positive weights and includes a weight for the row to itself which reflects the similarity of the keystone nod . |
2,925 | private void process ( Iterator < String > tokens ) { long numTokens = 0 ; while ( tokens . hasNext ( ) ) { String token = tokens . next ( ) ; if ( doLowerCasing ) token = token . toLowerCase ( ) ; if ( token . matches ( "[0-9]+" ) ) token = "<NUM>" ; if ( token . matches ( "[^\\w\\s;:\\(\\)\\[\\]'!/&?\",\\.<>]" ) ) co... | Counts all of the tokens in the iterator |
2,926 | public void setCurrent ( String value ) { current . replace ( 0 , current . length ( ) , value ) ; cursor = 0 ; limit = current . length ( ) ; limit_backward = 0 ; bra = cursor ; ket = limit ; } | Set the current string . |
2,927 | private TernaryVector getTermIndexVector ( String term ) { TernaryVector iv = termToIndexVector . get ( term ) ; if ( iv == null ) { synchronized ( this ) { iv = termToIndexVector . get ( term ) ; if ( iv == null ) { termToIndex . put ( term , termIndexCounter ++ ) ; termToReflectiveSemantics . put ( term , createVecto... | Returns the index vector for the term or if creates one if the term to index vector mapping does not yet exist . |
2,928 | private void processSpace ( ) throws IOException { LOGGER . info ( "generating reflective vectors" ) ; compressedDocumentsWriter . close ( ) ; int numDocuments = documentCounter . get ( ) ; termToIndexVector . clear ( ) ; indexToTerm = new String [ termToIndex . size ( ) ] ; for ( Map . Entry < String , Integer > e : t... | Computes the reflective semantic vectors for word meanings |
2,929 | private void processIntDocument ( IntegerVector docVector , int [ ] document ) { for ( int termIndex : document ) { IntegerVector reflectiveVector = termToReflectiveSemantics . get ( indexToTerm [ termIndex ] ) ; synchronized ( reflectiveVector ) { VectorMath . add ( reflectiveVector , docVector ) ; } } } | Processes the compressed version of a document where each integer indicates that token s index adding the document s vector to the reflective semantic vector each time a term occurs in the document . |
2,930 | public static Iterator < MatrixEntry > getMatrixFileIterator ( File matrixFile , Format fileFormat ) throws IOException { switch ( fileFormat ) { case DENSE_TEXT : return new DenseTextFileIterator ( matrixFile ) ; case SVDLIBC_SPARSE_BINARY : return new SvdlibcSparseBinaryFileIterator ( matrixFile ) ; case SVDLIBC_SPAR... | Returns an iterator over the matrix entries in the data file . For sparse formats that specify only non - zero no zero valued entries will be returened . Conversely for dense matrix formats all of the entries including zero entries will be returned . |
2,931 | private int getDimension ( PathSignature path ) { Integer index = pathToIndex . get ( path ) ; if ( index == null && ! readOnly ) { synchronized ( this ) { index = pathToIndex . get ( path ) ; if ( index == null ) { int i = pathToIndex . size ( ) ; pathToIndex . put ( path , i ) ; return i ; } } } return index ; } | Returns the dimension represention the occurrence of the provided path . If the path was not previously assigned an index this method adds one for it and returns that index . |
2,932 | public BufferedReader open ( String fileName ) throws IOException { Path filePath = new Path ( fileName ) ; if ( ! hadoopFs . exists ( filePath ) ) { throw new IOException ( fileName + " does not exist in HDFS" ) ; } BufferedReader br = new BufferedReader ( new InputStreamReader ( hadoopFs . open ( filePath ) ) ) ; ret... | Finds the file with the specified name and returns a reader for that files contents . |
2,933 | static Matrix [ ] svdlibc ( File matrix , int dimensions , Format format ) { try { String formatString = "" ; switch ( format ) { case SVDLIBC_DENSE_BINARY : formatString = " -r db " ; break ; case SVDLIBC_DENSE_TEXT : formatString = " -r dt " ; break ; case SVDLIBC_SPARSE_BINARY : formatString = " -r sb " ; break ; ca... | Computes the SVD using SVDLIBC . |
2,934 | static Matrix [ ] matlabSVDS ( File matrix , int dimensions ) { try { File uOutput = File . createTempFile ( "matlab-svds-U" , ".dat" ) ; File sOutput = File . createTempFile ( "matlab-svds-S" , ".dat" ) ; File vOutput = File . createTempFile ( "matlab-svds-V" , ".dat" ) ; if ( SVD_LOGGER . isLoggable ( Level . FINE ) ... | Computes the SVD using Matlab . |
2,935 | private static Set < Language > getApplicableLanguages ( PMDConfiguration configuration , RuleSets ruleSets ) { Set < Language > languages = new HashSet < > ( ) ; LanguageVersionDiscoverer discoverer = configuration . getLanguageVersionDiscoverer ( ) ; for ( Rule rule : ruleSets . getAllRules ( ) ) { Language language ... | Paste from PMD |
2,936 | public ReviewResult parseResults ( ) throws IOException { ReviewResult result = new ReviewResult ( ) ; ObjectMapper mapper = new ObjectMapper ( ) ; JsonNode rootNode = mapper . readTree ( new FileReader ( resultFile ) ) ; JsonNode issues = rootNode . path ( "issues" ) ; Iterator < JsonNode > issuesIterator = issues . i... | Parses the file and returns all the issues as a ReviewResult . |
2,937 | static Severity getSeverity ( String severityName ) { switch ( severityName ) { case "BLOCKER" : case "CRITICAL" : case "MAJOR" : return Severity . ERROR ; case "MINOR" : return Severity . WARNING ; case "INFO" : return Severity . INFO ; default : log . warn ( "Unknown severity: " + severityName ) ; } return Severity .... | Converts a Sonar severity to a Sputnik severity . |
2,938 | private Map < String , Component > getComponents ( JsonNode componentsNode ) { Iterator < JsonNode > it = componentsNode . iterator ( ) ; Map < String , Component > components = Maps . newHashMap ( ) ; while ( it . hasNext ( ) ) { JsonNode componentNode = it . next ( ) ; JsonNode pathNode = componentNode . path ( "path... | Extracts all the components from the json data . |
2,939 | private String getIssueFilePath ( String issueComponent , Map < String , Component > components ) { Component comp = components . get ( issueComponent ) ; String file = comp . path ; if ( ! Strings . isNullOrEmpty ( comp . moduleKey ) ) { String theKey = comp . moduleKey ; while ( ! theKey . isEmpty ( ) ) { Component t... | Returns the path of the file linked to an issue created by Sonar . The path is relative to the folder where Sonar has been run . |
2,940 | public String reviewFile ( String filePath ) { log . info ( "Reviewing file: " + filePath ) ; String [ ] args = new String [ ] { NODE_JS , tsScript , TS_LINT_OUTPUT_KEY , TS_LINT_OUTPUT_VALUE , TS_LINT_CONFIG_PARAM , configFile , filePath } ; return new ExternalProcess ( ) . executeCommand ( args ) ; } | Executes TSLint to look for violations . |
2,941 | public File run ( ) throws IOException { Map < String , String > props = loadBaseProperties ( ) ; setAdditionalProperties ( props ) ; sonarEmbeddedScanner . addGlobalProperties ( props ) ; log . info ( "Sonar configuration: {}" , props . toString ( ) ) ; sonarEmbeddedScanner . start ( ) ; sonarEmbeddedScanner . execute... | Runs Sonar . |
2,942 | public Collection < BitfinexWallet > getWallets ( ) throws BitfinexClientException { throwExceptionIfUnauthenticated ( ) ; synchronized ( walletTable ) { return Collections . unmodifiableCollection ( walletTable . values ( ) ) ; } } | Get all wallets |
2,943 | public boolean removeOrderbookCallback ( final BitfinexOrderBookSymbol symbol , final BiConsumer < BitfinexOrderBookSymbol , BitfinexOrderBookEntry > callback ) throws BitfinexClientException { return channelCallbacks . removeCallback ( symbol , callback ) ; } | Remove the a trading orderbook callback |
2,944 | private boolean checkTickerFreshness ( ) { final QuoteManager quoteManager = bitfinexApiBroker . getQuoteManager ( ) ; final Map < BitfinexStreamSymbol , Long > heartbeatValues = quoteManager . getLastTickerActivity ( ) ; return checkTickerFreshness ( heartbeatValues ) ; } | Are all tickers up - to - date |
2,945 | private void sendHeartbeatIfNeeded ( ) { final long nextHeartbeat = lastHeartbeatSupplier . get ( ) + HEARTBEAT ; if ( nextHeartbeat < System . currentTimeMillis ( ) ) { logger . debug ( "Send heartbeat" ) ; bitfinexApiBroker . sendCommand ( new PingCommand ( ) ) ; } } | Send a heartbeat package on the connection |
2,946 | private void executeReconnect ( ) throws InterruptedException { websocketEndpoint . close ( ) ; logger . info ( "Wait for next reconnect timeslot" ) ; eventsInTimeslotManager . recordNewEvent ( ) ; eventsInTimeslotManager . waitForNewTimeslot ( ) ; logger . info ( "Wait for next reconnect timeslot DONE" ) ; bitfinexApi... | Execute the reconnect |
2,947 | public void recordNewEvent ( ) { final double thresholdTime = System . currentTimeMillis ( ) - ( timeslotInMilliseconds * 2.0 ) ; events . removeIf ( e -> e < thresholdTime ) ; events . add ( System . currentTimeMillis ( ) ) ; } | Record a new event |
2,948 | public boolean waitForNewTimeslot ( ) throws InterruptedException { boolean hasWaited = false ; while ( true ) { final long numberOfEventsInTimeSlot = getNumberOfEventsInTimeslot ( ) ; if ( numberOfEventsInTimeSlot > numberOfEvents ) { hasWaited = true ; Thread . sleep ( timeslotInMilliseconds / 10 ) ; } else { return ... | Wait for a new timeslot |
2,949 | public long getNumberOfEventsInTimeslot ( ) { final double thresholdTime = System . currentTimeMillis ( ) - ( timeslotInMilliseconds ) ; return events . stream ( ) . filter ( e -> e >= thresholdTime ) . count ( ) ; } | Get the number of events in the timeslot |
2,950 | public static BitfinexCandlestickSymbol fromBitfinexString ( final String symbol ) { if ( ! symbol . startsWith ( "trade:" ) ) { throw new IllegalArgumentException ( "Unable to parse: " + symbol ) ; } final String [ ] splitString = symbol . split ( ":" ) ; if ( splitString . length != 3 ) { throw new IllegalArgumentExc... | Construct from Bitfinex string |
2,951 | public Closeable onConnectionStateChange ( final Consumer < BitfinexConnectionStateEnum > listener ) { connectionStateConsumers . offer ( listener ) ; return ( ) -> connectionStateConsumers . remove ( listener ) ; } | registers listener for notifications on connection state |
2,952 | public Closeable onSubscribeChannelEvent ( final Consumer < BitfinexStreamSymbol > listener ) { subscribeChannelConsumers . offer ( listener ) ; return ( ) -> subscribeChannelConsumers . remove ( listener ) ; } | registers listener for subscribe events |
2,953 | public Closeable onUnsubscribeChannelEvent ( final Consumer < BitfinexStreamSymbol > listener ) { unsubscribeChannelConsumers . offer ( listener ) ; return ( ) -> unsubscribeChannelConsumers . remove ( listener ) ; } | registers listener for unsubscribe events |
2,954 | public Closeable onMyOrderNotification ( final BiConsumer < BitfinexAccountSymbol , BitfinexSubmittedOrder > listener ) { newOrderConsumers . offer ( listener ) ; return ( ) -> newOrderConsumers . remove ( listener ) ; } | registers listener for my order notifications |
2,955 | public Closeable onMySubmittedOrderEvent ( final BiConsumer < BitfinexAccountSymbol , Collection < BitfinexSubmittedOrder > > listener ) { submittedOrderConsumers . offer ( listener ) ; return ( ) -> submittedOrderConsumers . remove ( listener ) ; } | registers listener for user account related events - submitted order events |
2,956 | public Closeable onMyPositionEvent ( final BiConsumer < BitfinexAccountSymbol , Collection < BitfinexPosition > > listener ) { positionConsumers . offer ( listener ) ; return ( ) -> positionConsumers . remove ( listener ) ; } | registers listener for user account related events - position events |
2,957 | public Closeable onMyWalletEvent ( final BiConsumer < BitfinexAccountSymbol , Collection < BitfinexWallet > > listener ) { walletConsumers . offer ( listener ) ; return ( ) -> walletConsumers . remove ( listener ) ; } | registers listener for user account related events - wallet change events |
2,958 | public Closeable onCandlesticksEvent ( final BiConsumer < BitfinexCandlestickSymbol , Collection < BitfinexCandle > > listener ) { candlesConsumers . offer ( listener ) ; return ( ) -> candlesConsumers . remove ( listener ) ; } | registers listener for candlesticks info updates |
2,959 | public Closeable onOrderbookEvent ( final BiConsumer < BitfinexOrderBookSymbol , Collection < BitfinexOrderBookEntry > > listener ) { orderbookEntryConsumers . offer ( listener ) ; return ( ) -> orderbookEntryConsumers . remove ( listener ) ; } | registers listener for orderbook events |
2,960 | public Closeable onRawOrderbookEvent ( final BiConsumer < BitfinexOrderBookSymbol , Collection < BitfinexOrderBookEntry > > listener ) { rawOrderbookEntryConsumers . offer ( listener ) ; return ( ) -> rawOrderbookEntryConsumers . remove ( listener ) ; } | registers listener for raw orderbook events |
2,961 | public Closeable onTickEvent ( final BiConsumer < BitfinexTickerSymbol , BitfinexTick > listener ) { tickConsumers . offer ( listener ) ; return ( ) -> tickConsumers . remove ( listener ) ; } | registers listener for tick events |
2,962 | public Closeable onAuthenticationSuccessEvent ( final Consumer < BitfinexAccountSymbol > listener ) { authSuccessConsumers . offer ( listener ) ; return ( ) -> authSuccessConsumers . remove ( listener ) ; } | registers listener for event of successful authentication with api - key |
2,963 | public Closeable onAuthenticationFailedEvent ( final Consumer < BitfinexAccountSymbol > listener ) { authFailedConsumers . offer ( listener ) ; return ( ) -> authFailedConsumers . remove ( listener ) ; } | registers listener for event of failed authentication with api - key |
2,964 | public static BitfinexWebsocketClient newPooledClient ( final BitfinexWebsocketConfiguration config , final int channelsPerConnection ) { if ( channelsPerConnection < 10 || channelsPerConnection > 250 ) { throw new IllegalArgumentException ( "channelsPerConnection must be in range (10, 250)" ) ; } final BitfinexApiCall... | bitfinex client with subscribed channel managed . spreads amount of subscribed channels across multiple websocket physical connections . |
2,965 | public void setOrderFlags ( final int flags ) { orderFlags = Arrays . stream ( BitfinexOrderFlag . values ( ) ) . filter ( f -> ( ( f . getFlag ( ) & flags ) == f . getFlag ( ) ) ) . collect ( Collectors . toSet ( ) ) ; } | Convert a flag field into enums |
2,966 | public int getCombinedFlags ( ) { return orderFlags . stream ( ) . map ( BitfinexOrderFlag :: getFlag ) . reduce ( ( f1 , f2 ) -> f1 | f2 ) . orElse ( 0 ) ; } | Convert flag enums to flag field |
2,967 | public static BitfinexOrderBookSymbol rawOrderBook ( final BitfinexCurrencyPair currencyPair ) { return new BitfinexOrderBookSymbol ( currencyPair , BitfinexOrderBookSymbol . Precision . R0 , null , null ) ; } | returns symbol for raw order book channel |
2,968 | public static BitfinexOrderBookSymbol rawOrderBook ( final String currency , final String profitCurrency ) { final String currencyNonNull = Objects . requireNonNull ( currency ) . toUpperCase ( ) ; final String profitCurrencyNonNull = Objects . requireNonNull ( profitCurrency ) . toUpperCase ( ) ; return rawOrderBook (... | Returns symbol for raw order book channel |
2,969 | public static BitfinexOrderBookSymbol orderBook ( final BitfinexCurrencyPair currencyPair , final BitfinexOrderBookSymbol . Precision precision , final BitfinexOrderBookSymbol . Frequency frequency , final int pricePoints ) { if ( precision == BitfinexOrderBookSymbol . Precision . R0 ) { throw new IllegalArgumentExcept... | returns symbol for order book channel |
2,970 | public static BitfinexTickerSymbol ticker ( final String currency , final String profitCurrency ) { final String currencyNonNull = Objects . requireNonNull ( currency ) . toUpperCase ( ) ; final String profitCurrencyNonNull = Objects . requireNonNull ( profitCurrency ) . toUpperCase ( ) ; return ticker ( BitfinexCurren... | returns symbol for ticker channel |
2,971 | public static BitfinexFundingSymbol funding ( final String bitfinexCurrency ) { final String currencyNonNull = Objects . requireNonNull ( bitfinexCurrency ) . toUpperCase ( ) ; final BitfinexFundingCurrency currency = new BitfinexFundingCurrency ( currencyNonNull ) ; return funding ( currency ) ; } | returns symbol for funding |
2,972 | private void setupCommandCallbacks ( ) { commandCallbacks = new HashMap < > ( ) ; commandCallbacks . put ( "info" , new DoNothingCommandCallback ( ) ) ; final ConnectionHeartbeatCallback pong = new ConnectionHeartbeatCallback ( ) ; pong . onHeartbeatEvent ( l -> this . updateConnectionHeartbeat ( ) ) ; commandCallbacks... | Setup the command callbacks |
2,973 | public void connect ( ) throws BitfinexClientException { logger . debug ( "connect() called" ) ; connectionStateChange ( BitfinexConnectionStateEnum . CONNECTION_INIT ) ; try { sequenceNumberAuditor . reset ( ) ; final CountDownLatch connectionReadyLatch = new CountDownLatch ( 4 ) ; final Closeable authSuccessEventCall... | Open the connection |
2,974 | private void setupDefaultAccountInfoHandler ( ) { final BitfinexAccountSymbol accountSymbol = BitfinexSymbols . account ( BitfinexApiKeyPermissions . NO_PERMISSIONS ) ; final AccountInfoHandler accountInfoHandler = new AccountInfoHandler ( ACCCOUNT_INFO_CHANNEL , accountSymbol ) ; accountInfoHandler . onHeartbeatEvent ... | Setup the default info handler - can be replaced in onAuthenticationSuccessEvent |
2,975 | public void close ( ) { try { callbackRegistry . acceptConnectionStateChange ( BitfinexConnectionStateEnum . DISCONNECTION_INIT ) ; logger . debug ( "close() called" ) ; if ( heartbeatThread != null ) { heartbeatThread . interrupt ( ) ; heartbeatThread = null ; } if ( websocketEndpoint != null ) { websocketEndpoint . c... | Disconnect the websocket |
2,976 | public void sendCommand ( final BitfinexCommand command ) { try { if ( command instanceof BitfinexStreamSymbolToChannelIdResolverAware ) { final BitfinexStreamSymbolToChannelIdResolverAware aware = ( BitfinexStreamSymbolToChannelIdResolverAware ) command ; aware . setResolver ( symbol -> { final Integer channelId = get... | Send a new API command |
2,977 | public synchronized boolean reconnect ( ) { logger . debug ( "reconnect() called" ) ; try { callbackRegistry . acceptConnectionStateChange ( BitfinexConnectionStateEnum . RECONNECTION_INIT ) ; websocketEndpoint . close ( ) ; permissions = BitfinexApiKeyPermissions . NO_PERMISSIONS ; authenticated = false ; sequenceNumb... | Perform a reconnect |
2,978 | private void authenticateAndWait ( final CountDownLatch latch ) throws InterruptedException , BitfinexClientException { if ( authenticated ) { return ; } sendCommand ( new AuthCommand ( configuration . getAuthNonceProducer ( ) ) ) ; logger . debug ( "Waiting for connection ready events" ) ; latch . await ( 10 , TimeUni... | Execute the authentication and wait until the socket is ready |
2,979 | private void websocketCallback ( final String message ) { logger . debug ( "Recv: {}" , message ) ; if ( message . startsWith ( "{" ) ) { handleCommandCallback ( message ) ; } else if ( message . startsWith ( "[" ) ) { handleChannelCallback ( message ) ; } else { logger . error ( "Got unknown callback: {}" , message ) ... | We received a websocket callback |
2,980 | private void handleCommandCallback ( final String message ) { final JSONObject jsonObject = new JSONObject ( message ) ; final String eventType = jsonObject . getString ( "event" ) ; final CommandCallbackHandler commandCallbackHandler = commandCallbacks . get ( eventType ) ; if ( commandCallbackHandler == null ) { logg... | Handle a command callback |
2,981 | private void handleChannelCallback ( final String message ) { updateConnectionHeartbeat ( ) ; final JSONArray jsonArray = new JSONArray ( new JSONTokener ( message ) ) ; if ( connectionFeatureManager . isConnectionFeatureActive ( BitfinexConnectionFeature . SEQ_ALL ) ) { sequenceNumberAuditor . auditPackage ( jsonArray... | Handle a channel callback |
2,982 | private Integer getChannelForSymbol ( final BitfinexStreamSymbol symbol ) { synchronized ( channelIdToHandlerMap ) { return channelIdToHandlerMap . values ( ) . stream ( ) . filter ( v -> Objects . equals ( v . getSymbol ( ) , symbol ) ) . map ( ChannelCallbackHandler :: getChannelId ) . findFirst ( ) . orElse ( null )... | Find the channel for the given symbol |
2,983 | private void resubscribeChannels ( ) throws InterruptedException , BitfinexClientException { final Map < Integer , ChannelCallbackHandler > oldChannelIdSymbolMap = new HashMap < > ( ) ; synchronized ( channelIdToHandlerMap ) { oldChannelIdSymbolMap . putAll ( channelIdToHandlerMap ) ; channelIdToHandlerMap . clear ( ) ... | Re - subscribe the old ticker |
2,984 | private void waitForChannelResubscription ( final Map < Integer , ChannelCallbackHandler > oldChannelIdSymbolMap ) throws BitfinexClientException , InterruptedException { final Stopwatch stopwatch = Stopwatch . createStarted ( ) ; final long MAX_WAIT_TIME_IN_MS = TimeUnit . MINUTES . toMillis ( 3 ) ; logger . info ( "W... | Wait for the successful channel re - subscription |
2,985 | private void handleResubscribeFailed ( final Map < Integer , ChannelCallbackHandler > oldChannelIdSymbolMap ) throws BitfinexClientException , InterruptedException { final int requiredSymbols = oldChannelIdSymbolMap . size ( ) ; final int subscribedSymbols = channelIdToHandlerMap . size ( ) ; unsubscribeAllChannels ( )... | Handle channel re - subscribe failed |
2,986 | public void handleEvent ( final BitfinexStreamSymbol symbol ) { final List < FutureOperation > futuresToFinish = pendingFutures . stream ( ) . filter ( f -> f . getSymbol ( ) . equals ( symbol ) ) . collect ( Collectors . toList ( ) ) ; pendingFutures . removeAll ( futuresToFinish ) ; futuresToFinish . forEach ( f -> f... | Handle a subscribe or unsubscribe event |
2,987 | public void registerTickCallback ( final BitfinexTickerSymbol symbol , final BiConsumer < BitfinexTickerSymbol , BitfinexTick > callback ) throws BitfinexClientException { tickerCallbacks . registerCallback ( symbol , callback ) ; } | Register a new tick callback |
2,988 | public boolean removeTickCallback ( final BitfinexTickerSymbol symbol , final BiConsumer < BitfinexTickerSymbol , BitfinexTick > callback ) throws BitfinexClientException { return tickerCallbacks . removeCallback ( symbol , callback ) ; } | Remove the a tick callback |
2,989 | public void handleCandleCollection ( final BitfinexTickerSymbol symbol , final List < BitfinexTick > candles ) { updateChannelHeartbeat ( symbol ) ; tickerCallbacks . handleEventsCollection ( symbol , candles ) ; } | Process a list with candles |
2,990 | public void handleNewTick ( final BitfinexTickerSymbol currencyPair , final BitfinexTick tick ) { updateChannelHeartbeat ( currencyPair ) ; tickerCallbacks . handleEvent ( currencyPair , tick ) ; } | Handle a new candle |
2,991 | public FutureOperation subscribeTicker ( final BitfinexTickerSymbol tickerSymbol ) throws BitfinexClientException { final FutureOperation future = new FutureOperation ( tickerSymbol ) ; pendingSubscribes . registerFuture ( future ) ; final SubscribeTickerCommand command = new SubscribeTickerCommand ( tickerSymbol ) ; c... | Subscribe a ticker |
2,992 | public FutureOperation unsubscribeTicker ( final BitfinexTickerSymbol tickerSymbol ) { final FutureOperation future = new FutureOperation ( tickerSymbol ) ; pendingUnsubscribes . registerFuture ( future ) ; lastTickerActivity . remove ( tickerSymbol ) ; final UnsubscribeChannelCommand command = new UnsubscribeChannelCo... | Unsubscribe a ticker |
2,993 | public void registerCandlestickCallback ( final BitfinexCandlestickSymbol symbol , final BiConsumer < BitfinexCandlestickSymbol , BitfinexCandle > callback ) throws BitfinexClientException { candleCallbacks . registerCallback ( symbol , callback ) ; } | Register a new candlestick callback |
2,994 | public boolean removeCandlestickCallback ( final BitfinexCandlestickSymbol symbol , final BiConsumer < BitfinexCandlestickSymbol , BitfinexCandle > callback ) throws BitfinexClientException { return candleCallbacks . removeCallback ( symbol , callback ) ; } | Remove the a candlestick callback |
2,995 | public void handleCandlestickCollection ( final BitfinexCandlestickSymbol symbol , final Collection < BitfinexCandle > ticksBuffer ) { candleCallbacks . handleEventsCollection ( symbol , ticksBuffer ) ; } | Process a list with candlesticks |
2,996 | public void handleNewCandlestick ( final BitfinexCandlestickSymbol currencyPair , final BitfinexCandle tick ) { updateChannelHeartbeat ( currencyPair ) ; candleCallbacks . handleEvent ( currencyPair , tick ) ; } | Handle a new candlestick |
2,997 | public FutureOperation subscribeCandles ( final BitfinexCandlestickSymbol symbol ) throws BitfinexClientException { final FutureOperation future = new FutureOperation ( symbol ) ; pendingSubscribes . registerFuture ( future ) ; final SubscribeCandlesCommand command = new SubscribeCandlesCommand ( symbol ) ; client . se... | Subscribe candles for a symbol |
2,998 | public FutureOperation unsubscribeCandles ( final BitfinexCandlestickSymbol symbol ) { lastTickerActivity . remove ( symbol ) ; final FutureOperation future = new FutureOperation ( symbol ) ; pendingUnsubscribes . registerFuture ( future ) ; final UnsubscribeChannelCommand command = new UnsubscribeChannelCommand ( symb... | Unsubscribe the candles |
2,999 | public void registerExecutedTradeCallback ( final BitfinexExecutedTradeSymbol orderbookConfiguration , final BiConsumer < BitfinexExecutedTradeSymbol , BitfinexExecutedTrade > callback ) throws BitfinexClientException { tradesCallbacks . registerCallback ( orderbookConfiguration , callback ) ; } | Register a new executed trade callback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.