idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
130,300
private void freePacket ( Packet packet ) { if ( packet != null && packet . getData ( ) != null ) { packet . clearData ( ) ; } }
Releases a packet .
130,301
private void freeChannels ( ) { for ( ChannelInfo info : channels . values ( ) ) { freePacket ( info . getReadPacket ( ) ) ; freePacket ( info . getWritePacket ( ) ) ; } channels . clear ( ) ; }
Releases the channels .
130,302
public void setLastReadPacket ( int channelId , Packet packet ) { final ChannelInfo info = getChannelInfo ( channelId ) ; Packet prevPacket = info . getReadPacket ( ) ; info . setReadPacket ( packet ) ; freePacket ( prevPacket ) ; }
Setter for last read packet .
130,303
public static boolean deleteDirectory ( String directory , boolean useOSNativeDelete ) throws IOException { boolean result = false ; if ( ! useOSNativeDelete ) { File dir = new File ( directory ) ; for ( File file : dir . listFiles ( ) ) { if ( file . delete ( ) ) { log . debug ( "{} was deleted" , file . getName ( ) )...
Deletes a directory and its contents . This will fail if there are any file locks or if the directory cannot be emptied .
130,304
private final static Thread stdOut ( final Process p ) { final byte [ ] empty = new byte [ 128 ] ; for ( int b = 0 ; b < empty . length ; b ++ ) { empty [ b ] = ( byte ) 0 ; } Thread std = new Thread ( ) { public void run ( ) { StringBuilder sb = new StringBuilder ( 1024 ) ; byte [ ] buf = new byte [ 128 ] ; BufferedIn...
Special method for capture of StdOut .
130,305
public static void unzip ( String compressedFileName , String destinationDir ) { String dirName = null ; String applicationName = compressedFileName . substring ( compressedFileName . lastIndexOf ( "/" ) ) ; int dashIndex = applicationName . indexOf ( '-' ) ; if ( dashIndex != - 1 ) { dirName = compressedFileName . sub...
Unzips a war file to an application located under the webapps directory
130,306
public static String formatPath ( String absWebappsPath , String contextDirName ) { StringBuilder path = new StringBuilder ( absWebappsPath . length ( ) + contextDirName . length ( ) ) ; path . append ( absWebappsPath ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Path start: {}" , path . toString ( ) ) ; } int i...
Quick - n - dirty directory formatting to support launching in windows specifically from ant .
130,307
public static String generateCustomName ( ) { Random random = new Random ( ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( PropertyConverter . getCurrentTimeSeconds ( ) ) ; sb . append ( '_' ) ; int i = random . nextInt ( 99999 ) ; if ( i < 10 ) { sb . append ( "0000" ) ; } else if ( i < 100 ) { sb . appen...
Generates a custom name containing numbers and an underscore ex . 282818_00023 . The name contains current seconds and a random number component .
130,308
public static byte [ ] readAsByteArray ( File localSwfFile ) { byte [ ] fileBytes = new byte [ ( int ) localSwfFile . length ( ) ] ; byte [ ] b = new byte [ 1 ] ; FileInputStream fis = null ; try { fis = new FileInputStream ( localSwfFile ) ; for ( int i = 0 ; i < Integer . MAX_VALUE ; i ++ ) { if ( fis . read ( b ) !=...
Reads all the bytes of a given file into an array . If the file size exceeds Integer . MAX_VALUE it will be truncated .
130,309
private Set < ISharedObjectSecurity > getSecurityHandlers ( ) { ISharedObjectSecurityService security = ( ISharedObjectSecurityService ) ScopeUtils . getScopeService ( getParent ( ) , ISharedObjectSecurityService . class ) ; if ( security == null ) { return null ; } return security . getSharedObjectSecurity ( ) ; }
Return security handlers for this shared object or
130,310
protected boolean isConnectionAllowed ( ) { for ( ISharedObjectSecurity handler : securityHandlers ) { if ( ! handler . isConnectionAllowed ( this ) ) { return false ; } } final Set < ISharedObjectSecurity > handlers = getSecurityHandlers ( ) ; if ( handlers == null ) { return true ; } for ( ISharedObjectSecurity handl...
Call handlers and check if connection to the existing SO is allowed .
130,311
protected boolean isWriteAllowed ( String key , Object value ) { for ( ISharedObjectSecurity handler : securityHandlers ) { if ( ! handler . isWriteAllowed ( this , key , value ) ) { return false ; } } final Set < ISharedObjectSecurity > handlers = getSecurityHandlers ( ) ; if ( handlers == null ) { return true ; } for...
Call handlers and check if writing to the SO is allowed .
130,312
protected boolean isDeleteAllowed ( String key ) { for ( ISharedObjectSecurity handler : securityHandlers ) { if ( ! handler . isDeleteAllowed ( this , key ) ) { return false ; } } final Set < ISharedObjectSecurity > handlers = getSecurityHandlers ( ) ; if ( handlers == null ) { return true ; } for ( ISharedObjectSecur...
Call handlers and check if deleting a property from the SO is allowed .
130,313
protected boolean isSendAllowed ( String message , List < ? > arguments ) { for ( ISharedObjectSecurity handler : securityHandlers ) { if ( ! handler . isSendAllowed ( this , message , arguments ) ) { return false ; } } final Set < ISharedObjectSecurity > handlers = getSecurityHandlers ( ) ; if ( handlers == null ) { r...
Call handlers and check if sending a message to the clients connected to the SO is allowed .
130,314
public static void handleError ( HttpResponse response ) throws ParseException , IOException { log . debug ( "{}" , response . getStatusLine ( ) . toString ( ) ) ; HttpEntity entity = response . getEntity ( ) ; if ( entity != null ) { log . debug ( "{}" , EntityUtils . toString ( entity ) ) ; } }
Logs details about the request error .
130,315
public static void writeReverseInt ( IoBuffer out , int value ) { out . put ( ( byte ) ( 0xFF & value ) ) ; out . put ( ( byte ) ( 0xFF & ( value >> 8 ) ) ) ; out . put ( ( byte ) ( 0xFF & ( value >> 16 ) ) ) ; out . put ( ( byte ) ( 0xFF & ( value >> 24 ) ) ) ; }
Writes reversed integer to buffer .
130,316
public static int readUnsignedMediumInt ( IoBuffer in ) { final byte a = in . get ( ) ; final byte b = in . get ( ) ; final byte c = in . get ( ) ; int val = 0 ; val += ( a & 0xff ) << 16 ; val += ( b & 0xff ) << 8 ; val += ( c & 0xff ) ; return val ; }
Read unsigned 24 bit integer .
130,317
public static int readMediumInt ( IoBuffer in ) { final byte a = in . get ( ) ; final byte b = in . get ( ) ; final byte c = in . get ( ) ; int val = 0 ; val += ( a & 0xff ) << 16 ; val += ( b & 0xff ) << 8 ; val += ( c & 0xff ) ; return val ; }
Read 24 bit integer .
130,318
public static int readReverseInt ( IoBuffer in ) { final byte a = in . get ( ) ; final byte b = in . get ( ) ; final byte c = in . get ( ) ; final byte d = in . get ( ) ; int val = 0 ; val += ( d & 0xff ) << 24 ; val += ( c & 0xff ) << 16 ; val += ( b & 0xff ) << 8 ; val += ( a & 0xff ) ; return val ; }
Read integer in reversed order .
130,319
public static void encodeHeaderByte ( IoBuffer out , byte headerSize , int channelId ) { if ( channelId <= 63 ) { out . put ( ( byte ) ( ( headerSize << 6 ) + channelId ) ) ; } else if ( channelId <= 319 ) { out . put ( ( byte ) ( headerSize << 6 ) ) ; out . put ( ( byte ) ( channelId - 64 ) ) ; } else { out . put ( ( ...
Encodes header size marker and channel id into header marker .
130,320
public static long diffTimestamps ( final int a , final int b ) { final long unsignedA = a & 0xFFFFFFFFL ; final long unsignedB = b & 0xFFFFFFFFL ; final long delta = unsignedA - unsignedB ; return delta ; }
Calculates the delta between two time stamps adjusting for time stamp wrapping .
130,321
public void startWaitForHandshake ( ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "startWaitForHandshake - {}" , sessionId ) ; } if ( scheduler != null ) { try { waitForHandshakeTask = scheduler . schedule ( new WaitForHandshakeTask ( ) , new Date ( System . currentTimeMillis ( ) + maxHandshakeTimeout ) ) ; } cat...
Start waiting for a valid handshake .
130,322
private void stopWaitForHandshake ( ) { if ( waitForHandshakeTask != null ) { boolean cancelled = waitForHandshakeTask . cancel ( true ) ; waitForHandshakeTask = null ; if ( cancelled && log . isDebugEnabled ( ) ) { log . debug ( "waitForHandshake was cancelled for {}" , sessionId ) ; } } }
Cancels wait for handshake task .
130,323
private void startRoundTripMeasurement ( ) { if ( scheduler != null ) { if ( pingInterval > 0 ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "startRoundTripMeasurement - {}" , sessionId ) ; } try { keepAliveTask = scheduler . scheduleWithFixedDelay ( new KeepAliveTask ( ) , new Date ( System . currentTimeMillis ( ...
Starts measurement .
130,324
private void stopRoundTripMeasurement ( ) { if ( keepAliveTask != null ) { boolean cancelled = keepAliveTask . cancel ( true ) ; keepAliveTask = null ; if ( cancelled && log . isDebugEnabled ( ) ) { log . debug ( "Keep alive was cancelled for {}" , sessionId ) ; } } }
Stops measurement .
130,325
public void setup ( String host , String path , Map < String , Object > params ) { this . host = host ; this . path = path ; this . params = params ; if ( Integer . valueOf ( 3 ) . equals ( params . get ( "objectEncoding" ) ) ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Setting object encoding to AMF3" ) ; } st...
Initialize connection .
130,326
public Channel getChannel ( int channelId ) { Channel channel = channels . putIfAbsent ( channelId , new Channel ( this , channelId ) ) ; if ( channel == null ) { channel = channels . get ( channelId ) ; } return channel ; }
Return channel by id .
130,327
public void closeChannel ( int channelId ) { if ( log . isTraceEnabled ( ) ) { log . trace ( "closeChannel: {}" , channelId ) ; } Channel chan = channels . remove ( channelId ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "channel: {} for id: {}" , chan , channelId ) ; if ( chan == null ) { log . trace ( "Channels...
Closes channel .
130,328
public boolean isValidStreamId ( Number streamId ) { double d = streamId . doubleValue ( ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Checking validation for streamId {}; reservedStreams: {}; streams: {}, connection: {}" , new Object [ ] { d , reservedStreams , streams , sessionId } ) ; } if ( d <= 0 || ! reser...
Returns whether or not a given stream id is valid .
130,329
public boolean isIdle ( ) { long lastPingTime = lastPingSentOn . get ( ) ; long lastPongTime = lastPongReceivedOn . get ( ) ; boolean idle = ( lastPongTime > 0 && ( lastPingTime - lastPongTime > maxInactivity ) ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Connection {} {} idle" , getSessionId ( ) , ( idle ? "is...
Returns whether or not the connection has been idle for a maximum period .
130,330
public Number getStreamIdForChannelId ( int channelId ) { if ( channelId < 4 ) { return 0 ; } Number streamId = Math . floor ( ( ( channelId - 4 ) / 5.0d ) + 1 ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Stream id: {} requested for channel id: {}" , streamId , channelId ) ; } return streamId ; }
Return stream id for given channel id .
130,331
public IClientStream getStreamByChannelId ( int channelId ) { if ( channelId < 4 ) { return null ; } Number streamId = getStreamIdForChannelId ( channelId ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Stream requested for channel id: {} stream id: {} streams: {}" , channelId , streamId , streams ) ; } return get...
Return stream by given channel id .
130,332
public int getChannelIdForStreamId ( Number streamId ) { int channelId = ( int ) ( streamId . doubleValue ( ) * 5 ) - 1 ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Channel id: {} requested for stream id: {}" , channelId , streamId ) ; } return channelId ; }
Return channel id for given stream id .
130,333
public OutputStream createOutputStream ( Number streamId ) { int channelId = getChannelIdForStreamId ( streamId ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Create output - stream id: {} channel id: {}" , streamId , channelId ) ; } final Channel data = getChannel ( channelId ++ ) ; final Channel video = getChan...
Creates output stream object from stream id . Output stream consists of audio video and data channels .
130,334
private void customizeStream ( Number streamId , AbstractClientStream stream ) { Integer buffer = streamBuffers . get ( streamId . doubleValue ( ) ) ; if ( buffer != null ) { stream . setClientBufferDuration ( buffer ) ; } stream . setName ( createStreamName ( ) ) ; stream . setConnection ( this ) ; stream . setScope (...
Specify name connection scope and etc for stream
130,335
private boolean registerStream ( IClientStream stream ) { if ( streams . putIfAbsent ( stream . getStreamId ( ) . doubleValue ( ) , stream ) == null ) { usedStreams . incrementAndGet ( ) ; return true ; } log . error ( "Unable to register stream {}, stream with id {} was already added" , stream , stream . getStreamId (...
Store a stream in the connection .
130,336
protected void updateBytesRead ( ) { if ( log . isTraceEnabled ( ) ) { log . trace ( "updateBytesRead" ) ; } long bytesRead = getReadBytes ( ) ; if ( bytesRead >= nextBytesRead ) { BytesRead sbr = new BytesRead ( ( int ) ( bytesRead % Integer . MAX_VALUE ) ) ; getChannel ( 2 ) . write ( sbr ) ; nextBytesRead += bytesRe...
Update number of bytes to read next value .
130,337
public void receivedBytesRead ( int bytes ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Client received {} bytes, written {} bytes, {} messages pending" , new Object [ ] { bytes , getWrittenBytes ( ) , getPendingMessages ( ) } ) ; } clientBytesRead . addAndGet ( bytes ) ; }
Read number of received bytes .
130,338
protected void writingMessage ( Packet message ) { if ( message . getMessage ( ) instanceof VideoData ) { Number streamId = message . getHeader ( ) . getStreamId ( ) ; final AtomicInteger value = new AtomicInteger ( ) ; AtomicInteger old = pendingVideos . putIfAbsent ( streamId . doubleValue ( ) , value ) ; if ( old ==...
Mark message as being written .
130,339
public void handleMessageReceived ( Packet packet ) { if ( log . isTraceEnabled ( ) ) { log . trace ( "handleMessageReceived - {}" , sessionId ) ; } if ( maxHandlingTimeout > 0 ) { packet . setExpirationTime ( System . currentTimeMillis ( ) + maxHandlingTimeout ) ; } if ( executor != null ) { final byte dataType = pack...
Handle the incoming message .
130,340
public void messageSent ( Packet message ) { if ( message . getMessage ( ) instanceof VideoData ) { Number streamId = message . getHeader ( ) . getStreamId ( ) ; AtomicInteger pending = pendingVideos . get ( streamId . doubleValue ( ) ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Stream id: {} pending: {} total ...
Mark message as sent .
130,341
public void sendSharedObjectMessage ( String name , int currentVersion , boolean persistent , Set < ISharedObjectEvent > events ) { SharedObjectMessage syncMessage = state . getEncoding ( ) == Encoding . AMF3 ? new FlexSharedObjectMessage ( null , name , currentVersion , persistent ) : new SharedObjectMessage ( null , ...
Send a shared object message .
130,342
public void pingReceived ( Ping pong ) { long now = System . currentTimeMillis ( ) ; long previousPingTime = lastPingSentOn . get ( ) ; int previousPingValue = ( int ) ( previousPingTime & 0xffffffffL ) ; int pongValue = pong . getValue2 ( ) . intValue ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Pong receive...
Marks that ping back was received .
130,343
public void printAutomaton ( final PrintStream out ) { out . println ( "digraph ahocorasick {" ) ; printDebug ( out , root ) ; out . println ( "}" ) ; }
Prints dot description of the automaton to out for visualization in GraphViz . Used for debugging and education .
130,344
public void setJavaScriptEscapeChars ( final int [ ] escapeCharacters ) { final CharacterEscapes ce = new CharacterEscapes ( ) { private static final long serialVersionUID = 1L ; public int [ ] getEscapeCodesForAscii ( ) { if ( escapeCharacters == null ) { return CharacterEscapes . standardAsciiEscapesForJSON ( ) ; } r...
By default JSON output does only have escaping where it is strictly necessary . This is recommended in the most cases . Nevertheless it can be sometimes useful to have some more escaping .
130,345
public void replay ( ) { int index = 0 ; for ( MessageType type : typeBuffer ) { switch ( type ) { case RECORD_START : getReceiver ( ) . startRecord ( valueBuffer . get ( index ) ) ; ++ index ; break ; case RECORD_END : getReceiver ( ) . endRecord ( ) ; break ; case ENTITY_START : getReceiver ( ) . startEntity ( valueB...
Replays the buffered event .
130,346
public InlineMorph with ( String line ) { if ( scriptBuilder . length ( ) == 0 ) { appendBoilerplate ( line ) ; } scriptBuilder . append ( line ) . append ( "\n" ) ; return this ; }
Adds a line to the morph script .
130,347
public static String repeatChars ( final char ch , final int count ) { return CharBuffer . allocate ( count ) . toString ( ) . replace ( '\0' , ch ) ; }
Creates a string which contains a sequence of repeated characters .
130,348
public String getCurrentPathWith ( final String literalName ) { if ( entityStack . size ( ) == 0 ) { return literalName ; } return getCurrentPath ( ) + entitySeparator + literalName ; }
Returns the current entity path with the given literal name appended .
130,349
String stringAt ( final int fromIndex , final int length , final Charset charset ) { return new String ( byteArray , fromIndex , length , charset ) ; }
Returns a string containing the characters in the specified part of the record .
130,350
private static MemoryPoolMXBean findTenuredGenPool ( ) { for ( final MemoryPoolMXBean pool : ManagementFactory . getMemoryPoolMXBeans ( ) ) if ( pool . getType ( ) == MemoryType . HEAP && pool . isUsageThresholdSupported ( ) ) { return pool ; } throw new AssertionError ( "Could not find tenured space" ) ; }
Tenured Space Pool can be determined by it being of type HEAP and by it being possible to set the usage threshold .
130,351
public ListRet listLive ( String prefix , int limit , String marker ) throws PiliException { return list ( true , prefix , limit , marker ) ; }
list streams which is live
130,352
public BatchLiveStatus [ ] batchLiveStatus ( String [ ] streamTitles ) throws PiliException { String path = baseUrl + "/livestreams" ; String json = gson . toJson ( new BatchLiveStatusOptions ( streamTitles ) ) ; try { String resp = cli . callWithJson ( path , json ) ; BatchLiveStatusRet ret = gson . fromJson ( resp , ...
batch get live status
130,353
public Stream info ( ) throws PiliException { try { String resp = cli . callWithGet ( baseUrl ) ; StreamInfo ret = gson . fromJson ( resp , StreamInfo . class ) ; ret . setMeta ( info . getHub ( ) , info . getKey ( ) ) ; this . info = ret ; return this ; } catch ( PiliException e ) { throw e ; } catch ( Exception e ) {...
fetch stream info
130,354
public LiveStatus liveStatus ( ) throws PiliException { String path = baseUrl + "/live" ; try { String resp = cli . callWithGet ( path ) ; LiveStatus status = gson . fromJson ( resp , LiveStatus . class ) ; return status ; } catch ( PiliException e ) { throw e ; } catch ( Exception e ) { throw new PiliException ( e ) ;...
get the status of live stream
130,355
public String save ( SaveOptions opts ) throws PiliException { String path = baseUrl + "/saveas" ; String json = gson . toJson ( opts ) ; try { String resp = cli . callWithJson ( path , json ) ; SaveRet ret = gson . fromJson ( resp , SaveRet . class ) ; return ret . fname ; } catch ( PiliException e ) { throw e ; } cat...
save playback with more options
130,356
public String snapshot ( SnapshotOptions opts ) throws PiliException { String path = baseUrl + "/snapshot" ; String json = gson . toJson ( opts ) ; try { String resp = cli . callWithJson ( path , json ) ; SnapshotRet ret = gson . fromJson ( resp , SnapshotRet . class ) ; return ret . fname ; } catch ( PiliException e )...
snapshot the live stream
130,357
public void updateConverts ( String [ ] profiles ) throws PiliException { String path = baseUrl + "/converts" ; String json = gson . toJson ( new ConvertsOptions ( profiles ) ) ; try { cli . callWithJson ( path , json ) ; } catch ( PiliException e ) { throw e ; } catch ( Exception e ) { throw new PiliException ( e ) ; ...
update convert configs
130,358
public Record [ ] historyRecord ( long start , long end ) throws PiliException { String path = appendQuery ( baseUrl + "/historyrecord" , start , end ) ; try { String resp = cli . callWithGet ( path ) ; HistoryRet ret = gson . fromJson ( resp , HistoryRet . class ) ; return ret . items ; } catch ( PiliException e ) { t...
query the stream history
130,359
public String toXML ( ) { Error error = getError ( ) ; if ( error != null ) { return error . toXML ( ) ; } StringWriter sw = new StringWriter ( ) ; String xml = "" ; try { JAXBContext context = JAXBContext . newInstance ( this . getClass ( ) ) ; Marshaller marshaller = context . createMarshaller ( ) ; marshaller . mars...
Map a Token instance to its XML representation .
130,360
public OneTouchResponse sendApprovalRequest ( ApprovalRequestParams approvalRequestParams ) throws AuthyException { JSONObject params = new JSONObject ( ) ; params . put ( "message" , approvalRequestParams . getMessage ( ) ) ; if ( approvalRequestParams . getSecondsToExpire ( ) != null ) { params . put ( "seconds_to_ex...
Sends the OneTouch s approval request to the Authy servers and returns the OneTouchResponse that comes back .
130,361
public UserStatus requestStatus ( int userId ) throws AuthyException { final Response response = this . get ( String . format ( USER_STATUS_PATH , userId ) , null ) ; UserStatus userStatus = userStatusFromJson ( response ) ; return userStatus ; }
Get user status .
130,362
protected void doExecute ( Task task , TermsByQueryRequest request , ActionListener < TermsByQueryResponse > listener ) { request . nowInMillis ( System . currentTimeMillis ( ) ) ; super . doExecute ( task , request , listener ) ; }
Executes the actions .
130,363
protected GroupShardsIterator shards ( ClusterState clusterState , TermsByQueryRequest request , String [ ] concreteIndices ) { Map < String , Set < String > > routingMap = indexNameExpressionResolver . resolveSearchRouting ( clusterState , request . routing ( ) , request . indices ( ) ) ; return clusterService . opera...
The shards this request will execute against .
130,364
public ActionRequestValidationException validate ( ) { ActionRequestValidationException validationException = super . validate ( ) ; if ( termsEncoding != null && termsEncoding . equals ( TermsEncoding . BYTES ) ) { if ( maxTermsPerShard == null ) { validationException = ValidateActions . addValidationError ( "maxTerms...
Validates the request
130,365
public long getVersion ( ) { long version = 1 ; ArrayList < String > indices = new ArrayList < > ( getIndices ( ) . keySet ( ) ) ; Collections . sort ( indices ) ; for ( String index : indices ) { version = 31 * version + getIndices ( ) . get ( index ) ; } return version ; }
Returns the version for the set of indices .
130,366
public Map < String , Long > getIndices ( ) { if ( indicesVersions != null ) { return indicesVersions ; } Map < String , Long > indicesVersions = Maps . newHashMap ( ) ; Set < String > indices = Sets . newHashSet ( ) ; for ( ShardIndexVersion shard : shards ) { indices . add ( shard . getShardRouting ( ) . getIndex ( )...
Returns a map with the version of each index .
130,367
private long getIndexVersion ( List < ShardIndexVersion > shards ) { long version = 1 ; Collections . sort ( shards , new Comparator < ShardIndexVersion > ( ) { public int compare ( ShardIndexVersion o1 , ShardIndexVersion o2 ) { return o1 . getShardRouting ( ) . id ( ) - o2 . getShardRouting ( ) . id ( ) ; } } ) ; for...
Computes a unique hash based on the version of the shards .
130,368
public void execute ( NodeTaskContext context ) { NodeTaskReporter taskReporter = new NodeTaskReporter ( this ) ; taskQueue = new ArrayDeque < > ( tasks ) ; if ( ! taskQueue . isEmpty ( ) ) { NodeTask task = taskQueue . poll ( ) ; task . execute ( context , taskReporter ) ; } else { listener . onSuccess ( ) ; } }
Starts the execution of the pipeline
130,369
public void put ( final long cacheKey , final FilterJoinTerms terms ) { logger . debug ( "{}: New cache entry {}" , Thread . currentThread ( ) . getName ( ) , cacheKey ) ; this . cache . put ( cacheKey , new CacheEntry ( terms . getEncodedTerms ( ) , terms . getSize ( ) , terms . isPruned ( ) ) ) ; }
Caches the provided list of encoded terms for the given filter join node .
130,370
public TransportRequestOptions transportOptions ( Settings settings ) { return TransportRequestOptions . builder ( ) . withType ( TransportRequestOptions . Type . REG ) . build ( ) ; }
Set transport options specific to a terms by query request . Enabling compression here does not really reduce data transfer even increase it on the contrary .
130,371
private void await ( ) { try { boolean nodeRemoved = this . removeConvertedNodes ( root ) ; if ( ! nodeRemoved && root . hasChildren ( ) ) { logger . debug ( "Visitor thread block - blocking queue size: {}" , blockingQueue . size ( ) ) ; this . blockingQueue . take ( ) ; this . blockingQueue . offer ( 0 ) ; logger . de...
Await for the completion of an async action .
130,372
private boolean removeConvertedNodes ( AbstractNode node ) { boolean nodeRemoved = false ; Iterator < AbstractNode > it = node . getChildren ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { FilterJoinNode child = ( FilterJoinNode ) it . next ( ) ; if ( child . getState ( ) . equals ( FilterJoinNode . State . CONVERTED...
Removes all the filter join leaf nodes that were converted . Returns true if at least one node has been removed .
130,373
protected void executeAsyncOperation ( final FilterJoinNode node ) { logger . debug ( "Executing async actions" ) ; node . setState ( FilterJoinNode . State . RUNNING ) ; NodePipelineManager pipeline = new NodePipelineManager ( ) ; pipeline . addListener ( new NodePipelineListener ( ) { public void onSuccess ( ) { node...
Executes the pipeline of async actions to compute the terms for this node .
130,374
private void checkForFailure ( FilterJoinNode node ) { if ( node . hasFailure ( ) ) { logger . error ( "Node processing failed: {}" , node . getFailure ( ) ) ; throw new ElasticsearchException ( "Unexpected failure while processing a node" , node . getFailure ( ) ) ; } }
Checks for an action failure
130,375
private void convertToTermsQuery ( FilterJoinNode node ) { Map < String , Object > parent = node . getParentSourceMap ( ) ; FilterJoinTerms terms = node . getTerms ( ) ; BytesRef bytes = terms . getEncodedTerms ( ) ; parent . remove ( FilterJoinBuilder . NAME ) ; Map < String , Object > queryParams = new HashMap < > ( ...
Converts a filter join into a terms query .
130,376
protected synchronized NumericTermsSet getTermsSet ( ) { if ( encodedTerms != null ) { long start = System . nanoTime ( ) ; termsSet = ( NumericTermsSet ) TermsSet . readFrom ( new BytesRef ( encodedTerms ) ) ; logger . debug ( "{}: Deserialized {} terms - took {} ms" , new Object [ ] { Thread . currentThread ( ) . get...
Returns the set of terms . This method will perform a late - decoding of the encoded terms and will release the byte array . This method needs to be synchronized as each segment thread will call it concurrently .
130,377
protected final int nullCheck ( int id , int s ) { int k = stk ; while ( true ) { k -- ; StackEntry e = stack [ k ] ; if ( e . type == NULL_CHECK_START ) { if ( e . getNullCheckNum ( ) == id ) { return e . getNullCheckPStr ( ) == s ? 1 : 0 ; } } } }
int for consistency with other null check routines
130,378
private final int fetchNameForNoNamedGroup ( int startCode , boolean ref ) { int src = p ; value = 0 ; int sign = 1 ; int endCode = nameEndCodePoint ( startCode ) ; int pnumHead = p ; int nameEnd = stop ; String err = null ; if ( ! left ( ) ) { newValueException ( EMPTY_GROUP_NAME ) ; } else { fetch ( ) ; if ( c == end...
make it return nameEnd!
130,379
public EthereumTransaction getEthereumTransactionFromObject ( Object row ) { EthereumTransaction result = null ; if ( row instanceof HiveEthereumTransaction ) { result = EthereumUDFUtil . convertToEthereumTransaction ( ( HiveEthereumTransaction ) row ) ; } else { StructField nonceSF = soi . getStructFieldRef ( "nonce" ...
Create an object of type EthereumTransaction from any HiveTable
130,380
public static EthereumTransaction convertToEthereumTransaction ( HiveEthereumTransaction transaction ) { EthereumTransaction result = new EthereumTransaction ( ) ; result . setNonce ( transaction . getNonce ( ) ) ; result . setValueRaw ( transaction . getValueRaw ( ) ) ; result . setReceiveAddress ( transaction . getRe...
Convert HiveEthereumTransaction to Ethereum Transaction
130,381
public static long getSize ( byte [ ] byteSize ) { if ( byteSize . length != 4 ) { return 0 ; } ByteBuffer converterBuffer = ByteBuffer . wrap ( byteSize ) ; converterBuffer . order ( ByteOrder . LITTLE_ENDIAN ) ; return convertSignedIntToUnsigned ( converterBuffer . getInt ( ) ) ; }
Reads a size from a reversed byte order such as block size in the block header
130,382
public static byte [ ] reverseByteArray ( byte [ ] inputByteArray ) { byte [ ] result = new byte [ inputByteArray . length ] ; for ( int i = inputByteArray . length - 1 ; i >= 0 ; i -- ) { result [ result . length - 1 - i ] = inputByteArray [ i ] ; } return result ; }
Reverses the order of the byte array
130,383
public static boolean compareMagics ( byte [ ] magic1 , byte [ ] magic2 ) { if ( magic1 . length != magic2 . length ) { return false ; } for ( int i = 0 ; i < magic1 . length ; i ++ ) { if ( magic1 [ i ] != magic2 [ i ] ) { return false ; } } return true ; }
Compares two Bitcoin magics
130,384
public static byte [ ] getTransactionHash ( BitcoinTransaction transaction ) throws IOException { ByteArrayOutputStream transactionBAOS = new ByteArrayOutputStream ( ) ; byte [ ] version = reverseByteArray ( convertIntToByteArray ( transaction . getVersion ( ) ) ) ; transactionBAOS . write ( version ) ; byte [ ] inCoun...
Calculates the double SHA256 - Hash of a transaction in little endian format . This could be used for certain analysis scenario where one want to investigate the referenced transaction used as an input for a Transaction . Furthermore it can be used as a unique identifier of the transaction
130,385
public static RLPObject rlpDecodeNextItem ( ByteBuffer bb ) { RLPObject result = null ; int objType = detectRLPObjectType ( bb ) ; switch ( objType ) { case EthereumUtil . RLP_OBJECTTYPE_ELEMENT : result = EthereumUtil . decodeRLPElement ( bb ) ; break ; case EthereumUtil . RLP_OBJECTTYPE_LIST : result = EthereumUtil ....
Read RLP data from a Byte Buffer .
130,386
public static int detectRLPObjectType ( ByteBuffer bb ) { bb . mark ( ) ; byte detector = bb . get ( ) ; int unsignedDetector = detector & 0xFF ; int result = EthereumUtil . RLP_OBJECTTYPE_INVALID ; if ( unsignedDetector <= 0x7f ) { result = EthereumUtil . RLP_OBJECTTYPE_ELEMENT ; } else if ( ( unsignedDetector >= 0x80...
Detects the object type of an RLP encoded object . Note that it does not modify the read position in the ByteBuffer .
130,387
public static Long calculateChainId ( EthereumTransaction eTrans ) { Long result = null ; long rawResult = EthereumUtil . convertVarNumberToLong ( new RLPElement ( new byte [ 0 ] , eTrans . getSig_v ( ) ) ) ; if ( ! ( ( rawResult == EthereumUtil . LOWER_REAL_V ) || ( rawResult == ( LOWER_REAL_V + 1 ) ) ) ) { result = (...
Calculates the chain Id
130,388
public static Short convertToByte ( RLPElement rpe ) { Short result = 0 ; if ( ( rpe . getRawData ( ) != null ) || ( rpe . getRawData ( ) . length == 1 ) ) { result = ( short ) ( rpe . getRawData ( ) [ 0 ] & 0xFF ) ; } return result ; }
Converts a byte in a RLPElement to byte
130,389
public static Integer convertToShort ( RLPElement rpe ) { Integer result = 0 ; byte [ ] rawBytes = rpe . getRawData ( ) ; if ( ( rawBytes != null ) ) { if ( rawBytes . length < EthereumUtil . WORD_SIZE ) { byte [ ] fullBytes = new byte [ EthereumUtil . WORD_SIZE ] ; int dtDiff = EthereumUtil . WORD_SIZE - rawBytes . le...
Converts a short in a RLPElement to short
130,390
public static Long convertToInt ( RLPElement rpe ) { Long result = 0L ; byte [ ] rawBytes = rpe . getRawData ( ) ; if ( ( rawBytes != null ) ) { if ( rawBytes . length < EthereumUtil . INT_SIZE ) { byte [ ] fullBytes = new byte [ EthereumUtil . INT_SIZE ] ; int dtDiff = EthereumUtil . INT_SIZE - rawBytes . length ; for...
Converts a int in a RLPElement to int
130,391
public static Long convertToLong ( RLPElement rpe ) { Long result = 0L ; byte [ ] rawBytes = rpe . getRawData ( ) ; if ( ( rawBytes != null ) ) { if ( rawBytes . length < EthereumUtil . LONG_SIZE ) { byte [ ] fullBytes = new byte [ EthereumUtil . LONG_SIZE ] ; int dtDiff = EthereumUtil . LONG_SIZE - rawBytes . length ;...
Converts a long in a RLPElement to long
130,392
public BitcoinAuxPOWBranch parseAuxPOWBranch ( ByteBuffer rawByteBuffer ) { byte [ ] noOfLinksVarInt = BitcoinUtil . convertVarIntByteBufferToByteArray ( rawByteBuffer ) ; long currentNoOfLinks = BitcoinUtil . getVarInt ( noOfLinksVarInt ) ; ArrayList < byte [ ] > links = new ArrayList ( ( int ) currentNoOfLinks ) ; fo...
Parse an AUXPowBranch
130,393
public List < BitcoinTransaction > parseTransactions ( ByteBuffer rawByteBuffer , long noOfTransactions ) { ArrayList < BitcoinTransaction > resultTransactions = new ArrayList < > ( ( int ) noOfTransactions ) ; for ( int k = 0 ; k < noOfTransactions ; k ++ ) { int currentVersion = rawByteBuffer . getInt ( ) ; byte [ ] ...
Parses the Bitcoin transactions in a byte buffer .
130,394
public static void jobTotalNumOfTransactions ( JavaSparkContext sc , Configuration hadoopConf , String inputFile , String outputFile ) { JavaPairRDD < BytesWritable , BitcoinBlock > bitcoinBlocksRDD = sc . newAPIHadoopFile ( inputFile , BitcoinBlockFileInputFormat . class , BytesWritable . class , BitcoinBlock . class ...
a job for counting the total number of transactions
130,395
public static Tuple2 < String , Long > mapNoOfTransaction ( BitcoinBlock block ) { return new Tuple2 < String , Long > ( "No of transactions: " , ( long ) ( block . getTransactions ( ) . size ( ) ) ) ; }
Maps the number of transactions of a block to a tuple
130,396
@ Action ( name = "Invoke AWS Lambda Function" , outputs = { @ Output ( Outputs . RETURN_CODE ) , @ Output ( Outputs . RETURN_RESULT ) , @ Output ( Outputs . EXCEPTION ) } , responses = { @ Response ( text = Outputs . SUCCESS , field = Outputs . RETURN_CODE , value = Outputs . SUCCESS_RETURN_CODE , matchType = MatchTyp...
Invokes an AWS Lambda Function in sync mode using AWS Java SDK
130,397
@ Action ( name = "Customize Linux Guest" , outputs = { @ Output ( Outputs . RETURN_CODE ) , @ Output ( Outputs . RETURN_RESULT ) , @ Output ( Outputs . EXCEPTION ) } , responses = { @ Response ( text = Outputs . SUCCESS , field = Outputs . RETURN_CODE , value = Outputs . RETURN_CODE_SUCCESS , matchType = MatchType . C...
Connects to specified data center and customize an existing linux OS based virtual machine identified by the inputs provided .
130,398
@ Action ( name = "Array Size" , outputs = { @ Output ( OutputNames . RETURN_RESULT ) , @ Output ( OutputNames . RETURN_CODE ) , @ Output ( OutputNames . EXCEPTION ) } , responses = { @ Response ( text = ResponseNames . SUCCESS , field = OutputNames . RETURN_CODE , value = ReturnCodes . SUCCESS , matchType = MatchType ...
This operation determines the number of elements in the given JSON array . If an element is itself another JSON array it only counts as 1 element ; in other words it will not expand and count embedded arrays . Null values are also considered to be an element .
130,399
public static String parseXml ( String xml , String expression ) throws ParserConfigurationException , IOException , XPathExpressionException , SAXException { DocumentBuilder builder = ResourceLoader . getDocumentBuilder ( ) ; Document document ; try { document = builder . parse ( new InputSource ( new StringReader ( x...
Parse the content of the given xml input and evaluates the given XPath expression .