idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
22,500 | @ Path ( "teams" ) public Response authorizedTeams ( @ HeaderParam ( "Authorization" ) @ DefaultValue ( "no token" ) String auth ) throws Exception { if ( ! this . isAuth ( auth ) ) { return Response . status ( Status . FORBIDDEN ) . build ( ) ; } Integer teams [ ] = getAuthorizedTeams ( ) ; return Response . ok ( new ... | Get the list of github team ids that are allowed to access this instance . |
22,501 | private void sendRequest ( HttpUriRequest request , int expectedStatus ) throws Exception { addAuthHeader ( request ) ; HttpClient client = httpClient ( ) ; HttpResponse response = client . execute ( request ) ; if ( response . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_NOT_FOUND ) { EntityUtils . consume... | Sends a request to the rest endpoint . |
22,502 | private String hashPasswordForShiro ( ) { HashFormatFactory HASH_FORMAT_FACTORY = new DefaultHashFormatFactory ( ) ; SecureRandomNumberGenerator generator = new SecureRandomNumberGenerator ( ) ; int byteSize = 128 / 8 ; ByteSource salt = generator . nextBytes ( byteSize ) ; SimpleHash hash = new SimpleHash ( "SHA-256" ... | Hashes a password the shiro way . |
22,503 | public static Field createTupleField ( String name , Schema schema ) { return Field . createTupleField ( name , schema ) ; } | Creates a field containing a Pangool Tuple . |
22,504 | protected void configure ( ) { try { InternalLoggerFactory . setDefaultFactory ( new Slf4JLoggerFactory ( ) ) ; File appRoot = new File ( System . getProperty ( CadmiumListener . BASE_PATH_ENV ) , "maven" ) ; FileUtils . forceMkdir ( appRoot ) ; String remoteMavenRepo = System . getProperty ( MAVEN_REPOSITORY ) ; Artif... | Called to do all bindings for this module . |
22,505 | public static Response internalError ( Throwable throwable , UriInfo uriInfo ) { GenericError error = new GenericError ( ExceptionUtils . getRootCauseMessage ( throwable ) , ErrorCode . INTERNAL . getCode ( ) , uriInfo . getAbsolutePath ( ) . toString ( ) ) ; if ( ! isProduction ( ) ) { error . setStack ( ExceptionUtil... | Creates Jersey response corresponding to internal error |
22,506 | public static GitService initializeConfigDirectory ( String uri , String branch , String root , String warName , HistoryManager historyManager , ConfigManager configManager ) throws Exception { initializeBaseDirectoryStructure ( root , warName ) ; String warDir = FileSystemManager . getChildDirectoryIfExists ( root , w... | Initializes war configuration directory for a Cadmium war . |
22,507 | public String checkinNewContent ( String sourceDirectory , String message ) throws Exception { RmCommand remove = git . rm ( ) ; boolean hasFiles = false ; for ( String filename : new File ( getBaseDirectory ( ) ) . list ( ) ) { if ( ! filename . equals ( ".git" ) ) { remove . addFilepattern ( filename ) ; hasFiles = t... | Checks in content from a source directory into the current git repository . |
22,508 | public ObjectNode convertToObjectNode ( ILoggingEvent event ) { final ObjectNode logLine = mapper . valueToTree ( event instanceof OtlType ? event : new ApplicationLogEvent ( event ) ) ; final Marker marker = event . getMarker ( ) ; if ( marker instanceof LogMetadata ) { ObjectNode metadataNode = mapper . valueToTree (... | Prepare a log event but don t append it return it as an ObjectNode instead . |
22,509 | protected byte [ ] getLogMessage ( final ObjectNode event ) { try ( ByteArrayBuilder buf = new ByteArrayBuilder ( ) ) { mapper . writeValue ( buf , event ) ; buf . append ( '\n' ) ; return buf . toByteArray ( ) ; } catch ( IOException e ) { addError ( "while serializing log event" , e ) ; return NADA ; } } | Convert the JSON object to a byte array to log |
22,510 | public void execute ( ) throws Exception { String content = null ; String siteUrl = null ; if ( params . size ( ) == 2 ) { content = params . get ( 0 ) ; siteUrl = getSecureBaseUrl ( params . get ( 1 ) ) ; } else if ( params . size ( ) == 0 ) { System . err . println ( "The content directory and site must be specifed."... | Does the work for this command . |
22,511 | public static void enableSerialization ( Configuration conf ) { String serClass = TupleSerialization . class . getName ( ) ; Collection < String > currentSers = conf . getStringCollection ( "io.serializations" ) ; if ( currentSers . size ( ) == 0 ) { conf . set ( "io.serializations" , serClass ) ; return ; } if ( ! cur... | Use this method to enable this serialization in Hadoop |
22,512 | public static void disableSerialization ( Configuration conf ) { String ser = conf . get ( "io.serializations" ) . trim ( ) ; String stToSearch = Pattern . quote ( "," + TupleSerialization . class . getName ( ) ) ; ser = ser . replaceAll ( stToSearch , "" ) ; conf . set ( "io.serializations" , ser ) ; } | Use this method to disable this serialization in Hadoop |
22,513 | public static int compare ( String ns1 , String ln1 , String ns2 , String ln2 ) { if ( ns1 == null ) { ns1 = Constants . XML_NULL_NS_URI ; } if ( ns2 == null ) { ns2 = Constants . XML_NULL_NS_URI ; } int cLocalPart = ln1 . compareTo ( ln2 ) ; return ( cLocalPart == 0 ? ns1 . compareTo ( ns2 ) : cLocalPart ) ; } | Sort lexicographically by qname local - name then by qname uri |
22,514 | public static void postConstructQuietly ( Object obj , Logger log ) { try { postConstruct ( obj , log ) ; } catch ( Throwable t ) { log . warn ( "Could not @PostConstruct object" , t ) ; } } | Calls postConstruct with the same arguments logging any exceptions that are thrown at the level warn . |
22,515 | public static void preDestroyQuietly ( Object obj , Logger log ) { try { preDestroy ( obj , log ) ; } catch ( Throwable t ) { log . warn ( "Could not @PreDestroy object" , t ) ; } } | Calls preDestroy with the same arguments logging any exceptions that are thrown at the level warn . |
22,516 | private static List < Method > getAnnotatedMethodsFromChildToParent ( Class < ? > clazz , Class < ? extends Annotation > annotation , Logger log ) { List < Method > methodsToRun = new ArrayList < Method > ( ) ; while ( clazz != null ) { List < Method > newMethods = getMethodsWithAnnotation ( clazz , annotation , log ) ... | Locates all annotated methods on the type passed in sorted as declared from the type to its super class . |
22,517 | private static boolean containsMethod ( Method method , List < Method > methods ) { if ( methods != null ) { for ( Method aMethod : methods ) { if ( method . getName ( ) . equals ( aMethod . getName ( ) ) ) { return true ; } } } return false ; } | Checks if the passed in method already exists in the list of methods . Checks for equality by the name of the method . |
22,518 | private static void removeMethodByName ( Method method , List < Method > methods ) { if ( methods != null ) { Iterator < Method > itr = methods . iterator ( ) ; Method aMethod = null ; while ( itr . hasNext ( ) ) { aMethod = itr . next ( ) ; if ( aMethod . getName ( ) . equals ( method . getName ( ) ) ) { itr . remove ... | Removes a method from the given list and adds it to the end of the list . |
22,519 | private static List < Method > getMethodsWithAnnotation ( Class < ? > clazz , Class < ? extends Annotation > annotation , Logger log ) { List < Method > annotatedMethods = new ArrayList < Method > ( ) ; Method classMethods [ ] = clazz . getDeclaredMethods ( ) ; for ( Method classMethod : classMethods ) { if ( classMeth... | Locates all methods annotated with a given annotation that are declared directly in the class passed in alphabetical order . |
22,520 | public static Jsr250Executor createJsr250Executor ( Injector injector , final Logger log , Scope ... scopes ) { final Set < Object > instances = findInstancesInScopes ( injector , scopes ) ; final List < Object > reverseInstances = new ArrayList < Object > ( instances ) ; Collections . reverse ( reverseInstances ) ; re... | Creates a Jsr250Executor for the specified scopes . |
22,521 | public static Set < Object > findInstancesInScopes ( Injector injector , Class < ? extends Annotation > ... scopeAnnotations ) { Set < Object > objects = new TreeSet < Object > ( new Comparator < Object > ( ) { public int compare ( Object o0 , Object o1 ) { return o0 . getClass ( ) . getName ( ) . compareTo ( o1 . getC... | Finds all of the instances in the specified scopes . |
22,522 | public static Map < Key < ? > , Binding < ? > > findBindingsInScope ( Injector injector , Class < ? extends Annotation > ... scopeAnnotations ) { Map < Key < ? > , Binding < ? > > bindings = new LinkedHashMap < Key < ? > , Binding < ? > > ( ) ; ALL_BINDINGS : for ( Map . Entry < Key < ? > , Binding < ? > > entry : inje... | Finds all of the unique providers in the injector in the specified scopes . |
22,523 | public static Map < Key < ? > , Binding < ? > > findBindingsInScope ( Injector injector , Scope ... scopes ) { Map < Key < ? > , Binding < ? > > bindings = new LinkedHashMap < Key < ? > , Binding < ? > > ( ) ; ALL_BINDINGS : for ( Map . Entry < Key < ? > , Binding < ? > > entry : injector . getAllBindings ( ) . entrySe... | Returns the bindings in the specified scope . |
22,524 | public static boolean inScope ( final Injector injector , final Binding < ? > binding , final Class < ? extends Annotation > scope ) { return binding . acceptScopingVisitor ( new BindingScopingVisitor < Boolean > ( ) { public Boolean visitEagerSingleton ( ) { return scope == Singleton . class || scope == javax . inject... | Returns true if the binding is in the specified scope false otherwise . |
22,525 | private void init ( Class < ? > type ) { if ( method . isAnnotationPresent ( CoordinatorOnly . class ) || type . isAnnotationPresent ( CoordinatorOnly . class ) ) { coordinatorOnly = true ; } if ( method . isAnnotationPresent ( Scheduled . class ) ) { annotation = method . getAnnotation ( Scheduled . class ) ; } else i... | Sets all values needed for the scheduling of this Runnable . |
22,526 | private void checkRunnable ( Class < ? > type ) { if ( Runnable . class . isAssignableFrom ( type ) ) { try { this . method = type . getMethod ( "run" ) ; } catch ( Exception e ) { throw new RuntimeException ( "Cannot get run method of runnable class." , e ) ; } } } | Checks if the type is a Runnable and gets the run method . |
22,527 | public static String [ ] sendRequest ( String token , String site , OPERATION op , String path ) throws Exception { HttpClient client = httpClient ( ) ; HttpUriRequest message = null ; if ( op == OPERATION . DISABLE ) { message = new HttpPut ( site + ENDPOINT + path ) ; } else if ( op == OPERATION . ENABLE ) { message ... | Sends acl request to cadmium . |
22,528 | public void shallowCopy ( ITuple tupleDest ) { for ( Field field : this . getSchema ( ) . getFields ( ) ) { tupleDest . set ( field . getName ( ) , this . get ( field . getName ( ) ) ) ; } } | Simple shallow copy of this Tuple to another Tuple . |
22,529 | public static final String getQualifiedName ( String localName , String pfx ) { pfx = pfx == null ? "" : pfx ; return pfx . length ( ) == 0 ? localName : ( pfx + Constants . COLON + localName ) ; } | Returns qualified name as String |
22,530 | public void setOption ( String key , Object value ) throws UnsupportedOption { if ( key . equals ( INCLUDE_COOKIE ) ) { options . put ( key , null ) ; } else if ( key . equals ( INCLUDE_OPTIONS ) ) { options . put ( key , null ) ; } else if ( key . equals ( INCLUDE_SCHEMA_ID ) ) { options . put ( key , null ) ; } else ... | Enables given option with value . |
22,531 | public boolean unsetOption ( String key ) { boolean b = options . containsKey ( key ) ; options . remove ( key ) ; return b ; } | Disables given option . |
22,532 | private static void checkNamedOutputName ( JobContext job , String namedOutput , boolean alreadyDefined ) { validateOutputName ( namedOutput ) ; List < String > definedChannels = getNamedOutputsList ( job ) ; if ( alreadyDefined && definedChannels . contains ( namedOutput ) ) { throw new IllegalArgumentException ( "Nam... | Checks if a named output name is valid . |
22,533 | private static String getDefaultNamedOutputFormatInstanceFile ( JobContext job ) { return job . getConfiguration ( ) . get ( DEFAULT_MO_PREFIX + FORMAT_INSTANCE_FILE , null ) ; } | Returns the DEFAULT named output OutputFormat . |
22,534 | private static Class < ? > getDefaultNamedOutputKeyClass ( JobContext job ) { return job . getConfiguration ( ) . getClass ( DEFAULT_MO_PREFIX + KEY , null , Object . class ) ; } | Returns the DEFAULT key class for a named output . |
22,535 | private static Class < ? > getDefaultNamedOutputValueClass ( JobContext job ) { return job . getConfiguration ( ) . getClass ( DEFAULT_MO_PREFIX + VALUE , null , Object . class ) ; } | Returns the DEFAULT value class for a named output . |
22,536 | public static String addNamedOutput ( Job job , String namedOutput , OutputFormat outputFormat , Class < ? > keyClass , Class < ? > valueClass ) throws FileNotFoundException , IOException , URISyntaxException { checkNamedOutputName ( job , namedOutput , true ) ; Configuration conf = job . getConfiguration ( ) ; String ... | Adds a named output for the job . Returns the instance file that has been created . |
22,537 | @ SuppressWarnings ( "unchecked" ) public < K , V > void write ( String namedOutput , K key , V value , String baseOutputPath ) throws IOException , InterruptedException { checkNamedOutputName ( context , namedOutput , false ) ; checkBaseOutputPath ( baseOutputPath ) ; if ( ! namedOutputs . contains ( namedOutput ) ) {... | Write key and value to baseOutputPath using the namedOutput . |
22,538 | public void close ( ) throws IOException , InterruptedException { for ( OutputContext outputContext : this . outputContexts . values ( ) ) { outputContext . recordWriter . close ( outputContext . taskAttemptContext ) ; outputContext . outputCommitter . commitTask ( outputContext . taskAttemptContext ) ; JobContext jCon... | Closes all the opened outputs . |
22,539 | private WhiteSpace getDatatypeWhiteSpace ( ) { Grammar currGr = this . getCurrentGrammar ( ) ; if ( currGr . isSchemaInformed ( ) && currGr . getNumberOfEvents ( ) > 0 ) { Production prod = currGr . getProduction ( 0 ) ; if ( prod . getEvent ( ) . getEventType ( ) == EventType . CHARACTERS ) { Characters ch = ( Charact... | returns null if no CH datatype is available or schema - less |
22,540 | public void skip ( long n ) throws IOException { if ( capacity == 0 ) { while ( n != 0 ) { n -= istream . skip ( n ) ; } } else { for ( int i = 0 ; i < n ; n ++ ) { readBits ( 8 ) ; } } } | Skip n bytes |
22,541 | public int readBits ( int n ) throws IOException { assert ( n > 0 ) ; int result ; if ( n <= capacity ) { result = ( buffer >> ( capacity -= n ) ) & ( 0xff >> ( BUFFER_CAPACITY - n ) ) ; } else if ( capacity == 0 && n == BUFFER_CAPACITY ) { result = readDirectByte ( ) ; } else { result = buffer & ( 0xff >> ( BUFFER_CAP... | Read the next n bits and return the result as an integer . |
22,542 | public void readFields ( ITuple tuple , Deserializer [ ] customDeserializers ) throws IOException { readFields ( tuple , readSchema , customDeserializers ) ; } | Read fields using the specified readSchema in the constructor . |
22,543 | public final void mutate ( Context context ) throws MutagenException { performMutation ( context ) ; int version = getResultingState ( ) . getID ( ) ; String change = getChangeSummary ( ) ; if ( change == null ) { change = "" ; } String changeHash = md5String ( change ) ; try { MutationBatch batch = getKeyspace ( ) . p... | Performs the actual mutation and then updates the recorded schema version |
22,544 | public static String toHex ( byte [ ] bytes ) { StringBuilder hexString = new StringBuilder ( ) ; for ( int i = 0 ; i < bytes . length ; i ++ ) { String hex = Integer . toHexString ( 0xFF & bytes [ i ] ) ; if ( hex . length ( ) == 1 ) { hexString . append ( '0' ) ; } hexString . append ( hex ) ; } return hexString . to... | Encode a byte array as a hexadecimal string |
22,545 | public static List < String > getDeployed ( String url , String token ) throws Exception { List < String > deployed = new ArrayList < String > ( ) ; HttpClient client = httpClient ( ) ; HttpGet get = new HttpGet ( url + "/system/deployment/list" ) ; addAuthHeader ( token , get ) ; HttpResponse resp = client . execute (... | Retrieves a list of Cadmium wars that are deployed . |
22,546 | public static void undeploy ( String url , String warName , String token ) throws Exception { HttpClient client = httpClient ( ) ; HttpPost del = new HttpPost ( url + "/system/undeploy" ) ; addAuthHeader ( token , del ) ; del . addHeader ( "Content-Type" , MediaType . APPLICATION_JSON ) ; UndeployRequest req = new Unde... | Sends the undeploy command to a Cadmium - Deployer war . |
22,547 | public void set ( int bit , boolean value ) { int bite = byteForBit ( bit ) ; ensureSpace ( bite + 1 ) ; int bitOnByte = bitOnByte ( bit , bite ) ; if ( value ) { bits [ bite ] = byteBitSet ( bitOnByte , bits [ bite ] ) ; } else { bits [ bite ] = byteBitUnset ( bitOnByte , bits [ bite ] ) ; } } | Sets or unsets a bit . The smaller allowed bit is 0 |
22,548 | public boolean isSet ( int bit ) { int bite = byteForBit ( bit ) ; if ( bite >= bits . length || bits . length == 0 ) { return false ; } int bitOnByte = bitOnByte ( bit , bite ) ; return ( ( 1 << bitOnByte ) & bits [ bite ] ) != 0 ; } | Returns the value of a given bit . False is returned for unexisting bits . |
22,549 | public void ser ( DataOutput out ) throws IOException { if ( bits . length == 0 ) { out . writeByte ( 0 ) ; return ; } int bytesToWrite ; for ( bytesToWrite = bits . length ; bytesToWrite > 1 && bits [ bytesToWrite - 1 ] == 0 ; bytesToWrite -- ) ; for ( int i = 0 ; i < ( bytesToWrite - 1 ) ; i ++ ) { out . writeByte ( ... | Serializes the bit field to the data output . It uses one byte per each 7 bits . If the rightmost bit of the read byte is set that means that there are more bytes to consume . The latest byte has the rightmost bit unset . |
22,550 | public int deser ( byte [ ] bytes , int start ) throws IOException { int idx = 0 ; byte current ; do { current = bytes [ start + idx ] ; ensureSpace ( idx + 1 ) ; bits [ idx ] = ( byte ) ( current & ~ 1 ) ; idx ++ ; } while ( ( current & 1 ) != 0 ) ; for ( int i = idx ; i < bits . length ; i ++ ) { bits [ i ] = 0 ; } r... | Deserialize a BitField serialized from a byte array . Return the number of bytes consumed . |
22,551 | protected void ensureSpace ( int bytes ) { if ( bits . length < bytes ) { bits = Arrays . copyOf ( bits , bytes ) ; } } | Ensures a minimum size for the backing byte array |
22,552 | public TypeDescription addTypeDescription ( TypeDescription definition ) { if ( definition != null && definition . getTag ( ) != null ) { tagsDefined . add ( definition . getTag ( ) ) ; } return super . addTypeDescription ( definition ) ; } | Overridden to capture what tags are defined specially . |
22,553 | protected Construct getConstructor ( Node node ) { Construct construct = super . getConstructor ( node ) ; logger . trace ( "getting constructor for node {} Tag {} = {}" , new Object [ ] { node , node . getTag ( ) , construct } ) ; if ( construct instanceof ConstructYamlObject && ! tagsDefined . contains ( node . getTa... | Overridden to fetch constructor even if tag is not mapped . |
22,554 | private void resolveType ( Node node ) throws ClassNotFoundException { String typeName = node . getTag ( ) . getClassName ( ) ; if ( typeName . equals ( "int" ) ) { node . setType ( Integer . TYPE ) ; } else if ( typeName . equals ( "float" ) ) { node . setType ( Float . TYPE ) ; } else if ( typeName . equals ( "double... | Resolves the type of a node after the tag gets re - resolved . |
22,555 | protected UUID getRequestIdFrom ( Request request , Response response ) { return optUuid ( response . getHeader ( OTHeaders . REQUEST_ID ) ) ; } | Provides a hook whereby an alternate source can be provided for grabbing the requestId |
22,556 | public static LoggerConfig [ ] setLogLevel ( String loggerName , String level ) { if ( StringUtils . isBlank ( loggerName ) ) { loggerName = ch . qos . logback . classic . Logger . ROOT_LOGGER_NAME ; } LoggerContext context = ( LoggerContext ) LoggerFactory . getILoggerFactory ( ) ; log . debug ( "Setting {} to level {... | Updates a logger with a given name to the given level . |
22,557 | public int decodeNBitUnsignedInteger ( int n ) throws IOException { assert ( n >= 0 ) ; int bitsRead = 0 ; int result = 0 ; while ( bitsRead < n ) { result += ( decode ( ) << bitsRead ) ; bitsRead += 8 ; } return result ; } | Decodes and returns an n - bit unsigned integer using the minimum number of bytes required for n bits . |
22,558 | public Set < String > configureJob ( Job job ) throws FileNotFoundException , IOException , TupleMRException { Set < String > instanceFiles = new HashSet < String > ( ) ; for ( Output output : getNamedOutputs ( ) ) { try { if ( output . isDefault ) { instanceFiles . add ( PangoolMultipleOutputs . setDefaultNamedOutput ... | Use this method for configuring a Job instance according to the named outputs specs that has been specified . Returns the instance files that have been created . |
22,559 | public boolean canCheckWar ( String warName , String url , HttpClient client ) { HttpOptions opt = new HttpOptions ( url + "/" + warName ) ; try { HttpResponse response = client . execute ( opt ) ; if ( response . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_OK ) { Header allowHeader [ ] = response . getHea... | Checks via an http options request that the endpoint exists to check for deployment state . |
22,560 | public void encodeBinary ( byte [ ] b ) throws IOException { encodeUnsignedInteger ( b . length ) ; encode ( b , 0 , b . length ) ; } | Encode a binary value as a length - prefixed sequence of octets . |
22,561 | public void encodeString ( final String s ) throws IOException { final int lenChars = s . length ( ) ; final int lenCharacters = s . codePointCount ( 0 , lenChars ) ; encodeUnsignedInteger ( lenCharacters ) ; encodeStringOnly ( s ) ; } | Encode a string as a length - prefixed sequence of UCS codepoints each of which is encoded as an integer . Look for codepoints of more than 16 bits that are represented as UTF - 16 surrogate pairs in Java . |
22,562 | public void encodeInteger ( int n ) throws IOException { if ( n < 0 ) { encodeBoolean ( true ) ; encodeUnsignedInteger ( ( - n ) - 1 ) ; } else { encodeBoolean ( false ) ; encodeUnsignedInteger ( n ) ; } } | Encode an arbitrary precision integer using a sign bit followed by a sequence of octets . The most significant bit of the last octet is set to zero to indicate sequence termination . Only seven bits per octet are used to store the integer s value . |
22,563 | public void encodeUnsignedInteger ( int n ) throws IOException { if ( n < 0 ) { throw new UnsupportedOperationException ( ) ; } if ( n < 128 ) { encode ( n ) ; } else { final int n7BitBlocks = MethodsBag . numberOf7BitBlocksToRepresent ( n ) ; switch ( n7BitBlocks ) { case 5 : encode ( 128 | n ) ; n = n >>> 7 ; case 4 ... | Encode an arbitrary precision non negative integer using a sequence of octets . The most significant bit of the last octet is set to zero to indicate sequence termination . Only seven bits per octet are used to store the integer s value . |
22,564 | public void encodeFloat ( FloatValue fv ) throws IOException { encodeIntegerValue ( fv . getMantissa ( ) ) ; encodeIntegerValue ( fv . getExponent ( ) ) ; } | Encode a Float represented as two consecutive Integers . The first Integer represents the mantissa of the floating point number and the second Integer represents the 10 - based exponent of the floating point number |
22,565 | private void addAddressHelper ( InternetAddressSet set , String address ) { if ( address . contains ( "," ) || address . contains ( ";" ) ) { String [ ] addresses = address . split ( "[,;]" ) ; for ( String a : addresses ) { set . add ( a ) ; } } else { set . add ( address ) ; } } | Checks if the addresses need to be split either on or ; |
22,566 | public void simplify ( ) { ccSet . removeAll ( toSet ) ; bccSet . removeAll ( toSet ) ; bccSet . removeAll ( ccSet ) ; } | Simplifies this email by removing duplicate pieces of information . The standard implementation removes duplicate recipient emails in the to cc and bcc sets . |
22,567 | protected void populate ( MimeMessage message ) throws MessagingException { message . addRecipients ( Message . RecipientType . TO , toSet . toInternetAddressArray ( ) ) ; message . addRecipients ( Message . RecipientType . CC , ccSet . toInternetAddressArray ( ) ) ; message . addRecipients ( Message . RecipientType . ... | Populates a mime message with the recipient addresses from address reply to address and the subject . |
22,568 | public static AttachLogFilter attach ( Filter < ILoggingEvent > filter , String configKey ) { return new AttachLogFilter ( filter , configKey ) ; } | Create an attach log filter |
22,569 | public static void enableThriftSerialization ( Configuration conf ) { String ser = conf . get ( "io.serializations" ) . trim ( ) ; if ( ser . length ( ) != 0 ) { ser += "," ; } ser += ThriftSerialization . class . getName ( ) ; conf . set ( "io.serializations" , ser ) ; } | Enables Thrift Serialization support in Hadoop . |
22,570 | public static void main ( String [ ] args ) { try { jCommander = new JCommander ( ) ; jCommander . setProgramName ( "cadmium" ) ; HelpCommand helpCommand = new HelpCommand ( ) ; jCommander . addCommand ( "help" , helpCommand ) ; Map < String , CliCommand > commands = wireCommands ( jCommander ) ; try { jCommander . par... | The main entry point to Cadmium cli . |
22,571 | private static void setupSsh ( boolean noPrompt ) { File sshDir = new File ( System . getProperty ( "user.home" ) , ".ssh" ) ; if ( sshDir . exists ( ) ) { GitService . setupLocalSsh ( sshDir . getAbsolutePath ( ) , noPrompt ) ; } } | Sets up the ssh configuration that git will use to communicate with the remote git repositories . |
22,572 | public static void emptyMatrix ( byte [ ] [ ] matrix , int maxX , int maxY ) { for ( int i = 0 ; i < maxX ; i ++ ) { for ( int j = 0 ; j < maxY ; j ++ ) { matrix [ i ] [ j ] = 0 ; } } } | It is not very efficient but it is simple enough |
22,573 | static public byte [ ] decode ( String encoded ) { if ( encoded == null ) return null ; int lengthData = encoded . length ( ) ; if ( lengthData % 2 != 0 ) return null ; char [ ] binaryData = encoded . toCharArray ( ) ; int lengthDecode = lengthData / 2 ; byte [ ] decodedData = new byte [ lengthDecode ] ; byte temp1 , t... | Decode hex string to a byte array |
22,574 | public static DateTimeValue parse ( Calendar cal , DateTimeType type ) { int sYear = 0 ; int sMonthDay = 0 ; int sTime = 0 ; int sFractionalSecs = 0 ; boolean sPresenceTimezone = false ; int sTimezone ; switch ( type ) { case gYear : case gYearMonth : case date : sYear = cal . get ( Calendar . YEAR ) ; sMonthDay = getM... | Encode Date - Time as a sequence of values representing the individual components of the Date - Time . |
22,575 | protected static void setMonthDay ( int monthDay , Calendar cal ) { int month = monthDay / MONTH_MULTIPLICATOR ; cal . set ( Calendar . MONTH , month - 1 ) ; int day = monthDay - month * MONTH_MULTIPLICATOR ; cal . set ( Calendar . DAY_OF_MONTH , day ) ; } | Sets month and day of the given calendar making use of of the monthDay representation defined in EXI format |
22,576 | protected static void setTime ( int time , Calendar cal ) { int hour = time / ( 64 * 64 ) ; time -= hour * ( 64 * 64 ) ; int minute = time / 64 ; time -= minute * 64 ; cal . set ( Calendar . HOUR_OF_DAY , hour ) ; cal . set ( Calendar . MINUTE , minute ) ; cal . set ( Calendar . SECOND , time ) ; } | Sets hour minute and second of the given calendar making use of of the time representation defined in EXI format |
22,577 | private static void addPortMapping ( Integer insecurePort , Integer securePort ) { TO_SECURE_PORT_MAP . put ( insecurePort , securePort ) ; TO_INSECURE_PORT_MAP . put ( securePort , insecurePort ) ; } | Adds an entry to the secure and insecure port map . |
22,578 | public static int getDefaultPort ( String protocol ) { if ( HTTP_PROTOCOL . equals ( protocol ) ) { return DEFAULT_HTTP_PORT ; } else if ( HTTPS_PROTOCOL . equals ( protocol ) ) { return DEFAULT_HTTPS_PORT ; } else { throw new IllegalArgumentException ( "No known default for " + protocol ) ; } } | Returns the default port for the specified protocol . |
22,579 | public static int mapPort ( Map < Integer , Integer > mapping , int port ) { Integer mappedPort = mapping . get ( port ) ; if ( mappedPort == null ) throw new RuntimeException ( "Could not map port " + port ) ; return mappedPort ; } | Looks up a corresponding port number from a port mapping . |
22,580 | public String secureUrl ( HttpServletRequest request , HttpServletResponse response ) throws IOException { String protocol = getProtocol ( request ) ; if ( protocol . equalsIgnoreCase ( HTTP_PROTOCOL ) ) { int port = mapPort ( TO_SECURE_PORT_MAP , getPort ( request ) ) ; try { URI newUri = changeProtocolAndPort ( HTTPS... | Returns the secure version of the original URL for the request . |
22,581 | public String insecureUrl ( HttpServletRequest request , HttpServletResponse response ) throws IOException { String protocol = getProtocol ( request ) ; if ( protocol . equalsIgnoreCase ( HTTPS_PROTOCOL ) ) { int port = mapPort ( TO_INSECURE_PORT_MAP , getPort ( request ) ) ; try { return changeProtocolAndPort ( HTTP_P... | Returns the insecure version of the original URL for the request . |
22,582 | public void makeSecure ( HttpServletRequest request , HttpServletResponse response ) throws IOException { response . setStatus ( HttpServletResponse . SC_MOVED_PERMANENTLY ) ; response . setHeader ( "Location" , secureUrl ( request , response ) ) ; response . getOutputStream ( ) . flush ( ) ; response . getOutputStream... | Sends a moved perminately redirect to the secure form of the request URL . |
22,583 | public void makeInsecure ( HttpServletRequest request , HttpServletResponse response ) throws IOException { response . setStatus ( HttpServletResponse . SC_MOVED_PERMANENTLY ) ; response . setHeader ( "Location" , insecureUrl ( request , response ) ) ; response . getOutputStream ( ) . flush ( ) ; response . getOutputSt... | Sends a moved perminately redirect to the insecure form of the request URL . |
22,584 | public void init ( Configuration conf , Path generatedModel ) throws IOException , InterruptedException { FileSystem fileSystem = FileSystem . get ( conf ) ; for ( Category category : Category . values ( ) ) { wordCountPerCategory . put ( category , new HashMap < String , Integer > ( ) ) ; } Set < String > vocabulary =... | Read the Naive Bayes Model from HDFS |
22,585 | public Category classify ( String text ) { StringTokenizer itr = new StringTokenizer ( text ) ; Map < Category , Double > scorePerCategory = new HashMap < Category , Double > ( ) ; double bestScore = Double . NEGATIVE_INFINITY ; Category bestCategory = null ; while ( itr . hasMoreTokens ( ) ) { String token = NaiveBaye... | Naive Bayes Text Classification with Add - 1 Smoothing |
22,586 | public static int numberOf7BitBlocksToRepresent ( final long l ) { if ( l < 0xffffffff ) { return numberOf7BitBlocksToRepresent ( ( int ) l ) ; } else if ( l < 0x800000000L ) { return 5 ; } else if ( l < 0x40000000000L ) { return 6 ; } else if ( l < 0x2000000000000L ) { return 7 ; } else if ( l < 0x100000000000000L ) {... | Returns the least number of 7 bit - blocks that is needed to represent the parameter l . Returns 1 if parameter l is 0 . |
22,587 | public static MimeBodyPart newMultipartBodyPart ( Multipart multipart ) throws MessagingException { MimeBodyPart mimeBodyPart = new MimeBodyPart ( ) ; mimeBodyPart . setContent ( multipart ) ; return mimeBodyPart ; } | Creates a body part for a multipart . |
22,588 | public static MimeBodyPart newHtmlAttachmentBodyPart ( URL contentUrl , String contentId ) throws MessagingException { MimeBodyPart mimeBodyPart = new MimeBodyPart ( ) ; mimeBodyPart . setDataHandler ( new DataHandler ( contentUrl ) ) ; if ( contentId != null ) { mimeBodyPart . setHeader ( "Content-ID" , contentId ) ; ... | Creates a body part for an attachment that is used by an html body part . |
22,589 | public static String fileNameForUrl ( URL contentUrl ) { String fileName = null ; Matcher matcher = FILE_NAME_PATTERN . matcher ( contentUrl . getPath ( ) ) ; if ( matcher . find ( ) ) { fileName = matcher . group ( 1 ) ; } return fileName ; } | Returns the content disposition file name for a url . If a file name cannot be parsed from this url then null is returned . |
22,590 | private void initCommonAndGroupSchemaSerialization ( ) { commonSerializers = getSerializers ( commonSchema , null ) ; commonDeserializers = getDeserializers ( commonSchema , commonSchema , null ) ; groupSerializers = getSerializers ( groupSchema , null ) ; groupDeserializers = getDeserializers ( groupSchema , groupSche... | This serializers have been defined by the user in an OBJECT field |
22,591 | private Field checkFieldInAllSchemas ( String name ) throws TupleMRException { Field field = null ; for ( int i = 0 ; i < mrConfig . getIntermediateSchemas ( ) . size ( ) ; i ++ ) { Field fieldInSource = checkFieldInSchema ( name , i ) ; if ( field == null ) { field = fieldInSource ; } else if ( field . getType ( ) != ... | Checks that the field with the given name is in all schemas and select a representative field that will be used for serializing . In the case of having a mixture of fields some of them nullable and some others no nullables a nullable Field will be returned . |
22,592 | public File resolveMavenArtifact ( String artifact ) throws ArtifactResolutionException { ClassLoader oldContext = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { Thread . currentThread ( ) . setContextClassLoader ( this . getClass ( ) . getClassLoader ( ) ) ; RepositorySystem repoSystem = newRepositoryS... | Fetches a maven artifact and returns a File Object that points to its location . |
22,593 | protected RepositorySystemSession newSession ( RepositorySystem system ) { MavenRepositorySystemSession session = new MavenRepositorySystemSession ( ) ; LocalRepository localRepo = new LocalRepository ( localRepository ) ; session . setLocalRepositoryManager ( system . newLocalRepositoryManager ( localRepo ) ) ; return... | Creates a new RepositorySystemSession . |
22,594 | private static Path locateFileInCache ( Configuration conf , String filename ) throws IOException { return new Path ( getInstancesFolder ( FileSystem . get ( conf ) , conf ) , filename ) ; } | Locates a file in the temporal folder |
22,595 | public static File getWritableDirectoryWithFailovers ( String ... directories ) throws FileNotFoundException { File logDir = null ; for ( String directory : directories ) { if ( directory != null ) { try { logDir = ensureDirectoryWriteable ( new File ( directory ) ) ; } catch ( FileNotFoundException e ) { log . debug (... | Gets the first writable directory that exists or can be created . |
22,596 | public static File ensureDirectoryWriteable ( File logDir ) throws FileNotFoundException { try { FileUtils . forceMkdir ( logDir ) ; } catch ( IOException e ) { log . debug ( "Failed to create directory " + logDir , e ) ; throw new FileNotFoundException ( "Failed to create directory: " + logDir + " IOException: " + e .... | Try s to create a directory and ensures that it is writable . |
22,597 | public int getPartition ( DatumWrapper < ITuple > key , NullWritable value , int numPartitions ) { if ( numPartitions == 1 ) { return 0 ; } else { ITuple tuple = key . datum ( ) ; String sourceName = tuple . getSchema ( ) . getName ( ) ; Integer schemaId = tupleMRConfig . getSchemaIdByName ( sourceName ) ; if ( schemaI... | to perform hashCode of strings |
22,598 | public int partialHashCode ( ITuple tuple , int [ ] fields ) { int result = 0 ; for ( int field : fields ) { Object o = tuple . get ( field ) ; if ( o == null ) { continue ; } int hashCode ; if ( o instanceof String ) { HELPER_UTF8 . set ( ( String ) o ) ; hashCode = HELPER_UTF8 . hashCode ( ) ; } else if ( o instanceo... | Calculates a combinated hashCode using the specified number of fields . |
22,599 | public void init ( FilterConfig config ) throws ServletException { if ( config . getInitParameter ( "ignorePrefix" ) != null ) { ignorePath = config . getInitParameter ( "ignorePrefix" ) ; } } | Configures the ignore prefix . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.