idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
154,200 | public static Object createCompositeServiceProxy ( ClassLoader classLoader , Object [ ] services , boolean allowMultipleInheritance ) { return createCompositeServiceProxy ( classLoader , services , null , allowMultipleInheritance ) ; } | Creates a composite service using all of the given services . |
154,201 | public static Object createCompositeServiceProxy ( ClassLoader classLoader , Object [ ] services , Class < ? > [ ] serviceInterfaces , boolean allowMultipleInheritance ) { Set < Class < ? > > interfaces = collectInterfaces ( services , serviceInterfaces ) ; final Map < Class < ? > , Object > serviceClassToInstanceMappi... | Creates a composite service using all of the given services and implementing the given interfaces . |
154,202 | private void registerJsonProxyBean ( DefaultListableBeanFactory defaultListableBeanFactory , String className , String path ) { BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder . rootBeanDefinition ( JsonProxyFactoryBean . class ) . addPropertyValue ( "serviceUrl" , appendBasePath ( path ) ) . addPro... | Registers a new proxy bean with the bean factory . |
154,203 | private String appendBasePath ( String path ) { try { return new URL ( baseUrl , path ) . toString ( ) ; } catch ( MalformedURLException e ) { throw new IllegalArgumentException ( format ( "Cannot combine URLs '%s' and '%s' to valid URL." , baseUrl , path ) , e ) ; } } | Appends the base path to the path found in the interface . |
154,204 | static Set < Method > findCandidateMethods ( Class < ? > [ ] classes , String name ) { StringBuilder sb = new StringBuilder ( ) ; for ( Class < ? > clazz : classes ) { sb . append ( clazz . getName ( ) ) . append ( "::" ) ; } String cacheKey = sb . append ( name ) . toString ( ) ; if ( methodCache . containsKey ( cache... | Finds methods with the given name on the given class . |
154,205 | public static Object parseArguments ( Method method , Object [ ] arguments ) { JsonRpcParamsPassMode paramsPassMode = JsonRpcParamsPassMode . AUTO ; JsonRpcMethod jsonRpcMethod = getAnnotation ( method , JsonRpcMethod . class ) ; if ( jsonRpcMethod != null ) paramsPassMode = jsonRpcMethod . paramsPassMode ( ) ; Map < S... | Parses the given arguments for the given method optionally turning them into named parameters . |
154,206 | private void addHeaders ( HttpRequest request , Map < String , String > headers ) { for ( Map . Entry < String , String > key : headers . entrySet ( ) ) { request . addHeader ( key . getKey ( ) , key . getValue ( ) ) ; } } | Set the request headers . |
154,207 | private Object invokeAndReadResponse ( String methodName , Object argument , Type returnType , OutputStream output , InputStream input , String id ) throws Throwable { invoke ( methodName , argument , output , id ) ; return readResponse ( returnType , input , id ) ; } | Invokes the given method on the remote service passing the given arguments and reads a response . |
154,208 | private Object readResponse ( Type returnType , InputStream input , String id ) throws Throwable { ReadContext context = ReadContext . getReadContext ( input , mapper ) ; ObjectNode jsonObject = getValidResponse ( id , context ) ; notifyAnswerListener ( jsonObject ) ; handleErrorResponse ( jsonObject ) ; if ( hasResult... | Reads a JSON - PRC response from the server . This blocks until a response is received . If an id is given responses that do not correspond are disregarded . |
154,209 | private ObjectNode internalCreateRequest ( String methodName , Object arguments , String id ) { final ObjectNode request = mapper . createObjectNode ( ) ; addId ( id , request ) ; addProtocolAndMethod ( methodName , request ) ; addParameters ( arguments , request ) ; addAdditionalHeaders ( request ) ; notifyBeforeReque... | Creates RPC request . |
154,210 | public void invokeNotification ( String methodName , Object argument , OutputStream output ) throws IOException { writeRequest ( methodName , argument , output , null ) ; output . flush ( ) ; } | Invokes the given method on the remote service passing the given argument without reading or expecting a return response . |
154,211 | private JsonEncoding getJsonEncoding ( MediaType contentType ) { if ( contentType != null && contentType . getCharset ( ) != null ) { Charset charset = contentType . getCharset ( ) ; for ( JsonEncoding encoding : JsonEncoding . values ( ) ) { if ( charset . name ( ) . equals ( encoding . getJavaName ( ) ) ) { return en... | Determine the JSON encoding to use for the given content type . |
154,212 | private void registerServiceProxy ( DefaultListableBeanFactory defaultListableBeanFactory , String servicePath , String serviceBeanName ) { BeanDefinitionBuilder builder = BeanDefinitionBuilder . rootBeanDefinition ( JsonServiceExporter . class ) . addPropertyReference ( "service" , serviceBeanName ) ; BeanDefinition s... | Registers the new beans with the bean factory . |
154,213 | Optional < EntityDescriptor > referencingEntity ( AttributeDescriptor attribute ) { if ( ! Names . isEmpty ( attribute . referencedTable ( ) ) ) { return entities . values ( ) . stream ( ) . filter ( entity -> entity . tableName ( ) . equalsIgnoreCase ( attribute . referencedTable ( ) ) ) . findFirst ( ) ; } else if ( ... | Given a association attribute in an Entity find the Entity the attribute is referencing . |
154,214 | Optional < ? extends AttributeDescriptor > referencingAttribute ( AttributeDescriptor attribute , EntityDescriptor referenced ) { String referencedColumn = attribute . referencedColumn ( ) ; if ( Names . isEmpty ( referencedColumn ) ) { List < AttributeDescriptor > keys = referenced . attributes ( ) . stream ( ) . filt... | Given an attribute in a given type finds the corresponding attribute that it is referencing in that referencing type . |
154,215 | Set < AttributeDescriptor > mappedAttributes ( EntityDescriptor entity , AttributeDescriptor attribute , EntityDescriptor referenced ) { String mappedBy = attribute . mappedBy ( ) ; if ( Names . isEmpty ( mappedBy ) ) { return referenced . attributes ( ) . stream ( ) . filter ( other -> other . cardinality ( ) != null ... | Given an association in an entity find the attributes it maps onto in the referenced entity . |
154,216 | protected void bindBlobLiteral ( int index , byte [ ] value ) { if ( blobLiterals == null ) { blobLiterals = new LinkedHashMap < > ( ) ; } blobLiterals . put ( index , value ) ; } | inlines a blob literal into the sql statement since it can t be used as bind parameter |
154,217 | public void createIndexes ( Connection connection , TableCreationMode mode ) { ArrayList < Type < ? > > sorted = sortTypes ( ) ; for ( Type < ? > type : sorted ) { createIndexes ( connection , mode , type ) ; } } | Creates all indexes in the model . |
154,218 | public String createTablesString ( TableCreationMode mode ) { ArrayList < Type < ? > > sorted = sortTypes ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( Type < ? > type : sorted ) { String sql = tableCreateStatement ( type , mode ) ; sb . append ( sql ) ; sb . append ( ";\n" ) ; } return sb . toString ( ) ; } | Convenience method to generated the create table statements as a string . |
154,219 | public void dropTables ( ) { try ( Connection connection = getConnection ( ) ; Statement statement = connection . createStatement ( ) ) { ArrayList < Type < ? > > reversed = sortTypes ( ) ; Collections . reverse ( reversed ) ; executeDropStatements ( statement , reversed ) ; } catch ( SQLException e ) { throw new Table... | Drop all tables in the schema . Note if the platform supports if exists that will be used in the statement if not and the table doesn t exist an exception will be thrown . |
154,220 | public void dropTable ( Type < ? > type ) { try ( Connection connection = getConnection ( ) ; Statement statement = connection . createStatement ( ) ) { executeDropStatements ( statement , Collections . < Type < ? > > singletonList ( type ) ) ; } catch ( SQLException e ) { throw new TableModificationException ( e ) ; }... | Drops a single table in the schema . |
154,221 | public < T > String tableCreateStatement ( Type < T > type , TableCreationMode mode ) { String tableName = type . getName ( ) ; QueryBuilder qb = createQueryBuilder ( ) ; qb . keyword ( CREATE ) ; if ( type . getTableCreateAttributes ( ) != null ) { for ( String attribute : type . getTableCreateAttributes ( ) ) { qb . ... | Generates the create table for a specific type . |
154,222 | public T copy ( final T obj ) { try { return serializer . read ( serializer . serialize ( obj ) ) ; } catch ( ClassNotFoundException e ) { throw new SerializerException ( "Copying failed." , e ) ; } } | Returns a copy of the passed in instance by serializing and deserializing it . |
154,223 | public void registerXAResource ( String uniqueName , XAResource xaResource ) { Ehcache3XAResourceProducer xaResourceProducer = producers . get ( uniqueName ) ; if ( xaResourceProducer == null ) { xaResourceProducer = new Ehcache3XAResourceProducer ( ) ; xaResourceProducer . setUniqueName ( uniqueName ) ; xaResourceProd... | Register an XAResource of a cache with BTM . The first time a XAResource is registered a new EhCacheXAResourceProducer is created to hold it . |
154,224 | public void unregisterXAResource ( String uniqueName , XAResource xaResource ) { Ehcache3XAResourceProducer xaResourceProducer = producers . get ( uniqueName ) ; if ( xaResourceProducer != null ) { boolean found = xaResourceProducer . removeXAResource ( xaResource ) ; if ( ! found ) { throw new IllegalStateException ( ... | Unregister an XAResource of a cache from BTM . |
154,225 | public void compact ( ServerStoreProxy . ChainEntry entry ) { ChainBuilder builder = new ChainBuilder ( ) ; for ( PutOperation < K , V > operation : resolveAll ( entry ) . values ( ) ) { builder = builder . add ( codec . encode ( operation ) ) ; } Chain compacted = builder . build ( ) ; if ( compacted . length ( ) < en... | Compacts the given chain entry by resolving every key within . |
154,226 | protected Map < K , PutOperation < K , V > > resolveAll ( Chain chain ) { Map < K , PutOperation < K , V > > compacted = new HashMap < > ( 2 ) ; for ( Element element : chain ) { ByteBuffer payload = element . getPayload ( ) ; Operation < K , V > operation = codec . decode ( payload ) ; compacted . compute ( operation ... | Resolves all keys within the given chain to their equivalent put operations . |
154,227 | public static long parse ( String configuredMemorySize ) throws IllegalArgumentException { MemorySize size = parseIncludingUnit ( configuredMemorySize ) ; return size . calculateMemorySizeInBytes ( ) ; } | Parse a String containing a human - readable memory size . |
154,228 | public boolean abandonLeadership ( String entityIdentifier , boolean healthyConnection ) { Hold hold = maintenanceHolds . remove ( entityIdentifier ) ; return ( hold != null ) && healthyConnection && silentlyUnlock ( hold , entityIdentifier ) ; } | Proactively abandon leadership before closing connection . |
154,229 | private boolean abandonFetchHolds ( String entityIdentifier , boolean healthyConnection ) { Hold hold = fetchHolds . remove ( entityIdentifier ) ; return ( hold != null ) && healthyConnection && silentlyUnlock ( hold , entityIdentifier ) ; } | Proactively abandon any READ holds before closing connection . |
154,230 | private void init ( ) { ServerSideServerStore serverStore = ehcacheStateService . getStore ( storeIdentifier ) ; ServerStoreBinding serverStoreBinding = new ServerStoreBinding ( storeIdentifier , serverStore ) ; CompletableFuture < Void > r1 = managementRegistry . register ( serverStoreBinding ) ; ServerSideConfigurati... | the goal of the following code is to send the management metadata from the entity into the monitoring tree AFTER the entity creation |
154,231 | public ClusteringServiceConfigurationBuilder timeouts ( Builder < ? extends Timeouts > timeoutsBuilder ) { return new ClusteringServiceConfigurationBuilder ( this . connectionSource , timeoutsBuilder . build ( ) , this . autoCreate ) ; } | Adds timeouts . Read operations which time out return a result comparable to a cache miss . Write operations which time out won t do anything . Lifecycle operations which time out will fail with exception |
154,232 | public ClusteringServiceConfigurationBuilder readOperationTimeout ( long duration , TimeUnit unit ) { Duration readTimeout = Duration . of ( duration , toChronoUnit ( unit ) ) ; return timeouts ( TimeoutsBuilder . timeouts ( ) . read ( readTimeout ) . build ( ) ) ; } | Adds a read operation timeout . Read operations which time out return a result comparable to a cache miss . |
154,233 | private void removeCache ( final String alias , final boolean removeFromConfig ) { statusTransitioner . checkAvailable ( ) ; final CacheHolder cacheHolder = caches . remove ( alias ) ; if ( cacheHolder != null ) { final InternalCache < ? , ? > ehcache = cacheHolder . retrieve ( cacheHolder . keyType , cacheHolder . val... | Closes and removes a cache by alias from this cache manager . |
154,234 | private < K , V > CacheConfiguration < K , V > adjustConfigurationWithCacheManagerDefaults ( String alias , CacheConfiguration < K , V > config ) { ClassLoader cacheClassLoader = config . getClassLoader ( ) ; List < ServiceConfiguration < ? > > configurationList = new ArrayList < > ( ) ; configurationList . addAll ( co... | adjusts the config to reflect new classloader & serialization provider |
154,235 | boolean evict ( StoreEventSink < K , V > eventSink ) { evictionObserver . begin ( ) ; Random random = new Random ( ) ; @ SuppressWarnings ( "unchecked" ) Map . Entry < K , OnHeapValueHolder < V > > candidate = map . getEvictionCandidate ( random , SAMPLE_SIZE , EVICTION_PRIORITIZER , EVICTION_ADVISOR ) ; if ( candidate... | Try to evict a mapping . |
154,236 | public V getFailure ( K key , StoreAccessException e ) { try { return loaderWriter . load ( key ) ; } catch ( Exception e1 ) { throw ExceptionFactory . newCacheLoadingException ( e1 , e ) ; } finally { cleanup ( key , e ) ; } } | Get the value from the loader - writer . |
154,237 | public boolean containsKeyFailure ( K key , StoreAccessException e ) { cleanup ( key , e ) ; return false ; } | Return false . It doesn t matter if the key is present in the backend we consider it s not in the cache . |
154,238 | public void putFailure ( K key , V value , StoreAccessException e ) { try { loaderWriter . write ( key , value ) ; } catch ( Exception e1 ) { throw ExceptionFactory . newCacheWritingException ( e1 , e ) ; } finally { cleanup ( key , e ) ; } } | Write the value to the loader - write . |
154,239 | public void removeFailure ( K key , StoreAccessException e ) { try { loaderWriter . delete ( key ) ; } catch ( Exception e1 ) { throw ExceptionFactory . newCacheWritingException ( e1 , e ) ; } finally { cleanup ( key , e ) ; } } | Delete the key from the loader - writer . |
154,240 | public V putIfAbsentFailure ( K key , V value , StoreAccessException e ) { try { try { V loaded = loaderWriter . load ( key ) ; if ( loaded != null ) { return loaded ; } } catch ( Exception e1 ) { throw ExceptionFactory . newCacheLoadingException ( e1 , e ) ; } try { loaderWriter . write ( key , value ) ; } catch ( Exc... | Write the value to the loader - writer if it doesn t already exist in it . Note that the load and write pair is not atomic . This atomicity if needed should be handled by the something else . |
154,241 | public boolean removeFailure ( K key , V value , StoreAccessException e ) { try { V loadedValue ; try { loadedValue = loaderWriter . load ( key ) ; } catch ( Exception e1 ) { throw ExceptionFactory . newCacheLoadingException ( e1 , e ) ; } if ( loadedValue == null ) { return false ; } if ( ! loadedValue . equals ( valu... | Delete the key from the loader - writer if it is found with a matching value . Note that the load and write pair is not atomic . This atomicity if needed should be handled by the something else . |
154,242 | @ SuppressWarnings ( "unchecked" ) public Map < K , V > getAllFailure ( Iterable < ? extends K > keys , StoreAccessException e ) { try { return loaderWriter . loadAll ( ( Iterable ) keys ) ; } catch ( BulkCacheLoadingException e1 ) { throw e1 ; } catch ( Exception e1 ) { throw ExceptionFactory . newCacheLoadingExceptio... | Get all entries for the provided keys . Entries not found by the loader - writer are expected to be an entry with the key and a null value . |
154,243 | public void putAllFailure ( Map < ? extends K , ? extends V > entries , StoreAccessException e ) { try { loaderWriter . writeAll ( entries . entrySet ( ) ) ; } catch ( BulkCacheWritingException e1 ) { throw e1 ; } catch ( Exception e1 ) { throw ExceptionFactory . newCacheWritingException ( e1 , e ) ; } finally { cleanu... | Write all entries to the loader - writer . |
154,244 | public void removeAllFailure ( Iterable < ? extends K > keys , StoreAccessException e ) { try { loaderWriter . deleteAll ( keys ) ; } catch ( BulkCacheWritingException e1 ) { throw e1 ; } catch ( Exception e1 ) { throw ExceptionFactory . newCacheWritingException ( e1 , e ) ; } finally { cleanup ( keys , e ) ; } } | Delete all keys from the loader - writer . |
154,245 | public void addPool ( String alias , int minSize , int maxSize ) { if ( alias == null ) { throw new NullPointerException ( "Pool alias cannot be null" ) ; } if ( poolConfigurations . containsKey ( alias ) ) { throw new IllegalArgumentException ( "A pool with the alias '" + alias + "' is already configured" ) ; } else {... | Adds a new pool with the provided minimum and maximum . |
154,246 | protected void cleanup ( StoreAccessException from ) { try { store . obliterate ( ) ; } catch ( StoreAccessException e ) { inconsistent ( from , e ) ; return ; } recovered ( from ) ; } | Clear all entries from the store . |
154,247 | protected void cleanup ( Iterable < ? extends K > keys , StoreAccessException from ) { try { store . obliterate ( keys ) ; } catch ( StoreAccessException e ) { inconsistent ( keys , from , e ) ; return ; } recovered ( keys , from ) ; } | Clean all keys from the store . |
154,248 | protected void recovered ( Iterable < ? extends K > keys , StoreAccessException from ) { LOGGER . info ( "Ehcache keys {} recovered from" , keys , from ) ; } | Called when the cache recovered from a failing store operation on a list of keys . |
154,249 | protected void inconsistent ( K key , StoreAccessException because , StoreAccessException ... cleanup ) { pacedErrorLog ( "Ehcache key {} in possible inconsistent state" , key , because ) ; } | Called when the cache failed to recover from a failing store operation on a key . |
154,250 | protected void inconsistent ( Iterable < ? extends K > keys , StoreAccessException because , StoreAccessException ... cleanup ) { pacedErrorLog ( "Ehcache keys {} in possible inconsistent state" , keys , because ) ; } | Called when the cache failed to recover from a failing store operation on a list of keys . |
154,251 | public ServerSideConfigurationBuilder resourcePool ( String name , long size , MemoryUnit unit , String serverResource ) { return resourcePool ( name , new Pool ( unit . toBytes ( size ) , serverResource ) ) ; } | Adds a resource pool with the given name and size and consuming the given server resource . |
154,252 | private synchronized void registerCacheEventListener ( EventListenerWrapper < K , V > wrapper ) { if ( aSyncListenersList . contains ( wrapper ) || syncListenersList . contains ( wrapper ) ) { throw new IllegalStateException ( "Cache Event Listener already registered: " + wrapper . getListener ( ) ) ; } if ( wrapper . ... | Synchronized to make sure listener addition is atomic in order to prevent having the same listener registered under multiple configurations |
154,253 | private synchronized boolean removeWrapperFromList ( EventListenerWrapper < K , V > wrapper , List < EventListenerWrapper < K , V > > listenersList ) { int index = listenersList . indexOf ( wrapper ) ; if ( index != - 1 ) { EventListenerWrapper < K , V > containedWrapper = listenersList . remove ( index ) ; if ( contai... | Synchronized to make sure listener removal is atomic |
154,254 | private void init ( ) { CompletableFuture . allOf ( managementRegistry . register ( generateClusterTierManagerBinding ( ) ) , managementRegistry . register ( PoolBinding . ALL_SHARED ) ) . thenRun ( managementRegistry :: refresh ) ; } | the goal of the following code is to send the management metadata from the entity into the monitoring tre AFTER the entity creation |
154,255 | public boolean seen ( long msgId ) { boolean seen = nonContiguousMsgIds . contains ( msgId ) || msgId <= highestContiguousMsgId ; tryReconcile ( ) ; return seen ; } | Check wheather the given message id is already seen by track call . |
154,256 | private void reconcile ( ) { if ( nonContiguousMsgIds . isEmpty ( ) ) { return ; } if ( highestContiguousMsgId == - 1L && isSyncCompleted ) { Long min = nonContiguousMsgIds . last ( ) ; LOGGER . info ( "Setting highestContiguousMsgId to {} from -1" , min ) ; highestContiguousMsgId = min ; nonContiguousMsgIds . removeIf... | Remove the contiguous seen msgIds from the nonContiguousMsgIds and update highestContiguousMsgId |
154,257 | private void tryReconcile ( ) { if ( ! this . reconciliationLock . tryLock ( ) ) { return ; } try { reconcile ( ) ; if ( nonContiguousMsgIds . size ( ) > 500 ) { LOGGER . warn ( "Non - Contiguous Message ID has size : {}, with highestContiguousMsgId as : {}" , nonContiguousMsgIds . size ( ) , highestContiguousMsgId ) ;... | Try to reconcile if the lock is available otherwise just return as other thread would have hold the lock and performing reconcile . |
154,258 | public DefaultResilienceStrategyConfiguration bind ( RecoveryStore < ? > store , CacheLoaderWriter < ? , ? > loaderWriter ) throws IllegalStateException { if ( getInstance ( ) == null ) { Object [ ] arguments = getArguments ( ) ; Object [ ] boundArguments = Arrays . copyOf ( arguments , arguments . length + 2 ) ; bound... | Returns a configuration object bound to the given store and cache loader - writer . |
154,259 | public void setLastAccessTime ( long lastAccessTime ) { while ( true ) { long current = this . lastAccessTime ; if ( current >= lastAccessTime ) { break ; } if ( ACCESSTIME_UPDATER . compareAndSet ( this , current , lastAccessTime ) ) { break ; } } } | Set the last time this entry was accessed in milliseconds . |
154,260 | public PutOperation < K , V > applyOperation ( K key , PutOperation < K , V > existing , Operation < K , V > operation ) { final Result < K , V > newValue = operation . apply ( existing ) ; if ( newValue == null ) { return null ; } else { return newValue . asOperationExpiringAt ( Long . MAX_VALUE ) ; } } | Applies the given operation returning a result that never expires . |
154,261 | public Map < K , ValueHolder < V > > bulkCompute ( final Set < ? extends K > keys , final Function < Iterable < ? extends Map . Entry < ? extends K , ? extends V > > , Iterable < ? extends Map . Entry < ? extends K , ? extends V > > > remappingFunction ) throws StoreAccessException { Map < K , ValueHolder < V > > value... | The assumption is that this method will be invoked only by cache . putAll and cache . removeAll methods . |
154,262 | public V getFailure ( K key , StoreAccessException e ) { cleanup ( key , e ) ; return null ; } | Return null . |
154,263 | public V putIfAbsentFailure ( K key , V value , StoreAccessException e ) { cleanup ( key , e ) ; return null ; } | Do nothing and return null . |
154,264 | public Map < K , V > getAllFailure ( Iterable < ? extends K > keys , StoreAccessException e ) { cleanup ( keys , e ) ; HashMap < K , V > result = keys instanceof Collection < ? > ? new HashMap < > ( ( ( Collection < ? extends K > ) keys ) . size ( ) ) : new HashMap < > ( ) ; for ( K key : keys ) { result . put ( key , ... | Do nothing and return a map of all the provided keys and null values . |
154,265 | public PooledExecutionServiceConfigurationBuilder defaultPool ( String alias , int minSize , int maxSize ) { PooledExecutionServiceConfigurationBuilder other = new PooledExecutionServiceConfigurationBuilder ( this ) ; other . defaultPool = new Pool ( alias , minSize , maxSize ) ; return other ; } | Adds a default pool configuration to the returned builder . |
154,266 | public PooledExecutionServiceConfigurationBuilder pool ( String alias , int minSize , int maxSize ) { PooledExecutionServiceConfigurationBuilder other = new PooledExecutionServiceConfigurationBuilder ( this ) ; other . pools . add ( new Pool ( alias , minSize , maxSize ) ) ; return other ; } | Adds a pool configuration to the returned builder . |
154,267 | private long calculateExpiryTime ( K key , PutOperation < K , V > existing , Operation < K , V > operation , Result < K , V > newValue ) { if ( operation . isExpiryAvailable ( ) ) { return operation . expirationTime ( ) ; } else { try { Duration duration ; if ( existing == null ) { duration = requireNonNull ( expiry . ... | Calculates the expiration time of the new state based on this resolvers expiry policy . |
154,268 | public static boolean isAvailable ( ServiceProvider < Service > serviceProvider ) { return ENTITY_SERVICE_CLASS != null && serviceProvider . getService ( ENTITY_SERVICE_CLASS ) != null ; } | Check if clustering is active for this cache manager |
154,269 | public static int findBestCollectionSize ( Iterable < ? > iterable , int bestBet ) { return ( iterable instanceof Collection ? ( ( Collection < ? > ) iterable ) . size ( ) : bestBet ) ; } | Used to create a new collection with the correct size . Given an iterable will try to see it the iterable actually have a size and will return it . If the iterable has no known size we return the best bet . |
154,270 | public static DedicatedClusteredResourcePool clusteredDedicated ( String fromResource , long size , MemoryUnit unit ) { return new DedicatedClusteredResourcePoolImpl ( fromResource , size , unit ) ; } | Creates a new clustered resource pool using dedicated clustered resources . |
154,271 | public static < T > Optional < T > findStatisticOnDescendants ( Object context , String tag , String statName ) { @ SuppressWarnings ( "unchecked" ) Set < TreeNode > statResult = queryBuilder ( ) . descendants ( ) . filter ( context ( attributes ( Matchers . allOf ( hasAttribute ( "name" , statName ) , hasTag ( tag ) )... | Search for a statistic on the descendant of the context that matches the tag and statistic name . |
154,272 | public long getQueueSize ( ) { Batch snapshot = openBatch ; return executorQueue . size ( ) * batchSize + ( snapshot == null ? 0 : snapshot . size ( ) ) ; } | Gets the best estimate for items in the queue still awaiting processing . Since the value returned is a rough estimate it can sometimes be more than the number of items actually in the queue but not less . |
154,273 | public Result < K , V > apply ( final Result < K , V > previousOperation ) { if ( previousOperation == null ) { return this ; } else { return previousOperation ; } } | PutIfAbsent operation succeeds only when there is no previous operation for the same key . |
154,274 | public void setClip ( Rectangle2D clip ) { xMin = clip . getX ( ) ; xMax = xMin + clip . getWidth ( ) ; yMin = clip . getY ( ) ; yMax = yMin + clip . getHeight ( ) ; } | Sets the clip rectangle . |
154,275 | public static < T extends Comparable < ? super T > > void sort ( List < T > list ) { sort ( list , QuickSort . < T > naturalOrder ( ) ) ; } | Sorts the given list according to natural order . |
154,276 | public static < T > void sort ( List < T > list , Comparator < ? super T > comparator ) { if ( list instanceof RandomAccess ) { quicksort ( list , comparator ) ; } else { List < T > copy = new ArrayList < > ( list ) ; quicksort ( copy , comparator ) ; list . clear ( ) ; list . addAll ( copy ) ; } } | Sorts the given list using the given comparator . |
154,277 | public Rectangle getTextBounds ( ) { List < TextElement > texts = this . getText ( ) ; if ( ! texts . isEmpty ( ) ) { return Utils . bounds ( texts ) ; } else { return new Rectangle ( ) ; } } | Returns the minimum bounding box that contains all the TextElements on this Page |
154,278 | public static float [ ] filter ( float [ ] data , float alpha ) { float [ ] rv = new float [ data . length ] ; rv [ 0 ] = data [ 0 ] ; for ( int i = 1 ; i < data . length ; i ++ ) { rv [ i ] = rv [ i - 1 ] + alpha * ( data [ i ] - rv [ i - 1 ] ) ; } return rv ; } | Simple Low pass filter |
154,279 | public List < Table > extract ( Page page , List < Ruling > rulings ) { List < Ruling > horizontalR = new ArrayList < > ( ) , verticalR = new ArrayList < > ( ) ; for ( Ruling r : rulings ) { if ( r . horizontal ( ) ) { horizontalR . add ( r ) ; } else if ( r . vertical ( ) ) { verticalR . add ( r ) ; } } horizontalR = ... | Extract a list of Table from page using rulings as separators |
154,280 | public static < T extends Comparable < ? super T > > void sort ( List < T > list ) { if ( useQuickSort ) QuickSort . sort ( list ) ; else Collections . sort ( list ) ; } | Wrap Collections . sort so we can fallback to a non - stable quicksort if we re running on JDK7 + |
154,281 | public void normalize ( ) { double angle = this . getAngle ( ) ; if ( Utils . within ( angle , 0 , 1 ) || Utils . within ( angle , 180 , 1 ) ) { this . setLine ( this . x1 , this . y1 , this . x2 , this . y1 ) ; } else if ( Utils . within ( angle , 90 , 1 ) || Utils . within ( angle , 270 , 1 ) ) { this . setLine ( thi... | Normalize almost horizontal or almost vertical lines |
154,282 | private static OutputFormat whichOutputFormat ( CommandLine line ) throws ParseException { if ( ! line . hasOption ( 'f' ) ) { return OutputFormat . CSV ; } try { return OutputFormat . valueOf ( line . getOptionValue ( 'f' ) ) ; } catch ( IllegalArgumentException e ) { throw new ParseException ( String . format ( "form... | CommandLine parsing methods |
154,283 | public static List < Float > parseFloatList ( String option ) throws ParseException { String [ ] f = option . split ( "," ) ; List < Float > rv = new ArrayList < > ( ) ; try { for ( int i = 0 ; i < f . length ; i ++ ) { rv . add ( Float . parseFloat ( f [ i ] ) ) ; } return rv ; } catch ( NumberFormatException e ) { th... | utilities etc . |
154,284 | public TextChunk [ ] splitAt ( int i ) { if ( i < 1 || i >= this . getTextElements ( ) . size ( ) ) { throw new IllegalArgumentException ( ) ; } TextChunk [ ] rv = new TextChunk [ ] { new TextChunk ( this . getTextElements ( ) . subList ( 0 , i ) ) , new TextChunk ( this . getTextElements ( ) . subList ( i , this . get... | Splits a TextChunk in two at the position of the i - th TextElement |
154,285 | public void smoothScrollToPosition ( int position ) { int transformedPosition = transformInnerPositionIfNeed ( position ) ; super . smoothScrollToPosition ( transformedPosition ) ; Log . e ( "test" , "transformedPosition:" + transformedPosition ) ; } | Starts a smooth scroll to an adapter position . if position < adapter . getActualCount position will be transform to right position . |
154,286 | @ SuppressWarnings ( "unchecked" ) static < T , A extends BindingCollectionAdapter < T > > A createClass ( Class < ? extends BindingCollectionAdapter > adapterClass , ItemBinding < T > itemBinding ) { try { return ( A ) adapterClass . getConstructor ( ItemBinding . class ) . newInstance ( itemBinding ) ; } catch ( Exce... | Constructs a binding adapter class from it s class name using reflection . |
154,287 | public DiffUtil . DiffResult calculateDiff ( final List < T > newItems ) { final ArrayList < T > frozenList ; synchronized ( LIST_LOCK ) { frozenList = new ArrayList < > ( list ) ; } return doCalculateDiff ( frozenList , newItems ) ; } | Calculates the list of update operations that can convert this list into the given one . |
154,288 | public final ItemBinding < T > bindExtra ( int variableId , Object value ) { if ( extraBindings == null ) { extraBindings = new SparseArray < > ( 1 ) ; } extraBindings . put ( variableId , value ) ; return this ; } | Bind an extra variable to the view with the given variable id . The same instance will be provided to all views the binding is bound to . |
154,289 | public final Object extraBinding ( int variableId ) { if ( extraBindings == null ) { return null ; } return extraBindings . get ( variableId ) ; } | Returns the current extra binding for the given variable id or null if one isn t present . |
154,290 | public void onItemBind ( int position , T item ) { if ( onItemBind != null ) { variableId = VAR_INVALID ; layoutRes = LAYOUT_NONE ; onItemBind . onItemBind ( this , position , item ) ; if ( variableId == VAR_INVALID ) { throw new IllegalStateException ( "variableId not set in onItemBind()" ) ; } if ( layoutRes == LAYOU... | Updates the state of the binding for the given item and position . This is called internally by the binding collection adapters . |
154,291 | public MergeObservableList < T > insertItem ( T object ) { lists . add ( Collections . singletonList ( object ) ) ; modCount += 1 ; listeners . notifyInserted ( this , size ( ) - 1 , 1 ) ; return this ; } | Inserts the given item into the merge list . |
154,292 | public boolean removeItem ( T object ) { int size = 0 ; for ( int i = 0 , listsSize = lists . size ( ) ; i < listsSize ; i ++ ) { List < ? extends T > list = lists . get ( i ) ; if ( ! ( list instanceof ObservableList ) ) { Object item = list . get ( 0 ) ; if ( ( object == null ) ? ( item == null ) : object . equals ( ... | Removes the given item from the merge list . |
154,293 | public void removeAll ( ) { int size = size ( ) ; if ( size == 0 ) { return ; } for ( int i = 0 , listSize = lists . size ( ) ; i < listSize ; i ++ ) { List < ? extends T > list = lists . get ( i ) ; if ( list instanceof ObservableList ) { ( ( ObservableList ) list ) . removeOnListChangedCallback ( callback ) ; } } lis... | Removes all items and lists from the merge list . |
154,294 | public static void endTransitions ( final ViewGroup sceneRoot ) { sPendingTransitions . remove ( sceneRoot ) ; final ArrayList < Transition > runningTransitions = getRunningTransitions ( sceneRoot ) ; if ( ! runningTransitions . isEmpty ( ) ) { ArrayList < Transition > copy = new ArrayList ( runningTransitions ) ; for ... | Ends all pending and ongoing transitions on the specified scene root . |
154,295 | public TransitionSet setOrdering ( int ordering ) { switch ( ordering ) { case ORDERING_SEQUENTIAL : mPlayTogether = false ; break ; case ORDERING_TOGETHER : mPlayTogether = true ; break ; default : throw new AndroidRuntimeException ( "Invalid parameter for TransitionSet " + "ordering: " + ordering ) ; } return this ; ... | Sets the play order of this set s child transitions . |
154,296 | public Transition getTransitionAt ( int index ) { if ( index < 0 || index >= mTransitions . size ( ) ) { return null ; } return mTransitions . get ( index ) ; } | Returns the child Transition at the specified position in the TransitionSet . |
154,297 | private static void extract ( String s , int start , ExtractFloatResult result ) { int currentIndex = start ; boolean foundSeparator = false ; result . mEndWithNegOrDot = false ; boolean secondDot = false ; boolean isExponential = false ; for ( ; currentIndex < s . length ( ) ; currentIndex ++ ) { boolean isPrevExponen... | Calculate the position of the next comma or space or negative sign |
154,298 | protected void runAnimators ( ) { if ( DBG ) { Log . d ( LOG_TAG , "runAnimators() on " + this ) ; } start ( ) ; ArrayMap < Animator , AnimationInfo > runningAnimators = getRunningAnimators ( ) ; for ( Animator anim : mAnimators ) { if ( DBG ) { Log . d ( LOG_TAG , " anim: " + anim ) ; } if ( runningAnimators . contai... | This is called internally once all animations have been set up by the transition hierarchy . |
154,299 | protected void start ( ) { if ( mNumInstances == 0 ) { if ( mListeners != null && mListeners . size ( ) > 0 ) { ArrayList < TransitionListener > tmpListeners = ( ArrayList < TransitionListener > ) mListeners . clone ( ) ; int numListeners = tmpListeners . size ( ) ; for ( int i = 0 ; i < numListeners ; ++ i ) { tmpList... | This method is called automatically by the transition and TransitionSet classes prior to a Transition subclass starting ; subclasses should not need to call it directly . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.