| Home  | Casa  | Hardware  | Networking  | Programmazione  | Software  | Domanda  | Sistemi  |   
Programmazione  
  • C /C + + Programming

  • Computer Programming Languages

  • Delphi Programming

  • Java Programming

  • Programmazione Javascript

  • PHP /MySQL Programmazione

  • Perl Programming

  • Python Programming

  • rubino Programmazione

  • Nozioni di base di Visual Programming
  •  
    Conoscenza Informatica >> Programmazione >> Computer Programming Languages >> Content
    Come costruire un indice invertito Con MapReduce
    MapReduce è un modello di programmazione parallela sviluppata in Google per grandi insiemi di dati . Esso elabora i dati in blocchi piuttosto che in ordine sequenziale . In tal modo, essa si basa sulla mappa di funzioni di ingresso accoppiati (chiavi) e valori che poi mette attraverso la funzione reduce - in tal modo , il suo nome - per rendere più facili i dati per capire . Invece di fornire la funzione di mappa con una chiave e un valore , un indice invertito coppie di parole e documenti per la ricerca di testo . È possibile utilizzare gli indici invertiti in MapReduce per creare un indice per una ricerca per parole chiave , per esempio. Istruzioni
    1

    Digitare il seguente codice per la funzione mappa :

    pubblico InvertedIndexerMapper classe statica estende MapReduceBaseimplements Mapper {private ultima parola del testo statico = new testo ( ) ; private posizione testo statico finale = nuovo testo ( ) ;

    pubblici mappa void ( tasto LongWritable , testo val , OutputCollector , Reporter giornalista ) throws IOException { FileSplit FileSplit = ( FileSplit ) reporter.getInputSplit (); String fileName = fileSplit.getPath ( ) getName () ; location.set ( fileName ) ;

    linea String - val.toString ( ) . ITR StringTokenizer = new StringTokenizer ( riga. toLowerCase ()); while ( itr.hasMoreTokens ( ) ) { word.set ( itr.nextToken ()); output.collect (word , posizione );} } }
    2

    Digitare il seguente codice per la funzione di ridurre :

    pubblico InvertedIndexerReducer classe statica estende MapReduceBaseimplements Reducer { public void ridurre ( tasto Text , valori Iterator , OutputCollector , Reporter giornalista ) throws IOException { boolean primo = true ; StringBuilder toReturn = new StringBuilder (); while ( values.hasNext ( ) ) {if ( primo ) toReturn.append ( "," ) ; ! primo = false; toReturn . append ( . values.next ( ) toString ()); } output.collect ( chiave , nuovo Testo ( toReturn.toString ( ))) ; } }
    3

    digitare il seguente codice per completare l' indice invertito :

    public static void main (String [] args ) throws IOException {if ( args.length < 2) { System.outprintln ( " uso: InvertedIndex < , percorso di uscita > "); System.exit ( 1) ; } JobConf conf = new JobConf ( InvertedIndex.class ) ; conf.setJobName ( " InvertedIndex " ) ;

    conf.setOutputKeyClass ( Text.class ) ; conf.setOutputValueClass ( Text.class ) ;

    conf.setMapperClass ( InvertedIndexerMapper.class ) ; conf.setReducerClass ( InvertedIndexerReducer.class ) ;

    FileInputFormat.setInputPaths ( conf, nuovo percorso ( args [ 0 ] ) ) ; FileOutputFormat.setOutputPath ( conf , nuovo percorso ( args [ 1] ) ) ; try { JobClient.runJob ( conf) ; } catch ( Exception e) { e.pringStackTrace (); } }

    Previous :

    next :
      Articoli Correlati
    ·Come aggiungere un Permalink 
    ·Come formattare un campo associato DataGrid 
    ·Come creare un link in Oracle Database 
    ·Come formattare un ListBox con valore selezionato 
    ·Di scripting lato client Vs . Scripting lato server 
    ·Procedure predefinite in Turbo Pascal 
    ·Come Non Log In XP con una password 
    ·Come utilizzare cvs diff 
    ·Come scrivere while Looping 
    ·Sviluppo di iPhone e Framework 
      Articoli in evidenza
    ·Come convertire un array PHP a JSON 
    ·Come configurare un Proxy Host per PHP JavaScript 
    ·Come creare un menu di programmazione Android 
    ·Alternative Eval 
    ·Come trovare il numero indice di un elemento in PHP 
    ·Come scorrere tutte le proprietà su un oggetto Python 
    ·Come utilizzare i parametri nelle SSIS 
    ·Come convertire BigInteger a Int. 
    ·Come analizzare un file di testo delimitato da tabulazi…
    ·Come convertire un personaggio all'altro su Ruby 
    Copyright © Conoscenza Informatica http://it.wingwit.com