idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
127,800 | public static String outputNestedList ( NestedList nl , int depth ) { String result = "" ; if ( nl == null ) { return result ; } for ( int i = 0 ; i < depth ; i ++ ) { result += " " ; } if ( nl . getClass ( ) == NestedListElement . class ) { result += nl . getText ( ) ; } else { result += "---" ; for ( NestedList nl2 :... | Returns String with all elements of a NestedList |
127,801 | private void writeHeader ( ) throws SQLException { Statement query ; String [ ] revTableHeaderQueries ; revTableHeaderQueries = sqlEncoder . getTable ( ) ; for ( String revTableHeaderQuery : revTableHeaderQueries ) { query = connection . createStatement ( ) ; query . executeUpdate ( revTableHeaderQuery ) ; query . clos... | Retrieves the encoded sql orders and executes them . |
127,802 | public void compress ( String path ) { try { File fileToArchive = new File ( path ) ; BufferedInputStream input = new BufferedInputStream ( new FileInputStream ( fileToArchive ) ) ; File archivedFile = new File ( fileToArchive . getName ( ) + ".bz2" ) ; archivedFile . createNewFile ( ) ; FileOutputStream fos = new File... | Creates bz2 archive file from file in path |
127,803 | public OutputStream getCompressionStream ( String path ) throws IOException { File archivedFile = new File ( path ) ; archivedFile . createNewFile ( ) ; FileOutputStream fos = new FileOutputStream ( archivedFile ) ; BufferedOutputStream bufStr = new BufferedOutputStream ( fos ) ; fos . write ( "BZ" . getBytes ( ) ) ; C... | Creates stream for compression |
127,804 | public InputStreamReader getDecompressionStream ( String path , String encoding ) throws IOException { File fileToUncompress = new File ( path ) ; BufferedInputStream fileStream = new BufferedInputStream ( new FileInputStream ( fileToUncompress ) ) ; fileStream . read ( ) ; fileStream . read ( ) ; BufferedInputStream b... | Creates Stream for decompression |
127,805 | public void decompress ( String path ) throws IOException { File bzip2 = new File ( path ) ; File unarchived = new File ( bzip2 . getName ( ) . replace ( ".bz2" , "" ) ) ; unarchived . createNewFile ( ) ; BufferedInputStream inputStr = new BufferedInputStream ( new FileInputStream ( bzip2 ) ) ; inputStr . read ( ) ; in... | Uncompress bz2 file |
127,806 | public void add ( final int currentArticleID , final long startTime , final long endTime , final List < ArticleIndexData > infoList ) { if ( ! infoList . isEmpty ( ) ) { StringBuilder fullRevBuffer = new StringBuilder ( ) ; StringBuilder revCountBuffer = new StringBuilder ( ) ; boolean first = true ; ArticleIndexData i... | Adds the information for an new entry in the article index . |
127,807 | public static SectionContainer eliminateEmptyStructures ( SectionContainer sc ) { for ( int i = sc . nrOfSubSections ( ) - 1 ; i >= 0 ; i -- ) { Section ss = sc . getSubSection ( i ) ; if ( ss . getClass ( ) == SectionContainer . class ) { SectionContainer sci = ( SectionContainer ) ss ; eliminateEmptyStructures ( sci ... | Removes all empty Structures from a SectionContainer and all substructures . |
127,808 | public static SectionContent eliminateEmptyStructures ( SectionContent sc ) { for ( int i = sc . nrOfParagraphs ( ) - 1 ; i >= 0 ; i -- ) { Paragraph p = sc . getParagraph ( i ) ; if ( p . empty ( ) ) sc . removeParagraph ( p ) ; } for ( int i = sc . nrOfDefinitionLists ( ) - 1 ; i >= 0 ; i -- ) { DefinitionList dl = s... | Removes all empty Structures from a SectionContent and all substructures . |
127,809 | public static NestedListContainer eliminateEmptyStructures ( NestedListContainer nlc ) { for ( int i = nlc . size ( ) - 1 ; i >= 0 ; i -- ) { NestedList nl = nlc . getNestedList ( i ) ; if ( nl . getClass ( ) == NestedListContainer . class ) eliminateEmptyStructures ( ( NestedListContainer ) nl ) ; if ( nl . empty ( ) ... | Removes all empty Structures from a NestedListContainer and all substructures . |
127,810 | public static Table eliminateEmptyStructures ( Table t ) { for ( int i = t . nrOfTableElements ( ) - 1 ; i >= 0 ; i -- ) { TableElement te = t . getTableElement ( i ) ; eliminateEmptyStructures ( te ) ; if ( te . empty ( ) ) t . removeTableElement ( te ) ; } return t ; } | Removes all empty Structures from a Table and all substructures . |
127,811 | public static TableElement eliminateEmptyStructures ( TableElement te ) { for ( int i = te . nrOfSections ( ) - 1 ; i >= 0 ; i -- ) { Section s = te . getSection ( i ) ; if ( s . getClass ( ) == SectionContainer . class ) eliminateEmptyStructures ( ( SectionContainer ) s ) ; else if ( s . getClass ( ) == SectionContent... | Removes all empty Structures from a TableElement and all substructures . |
127,812 | public static DefinitionList eliminateEmptyStructures ( DefinitionList dl ) { ContentElement dt = dl . getDefinedTerm ( ) ; if ( dt != null && dt . empty ( ) ) dl . setDefinedTerm ( null ) ; for ( int i = dl . nrOfDefinitions ( ) - 1 ; i >= 0 ; i -- ) { ContentElement ce = dl . getDefinition ( i ) ; if ( ce . empty ( )... | Removes all empty Structures from a DefinitionList and all substructures . |
127,813 | private void initXMLKeys ( ) { this . keywords = new SingleKeywordTree < WikipediaXMLKeys > ( ) ; keywords . addKeyword ( WikipediaXMLKeys . KEY_START_PAGE . getKeyword ( ) , WikipediaXMLKeys . KEY_START_PAGE ) ; keywords . addKeyword ( WikipediaXMLKeys . KEY_END_PAGE . getKeyword ( ) , WikipediaXMLKeys . KEY_END_PAGE ... | Creates and initializes the xml keyword tree . |
127,814 | private void initNamespaces ( ) { Map < Integer , String > namespaceMap = new HashMap < Integer , String > ( ) ; try { int b = read ( ) ; this . keywords . reset ( ) ; StringBuilder buffer = null ; while ( b != - 1 ) { if ( buffer != null ) { buffer . append ( ( char ) b ) ; } if ( this . keywords . check ( ( char ) b ... | Reads the namespaces from the siteinfo section and processes them in order to initialize the ArticleFilter |
127,815 | protected boolean readHeader ( ) throws IOException , ArticleReaderException { this . taskHeader = new ArticleInformation ( ) ; int size , r = read ( ) ; StringBuilder buffer = null ; while ( r != - 1 ) { if ( buffer != null ) { buffer . append ( ( char ) r ) ; } if ( this . keywords . check ( ( char ) r ) ) { switch (... | Reads the header of an article . |
127,816 | protected void readContributor ( Revision rev , String str ) throws IOException , ArticleReaderException { char [ ] contrChars = str . toCharArray ( ) ; int size ; StringBuilder buffer = null ; this . keywords . reset ( ) ; for ( char curChar : contrChars ) { if ( buffer != null ) { buffer . append ( curChar ) ; } if (... | Parses the content within the contributor tags and adds the parsed info to the provided revision object . |
127,817 | private void extractTemplates ( ) throws WikiApiException { PageIterator pageIter = new PageIterator ( getWiki ( ) , true , pageBuffer ) ; RevisionApi revApi = new RevisionApi ( dbConf ) ; int pageCounter = 0 ; long revisionCounter = 0L ; while ( pageIter . hasNext ( ) ) { pageCounter ++ ; if ( pageCounter % VERBOSITY ... | Extracts templates from pages and revisions |
127,818 | private void processPages ( ) { PageIterator pageIter = new PageIterator ( getWiki ( ) , true , pageBuffer ) ; int pageCounter = 0 ; while ( pageIter . hasNext ( ) ) { pageCounter ++ ; if ( pageCounter % VERBOSITY == 0 ) { logger . info ( "{} pages processed ..." , pageCounter ) ; } Page curPage = pageIter . next ( ) ;... | Extracts templates from pages only |
127,819 | private void processRevisions ( ) { logger . info ( "Processing revisions, extracting template information ..." ) ; RevisionIterator revisionIter = null ; try { revisionIter = new RevisionIterator ( dbConf ) ; int revCounter = 0 ; while ( revisionIter . hasNext ( ) ) { revCounter ++ ; if ( revCounter % VERBOSITY == 0 )... | Processes only revision templates using the Revision Iterator |
127,820 | private void generateTemplateIndices ( WikipediaTemplateInfo info , Set < String > templateNames ) { try { for ( String name : templateNames ) { int id = info . checkTemplateId ( name ) ; if ( id != - 1 ) { tplNameToTplId . put ( name , id ) ; } } } catch ( WikiApiException e ) { } } | Loads existing ids into the map . If no id exists a template will get a new one in the dump writer |
127,821 | public void initialize ( InputStream inputStream , DumpTableEnum table ) throws IOException { unbufferedResult = new PipedInputStream ( ) ; decodedStream = new PipedOutputStream ( unbufferedResult ) ; result = new BufferedInputStream ( unbufferedResult , BUFFERSIZE ) ; xmlInputThread = new XMLDumpTableInputStreamThread... | Decorator for InputStream which allows to convert an XML input stream to SQL |
127,822 | protected void init ( InputStream inputStream ) throws IOException { stream = inputStream ; st = new StreamTokenizer ( new BufferedReader ( new InputStreamReader ( stream , ENCODING ) ) ) ; EOF_reached = false ; skipStatements ( ) ; } | Init the SQLFileParser with the input stream |
127,823 | private void validateSQLFields ( ) { boolean flag = controller . isEnableSQLDatabaseOutput ( ) ; enableSQLDatabaseConnection . setSelected ( flag ) ; sqlHostLabel . setEnabled ( flag ) ; sqlHostField . setEnabled ( flag ) ; sqlDatabaseLabel . setEnabled ( flag ) ; sqlDatabaseField . setEnabled ( flag ) ; sqlUserLabel .... | Validates the UNCOMPRESSED Settings . |
127,824 | public static void main ( final String [ ] args ) { if ( args . length != 1 ) { throw new IllegalArgumentException ( "Configuration File ist missing." ) ; } try { ConfigSettings config = readConfiguration ( args [ 0 ] ) ; new DiffToolThread ( config ) . run ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } | Starts the DiffTool application . |
127,825 | private static ConfigSettings readConfiguration ( final String path ) throws IOException , SAXException , ParserConfigurationException { ConfigurationReader reader = new ConfigurationReader ( path ) ; return reader . read ( ) ; } | Reads and parses the configuration file . |
127,826 | public static String capitalize ( String s ) { if ( Character . isLowerCase ( s . charAt ( 0 ) ) ) { return Character . toUpperCase ( s . charAt ( 0 ) ) + s . substring ( 1 ) ; } else { return s ; } } | Uppercases the first character of a string . |
127,827 | private void send ( ) throws IOException , SQLException { this . indexWriter . write ( articleIndex ) ; this . indexWriter . write ( revisionIndex ) ; this . indexWriter . write ( chronoIndex ) ; } | Checks whether the AbstractIndex classes have output available and forward them to the output writer . |
127,828 | public void index ( final Revision rev ) throws WikiApiException { int articleID = rev . getArticleID ( ) ; int fullRevisionID = rev . getFullRevisionID ( ) ; int revisionCounter = rev . getRevisionCounter ( ) ; if ( articleID != currentArticleID ) { if ( lastRev != null ) { info . setEndRevisionCount ( lastRev . getRe... | Processes the given revision . |
127,829 | public void close ( ) throws WikiApiException { try { this . revisionIndex . finalizeIndex ( ) ; this . chronoIndex . finalizeIndex ( ) ; info . setEndRevisionCount ( lastRev . getRevisionCounter ( ) ) ; this . infoList . add ( info ) ; this . articleIndex . add ( currentArticleID , startTime , endTime , infoList ) ; t... | Finalizes the indices and sends the rest of the data to the output . Afterwards the database connection will be closed . |
127,830 | private void applyConfig ( ) { this . components . applyConfig ( config ) ; switch ( config . getConfigType ( ) ) { case DEFAULT : break ; case IMPORT : this . archives . applyConfiguration ( config ) ; } repaint ( ) ; } | Applies the configuration file . |
127,831 | public boolean createConfigurationXML ( ) { errors = new ConfigVerification ( ) ; xmlConfig = new StringBuilder ( ) ; xmlConfig . append ( "<config>\r\n" ) ; components . toXML ( xmlConfig , errors ) ; xmlConfig . append ( "</config>\r\n" ) ; if ( errors . getRowCount ( ) != 0 ) { new ConfigDialog ( this ) . setVisible... | Creates the xml content representation of the currently used settings . |
127,832 | public void loadConfiguration ( ) { XMLFileChooser fc = new XMLFileChooser ( ) ; if ( fc . showOpenDialog ( new JPanel ( ) ) == XMLFileChooser . APPROVE_OPTION ) { this . loadConfig ( fc . getSelectedFile ( ) . getPath ( ) ) ; } } | Loads the configuration file . The path of the file will be chosen by displaying a FileChooser Dialog . |
127,833 | public void saveConfiguration ( ) { if ( this . createConfigurationXML ( ) ) { XMLFileChooser fc = new XMLFileChooser ( ) ; if ( fc . showSaveDialog ( new JPanel ( ) ) == XMLFileChooser . APPROVE_OPTION ) { String path = fc . getSelectedFile ( ) . getPath ( ) ; if ( path . indexOf ( '.' ) == - 1 ) { path += ".xml" ; } ... | Saves the configuration file . The path of the file will be chosen by displaying a FileChooser Dialog . |
127,834 | public boolean saveConfiguration ( final String path ) { if ( xmlConfig != null && ! errors . hasFailed ( ) ) { boolean success = true ; FileWriter writer = null ; try { writer = new FileWriter ( path ) ; writer . write ( xmlConfig . toString ( ) ) ; writer . flush ( ) ; } catch ( IOException ioe ) { ioe . printStackTr... | Save the configuration to a file . |
127,835 | public void setEnable7Zip ( final boolean enable7Zip ) { this . enable7Zip = enable7Zip ; if ( ! this . enable7Zip ) { if ( outputCompression == OutputCompressionEnum . SevenZip ) { outputCompression = OutputCompressionEnum . None ; } } } | Enables or disables the 7Zip support . |
127,836 | public void removeCycles ( ) throws WikiApiException { DefaultEdge edge = null ; while ( ( edge = findCycle ( ) ) != null ) { Category sourceCat = wiki . getCategory ( categoryGraph . getGraph ( ) . getEdgeSource ( edge ) ) ; Category targetCat = wiki . getCategory ( categoryGraph . getGraph ( ) . getEdgeTarget ( edge ... | Removes cycles from the graph that was used to construct the cycle handler . |
127,837 | private void loadExternal ( ) { Properties properties = new Properties ( ) ; try { properties . loadFromXML ( new FileInputStream ( PROPERTIES_PATH ) ) ; for ( String key : properties . stringPropertyNames ( ) ) { externalSupport . put ( key , properties . getProperty ( key ) ) ; } } catch ( IOException ignore ) { } } | Load the properties for external utilities from a XML file |
127,838 | private String getExtension ( String fileName ) { if ( fileName == null ) { return null ; } String ext = null ; int i = fileName . lastIndexOf ( '.' ) ; if ( i > 0 && i < fileName . length ( ) - 1 ) { ext = fileName . substring ( i + 1 ) . toLowerCase ( ) ; } return ext ; } | Return the extension of the filename |
127,839 | public boolean isSupported ( String fileName ) { String extension = getExtension ( fileName ) ; return isInternalSupported ( extension ) || isExternalSupported ( extension ) ; } | Check if the file is supported by the internal or external decompressor |
127,840 | private InputStream startExternal ( String fileName ) { InputStream result = null ; try { String extension = getExtension ( fileName ) ; String command = externalSupport . get ( extension ) . replace ( FILEPLACEHOLDER , fileName ) ; Process externalProcess = Runtime . getRuntime ( ) . exec ( command ) ; result = extern... | Start an external utility to unpack the the archive |
127,841 | private InputStream getDefault ( String fileName ) { InputStream result = null ; try { result = new BufferedInputStream ( new FileInputStream ( fileName ) ) ; } catch ( IOException ignore ) { } return result ; } | Get default InputStream to read the data from the file |
127,842 | private boolean isInWhiteList ( String tpl ) { if ( ( ! whiteList . isEmpty ( ) && whiteList . contains ( tpl ) ) || ( whiteList . isEmpty ( ) ) ) { return true ; } return false ; } | Checks if the input string is in white list |
127,843 | private boolean containsAllowedPrefix ( String tpl ) { if ( whitePrefixList . isEmpty ( ) ) return true ; for ( String i : whitePrefixList ) { if ( tpl . startsWith ( i ) ) return true ; } return false ; } | Checks if the input string contains prefixes from white list |
127,844 | private boolean containsRestrictedPrefix ( String tpl ) { for ( String i : blackPrefixList ) { if ( tpl . startsWith ( i ) ) return true ; } return false ; } | Checks if the input string contains prefixes from black list |
127,845 | public boolean acceptTemplate ( String tpl ) { if ( isInWhiteList ( tpl ) && ! isInBlackList ( tpl ) ) { if ( containsAllowedPrefix ( tpl ) && ! containsRestrictedPrefix ( tpl ) ) { return true ; } else { return false ; } } else { return false ; } } | Checks whether to include the template with the given name in the database or not . |
127,846 | public void add ( final int revisionID , final long revisionPrimaryKey , final long fullRevisionPrimaryKey ) { boolean sql = ! insertStatement . isEmpty ( ) ; if ( sql && buffer . length ( ) != insertStatement . length ( ) ) { this . buffer . append ( "," ) ; } this . buffer . append ( ( sql ? "(" : "" ) + revisionID +... | Adds the information for an new entry in the revision index . |
127,847 | public int getFirstRevisionPK ( final int articleID ) throws WikiApiException { try { if ( articleID < 1 ) { throw new IllegalArgumentException ( ) ; } PreparedStatement statement = null ; ResultSet result = null ; String firstRevPK ; try { statement = this . connection . prepareStatement ( "SELECT PrimaryKey " + "FROM... | Returns the PrimaryKey for the first revision of the given article |
127,848 | public int getNumberOfRevisions ( final int articleID ) throws WikiApiException { try { if ( articleID < 1 ) { throw new IllegalArgumentException ( ) ; } PreparedStatement statement = null ; ResultSet result = null ; String revCounters ; try { statement = this . connection . prepareStatement ( "SELECT RevisionCounter "... | Returns the number of revisions for the specified article . |
127,849 | public List < Timestamp > getRevisionTimestamps ( final int articleID ) throws WikiApiException { List < Timestamp > timestamps = new LinkedList < Timestamp > ( ) ; try { if ( articleID < 1 ) { throw new IllegalArgumentException ( ) ; } PreparedStatement statement = null ; ResultSet result = null ; try { if ( ! indexEx... | Returns the timestamps of all revisions connected to the specified article . |
127,850 | public int getNumberOfUniqueContributorsBeforeRevision ( final int revisionID , boolean onlyRegistered ) throws WikiApiException { try { if ( revisionID < 1 ) { throw new IllegalArgumentException ( ) ; } int articleID = getPageIdForRevisionId ( revisionID ) ; Timestamp ts = getRevision ( revisionID ) . getTimeStamp ( )... | Returns the number of unique contributors to an article that have contributed before the given revision . |
127,851 | public Map < String , Timestamp > getUserContributionMap ( final int articleID , String [ ] groupfilter ) throws WikiApiException { return getUserContributionMap ( articleID , groupfilter , false ) ; } | Returns a map of usernames mapped to the timestamps of their contributions . |
127,852 | public List < String > getUserGroups ( final int userID ) throws WikiApiException { List < String > groups = new LinkedList < String > ( ) ; try { if ( userID < 1 ) { throw new IllegalArgumentException ( ) ; } if ( ! tableExists ( "user_groups" ) ) { throw new WikiInitializationException ( "User group assignment data i... | Returns the group assignments of the specified user |
127,853 | public Map < Integer , List < Integer > > getUserRevisionIds ( int userid ) throws WikiApiException { Map < Integer , List < Integer > > revIds = new HashMap < Integer , List < Integer > > ( ) ; try { if ( userid < 1 ) { throw new IllegalArgumentException ( ) ; } if ( ! indexExists ( "revisions" , "userids" ) ) { Syste... | Returns the revisionids of all revisions created by given user |
127,854 | public Map < Timestamp , Collection < DiffPart > > getTimestampToRevisionMap ( final int articleID ) throws WikiApiException { Map < Timestamp , Collection < DiffPart > > tsDiffPartsMap = new HashMap < Timestamp , Collection < DiffPart > > ( ) ; try { if ( articleID < 1 ) { throw new IllegalArgumentException ( ) ; } Pr... | Returns a map of timestamps mapped on the corresponding DiffPart - Collections . Can be used to compile statistics over all changes that have been made in one article . |
127,855 | private Timestamp getDateOfAppearance ( final int articleID , final String firstOrLast ) throws WikiApiException { try { if ( articleID < 1 ) { throw new IllegalArgumentException ( ) ; } PreparedStatement statement = null ; ResultSet result = null ; long time ; try { statement = this . connection . prepareStatement ( "... | Returns the timestamp of the first or last revision connected to the specified article . |
127,856 | public Revision getRevision ( final int revisionID ) throws WikiApiException { try { if ( revisionID < 1 ) { throw new IllegalArgumentException ( ) ; } int fullRevPK = - 1 ; int limit = 1 ; PreparedStatement statement = null ; ResultSet result = null ; try { statement = this . connection . prepareStatement ( "SELECT Fu... | Returns the by the id specified revision . |
127,857 | public Revision getRevision ( final int articleID , final int revisionCounter ) throws WikiApiException { try { if ( articleID < 1 || revisionCounter < 1 ) { throw new IllegalArgumentException ( ) ; } int revisionIndex = checkMapping ( articleID , revisionCounter ) ; String fullRevisions , revCounters ; PreparedStateme... | Returns the by the article ID and revisionCounter specified revision . Note that this method returns the revision in chronological order . |
127,858 | public Revision getRevision ( final int articleID , final Timestamp time ) throws WikiApiException { try { PreparedStatement statement = null ; ResultSet result = null ; String fullRevisions ; String revisionCounters ; if ( articleID < 1 || time == null || time . getTime ( ) <= 0 ) { throw new IllegalArgumentException ... | Returns the by the article ID and timestamp specified revision . Note that the timestamp is not an unique identifier of a revision related to an article . The returned revision should be the first revision that can be found inside the database . |
127,859 | protected int checkMapping ( final int articleID , final int revisionCounter ) throws SQLException { PreparedStatement statement = null ; ResultSet result = null ; try { statement = this . connection . prepareStatement ( "SELECT Mapping " + "FROM index_chronological " + "WHERE ArticleID=? LIMIT 1" ) ; statement . setIn... | This method maps the chronological order to the revisionCounter . |
127,860 | private int getMapping ( final String mapping , final int revisionCounter ) { String tempA , tempB ; int length = 0 ; int revC = - 1 , mapC = - 1 ; int index , max = mapping . length ( ) ; while ( length < max && revC < revisionCounter ) { index = mapping . indexOf ( ' ' , length ) ; tempA = mapping . substring ( lengt... | This method returns the correct mapping of the given input . |
127,861 | private Revision getReferencedRevision ( final int articleID , final int revisionIndex , final String fullRevisions , final String revCounters ) throws WikiApiException { try { int fullRevPK = - 1 ; int limit = 1 ; String fullRev = null ; int revA = - 1 , revB = - 1 ; int lengthFR = 0 ; int lengthRC = 0 ; int index ; i... | This method identifies the correct full revision and retrieves the reference revision . |
127,862 | private boolean indexExists ( String table , String indexName ) throws SQLException { PreparedStatement statement = null ; ResultSet result = null ; try { statement = this . connection . prepareStatement ( "SHOW INDEX FROM " + table + " WHERE Key_name!= 'PRIMARY'" ) ; result = statement . executeQuery ( ) ; if ( result... | Checks if an index with a specific name exists in a given table . |
127,863 | public Map < Integer , Long > getIdMappingCategories ( ) { Map < Integer , Long > idMapping = new HashMap < Integer , Long > ( ) ; Session session = WikiHibernateUtil . getSessionFactory ( this . dbConfig ) . getCurrentSession ( ) ; session . beginTransaction ( ) ; Iterator results = session . createQuery ( "select cat... | Hibernate IDs are needed to load an object from the database . Internal references are via pageIDs . |
127,864 | private void init ( final Task < Revision > task ) { this . partCounter ++ ; this . result = new Task < Diff > ( task . getHeader ( ) , partCounter ) ; } | Initializes the processing of a RevisionTask using a new DiffTask . |
127,865 | protected void initNewTask ( final int taskID ) { this . articleID = taskID ; this . partCounter = 0 ; this . revisionCounter = 0 ; this . revPrevious = null ; this . revCurrent = null ; } | Initializes the processing of a new RevisionTask . |
127,866 | private Diff generateFullRevision ( final Revision revision ) throws UnsupportedEncodingException { Diff diff = new Diff ( ) ; RevisionCodecData codecData = new RevisionCodecData ( ) ; part = new DiffPart ( DiffAction . FULL_REVISION_UNCOMPRESSED ) ; text = revision . getRevisionText ( ) ; revCurrent = text . toCharArr... | Generates a FullRevision . |
127,867 | private void scan ( final char [ ] input , final int start , final int end ) { this . positions = new HashMap < Character , ArrayList < Integer > > ( ) ; ArrayList < Integer > list ; char c ; for ( int i = start ; i < end ; i ++ ) { c = input [ i ] ; list = positions . get ( c ) ; if ( list == null ) { list = new Array... | Scans the input and creates the character - > position mapping . |
127,868 | private boolean findLongestMatch ( final char [ ] revA , final ArrayList < Integer > list , final char [ ] revB , final int index ) { int match ; longestMatch_size = - 1 ; int size = list . size ( ) ; int revAsize = revA . length ; int revBsize = revB . length ; int start , end , count ; for ( int i = 0 ; i < size ; i ... | Searches the longest common substring |
127,869 | public boolean check ( final char c ) { current = current . get ( c ) ; if ( current == null ) { reset ( ) ; } return current . isKeyword ( ) ; } | Checks whether the character is related to the currently used node . If the comparison fails the keyword tree will be reseted to its root node otherwise the related node will replace the current node . |
127,870 | public void add ( final int articleID , final int revisionCounter , final long timestamp ) { if ( this . articleID != articleID ) { if ( list != null ) { addToBuffer ( ) ; } this . articleID = articleID ; this . list = new ArrayList < ChronoIndexData > ( ) ; } this . list . add ( new ChronoIndexData ( timestamp , revis... | Adds the information for an new entry in the chrono index . |
127,871 | private void addToBuffer ( ) { if ( list != null && ! list . isEmpty ( ) ) { ChronoIndexData info ; Collections . sort ( list ) ; StringBuilder reverseMapping = new StringBuilder ( ) ; int size = list . size ( ) ; for ( int i = 1 ; i <= size ; i ++ ) { info = list . get ( i - 1 ) ; if ( info . getRevisionCounter ( ) !=... | Creates the mapping and the reverse mapping . The generated information will be added to the query buffer . This list will be cleared afterwards . |
127,872 | private List < Integer > getPathToRoot ( int root , int node ) throws WikiApiException { List < Integer > pathToRoot = new LinkedList < Integer > ( ) ; List < Integer > shortestPath = new ArrayList < Integer > ( ) ; expandPath ( root , node , pathToRoot , shortestPath ) ; if ( shortestPath . size ( ) == 0 ) { return nu... | Returns the shortest path from node to root as a list of pageIds of the nodes on the path . Node and root are included in the path node list . |
127,873 | public int getPathLengthInEdges ( Category node1 , Category node2 ) { if ( this . graph . containsVertex ( node1 . getPageId ( ) ) && this . graph . containsVertex ( node2 . getPageId ( ) ) ) { if ( node1 . getPageId ( ) == node2 . getPageId ( ) ) { return 0 ; } List edgeList = DijkstraShortestPath . findPathBetween ( ... | Gets the path length between two category nodes - measured in edges . |
127,874 | public int getPathLengthInNodes ( Category node1 , Category node2 ) throws WikiApiException { int retValue = getPathLengthInEdges ( node1 , node2 ) ; if ( retValue == 0 ) { return 0 ; } else if ( retValue > 0 ) { return ( -- retValue ) ; } else if ( retValue == - 1 ) { return - 1 ; } else { throw new WikiApiException (... | Gets the path length between two category nodes - measured in nodes . |
127,875 | public void createRootPathMap ( ) throws WikiApiException { if ( rootPathMap != null ) { return ; } File rootPathFile = new File ( wiki . getWikipediaId ( ) + "_" + this . rootPathMapFilename ) ; if ( rootPathFile . exists ( ) ) { logger . info ( "Loading saved rootPathMap ..." ) ; rootPathMap = deserializeMap ( rootPa... | Computes the paths from each category node to the root . Computing n paths will take some time . Thus efficient computing is based on the assumption that all subpaths in the shortest path to the root are also shortest paths for the corresponding nodes . Starting with the leaf nodes gives the longest initial paths with ... |
127,876 | public void deleteRootPathMap ( ) throws WikiApiException { File rootPathFile = new File ( this . rootPathMapFilename + "_" + wiki . getLanguage ( ) + "_" + wiki . getMetaData ( ) . getVersion ( ) ) ; rootPathFile . delete ( ) ; } | Deleted the root path map file . |
127,877 | public Map < Integer , Integer > getDegreeDistribution ( ) { if ( degreeDistribution == null ) { logger . debug ( "Calling setGraphParameters" ) ; setGraphParameters ( ) ; } return degreeDistribution ; } | Computes the degree distribution . The degree of a node is the number of edges that it is connected with . The graph is treated as an undirected graph . Computing graph parameters requires touching all node pairs . Therefore if one is called the others are computed as well and stored for later retrieval . |
127,878 | private int getNumberOfNeighborConnections ( int node ) { int numberOfConnections = 0 ; Set < Integer > neighbors = getNeighbors ( node ) ; if ( neighbors . size ( ) > 0 ) { Object [ ] nodeArray = neighbors . toArray ( ) ; Arrays . sort ( nodeArray ) ; for ( int i = 0 ; i < neighbors . size ( ) ; i ++ ) { int outerNode... | Get the number of connections that exist between the neighbors of a node . |
127,879 | protected Set < Integer > getNeighbors ( int node ) { Set < Integer > neighbors = new HashSet < Integer > ( ) ; Set < DefaultEdge > edges = undirectedGraph . edgesOf ( node ) ; for ( DefaultEdge edge : edges ) { if ( undirectedGraph . getEdgeSource ( edge ) != node ) { neighbors . add ( undirectedGraph . getEdgeSource ... | Get the neighbors of a given node . The category graph is treated as an undirected graph . |
127,880 | private void setGraphParameters ( ) { double maxPathLength = 0.0 ; double shortestPathLengthSum = 0.0 ; double degreeSum = 0.0 ; double clusterCoefficientSum = 0.0 ; Set < Integer > nodes = undirectedGraph . vertexSet ( ) ; Set < Integer > wasSource = new HashSet < Integer > ( ) ; int progress = 0 ; for ( int node : no... | Computes and sets the diameter the average degree and the average shortest path length of the graph . Do not call this in the constructor . May run a while . It is called in the getters if parameters are not yet initialized when retrieved . |
127,881 | private double computeDepth ( ) throws WikiApiException { Category root = wiki . getMetaData ( ) . getMainCategory ( ) ; if ( root == null ) { logger . error ( "There is no root node for this wiki. Check the parameter that provides the name of the root node." ) ; return 0.0 ; } if ( ! graph . containsVertex ( root . ge... | Computes the depth of the category graph i . e . the maximum path length starting with the root node . |
127,882 | private void serializeMap ( Map < ? , ? > map , File file ) { try ( ObjectOutputStream os = new ObjectOutputStream ( new BufferedOutputStream ( new FileOutputStream ( file ) ) ) ) { os . writeObject ( map ) ; } catch ( Exception e ) { logger . error ( e . getLocalizedMessage ( ) , e ) ; } } | Serialize a Map . |
127,883 | private Map deserializeMap ( File file ) { Map < ? , ? > map ; try ( ObjectInputStream is = new ObjectInputStream ( new BufferedInputStream ( new FileInputStream ( file ) ) ) ) { map = ( Map < ? , ? > ) is . readObject ( ) ; } catch ( Exception e ) { logger . error ( e . getLocalizedMessage ( ) , e ) ; return null ; } ... | Deserialize a map |
127,884 | public void saveGraph ( String destination ) throws WikiApiException { try { GraphSerialization . saveGraph ( graph , destination ) ; } catch ( IOException e ) { throw new WikiApiException ( e ) ; } } | Serializes the graph to the given destination . |
127,885 | public void setSections ( List < Section > sections ) { for ( Section s : sections ) superSection . addSection ( s ) ; } | Sets the Sections of a ParsedPage . |
127,886 | public void validate ( ) { boolean flagA = ! controller . isEnableSQLDatabaseOutput ( ) ; boolean flagB = controller . isMultipleOutputFiles ( ) ; OutputCompressionEnum oce = controller . getOutputCompression ( ) ; enableZipEncodingCompression . setSelected ( controller . isZipCompressionEnabled ( ) ) ; disableOutputCo... | A call of this method should validate the status of the panels components . |
127,887 | private String copy ( final char [ ] array , final int start , final int end ) { StringBuilder text = new StringBuilder ( ) ; for ( int j = start ; j < end ; j ++ ) { text . append ( array [ j ] ) ; } return text . toString ( ) ; } | Copies the specified interval of characters for the array . |
127,888 | private void insert ( final char [ ] revB , final DiffBlock curB ) throws UnsupportedEncodingException { String text = copy ( revB , curB . getRevBStart ( ) , curB . getRevBEnd ( ) ) ; DiffPart action = new DiffPart ( DiffAction . INSERT ) ; action . setStart ( version . length ( ) ) ; codecData . checkBlocksizeS ( ver... | Creates an insert operation . |
127,889 | private void delete ( final DiffBlock curA ) { DiffPart action = new DiffPart ( DiffAction . DELETE ) ; action . setStart ( version . length ( ) ) ; codecData . checkBlocksizeS ( version . length ( ) ) ; action . setLength ( curA . getRevAEnd ( ) - curA . getRevAStart ( ) ) ; codecData . checkBlocksizeE ( action . getL... | Creates a delete operation . |
127,890 | private void replace ( final char [ ] revA , final char [ ] revB , final DiffBlock curA , final DiffBlock curB ) throws UnsupportedEncodingException { String text = copy ( revB , curB . getRevBStart ( ) , curB . getRevBEnd ( ) ) ; DiffPart action = new DiffPart ( DiffAction . REPLACE ) ; action . setStart ( version . l... | Creates a replace operation . |
127,891 | private void cut ( final char [ ] revA , final DiffBlock curA ) { String text = copy ( revA , curA . getRevAStart ( ) , curA . getRevAEnd ( ) ) ; DiffPart action = new DiffPart ( DiffAction . CUT ) ; action . setStart ( version . length ( ) ) ; codecData . checkBlocksizeS ( version . length ( ) ) ; action . setLength (... | Creates a cut operation . |
127,892 | private void paste ( final DiffBlock curB ) { String text = bufferMap . remove ( curB . getId ( ) ) ; DiffPart action = new DiffPart ( DiffAction . PASTE ) ; action . setStart ( version . length ( ) ) ; codecData . checkBlocksizeS ( version . length ( ) ) ; action . setText ( Integer . toString ( curB . getId ( ) ) ) ;... | Creates a paste operation . |
127,893 | private synchronized void log ( final String text ) { try { this . writer . write ( text ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; } } | Writes the given text to the output file . |
127,894 | public void logError ( final Level level , final String message , final Error e ) { try { Logger errors = LoggingFactory . getLogger ( LoggingFactory . NAME_ERROR_LOGGER ) ; errors . logThrowable ( level , message , e ) ; } catch ( LoggingException ex ) { ex . printStackTrace ( ) ; } if ( logLevel . toInt ( ) > level .... | The occurred error with the related log level and message has to be given to this method . |
127,895 | public synchronized void logMessage ( final Level level , final String message ) { if ( logLevel . toInt ( ) > level . toInt ( ) ) { return ; } try { this . writer . write ( System . currentTimeMillis ( ) + "\t" + consumerName + " [" + type . toString ( ) + "] " + "\t" + message + "\r\n" ) ; this . writer . flush ( ) ;... | This method will be called with a message and the related log level . It be verified if the message should be logged or not . |
127,896 | private synchronized void logThrowable ( final Level level , final String message , final Throwable t ) { if ( t != null ) { log ( "\r\n[" + System . currentTimeMillis ( ) + "]\t" + message ) ; log ( "\r\n" + t ) ; log ( "\r\n" ) ; for ( StackTraceElement st : t . getStackTrace ( ) ) { log ( "\t" + st . toString ( ) + ... | The occurred error or exception with the related log level and message will be logged by this method . |
127,897 | public static String sqlEscape ( String str ) { final int len = str . length ( ) ; buffer . setLength ( 0 ) ; StringBuilder sql = buffer ; for ( int i = 0 ; i < len ; i ++ ) { char c = str . charAt ( i ) ; switch ( c ) { case '\u0000' : sql . append ( '\\' ) . append ( '0' ) ; break ; case '\n' : sql . append ( '\\' ) ... | Replaces all problematic characters from a String with their escaped versions to make it SQL conform . |
127,898 | public static List < String > getTemplateNames ( String text , String title ) throws LinkTargetException , EngineException , FileNotFoundException , JAXBException { return ( List < String > ) parsePage ( new TemplateNameExtractor ( ) , text , title , - 1 ) ; } | Extracts template names from Wikitext by descending into every node and looking for templates . Results may contain duplicates if template appears multiple times in the article . |
127,899 | private static Object parsePage ( AstVisitor v , String text , String title , long revision ) throws LinkTargetException , EngineException , FileNotFoundException , JAXBException { return v . go ( getCompiledPage ( text , title , revision ) . getPage ( ) ) ; } | Parses the page with the Sweble parser using a SimpleWikiConfiguration and the provided visitor . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.