idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
36,600 | public static Object runPzConverter ( final Properties classXref , final String value , final Class < ? > typeToReturn ) { final String sConverter = classXref . getProperty ( typeToReturn . getName ( ) ) ; if ( sConverter == null ) { throw new FPConvertException ( typeToReturn . getName ( ) + " is not registered in pzc... | Converts a String value to the appropriate Object via the correct net . sf . flatpack . converter . PZConverter implementation | 170 | 28 |
36,601 | public static List < ColumnMetaData > buildMDFromSQLTable ( final Connection con , final String dataDefinition , final Parser parser ) throws SQLException { final List < ColumnMetaData > cmds = new ArrayList <> ( ) ; final String dfTbl = parser != null ? parser . getDataFileTable ( ) : "DATAFILE" ; final String dsTbl =... | Returns a definition of pz column metadata from a given pz datastructure held in an SQL database | 514 | 21 |
36,602 | public static List < String > splitFixedText ( final List < ColumnMetaData > columnMetaData , final String lineToParse , final boolean preserveLeadingWhitespace , final boolean preserveTrailingWhitespace ) { final List < String > splitResult = new ArrayList <> ( ) ; int recPosition = 1 ; for ( final ColumnMetaData colM... | Splits up a fixed width line of text | 226 | 9 |
36,603 | public static String getCMDKey ( final MetaData columnMD , final String line ) { if ( ! columnMD . isAnyRecordFormatSpecified ( ) ) { // no <RECORD> elements were specified for this parse, just return the // detail id return FPConstants . DETAIL_ID ; } final Iterator < Entry < String , XMLRecordElement > > mapEntries =... | Returns the key to the list of ColumnMetaData objects . Returns the correct MetaData per the mapping file and the data contained on the line | 305 | 28 |
36,604 | public int getColumnIndex ( final String colName ) { int idx = - 1 ; if ( columnIndex != null ) { final Integer i = columnIndex . get ( colName ) ; if ( i != null ) { idx = i . intValue ( ) ; } } return idx ; } | Returns the index of the column name . | 64 | 8 |
36,605 | public void writeExcelFile ( ) throws IOException , WriteException { WritableWorkbook excelWrkBook = null ; int curDsPointer = 0 ; try { final String [ ] columnNames = ds . getColumns ( ) ; final List < String > exportOnlyColumnsList = getExportOnlyColumns ( ) != null ? Arrays . asList ( exportOnlyColumns ) : null ; fi... | Writes the Excel file to disk | 790 | 7 |
36,606 | @ Override public void absolute ( final int localPointer ) { if ( localPointer < 0 || localPointer >= rows . size ( ) ) { throw new IndexOutOfBoundsException ( "INVALID POINTER LOCATION: " + localPointer ) ; } pointer = localPointer ; currentRecord = new RowRecord ( rows . get ( pointer ) , metaData , parser . isColumn... | Sets the absolute position of the record pointer | 124 | 9 |
36,607 | private static int convertAttributeToInt ( final String attribute ) { if ( attribute == null ) { return 0 ; } try { return Integer . parseInt ( attribute ) ; } catch ( final Exception ignore ) { return 0 ; } } | helper to convert to integer | 48 | 6 |
36,608 | public static Map < String , Object > buildParametersForColumns ( final String colsAsCsv ) { final Map < String , Object > mapping = new HashMap <> ( ) ; mapping . put ( FPConstants . DETAIL_ID , buildColumns ( colsAsCsv ) ) ; return mapping ; } | Creates a Mapping for a WriterFactory for the given list of columns . | 70 | 16 |
36,609 | public static List < ColumnMetaData > buildColumns ( final String colsAsCsv ) { final List < ColumnMetaData > listCol = new ArrayList <> ( ) ; buildColumns ( listCol , colsAsCsv ) ; return listCol ; } | Create a new list of ColumnMetaData based on a CSV list of column titles . | 58 | 17 |
36,610 | protected void addToCloseReaderList ( final Reader r ) { if ( readersToClose == null ) { readersToClose = new ArrayList <> ( ) ; } readersToClose . add ( r ) ; } | is completed . | 45 | 3 |
36,611 | protected String fetchNextRecord ( final BufferedReader br , final char qual , final char delim ) throws IOException { String line = null ; final StringBuilder lineData = new StringBuilder ( ) ; boolean processingMultiLine = false ; while ( ( line = br . readLine ( ) ) != null ) { lineCount ++ ; final String trimmed = ... | Reads a record from a delimited file . This will account for records which could span multiple lines . NULL will be returned when the end of the file is reached | 706 | 33 |
36,612 | @ Override public int compare ( final Row row0 , final Row row1 ) { int result = 0 ; for ( int i = 0 ; i < orderbys . size ( ) ; i ++ ) { final OrderColumn oc = orderbys . get ( i ) ; // null indicates "detail" record which is what the parser assigns // to <column> 's setup outside of <record> elements final String mdk... | overridden from the Comparator class . | 348 | 8 |
36,613 | public static TestContainer createContainer ( String configurationClassName ) throws Exception { Option [ ] options = getConfigurationOptions ( configurationClassName ) ; ExamSystem system = DefaultExamSystem . create ( options ) ; TestContainer testContainer = PaxExamRuntime . createContainer ( system ) ; testContaine... | Creates and starts a test container using options from a configuration class . | 71 | 14 |
36,614 | private static void waitForStop ( TestContainer testContainer , int localPort ) { try { ServerSocket serverSocket = new ServerSocket ( localPort ) ; Socket socket = serverSocket . accept ( ) ; InputStreamReader isr = new InputStreamReader ( socket . getInputStream ( ) , "UTF-8" ) ; BufferedReader reader = new BufferedR... | Opens a server socket listening for text commands on the given port . Each command is terminated by a newline . The server expects a stop command followed by a quit command . | 283 | 35 |
36,615 | private static void sanityCheck ( ) { List < TestContainerFactory > factories = new ArrayList < TestContainerFactory > ( ) ; Iterator < TestContainerFactory > iter = ServiceLoader . load ( TestContainerFactory . class ) . iterator ( ) ; while ( iter . hasNext ( ) ) { factories . add ( iter . next ( ) ) ; } if ( factori... | Exits with an exception if Classpath not set up properly . | 179 | 13 |
36,616 | String determineCachingName ( final File file , final String defaultBundleSymbolicName ) { String bundleSymbolicName = null ; String bundleVersion = null ; JarFile jar = null ; try { // verify that is a valid jar. Do not verify that is signed (the false param). jar = new JarFile ( file , false ) ; final Manifest manife... | Determine name to be used for caching on local file system . | 334 | 14 |
36,617 | public void join ( ) { try { UnicastRemoteObject . unexportObject ( registry , true ) ; /* * NOTE: javaRunner.waitForExit() works for Equinox and Felix, but not for Knopflerfish, * need to investigate why. OTOH, it may be better to kill the process as we're doing * now, just to be on the safe side. */ javaRunner . shut... | Waits for the remote framework to shutdown and frees all resources . | 112 | 14 |
36,618 | public void stop ( BundleContext bc ) throws Exception { String blockOnStop = System . getProperty ( "pax.exam.regression.blockOnStop" , "false" ) ; if ( Boolean . valueOf ( blockOnStop ) ) { Thread . sleep ( Long . MAX_VALUE ) ; } } | Optionally blocks framework shutdown for a shutdown timeout regression test . | 67 | 12 |
36,619 | @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) @ Override public void injectFields ( Object target ) { BeanManager mgr = BeanManagerLookup . getBeanManager ( ) ; AnnotatedType annotatedType = mgr . createAnnotatedType ( target . getClass ( ) ) ; InjectionTarget injectionTarget = mgr . createInjectionTarget ( annot... | Injects dependencies into the given target object whose lifecycle is not managed by the BeanManager itself . | 120 | 21 |
36,620 | public JarProbeOption classes ( Class < ? > ... klass ) { for ( Class < ? > c : klass ) { String resource = c . getName ( ) . replaceAll ( "\\." , "/" ) + ".class" ; resources . add ( resource ) ; } return this ; } | Adds the given classes to the JAR . | 65 | 9 |
36,621 | public JarProbeOption resources ( String ... resourcePaths ) { for ( String resource : resourcePaths ) { resources . add ( resource ) ; } return this ; } | Adds the given resources from the current class path to the JAR . | 36 | 14 |
36,622 | public URI buildJar ( ) { if ( option . getName ( ) == null ) { option . name ( UUID . randomUUID ( ) . toString ( ) ) ; } try { File explodedJarDir = getExplodedJarDir ( ) ; File probeJar = new File ( tempDir , option . getName ( ) + ".jar" ) ; ZipBuilder builder = new ZipBuilder ( probeJar ) ; builder . addDirectory ... | Builds a JAR from the given option . | 160 | 10 |
36,623 | public static MavenArtifactDeploymentOption mavenWar ( final String groupId , final String artifactId , final String version ) { return mavenWar ( ) . groupId ( groupId ) . artifactId ( artifactId ) . version ( version ) . type ( "war" ) ; } | Deploys a Maven WAR artifact with the given Maven coordinates . | 62 | 14 |
36,624 | private synchronized File createTemp ( File workingDirectory ) throws IOException { if ( workingDirectory == null ) { return createTempDir ( ) ; } else { workingDirectory . mkdirs ( ) ; return workingDirectory ; } } | Creates a fresh temp folder under the mentioned working folder . If workingFolder is null system wide temp location will be used . | 47 | 25 |
36,625 | public Option bundle ( String bsn ) { Collection < Option > urls = new ArrayList <> ( ) ; try { for ( File file : workspace . getProject ( bsn ) . getBuildFiles ( ) ) { urls . add ( url ( file . toURI ( ) . toASCIIString ( ) ) ) ; } } catch ( Exception e ) { throw new RuntimeException ( "Underlying Bnd Exception: " , e... | Add workspace - built bundle of name symbolicName to system - under - test . | 119 | 16 |
36,626 | public Option fromBndrun ( String runFileSpec ) { try { File runFile = workspace . getFile ( runFileSpec ) ; Run bndRunInstruction = new Run ( workspace , runFile . getParentFile ( ) , runFile ) ; return bndToExam ( bndRunInstruction ) ; } catch ( Exception e ) { throw new RuntimeException ( "Underlying Bnd Exception: ... | Add all bundles resolved by bndrun file to system - under - test . | 94 | 16 |
36,627 | private List < Dependency > getProvisionableDependencies ( ) { List < Dependency > dependencies = new ArrayList < Dependency > ( ) ; getLog ( ) . info ( "Adding dependencies in scope " + dependencyScope ) ; for ( Dependency d : getDependencies ( ) ) { if ( d . getScope ( ) != null && d . getScope ( ) . equalsIgnoreCase... | Dependency resolution inspired by servicemix depends - maven - plguin | 106 | 17 |
36,628 | private String createPaxRunnerScan ( Artifact artifact , String optionTokens ) { return "scan-bundle:" + artifact . getFile ( ) . toURI ( ) . normalize ( ) . toString ( ) + "@update" + optionTokens ; } | Creates scanner directives from artifact to be parsed by pax runner . Also includes options found and matched in settings part of configuration . | 54 | 26 |
36,629 | public void downloadAndInstall ( ) throws IOException { installDir . mkdirs ( ) ; File tempFile = File . createTempFile ( "pax-exam" , ".zip" ) ; FileOutputStream os = null ; LOG . info ( "downloading {} to {}" , zipUrl , tempFile ) ; try { os = new FileOutputStream ( tempFile ) ; StreamUtils . copyStream ( zipUrl . op... | Download and unpacks the archive . | 156 | 7 |
36,630 | public WarProbeOption overlay ( String overlayPath ) { overlays . add ( new File ( overlayPath ) . toURI ( ) . toString ( ) ) ; return this ; } | Adds an overlay from the given path to the WAR . This is similar to the overlay concept of the Maven WAR Plugin . If the overlay path is a directory its contents are copied recursively to the root of the WAR . If the overlay path is an archive its exploded contents are copied to the root of the WAR . All overlays are c... | 39 | 86 |
36,631 | public WarProbeOption autoClasspath ( boolean includeDefaultFilters ) { useClasspath = true ; if ( includeDefaultFilters ) { for ( String filter : DEFAULT_CLASS_PATH_EXCLUDES ) { classpathFilters . add ( filter ) ; } } return this ; } | Automatically add libraries and class folders from the current classpath . | 63 | 13 |
36,632 | public static KarafDistributionBaseConfigurationOption karafDistributionConfiguration ( String frameworkURL , String name , String karafVersion ) { return new KarafDistributionConfigurationOption ( frameworkURL , name , karafVersion ) ; } | Configures which distribution options to use . Relevant are the frameworkURL the frameworkName and the Karaf version since all of those params are relevant to decide which wrapper configurations to use . | 51 | 37 |
36,633 | public static Option [ ] editConfigurationFilePut ( final String configurationFilePath , File source , String ... keysToUseFromSource ) { return createOptionListFromFile ( source , new FileOptionFactory ( ) { @ Override public Option createOption ( String key , Object value ) { return new KarafDistributionConfiguration... | This option allows to configure each configuration file based on the karaf . home location . The value is put which means it is either replaced or added . For simpler configuration you can add a file source . If you want to put all values from this file do not configure any keysToUseFromSource ; otherwise define them t... | 90 | 71 |
36,634 | public static Option [ ] editConfigurationFileExtend ( final String configurationFilePath , File source , String ... keysToUseFromSource ) { return createOptionListFromFile ( source , new FileOptionFactory ( ) { @ Override public Option createOption ( String key , Object value ) { return new KarafDistributionConfigurat... | This option allows to configure each configuration file based on the karaf . home location . The value is extend which means it is either replaced or added . For simpler configuration you can add a file source . If you want to put all values from this file do not configure any keysToUseFromSource ; otherwise define the... | 92 | 71 |
36,635 | private Registry getRegistry ( int port ) throws RemoteException { Registry reg ; String hostName = System . getProperty ( "java.rmi.server.hostname" ) ; if ( hostName != null && ! hostName . isEmpty ( ) ) { reg = LocateRegistry . getRegistry ( hostName , port ) ; } else { reg = LocateRegistry . getRegistry ( port ) ; ... | shared utility module | 94 | 3 |
36,636 | protected static String getAttribute ( Node node , String name , boolean required ) { NamedNodeMap attributes = node . getAttributes ( ) ; Node idNode = attributes . getNamedItem ( name ) ; if ( idNode == null ) { if ( required ) { throw new IllegalArgumentException ( toPath ( node ) + " has no " + name + " attribute" ... | Get an Attribute from the given node and throwing an exception in the case it is required but not present | 118 | 21 |
36,637 | protected static Iterable < Node > evaluate ( Node element , XPathExpression expression , boolean detatch ) throws XPathExpressionException { final NodeList nodeList = ( NodeList ) expression . evaluate ( element , XPathConstants . NODESET ) ; return new Iterable < Node > ( ) { @ Override public Iterator < Node > itera... | evaluates a XPath expression and loops over the nodeset result | 186 | 13 |
36,638 | public String getProperty ( String key , String defaultValue ) { String value = resolver . get ( key ) ; return ( value == null ) ? defaultValue : value ; } | Returns the configuration property for the given key or the given default value . | 37 | 14 |
36,639 | public static ConfigurationOption newConfiguration ( String pid ) { return new org . ops4j . pax . exam . cm . internal . ConfigurationProvisionOption ( pid , new HashMap < String , Object > ( ) ) ; } | Creates a basic empty configuration for the given PID | 48 | 10 |
36,640 | public static ConfigurationOption overrideConfiguration ( String pid ) { return new org . ops4j . pax . exam . cm . internal . ConfigurationProvisionOption ( pid , new HashMap < String , Object > ( ) ) . override ( true ) . create ( false ) ; } | Creates an overriding empty configuration for the given PID | 58 | 10 |
36,641 | public static ConfigurationOption factoryConfiguration ( String pid ) { return new org . ops4j . pax . exam . cm . internal . ConfigurationProvisionOption ( pid , new HashMap < String , Object > ( ) ) . factory ( true ) ; } | Creates a factory empty configuration for the given PID | 53 | 10 |
36,642 | public static Option configurationFolder ( File folder , String extension ) { if ( ! folder . exists ( ) ) { throw new TestContainerException ( "folder " + folder + " does not exits" ) ; } List < Option > options = new ArrayList < Option > ( ) ; File [ ] files = folder . listFiles ( ) ; for ( File file : files ) { if (... | read all configuration files from a folder and transform them into configuration options | 369 | 13 |
36,643 | private BundleContext getBundleContext ( Bundle bundle , long timeout ) { long endTime = System . currentTimeMillis ( ) + timeout ; BundleContext bc = null ; while ( bc == null ) { bc = bundle . getBundleContext ( ) ; if ( bc == null ) { if ( System . currentTimeMillis ( ) >= endTime ) { throw new TestContainerExceptio... | Retrieve bundle context from given bundle . If the bundle is being restarted the bundle context can be null for some time | 124 | 24 |
36,644 | @ Produces @ RequestScoped public EntityManager getEntityManager ( EntityManagerFactory emf ) { log . debug ( "producing EntityManager" ) ; return emf . createEntityManager ( ) ; } | Use a producer method so that CDI will find this EntityManager . | 43 | 14 |
36,645 | public TestProbeBuilder createProbeBuilder ( Object testClassInstance ) throws IOException , ExamConfigurationException { if ( defaultProbeBuilder == null ) { defaultProbeBuilder = system . createProbe ( ) ; } TestProbeBuilder probeBuilder = overwriteWithUserDefinition ( currentTestClass , testClassInstance ) ; if ( pr... | Lazily creates a probe builder . The same probe builder will be reused for all test classes unless the default builder is overridden in a given class . | 107 | 31 |
36,646 | public static void streamCopy ( final InputStream in , final FileChannel out , final ProgressBar progressBar ) throws IOException { NullArgumentException . validateNotNull ( in , "Input stream" ) ; NullArgumentException . validateNotNull ( out , "Output stream" ) ; final long start = System . currentTimeMillis ( ) ; lo... | Copy a stream to a destination . It does not close the streams . | 189 | 14 |
36,647 | public static void streamCopy ( final URL url , final FileChannel out , final ProgressBar progressBar ) throws IOException { NullArgumentException . validateNotNull ( url , "URL" ) ; InputStream is = null ; try { is = url . openStream ( ) ; streamCopy ( is , out , progressBar ) ; } finally { if ( is != null ) { is . cl... | Copy a stream from an urlto a destination . | 88 | 10 |
36,648 | public void close ( ) throws IOException { if ( jarOutputStream != null ) { jarOutputStream . close ( ) ; } else if ( os != null ) { os . close ( ) ; } } | Closes the archive and releases file system resources . No more files or directories may be added after calling this method . | 43 | 23 |
36,649 | private void addDirectory ( File root , File directory , String targetPath , ZipOutputStream zos ) throws IOException { String prefix = targetPath ; if ( ! prefix . isEmpty ( ) && ! prefix . endsWith ( "/" ) ) { prefix += "/" ; } // directory entries are required, or else bundle classpath may be // broken if ( ! direct... | Recursively adds the contents of the given directory and all subdirectories to the given ZIP output stream . | 200 | 22 |
36,650 | private void addFile ( File root , File file , String prefix , ZipOutputStream zos ) throws IOException { FileInputStream fis = new FileInputStream ( file ) ; ZipEntry jarEntry = new ZipEntry ( prefix + normalizePath ( root , file ) ) ; zos . putNextEntry ( jarEntry ) ; StreamUtils . copyStream ( fis , zos , false ) ; ... | Adds a given file to the given ZIP output stream . | 94 | 11 |
36,651 | private String normalizePath ( File root , File file ) { String relativePath = file . getPath ( ) . substring ( root . getPath ( ) . length ( ) + 1 ) ; String path = relativePath . replaceAll ( "\\" + File . separator , "/" ) ; return path ; } | Returns the relative path of the given file with respect to the root directory with all file separators replaced by slashes . | 67 | 24 |
36,652 | public void copyBootClasspathLibraries ( ) throws IOException { BootClasspathLibraryOption [ ] bootClasspathLibraryOptions = subsystem . getOptions ( BootClasspathLibraryOption . class ) ; for ( BootClasspathLibraryOption bootClasspathLibraryOption : bootClasspathLibraryOptions ) { UrlReference libraryUrl = bootClasspa... | Copy jars specified as BootClasspathLibraryOption in system to the karaf lib path to make them available in the boot classpath | 138 | 27 |
36,653 | public void copyReferencedArtifactsToDeployFolder ( ) { File deploy = new File ( karafBase , "deploy" ) ; String [ ] fileEndings = new String [ ] { "jar" , "war" , "zip" , "kar" , "xml" } ; ProvisionOption < ? > [ ] options = subsystem . getOptions ( ProvisionOption . class ) ; for ( ProvisionOption < ? > option : opti... | Copy dependencies specified as ProvisionOption in system to the deploy folder | 167 | 12 |
36,654 | public KarafFeaturesOption getDependenciesFeature ( ) { if ( subsystem == null ) { return null ; } try { File featuresXmlFile = new File ( karafBase , "test-dependencies.xml" ) ; Writer wr = new OutputStreamWriter ( new FileOutputStream ( featuresXmlFile ) , "UTF-8" ) ; writeDependenciesFeature ( wr , subsystem . getOp... | Create a feature for the test dependencies specified as ProvisionOption in the system | 185 | 14 |
36,655 | static void writeDependenciesFeature ( Writer writer , ProvisionOption < ? > ... provisionOptions ) { XMLOutputFactory xof = XMLOutputFactory . newInstance ( ) ; xof . setProperty ( "javax.xml.stream.isRepairingNamespaces" , true ) ; XMLStreamWriter sw = null ; try { sw = xof . createXMLStreamWriter ( writer ) ; sw . w... | Write a feature xml structure for test dependencies specified as ProvisionOption in system to the given writer | 406 | 18 |
36,656 | public static void extract ( URL sourceURL , File targetFolder ) throws IOException { if ( sourceURL . getProtocol ( ) . equals ( "file" ) ) { if ( sourceURL . getFile ( ) . indexOf ( ".zip" ) > 0 ) { extractZipDistribution ( sourceURL , targetFolder ) ; } else if ( sourceURL . getFile ( ) . indexOf ( ".tar.gz" ) > 0 )... | Extract zip or tar . gz archives to a target folder | 248 | 13 |
36,657 | public CommandLineBuilder append ( final String [ ] segments ) { if ( segments != null && segments . length > 0 ) { final String [ ] command = new String [ commandLine . length + segments . length ] ; System . arraycopy ( commandLine , 0 , command , 0 , commandLine . length ) ; System . arraycopy ( segments , 0 , comma... | Appends an array of strings to command line . | 96 | 10 |
36,658 | public CommandLineBuilder append ( final String segment ) { if ( segment != null && ! segment . isEmpty ( ) ) { return append ( new String [ ] { segment } ) ; } return this ; } | Appends a string to command line . | 43 | 8 |
36,659 | public static String getArtifactVersion ( final String groupId , final String artifactId ) { final Properties dependencies = new Properties ( ) ; InputStream depInputStream = null ; try { String depFilePath = "META-INF/maven/dependencies.properties" ; URL fileURL = MavenUtils . class . getClassLoader ( ) . getResource ... | Gets the artifact version out of dependencies file . The dependencies file had to be generated by using the maven plugin . | 348 | 24 |
36,660 | public static MavenArtifactUrlReference . VersionResolver asInProject ( ) { return new MavenArtifactUrlReference . VersionResolver ( ) { @ Override public String getVersion ( final String groupId , final String artifactId ) { return getArtifactVersion ( groupId , artifactId ) ; } } ; } | Utility method for creating an artifact version resolver that will get the version out of maven project . | 69 | 21 |
36,661 | public URI buildWar ( ) { if ( option . getName ( ) == null ) { option . name ( UUID . randomUUID ( ) . toString ( ) ) ; } processClassPath ( ) ; try { File webResourceDir = getWebResourceDir ( ) ; File probeWar = new File ( tempDir , option . getName ( ) + ".war" ) ; ZipBuilder builder = new ZipBuilder ( probeWar ) ; ... | Builds a WAR from the given option . | 303 | 9 |
36,662 | private static void daxpy ( double constant , double vector1 [ ] , double vector2 [ ] ) { if ( constant == 0 ) return ; assert vector1 . length == vector2 . length ; for ( int i = 0 ; i < vector1 . length ; i ++ ) { vector2 [ i ] += constant * vector1 [ i ] ; } } | constant times a vector plus a vector | 76 | 8 |
36,663 | private static double dot ( double vector1 [ ] , double vector2 [ ] ) { double product = 0 ; assert vector1 . length == vector2 . length ; for ( int i = 0 ; i < vector1 . length ; i ++ ) { product += vector1 [ i ] * vector2 [ i ] ; } return product ; } | returns the dot product of two vectors | 71 | 8 |
36,664 | private static double euclideanNorm ( double vector [ ] ) { int n = vector . length ; if ( n < 1 ) { return 0 ; } if ( n == 1 ) { return Math . abs ( vector [ 0 ] ) ; } // this algorithm is (often) more accurate than just summing up the squares and taking the square-root afterwards double scale = 0 ; // scaling factor ... | returns the euclidean norm of a vector | 213 | 11 |
36,665 | private static void scale ( double constant , double vector [ ] ) { if ( constant == 1.0 ) return ; for ( int i = 0 ; i < vector . length ; i ++ ) { vector [ i ] *= constant ; } } | scales a vector by a constant | 51 | 7 |
36,666 | @ SuppressWarnings ( "unused" ) // Public API public void setAutoScaleEnabled ( boolean isAutoScaleEnabled ) { this . isAutoScaleEnabled = isAutoScaleEnabled ; for ( int i = 0 , size = foldableItemsMap . size ( ) ; i < size ; i ++ ) { foldableItemsMap . valueAt ( i ) . setAutoScaleEnabled ( isAutoScaleEnabled ) ; } } | Sets whether view should scale down to fit moving part into screen . | 91 | 14 |
36,667 | public void setFoldRotation ( float rotation ) { foldRotation = rotation ; topPart . applyFoldRotation ( rotation ) ; bottomPart . applyFoldRotation ( rotation ) ; setInTransformation ( rotation != 0f ) ; scaleFactor = 1f ; if ( isAutoScaleEnabled && width > 0 ) { double sin = Math . abs ( Math . sin ( Math . toRadians... | Fold rotation value in degrees . | 138 | 7 |
36,668 | public void setRollingDistance ( float distance ) { final float scaleY = scale * scaleFactor * scaleFactorY ; topPart . applyRollingDistance ( distance , scaleY ) ; bottomPart . applyRollingDistance ( distance , scaleY ) ; } | Translation preserving middle line splitting . | 54 | 6 |
36,669 | public void unfold ( View coverView , View detailsView ) { if ( this . coverView == coverView && this . detailsView == detailsView ) { scrollToPosition ( 1 ) ; // Starting unfold animation return ; } if ( ( this . coverView != null && this . coverView != coverView ) || ( this . detailsView != null && this . detailsView... | Starting unfold animation for given views . | 303 | 7 |
36,670 | public BytesWritable evaluate ( BytesWritable geomref ) { if ( geomref == null || geomref . getLength ( ) == 0 ) { LogUtils . Log_ArgumentsNull ( LOG ) ; return null ; } OGCGeometry ogcGeometry = GeometryUtils . geometryFromEsriShape ( geomref ) ; if ( ogcGeometry == null ) { LogUtils . Log_ArgumentsNull ( LOG ) ; retu... | Return the last point of the ST_Linestring . | 316 | 12 |
36,671 | public long getId ( double x , double y ) { double down = ( extentMax - y ) / binSize ; double over = ( x - extentMin ) / binSize ; return ( ( long ) down * numCols ) + ( long ) over ; } | Gets bin ID from a point . | 56 | 8 |
36,672 | public void queryEnvelope ( long binId , Envelope envelope ) { long down = binId / numCols ; long over = binId % numCols ; double xmin = extentMin + ( over * binSize ) ; double xmax = xmin + binSize ; double ymax = extentMax - ( down * binSize ) ; double ymin = ymax - binSize ; envelope . setCoords ( xmin , ymin , xmax... | Gets the envelope for the bin ID . | 105 | 9 |
36,673 | public void queryEnvelope ( double x , double y , Envelope envelope ) { double down = ( extentMax - y ) / binSize ; double over = ( x - extentMin ) / binSize ; double xmin = extentMin + ( over * binSize ) ; double xmax = xmin + binSize ; double ymax = extentMax - ( down * binSize ) ; double ymin = ymax - binSize ; enve... | Gets the envelope for the bin that contains the x y coords . | 113 | 15 |
36,674 | @ Override public boolean next ( LongWritable key , Text value ) throws IOException { JsonToken token ; // first call to nextKeyValue() so we need to create the parser and move to the // feature array if ( parser == null ) { parser = new JsonFactory ( ) . createJsonParser ( inputStream ) ; parser . setCodec ( new Objec... | Both Esri JSON and GeoJSON conveniently have features | 267 | 10 |
36,675 | public static void Log_SRIDMismatch ( Log logger , BytesWritable geomref1 , BytesWritable geomref2 ) { logger . error ( String . format ( messages [ MSG_SRID_MISMATCH ] , GeometryUtils . getWKID ( geomref1 ) , GeometryUtils . getWKID ( geomref2 ) ) ) ; } | Log when comparing geometries in different spatial references | 88 | 10 |
36,676 | public static int getWKID ( BytesWritable geomref ) { ByteBuffer bb = ByteBuffer . wrap ( geomref . getBytes ( ) ) ; return bb . getInt ( 0 ) ; } | Gets the WKID for the given hive geometry bytes | 48 | 12 |
36,677 | protected boolean moveToRecordStart ( ) throws IOException { int next = 0 ; long resetPosition = readerPosition ; // The case of split point exactly at whitespace between records, is // handled by forcing it to the split following, in the interest of // better balancing the splits, by consuming the whitespace in next()... | Given an arbitrary byte offset into a unenclosed JSON document find the start of the next record in the document . Discard trailing bytes from the previous record if we happened to seek to the middle of it | 637 | 41 |
36,678 | @ Override public float getProgress ( ) throws IOException { if ( reachedEnd ) return 1 ; else { final long filePos = in . position ( ) ; final long fileEnd = virtualEnd >>> 16 ; // Add 1 to the denominator to make sure it doesn't reach 1 here when // filePos == fileEnd. return ( float ) ( filePos - fileStart ) / ( fil... | Unless the end has been reached this only takes file position into account not the position within the block . | 92 | 20 |
36,679 | private int guessNextBGZFPos ( int p , int end ) throws IOException { for ( ; ; ) { for ( ; ; ) { in . seek ( p ) ; in . read ( buf . array ( ) , 0 , 4 ) ; int n = buf . getInt ( 0 ) ; if ( n == BGZF_MAGIC ) break ; // Skip ahead a bit more than 1 byte if you can. if ( n >>> 8 == BGZF_MAGIC << 8 >>> 8 ) ++ p ; else if ... | Returns a negative number if it doesn t find anything . | 400 | 11 |
36,680 | private static void writeTerminatorBlock ( final OutputStream out , final SAMFormat samOutputFormat ) throws IOException { if ( SAMFormat . CRAM == samOutputFormat ) { CramIO . issueEOF ( CramVersions . DEFAULT_CRAM_VERSION , out ) ; // terminate with CRAM EOF container } else if ( SAMFormat . BAM == samOutputFormat ) ... | Terminate the aggregated output stream with an appropriate SAMOutputFormat - dependent terminator block | 121 | 18 |
36,681 | public static < T extends Locatable > void setIntervals ( Configuration conf , List < T > intervals ) { setTraversalParameters ( conf , intervals , false ) ; } | Only include reads that overlap the given intervals . Unplaced unmapped reads are not included . | 37 | 18 |
36,682 | public static void unsetTraversalParameters ( Configuration conf ) { conf . unset ( BOUNDED_TRAVERSAL_PROPERTY ) ; conf . unset ( INTERVALS_PROPERTY ) ; conf . unset ( TRAVERSE_UNPLACED_UNMAPPED_PROPERTY ) ; } | Reset traversal parameters so that all reads are included . | 72 | 12 |
36,683 | static QueryInterval [ ] prepareQueryIntervals ( final List < Interval > rawIntervals , final SAMSequenceDictionary sequenceDictionary ) { if ( rawIntervals == null || rawIntervals . isEmpty ( ) ) { return null ; } // Convert each SimpleInterval to a QueryInterval final QueryInterval [ ] convertedIntervals = rawInterva... | Converts a List of SimpleIntervals into the format required by the SamReader query API | 158 | 18 |
36,684 | private static QueryInterval convertSimpleIntervalToQueryInterval ( final Interval interval , final SAMSequenceDictionary sequenceDictionary ) { if ( interval == null ) { throw new IllegalArgumentException ( "interval may not be null" ) ; } if ( sequenceDictionary == null ) { throw new IllegalArgumentException ( "seque... | Converts an interval in SimpleInterval format into an htsjdk QueryInterval . | 177 | 19 |
36,685 | public static void convertQuality ( Text quality , BaseQualityEncoding current , BaseQualityEncoding target ) { if ( current == target ) throw new IllegalArgumentException ( "current and target quality encodinds are the same (" + current + ")" ) ; byte [ ] bytes = quality . getBytes ( ) ; final int len = quality . getL... | Convert quality scores in - place . | 506 | 8 |
36,686 | public static int verifyQuality ( Text quality , BaseQualityEncoding encoding ) { // set allowed quality range int max , min ; if ( encoding == BaseQualityEncoding . Illumina ) { max = FormatConstants . ILLUMINA_OFFSET + FormatConstants . ILLUMINA_MAX ; min = FormatConstants . ILLUMINA_OFFSET ; } else if ( encoding == ... | Verify that the given quality bytes are within the range allowed for the specified encoding . | 215 | 17 |
36,687 | public static void main ( String [ ] args ) { if ( args . length == 0 ) { System . out . println ( "Usage: BGZFBlockIndex [BGZF block indices...]\n\n" + "Writes a few statistics about each BGZF block index." ) ; return ; } for ( String arg : args ) { final File f = new File ( arg ) ; if ( f . isFile ( ) && f . canRead ... | Writes some statistics about each BGZF block index file given as an argument . | 311 | 17 |
36,688 | private void init ( final Path output , final SAMFileHeader header , final boolean writeHeader , final TaskAttemptContext ctx ) throws IOException { init ( output . getFileSystem ( ctx . getConfiguration ( ) ) . create ( output ) , header , writeHeader , ctx ) ; } | first statement ... | 62 | 3 |
36,689 | static List < Path > getFilesMatching ( Path directory , String syntaxAndPattern , String excludesExt ) throws IOException { PathMatcher matcher = directory . getFileSystem ( ) . getPathMatcher ( syntaxAndPattern ) ; List < Path > parts = Files . walk ( directory ) . filter ( matcher :: matches ) . filter ( path -> exc... | Returns all the files in a directory that match the given pattern and that don t have the given extension . | 118 | 21 |
36,690 | static void mergeInto ( List < Path > parts , OutputStream out ) throws IOException { for ( final Path part : parts ) { Files . copy ( part , out ) ; Files . delete ( part ) ; } } | Merge the given part files in order into an output stream . This deletes the parts . | 47 | 19 |
36,691 | @ Override public List < InputSplit > getSplits ( JobContext job ) throws IOException { final List < InputSplit > splits = super . getSplits ( job ) ; // Align the splits so that they don't cross blocks // addIndexedSplits() requires the given splits to be sorted by file // path, so do so. Although FileInputFormat.getS... | The splits returned are FileSplits . | 291 | 8 |
36,692 | public static WrapSeekable < FSDataInputStream > openPath ( FileSystem fs , Path p ) throws IOException { return new WrapSeekable < FSDataInputStream > ( fs . open ( p ) , fs . getFileStatus ( p ) . getLen ( ) , p ) ; } | A helper for the common use case . | 64 | 8 |
36,693 | public static SAMFileHeader readSAMHeaderFrom ( final InputStream in , final Configuration conf ) { final ValidationStringency stringency = getValidationStringency ( conf ) ; SamReaderFactory readerFactory = SamReaderFactory . makeDefault ( ) . setOption ( SamReaderFactory . Option . EAGERLY_DECODE , false ) . setUseAs... | Does not close the stream . | 156 | 6 |
36,694 | public long skip ( long n ) throws IOException { boolean end = false ; long toskip = n ; while ( toskip > 0 && ! end ) { if ( bufferPosn < bufferLength ) { int skipped = ( int ) Math . min ( bufferLength - bufferPosn , toskip ) ; bufferPosn += skipped ; toskip -= skipped ; } if ( bufferPosn >= bufferLength ) { int load... | Skip n bytes from the InputStream . | 109 | 8 |
36,695 | @ Override public float getProgress ( ) { if ( length == 0 ) return 1 ; if ( ! isBGZF ) return ( float ) ( in . getPosition ( ) - fileStart ) / length ; try { if ( in . peek ( ) == - 1 ) return 1 ; } catch ( IOException e ) { return 1 ; } // Add 1 to the denominator to make sure that we never report 1 here. return ( fl... | For compressed BCF unless the end has been reached this is quite inaccurate . | 120 | 15 |
36,696 | public void processAlignment ( final SAMRecord rec ) throws IOException { // write an offset for the first record and for the g-th record thereafter (where // g is the granularity), to be consistent with the index method if ( count == 0 || ( count + 1 ) % granularity == 0 ) { SAMFileSource fileSource = rec . getFileSou... | Process the given record for the index . | 115 | 8 |
36,697 | public void writeVirtualOffset ( long virtualOffset ) throws IOException { lb . put ( 0 , virtualOffset ) ; out . write ( byteBuffer . array ( ) ) ; } | Write the given virtual offset to the index . This method is for internal use only . | 37 | 17 |
36,698 | public static void index ( final InputStream rawIn , final OutputStream out , final long inputSize , final int granularity ) throws IOException { final BlockCompressedInputStream in = new BlockCompressedInputStream ( rawIn ) ; final ByteBuffer byteBuffer = ByteBuffer . allocate ( 8 ) ; // Enough to fit a long final Lon... | Perform indexing on the given BAM file at the granularity level specified . | 327 | 17 |
36,699 | public static List < Interval > getIntervals ( final Configuration conf , final String intervalPropertyName ) { final String intervalsProperty = conf . get ( intervalPropertyName ) ; if ( intervalsProperty == null ) { return null ; } if ( intervalsProperty . isEmpty ( ) ) { return ImmutableList . of ( ) ; } final List ... | Returns the list of intervals found in a string configuration property separated by colons . | 317 | 16 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.