idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
37,600 | public void invokeMethods ( String queryName , GDATDecoder decoder ) throws InvocationTargetException , IllegalAccessException { for ( MethodInvoker methodInvoker : methodListMap . get ( queryName ) ) { decoder . reset ( ) ; methodInvoker . invoke ( decoder ) ; } } | This function invokes all the methods associated with the provided query name |
37,601 | public Map . Entry < String , GDATDecoder > getNext ( ) { Map . Entry < String , GDATDecoder > element = dataQueue . poll ( ) ; pendingRecords . add ( element ) ; return element ; } | This function returns the next entry in the data queue and adds it to a queue of pending items . This pendingRecords serves as a place holder for all the items of the current transaction . |
37,602 | public String getActualTableName ( QueueName queueName ) { if ( queueName . isQueue ( ) ) { return getTableNameForFlow ( queueName . getFirstComponent ( ) , queueName . getSecondComponent ( ) ) ; } else { throw new IllegalArgumentException ( "'" + queueName + "' is not a valid name for a queue." ) ; } } | This determines the actual table name from the table name prefix and the name of the queue . |
37,603 | public static long generateConsumerGroupId ( String flowId , String flowletId ) { return Hashing . md5 ( ) . newHasher ( ) . putString ( flowId ) . putString ( flowletId ) . hash ( ) . asLong ( ) ; } | Generates a queue consumer groupId for the given flowlet in the given program id . |
37,604 | public static Multimap < String , QueueName > configureQueue ( Program program , FlowSpecification flowSpec , QueueAdmin queueAdmin ) { Table < QueueSpecificationGenerator . Node , String , Set < QueueSpecification > > queueSpecs = new SimpleQueueSpecificationGenerator ( ) . create ( flowSpec ) ; Table < QueueName , Lo... | Configures all queues being used in a flow . |
37,605 | public void invoke ( Decoder decoder ) throws InvocationTargetException , IllegalAccessException { try { method . invoke ( callingObject , pojoCreator . decode ( decoder ) ) ; } catch ( IOException e ) { LOG . error ( "Skipping invocation of method {}. Cannot instantiate parameter object of type {}" , getMethodName ( )... | This method instantiates an object of the method parameter type using the incoming decoder object and then invokes the associated method . |
37,606 | private void writeLengthToStream ( int length , OutputStream out ) throws IOException { sharedByteBuffer . clear ( ) ; sharedByteBuffer . order ( ByteOrder . BIG_ENDIAN ) . putInt ( length ) ; sharedByteBuffer . flip ( ) ; out . write ( sharedByteBuffer . array ( ) , 0 , Ints . BYTES ) ; sharedByteBuffer . order ( byte... | Write Length in Big Endian Order as per GDAT format specification . |
37,607 | public static QueueName from ( byte [ ] bytes ) { return new QueueName ( URI . create ( new String ( bytes , Charsets . US_ASCII ) ) ) ; } | Constructs this class from byte array of queue URI . |
37,608 | public static QueueName fromStream ( String stream ) { URI uri = URI . create ( String . format ( "stream:///%s" , stream ) ) ; return new QueueName ( uri ) ; } | Generates an QueueName for the stream . |
37,609 | private void generateGetter ( Field field ) { if ( isPrivate ) { invokeReflection ( getMethod ( Object . class , "get" , Object . class ) , getterSignature ( ) ) ; } else { directGetter ( field ) ; } if ( field . getType ( ) . isPrimitive ( ) ) { primitiveGetter ( field ) ; } } | Generates the getter method and optionally the primitive getter . |
37,610 | private void generateSetter ( Field field ) { if ( isPrivate ) { invokeReflection ( getMethod ( void . class , "set" , Object . class , Object . class ) , setterSignature ( ) ) ; } else { directSetter ( field ) ; } if ( field . getType ( ) . isPrimitive ( ) ) { primitiveSetter ( field ) ; } } | Generates the setter method and optionally the primitive setter . |
37,611 | private void invokeReflection ( Method method , String signature ) { GeneratorAdapter mg = new GeneratorAdapter ( Opcodes . ACC_PUBLIC , method , signature , new Type [ 0 ] , classWriter ) ; Label beginTry = mg . newLabel ( ) ; Label endTry = mg . newLabel ( ) ; Label catchHandle = mg . newLabel ( ) ; mg . visitTryCatc... | Generates the try - catch block that wrap around the given reflection method call . |
37,612 | private void directGetter ( Field field ) { GeneratorAdapter mg = new GeneratorAdapter ( Opcodes . ACC_PUBLIC , getMethod ( Object . class , "get" , Object . class ) , getterSignature ( ) , new Type [ 0 ] , classWriter ) ; mg . loadArg ( 0 ) ; mg . checkCast ( Type . getType ( field . getDeclaringClass ( ) ) ) ; mg . g... | Generates a getter that get the value by directly accessing the class field . |
37,613 | private void directSetter ( Field field ) { GeneratorAdapter mg = new GeneratorAdapter ( Opcodes . ACC_PUBLIC , getMethod ( void . class , "set" , Object . class , Object . class ) , setterSignature ( ) , new Type [ 0 ] , classWriter ) ; mg . loadArg ( 0 ) ; mg . checkCast ( Type . getType ( field . getDeclaringClass (... | Generates a setter that set the value by directly accessing the class field . |
37,614 | public TransactionStateCache get ( ) { if ( instance == null ) { synchronized ( lock ) { if ( instance == null ) { instance = new DefaultTransactionStateCache ( namespace ) ; instance . setConf ( conf ) ; instance . start ( ) ; } } } return instance ; } | Returns a singleton instance of the transaction state cache performing lazy initialization if necessary . |
37,615 | private MessageDigest updateHash ( MessageDigest md5 , Schema schema , Set < String > knownRecords ) { switch ( schema . getType ( ) ) { case NULL : md5 . update ( ( byte ) 0 ) ; break ; case BOOLEAN : md5 . update ( ( byte ) 1 ) ; break ; case INT : md5 . update ( ( byte ) 2 ) ; break ; case LONG : md5 . update ( ( by... | Updates md5 based on the given schema . |
37,616 | private Method getEncodeMethod ( TypeToken < ? > outputType , Schema schema ) { String key = String . format ( "%s%s" , normalizeTypeName ( outputType ) , schema . getSchemaHash ( ) ) ; Method method = encodeMethods . get ( key ) ; if ( method != null ) { return method ; } TypeToken < ? > callOutputType = getCallTypeTo... | Returns the encode method for the given type and schema . The same method will be returned if the same type and schema has been passed to the method before . |
37,617 | private void generateEncodeBody ( GeneratorAdapter mg , Schema schema , TypeToken < ? > outputType , int value , int encoder , int schemaLocal , int seenRefs ) { Schema . Type schemaType = schema . getType ( ) ; switch ( schemaType ) { case NULL : break ; case BOOLEAN : encodeSimple ( mg , outputType , schema , "writeB... | Generates the encode method body with the binary encoder given in the local variable . |
37,618 | private void encodeInt ( GeneratorAdapter mg , int intValue , int encoder ) { mg . loadArg ( encoder ) ; mg . push ( intValue ) ; mg . invokeInterface ( Type . getType ( Encoder . class ) , getMethod ( Encoder . class , "writeInt" , int . class ) ) ; mg . pop ( ) ; } | Generates method body for encoding an compile time int value . |
37,619 | private void encodeSimple ( GeneratorAdapter mg , TypeToken < ? > type , Schema schema , String encodeMethod , int value , int encoder ) { TypeToken < ? > encodeType = type ; mg . loadArg ( encoder ) ; mg . loadArg ( value ) ; if ( Primitives . isWrapperType ( encodeType . getRawType ( ) ) ) { encodeType = TypeToken . ... | Generates method body for encoding simple schema type by calling corresponding write method in Encoder . |
37,620 | private void encodeEnum ( GeneratorAdapter mg , TypeToken < ? > outputType , int value , int encoder , int schemaLocal ) { mg . loadArg ( encoder ) ; mg . loadArg ( schemaLocal ) ; mg . loadArg ( value ) ; mg . invokeVirtual ( Type . getType ( outputType . getRawType ( ) ) , getMethod ( String . class , "name" ) ) ; mg... | Generates method body for encoding enum value . |
37,621 | private TypeToken < ? > getCallTypeToken ( TypeToken < ? > outputType , Schema schema ) { Schema . Type schemaType = schema . getType ( ) ; if ( schemaType == Schema . Type . RECORD || schemaType == Schema . Type . UNION ) { return TypeToken . of ( Object . class ) ; } if ( schemaType == Schema . Type . ARRAY && output... | Returns the type to be used on the encode method . This is needed to work with private classes that the generated DatumWriter doesn t have access to . |
37,622 | private synchronized void changeInstances ( String flowletId , int newInstanceCount , int oldInstanceCount ) throws Exception { instanceUpdater . update ( flowletId , newInstanceCount , oldInstanceCount ) ; } | Change the number of instances of the running flowlet . Notice that this method needs to be synchronized as change of instances involves multiple steps that need to be completed all at once . |
37,623 | public ImmutableSet < ClassInfo > getTopLevelClasses ( ) { return FluentIterable . from ( resources ) . filter ( ClassInfo . class ) . filter ( IS_TOP_LEVEL ) . toImmutableSet ( ) ; } | Returns all top level classes loadable from the current class path . |
37,624 | private Service createServiceHook ( String flowletName , Iterable < ConsumerSupplier < ? > > consumerSuppliers , AtomicReference < FlowletProgramController > controller ) { final List < String > streams = Lists . newArrayList ( ) ; for ( ConsumerSupplier < ? > consumerSupplier : consumerSuppliers ) { QueueName queueNam... | Create a initializer to be executed during the flowlet driver initialization . |
37,625 | public static Manifest getManifestWithMainClass ( Class < ? > klass ) { Manifest manifest = new Manifest ( ) ; manifest . getMainAttributes ( ) . put ( ManifestFields . MANIFEST_VERSION , "1.0" ) ; manifest . getMainAttributes ( ) . put ( ManifestFields . MAIN_CLASS , klass . getName ( ) ) ; return manifest ; } | Given a class generates a manifest file with main - class as class . |
37,626 | public static Map < String , String > fromPosixArray ( Iterable < String > args ) { Map < String , String > kvMap = Maps . newHashMap ( ) ; for ( String arg : args ) { kvMap . putAll ( Splitter . on ( "--" ) . omitEmptyStrings ( ) . trimResults ( ) . withKeyValueSeparator ( "=" ) . split ( arg ) ) ; } return kvMap ; } | Converts a POSIX compliant program argument array to a String - to - String Map . |
37,627 | public CConfiguration read ( Type type , String namespace ) throws IOException { String tableName = getTableName ( namespace ) ; CConfiguration conf = null ; HTable table = null ; try { table = new HTable ( hbaseConf , tableName ) ; Get get = new Get ( Bytes . toBytes ( type . name ( ) ) ) ; get . addFamily ( FAMILY ) ... | Reads the given configuration type from the HBase table looking for the HBase table name under the given namespace . |
37,628 | protected final void setSystemTag ( String name , String value ) { systemTags . put ( name , new SystemTagImpl ( name , value ) ) ; } | Sets system tag . |
37,629 | public static int getRandomPort ( ) { try { ServerSocket socket = new ServerSocket ( 0 ) ; try { return socket . getLocalPort ( ) ; } finally { socket . close ( ) ; } } catch ( IOException e ) { return - 1 ; } } | Find a random free port in localhost for binding . |
37,630 | public synchronized void updateCache ( ) { Map < byte [ ] , QueueConsumerConfig > newCache = Maps . newTreeMap ( Bytes . BYTES_COMPARATOR ) ; long now = System . currentTimeMillis ( ) ; HTable table = null ; try { table = new HTable ( hConf , configTableName ) ; Scan scan = new Scan ( ) ; scan . addFamily ( QueueEntryR... | This forces an immediate update of the config cache . It should only be called from the refresh thread or from tests to avoid having to add a sleep for the duration of the refresh interval . |
37,631 | @ SuppressWarnings ( "unchecked" ) private void setValue ( Object instance , Field field , String value ) throws IllegalAccessException { if ( ! field . isAccessible ( ) ) { field . setAccessible ( true ) ; } Class < ? > fieldType = field . getType ( ) ; if ( String . class . equals ( fieldType ) ) { field . set ( inst... | Sets the value of the field in the given instance by converting the value from String to the field type . Currently only allows primitive types boxed types String and Enum . |
37,632 | protected void startUp ( ) { try { startRTS ( ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Cannot initiate RTS. Missing or bad arguments" ) ; } try { startHFTA ( ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Cannot initiate HFTA processes. Missing or bad arguments" ) ; } try... | Sequentially invokes the required Streaming Engine processes . |
37,633 | public void startRTS ( ) throws IOException { List < HubDataSource > dataSources = hubDataStore . getHubDataSources ( ) ; List < String > com = Lists . newArrayList ( ) ; com . add ( getHostPort ( hubDataStore . getHubAddress ( ) ) ) ; com . add ( hubDataStore . getInstanceName ( ) ) ; for ( HubDataSource source : data... | Starts RTS process . |
37,634 | public void startHFTA ( ) throws IOException { int hftaCount = MetaInformationParser . getHFTACount ( new File ( this . hubDataStore . getBinaryLocation ( ) . toURI ( ) ) ) ; for ( int i = 0 ; i < hftaCount ; i ++ ) { List < String > com = Lists . newArrayList ( ) ; com . add ( getHostPort ( hubDataStore . getHubAddres... | Starts HFTA processes . |
37,635 | public void startGSEXIT ( ) throws IOException { List < HubDataSink > dataSinks = hubDataStore . getHubDataSinks ( ) ; for ( HubDataSink hubDataSink : dataSinks ) { List < String > com = Lists . newArrayList ( ) ; com . add ( getHostPort ( hubDataStore . getHubAddress ( ) ) ) ; com . add ( hubDataStore . getInstanceNam... | Starts GSEXIT processes . |
37,636 | private String getStringValue ( Object instance , Field field ) throws IllegalAccessException { Class < ? > fieldType = field . getType ( ) ; Preconditions . checkArgument ( fieldType . isPrimitive ( ) || Primitives . isWrapperType ( fieldType ) || String . class . equals ( fieldType ) || fieldType . isEnum ( ) , "Unsu... | Gets the value of the field in the given instance as String . Currently only allows primitive types boxed types String and Enum . |
37,637 | public static boolean checkSchema ( Set < Schema > output , Set < Schema > input ) { return findSchema ( output , input ) != null ; } | Given two schema s checks if there exists compatibility or equality . |
37,638 | private static byte [ ] serializeEmptyHashKeys ( ) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; Encoder encoder = new BinaryEncoder ( bos ) ; encoder . writeInt ( 0 ) ; return bos . toByteArray ( ) ; } catch ( IOException e ) { throw new RuntimeException ( "encoding empty hash keys went wrong - b... | many entries will have no hash keys . Serialize that once and for good |
37,639 | public Encoder writeRaw ( byte [ ] rawBytes , int off , int len ) throws IOException { output . write ( rawBytes , off , len ) ; return this ; } | Writes raw bytes to the buffer without encoding . |
37,640 | private static ClassPath getAPIClassPath ( ) throws IOException { ClassLoader classLoader = Flow . class . getClassLoader ( ) ; String resourceName = Flow . class . getName ( ) . replace ( '.' , '/' ) + ".class" ; URL url = classLoader . getResource ( resourceName ) ; if ( url == null ) { throw new IOException ( "Resou... | Gathers all resources for api classes . |
37,641 | private static URL getClassPathURL ( String resourceName , URL resourceURL ) { try { if ( "file" . equals ( resourceURL . getProtocol ( ) ) ) { String path = resourceURL . getFile ( ) ; int endIdx = path . length ( ) - resourceName . length ( ) ; if ( endIdx > 1 ) { endIdx -- ; } return new URL ( "file" , "" , - 1 , pa... | Find the classpath that contains the given resource . |
37,642 | private HBaseQueueAdmin ensureTableExists ( QueueName queueName ) throws IOException { HBaseQueueAdmin admin = queueAdmin ; try { if ( ! admin . exists ( queueName ) ) { admin . create ( queueName ) ; } } catch ( Exception e ) { throw new IOException ( "Failed to open table " + admin . getActualTableName ( queueName ) ... | Helper method to select the queue or stream admin and to ensure it s table exists . |
37,643 | public static String getSerializedSchema ( String gdatHeader ) { int startBracketIndex = gdatHeader . indexOf ( "{" ) ; startBracketIndex = gdatHeader . indexOf ( "{" , startBracketIndex + 1 ) ; int endBracketIndex = gdatHeader . indexOf ( "}" ) ; Preconditions . checkArgument ( endBracketIndex > startBracketIndex ) ; ... | Given a gdatHeader extract serialized Schema String . |
37,644 | public static int getHFTACount ( File fileLocation ) { Document qtree = getQTree ( fileLocation ) ; int count ; count = qtree . getElementsByTagName ( "HFTA" ) . getLength ( ) ; return count ; } | This method returns the number of HFTA processes to be instantiated by parsing the qtree . xml file |
37,645 | public Delete delete ( Delete delete ) { delete . deleteColumns ( QueueEntryRow . COLUMN_FAMILY , consumerStateColumn ) ; return delete ; } | Adds a delete of this consumer state to the given Delete object . |
37,646 | public Object decode ( Decoder decoder ) throws IOException { try { return outputGenerator . read ( decoder , schema ) ; } catch ( IOException e ) { LOG . error ( "Cannot instantiate object of type {}" , outputClass . getName ( ) , e ) ; throw e ; } } | This function is called for each incoming byte record . |
37,647 | private Table < String , Integer , ProgramController > createFlowlets ( Program program , RunId runId , FlowSpecification flowSpec ) { Table < String , Integer , ProgramController > flowlets = HashBasedTable . create ( ) ; try { for ( Map . Entry < String , FlowletDefinition > entry : flowSpec . getFlowlets ( ) . entry... | Starts all flowlets in the flow program . |
37,648 | public final void initialize ( FlowletContext ctx ) throws Exception { super . initialize ( ctx ) ; portsAnnouncementList = Lists . newArrayList ( ) ; DefaultInputFlowletConfigurer configurer = new DefaultInputFlowletConfigurer ( this ) ; create ( configurer ) ; InputFlowletSpecification spec = configurer . createInput... | This method initializes all the components required to setup the SQL Compiler environment . |
37,649 | @ Tick ( delay = 200L , unit = TimeUnit . MILLISECONDS ) protected void processGDATRecords ( ) throws InvocationTargetException , IllegalAccessException { stopwatch . reset ( ) ; stopwatch . start ( ) ; while ( ! recordQueue . isEmpty ( ) ) { long elapsedTime = stopwatch . elapsedTime ( TimeUnit . SECONDS ) ; if ( elap... | This process method consumes the records queued in dataManager and invokes the associated process methods for each output query |
37,650 | public void notifyFailure ( Set < String > errorProcessNames ) { if ( errorProcessNames != null ) { LOG . warn ( "Missing pings from : " + errorProcessNames . toString ( ) ) ; } else { LOG . warn ( "No heartbeats registered" ) ; } healthInspector . stopAndWait ( ) ; healthInspector = new HealthInspector ( this ) ; inpu... | ProcessMonitor callback function Restarts SQL Compiler processes |
37,651 | protected void updateVersionInPreferences ( ) { SharedPreferences sp = PreferenceManager . getDefaultSharedPreferences ( mContext ) ; SharedPreferences . Editor editor = sp . edit ( ) ; editor . putInt ( VERSION_KEY , mCurrentVersionCode ) ; editor . commit ( ) ; } | Write current version code to the preferences . |
37,652 | public List < ReleaseItem > getChangeLog ( boolean full ) { SparseArray < ReleaseItem > masterChangelog = getMasterChangeLog ( full ) ; SparseArray < ReleaseItem > changelog = getLocalizedChangeLog ( full ) ; List < ReleaseItem > mergedChangeLog = new ArrayList < ReleaseItem > ( masterChangelog . size ( ) ) ; for ( int... | Returns the merged change log . |
37,653 | protected final SparseArray < ReleaseItem > readChangeLogFromResource ( int resId , boolean full ) { XmlResourceParser xml = mContext . getResources ( ) . getXml ( resId ) ; try { return readChangeLog ( xml , full ) ; } finally { xml . close ( ) ; } } | Read change log from XML resource file . |
37,654 | protected SparseArray < ReleaseItem > readChangeLog ( XmlPullParser xml , boolean full ) { SparseArray < ReleaseItem > result = new SparseArray < ReleaseItem > ( ) ; try { int eventType = xml . getEventType ( ) ; while ( eventType != XmlPullParser . END_DOCUMENT ) { if ( eventType == XmlPullParser . START_TAG && xml . ... | Read the change log from an XML file . |
37,655 | public List < String > orderedGroups ( ) { int groupCount = groupCount ( ) ; List < String > groups = new ArrayList < String > ( groupCount ) ; for ( int i = 1 ; i <= groupCount ; i ++ ) { groups . add ( group ( i ) ) ; } return groups ; } | Gets a list of the matches in the order in which they occur in a matching input string |
37,656 | public String group ( String groupName ) { int idx = groupIndex ( groupName ) ; if ( idx < 0 ) { throw new IndexOutOfBoundsException ( "No group \"" + groupName + "\"" ) ; } return group ( idx ) ; } | Returns the input subsequence captured by the named group during the previous match operation . |
37,657 | public List < Map < String , String > > namedGroups ( ) { List < Map < String , String > > result = new ArrayList < Map < String , String > > ( ) ; List < String > groupNames = parentPattern . groupNames ( ) ; if ( groupNames . isEmpty ( ) ) { return result ; } int nextIndex = 0 ; while ( matcher . find ( nextIndex ) )... | Finds all named groups that exist in the input string . This resets the matcher and attempts to match the input against the pre - specified pattern . |
37,658 | public List < String > groupNames ( ) { if ( groupNames == null ) { groupNames = new ArrayList < String > ( groupInfo . keySet ( ) ) ; } return Collections . unmodifiableList ( groupNames ) ; } | Gets the names of all capture groups |
37,659 | private boolean groupInfoMatches ( Map < String , List < GroupInfo > > a , Map < String , List < GroupInfo > > b ) { if ( a == null && b == null ) { return true ; } boolean isMatch = false ; if ( a != null && b != null ) { if ( a . isEmpty ( ) && b . isEmpty ( ) ) { isMatch = true ; } else if ( a . size ( ) == b . size... | Compares the keys and values of two group - info maps |
37,660 | private static double limitHprime ( double hPrime ) { hPrime /= 360.0 ; final double limited = 360.0 * ( hPrime - floor ( hPrime ) ) ; if ( limited < - 180.0 ) { return limited + 360.0 ; } else if ( limited > 180.0 ) { return limited - 360.0 ; } else { return limited ; } } | limit H values according to A . 2 . 11 |
37,661 | public String lookupHttpCrossDomain ( String httpsDomainName ) { Iterator iter = crossDomainMappings . keySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { String httpDomainName = ( String ) iter . next ( ) ; if ( crossDomainMappings . get ( httpDomainName ) . equals ( httpsDomainName ) ) { return httpDomainName ... | returns the HTTP domain Name |
37,662 | private void badRequest ( HttpServletResponse res ) throws IOException { res . setContentType ( "text/html" ) ; PrintWriter pw = res . getWriter ( ) ; pw . write ( BAD_REQUEST ) ; pw . close ( ) ; } | writes the Bad Request String in the Servlet response if condition falis |
37,663 | public static String getMD5 ( String md5Salt ) { try { MessageDigest md = MessageDigest . getInstance ( MD5 ) ; byte [ ] array = md . digest ( md5Salt . getBytes ( UTF8 ) ) ; StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < array . length ; ++ i ) { sb . append ( Integer . toHexString ( ( array [ i ] & 0x... | generates the MD5 Hash value from given salt value |
37,664 | public static float compare ( final int numOfBits , final String str1 , final String str2 ) { return compare ( numOfBits , BaseEncoding . base64 ( ) . decode ( str1 ) , BaseEncoding . base64 ( ) . decode ( str2 ) ) ; } | Compare base64 strings for MinHash . |
37,665 | public static float compare ( final int numOfBits , final byte [ ] data1 , final byte [ ] data2 ) { if ( data1 . length != data2 . length ) { return 0 ; } final int count = countSameBits ( data1 , data2 ) ; return ( float ) count / ( float ) numOfBits ; } | Compare bytes for MinHash . |
37,666 | public static HashFunction [ ] createHashFunctions ( final int seed , final int num ) { final HashFunction [ ] hashFunctions = new HashFunction [ num ] ; for ( int i = 0 ; i < num ; i ++ ) { hashFunctions [ i ] = Hashing . murmur3_128 ( seed + i ) ; } return hashFunctions ; } | Create hash functions . |
37,667 | public static String toBinaryString ( final byte [ ] data ) { if ( data == null ) { return null ; } final StringBuilder buf = new StringBuilder ( data . length * 8 ) ; for ( final byte element : data ) { byte bits = element ; for ( int j = 0 ; j < 8 ; j ++ ) { if ( ( bits & 0x80 ) == 0x80 ) { buf . append ( '1' ) ; } e... | Returns a string formatted by bits . |
37,668 | public static int bitCount ( final byte [ ] data ) { int count = 0 ; for ( final byte element : data ) { byte bits = element ; for ( int j = 0 ; j < 8 ; j ++ ) { if ( ( bits & 1 ) == 1 ) { count ++ ; } bits >>= 1 ; } } return count ; } | Count the number of true bits . |
37,669 | public static Analyzer createAnalyzer ( final Tokenizer tokenizer , final int hashBit , final int seed , final int num ) { final HashFunction [ ] hashFunctions = MinHash . createHashFunctions ( seed , num ) ; final Analyzer minhashAnalyzer = new Analyzer ( ) { protected TokenStreamComponents createComponents ( final St... | Create an analyzer to calculate a minhash . |
37,670 | public static Data newData ( final Analyzer analyzer , final String text , final int numOfBits ) { return new Data ( analyzer , text , numOfBits ) ; } | Create a target data which has analyzer text and the number of bits . |
37,671 | public void defineMethod ( String methodName , int modifiers , String signature , CodeBlock methodBody ) { this . methods . add ( new MethodDefinition ( methodName , modifiers , signature , methodBody ) ) ; } | Defines a new method on the target class |
37,672 | public FieldDefinition defineField ( String fieldName , int modifiers , String signature , Object value ) { FieldDefinition field = new FieldDefinition ( fieldName , modifiers , signature , value ) ; this . fields . add ( field ) ; return field ; } | Defines a new field on the target class |
37,673 | public byte [ ] toBytes ( JDKVersion version ) { ClassNode node = new ClassNode ( ) ; node . version = version . getVer ( ) ; node . access = this . access | ACC_SUPER ; node . name = this . className ; node . superName = this . superClassName ; node . sourceFile = this . sourceFile ; node . sourceDebug = this . source... | Convert this class representation to JDK bytecode |
37,674 | public CodeBlock frame_same ( final Object ... stackArguments ) { final int type ; switch ( stackArguments . length ) { case 0 : type = Opcodes . F_SAME ; break ; case 1 : type = Opcodes . F_SAME1 ; break ; default : throw new IllegalArgumentException ( "same frame should have 0" + " or 1 arguments on stack" ) ; } inst... | adds a compressed frame to the stack |
37,675 | public void registerServiceConfiguration ( String id , String configFile , DescribeService service ) throws POIProxyException { if ( service == null || configFile == null || service . getId ( ) == null ) { throw new POIProxyException ( "Null service configuration" ) ; } this . registeredConfigurations . put ( id , conf... | Registers a new service into the library |
37,676 | public String getServiceAsJSON ( String id ) { String path = this . registeredConfigurations . get ( id ) ; if ( path == null ) { return null ; } File f = new File ( CONFIGURATION_DIR + File . separator + path ) ; FileInputStream fis = null ; InputStream in = null ; OutputStream out = null ; String res = null ; try { f... | Returns the content of the json document describing a service given its id |
37,677 | static void printClassPath ( ) { URLClassLoader sysLoader = ( URLClassLoader ) ClassLoader . getSystemClassLoader ( ) ; if ( sysLoader == null ) { System . out . println ( "No system class loader. (Maybe means bootstrap class loader is being used?)" ) ; } else { System . out . println ( "Classpath:" ) ; for ( URL url :... | Print the classpath . |
37,678 | public String [ ] parse ( String [ ] args ) throws ArgException { List < String > nonOptions = new ArrayList < > ( ) ; boolean ignoreOptions = false ; String tail = "" ; String arg ; for ( int ii = 0 ; ii < args . length ; ) { if ( tail . length ( ) > 0 ) { arg = tail ; tail = "" ; } else { arg = args [ ii ] ; } if ( a... | Sets option variables from the given command line . |
37,679 | public String [ ] parse ( String message , String [ ] args ) { String [ ] nonOptions = null ; try { nonOptions = parse ( args ) ; } catch ( ArgException ae ) { String exceptionMessage = ae . getMessage ( ) ; if ( exceptionMessage != null ) { System . out . println ( exceptionMessage ) ; } System . out . println ( messa... | Sets option variables from the given command line ; if any command - line argument is illegal prints the given message and terminates the program . |
37,680 | public void printUsage ( PrintStream ps ) { hasListOption = false ; if ( usageSynopsis != null ) { ps . printf ( "Usage: %s%n" , usageSynopsis ) ; } ps . println ( usage ( ) ) ; if ( hasListOption ) { ps . println ( ) ; ps . println ( LIST_HELP ) ; } } | Prints usage information to the given PrintStream . Uses the usage synopsis passed into the constructor if any . |
37,681 | public String usage ( boolean showUnpublicized , String ... groupNames ) { if ( ! hasGroups ) { if ( groupNames . length > 0 ) { throw new IllegalArgumentException ( "This instance of Options does not have any option groups defined" ) ; } return formatOptions ( options , maxOptionLength ( options , showUnpublicized ) ,... | Returns a usage message for command - line options . |
37,682 | private int maxOptionLength ( List < OptionInfo > optList , boolean showUnpublicized ) { int maxLength = 0 ; for ( OptionInfo oi : optList ) { if ( oi . unpublicized && ! showUnpublicized ) { continue ; } int len = oi . synopsis ( ) . length ( ) ; if ( len > maxLength ) { maxLength = len ; } } return maxLength ; } | Return the length of the longest synopsis message in a list of options . Useful for aligning options in usage strings . |
37,683 | @ SuppressWarnings ( "nullness" ) private Object getRefArg ( OptionInfo oi , String argName , String argValue ) throws ArgException { Object val ; try { if ( oi . constructor != null ) { val = oi . constructor . newInstance ( new Object [ ] { argValue } ) ; } else if ( oi . baseType . isEnum ( ) ) { @ SuppressWarnings ... | Given a value string supplied on the command line create an object . The only expected error is some sort of parse error from the constructor . |
37,684 | public String settings ( boolean showUnpublicized ) { StringJoiner out = new StringJoiner ( lineSeparator ) ; int maxLength = maxOptionLength ( options , showUnpublicized ) ; for ( OptionInfo oi : options ) { @ SuppressWarnings ( "formatter" ) String use = String . format ( "%-" + maxLength + "s = " , oi . longName ) ;... | Returns a string containing the current setting for each option in command - line format that can be parsed by Options . Contains every known option even if the option was not specified on the command line . Never contains duplicates . |
37,685 | public String payload ( int index ) { return payload . size ( ) > index ? payload . get ( index ) : null ; } | Returns a payload at index or null if no payload found there |
37,686 | public static String generateToken ( byte [ ] secret , long seconds , String oid , String ... payload ) { long due = Life . due ( seconds ) ; List < String > l = new ArrayList < String > ( 2 + payload . length ) ; l . add ( oid ) ; l . add ( String . valueOf ( due ) ) ; l . addAll ( C . listOf ( payload ) ) ; String s ... | Generate a token string with secret key ID and optionally payloads |
37,687 | @ SuppressWarnings ( "unused" ) public static boolean isTokenValid ( byte [ ] secret , String oid , String token ) { if ( S . anyBlank ( oid , token ) ) { return false ; } String s = Crypto . decryptAES ( token , secret ) ; String [ ] sa = s . split ( "\\|" ) ; if ( sa . length < 2 ) return false ; if ( ! S . isEqual (... | Check if a string is a valid token |
37,688 | public DescribeService parse ( String json ) { Gson gson = createGSON ( ) ; return gson . fromJson ( json , DescribeService . class ) ; } | Parses a describe service json document passed as a String |
37,689 | public List < List < List < Double > > > getCoordinates ( ) { List < List < List < Double > > > polygon = new ArrayList < List < List < Double > > > ( ) ; for ( LineString lineString : coordinates ) { polygon . add ( lineString . getCoordinates ( ) ) ; } return polygon ; } | Should throw is not a polygon exception |
37,690 | public List < String > getServicesIDByCategory ( String category ) { Set < String > servicesID = services . keySet ( ) ; Iterator < String > it = servicesID . iterator ( ) ; List < String > ids = new ArrayList < String > ( ) ; if ( category == null ) { return ids ; } String key ; while ( it . hasNext ( ) ) { key = it .... | Iterates the list of registered services and for those that support the category passed as a parameter return their ID |
37,691 | public boolean supportsCategory ( String category ) { if ( category == null ) { return false ; } List < String > categories = this . getCategories ( ) ; for ( String cat : categories ) { if ( cat . compareToIgnoreCase ( category ) == 0 ) { return true ; } } return false ; } | Returns true if there is any service registered that supports the category parameter |
37,692 | private Param getQueryParam ( List < Param > optionalParams ) { for ( Param p : optionalParams ) { if ( p == null ) { continue ; } if ( p . getType ( ) . equals ( ParamEnum . QUERY . name ) ) { return p ; } } return null ; } | FIXME Extract the ArrayList to a Class |
37,693 | public static boolean start ( RootDoc root ) { List < Object > objs = new ArrayList < > ( ) ; for ( ClassDoc doc : root . specifiedClasses ( ) ) { if ( doc . containingClass ( ) != null ) { continue ; } Class < ? > clazz ; try { @ SuppressWarnings ( "signature" ) String className = doc . qualifiedName ( ) ; clazz = Cla... | Entry point for the doclet . |
37,694 | public static int optionLength ( String option ) { if ( option . equals ( "-help" ) ) { System . out . printf ( USAGE ) ; return 1 ; } if ( option . equals ( "-i" ) || option . equals ( "-classdoc" ) || option . equals ( "-singledash" ) ) { return 1 ; } if ( option . equals ( "-docfile" ) || option . equals ( "-outfile... | Given a command - line option of this doclet returns the number of arguments you must specify on the command line for the given option . Returns 0 if the argument is not recognized . This method is automatically invoked by Javadoc . |
37,695 | @ SuppressWarnings ( "index" ) public static boolean validOptions ( String [ ] @ MinLen ( 1 ) [ ] options , DocErrorReporter reporter ) { boolean hasDocFile = false ; boolean hasOutFile = false ; boolean hasDestDir = false ; boolean hasFormat = false ; boolean inPlace = false ; String docFile = null ; String outFile = ... | Tests the validity of command - line arguments passed to this doclet . Returns true if the option usage is valid and false otherwise . This method is automatically invoked by Javadoc . |
37,696 | public void write ( ) throws Exception { PrintWriter out ; String output = output ( ) ; if ( outFile != null ) { out = new PrintWriter ( Files . newBufferedWriter ( outFile . toPath ( ) , UTF_8 ) ) ; } else if ( inPlace ) { assert docFile != null : "@AssumeAssertion(nullness): dependent: docFile is non-null if inPlace ... | Write the output of this doclet to the correct file . |
37,697 | @ RequiresNonNull ( "docFile" ) private String newDocFileText ( ) throws Exception { StringJoiner b = new StringJoiner ( lineSep ) ; BufferedReader doc = Files . newBufferedReader ( docFile . toPath ( ) , UTF_8 ) ; String docline ; boolean replacing = false ; boolean replacedOnce = false ; String prefix = null ; while ... | Get the result of inserting the options documentation into the docfile . |
37,698 | public String optionsToHtml ( int refillWidth ) { StringJoiner b = new StringJoiner ( lineSep ) ; if ( includeClassDoc && root . classes ( ) . length > 0 ) { b . add ( OptionsDoclet . javadocToHtml ( root . classes ( ) [ 0 ] ) ) ; b . add ( "<p>Command line options:</p>" ) ; } b . add ( "<ul>" ) ; if ( ! options . hasG... | Get the HTML documentation for the underlying Options instance . |
37,699 | public String optionsToJavadoc ( int padding , int refillWidth ) { StringJoiner b = new StringJoiner ( lineSep ) ; Scanner s = new Scanner ( optionsToHtml ( refillWidth - padding - 2 ) ) ; while ( s . hasNextLine ( ) ) { String line = s . nextLine ( ) ; StringBuilder bb = new StringBuilder ( ) ; bb . append ( StringUti... | Get the HTML documentation for the underlying Options instance formatted as a Javadoc comment . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.