1 | <html> |
---|
2 | <!-- |
---|
3 | Licensed to the Apache Software Foundation (ASF) under one or more |
---|
4 | contributor license agreements. See the NOTICE file distributed with |
---|
5 | this work for additional information regarding copyright ownership. |
---|
6 | The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
7 | (the "License"); you may not use this file except in compliance with |
---|
8 | the License. You may obtain a copy of the License at |
---|
9 | |
---|
10 | http://www.apache.org/licenses/LICENSE-2.0 |
---|
11 | |
---|
12 | Unless required by applicable law or agreed to in writing, software |
---|
13 | distributed under the License is distributed on an "AS IS" BASIS, |
---|
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
15 | See the License for the specific language governing permissions and |
---|
16 | limitations under the License. |
---|
17 | --> |
---|
18 | |
---|
19 | <body> |
---|
20 | <h2>org.apache.hadoop.mapred.lib.db Package</h2> |
---|
21 | <p> |
---|
22 | This package contains a library to read records from a database as an |
---|
23 | input to a mapreduce job, and write the output records to the database. |
---|
24 | </p> |
---|
25 | <p> |
---|
26 | The Database to access can be configured using the static methods in the |
---|
27 | DBConfiguration class. Jobs reading input from a database should use |
---|
28 | DBInputFormat#setInput() to set the configuration. And jobs writing |
---|
29 | its output to the database should use DBOutputFormat#setOutput(). |
---|
30 | </p> |
---|
31 | <p> |
---|
32 | Tuples from/to the database are converted to/from Java objects using |
---|
33 | DBWritable methods. Typically, for each table in the db, a class extending |
---|
34 | DBWritable is defined, which holds the fields of the tuple. The fields |
---|
35 | of a record are read from the database using DBWritable#readFields(ResultSet), |
---|
36 | and written to the database using DBWritable#write(PreparedStatament |
---|
37 | statement). |
---|
38 | </p> |
---|
39 | <p> |
---|
40 | An example program using both DBInputFormat and DBOutputFormat can be found |
---|
41 | at src/examples/org/apache/hadoop/examples/DBCountPageview.java. |
---|
42 | </p> |
---|
43 | </body> |
---|
44 | </html> |
---|