The RandomWriter (random write) example uses MapReduce to randomly write data to dfs. Input a single file name for each map, and then randomly write the keys and values of BytesWritable to the DFS Sequence File. Map does not produce any output, so reduce is not executed. The generated data can be configured. The configuration variable is named below. The default value is test. rando.
The RandomWriter (random write) example uses Map/REdUce writes data randomlyDfS. Input a single file name for each map, and then randomly write the keys and values of BytesWritable to the DFS Sequence File. Map does not produce any output, so reDuCe is not executed. The generated data can be configured. The configuration variables are as follows:
| Name |
Default Value |
Description |
|
Test. randomWriteR. maps_per_host |
10 |
Number of maps/host |
|
Test. randomwrite. bytes_per_map |
1073741824 |
Number of bytes written/map |
|
Test. randomwrite. min_key |
10 |
Minimum size of the key in bytes |
|
Test. randomwrite. max_key |
1000 |
Maximum size of the key in bytes |
|
Test. randomwrite. min_value |
0 |
Minimum size of the value |
|
Test. randomwrite. max_value |
20000 |
Maximum size of the value |
Test. randomwriter. maps_per_host indicates the number of times map is run on each slave node.By default, there is only one data node, so there are 10 maps, each map has 1 GB of data, so 10 Gb of data needs to be written to hdfs. However, I configured only two slave nodes in the test environment, so there are two maps.
Test. randomwrite. bytes_per_map I originally thought it was the size of the random write output test file. The default value is 1G = 1*1024*1024*1024, but after I change this data to 1*1024*1024, the output test file is still 1 GB, which makes me very puzzled.(?)
Code instance
Test. randomwrite. bytes_per_map = 1*1024*1024, test. randomwriter. maps_per_host = 1.
- /**
- * LicenSedTo the Apache Software Foundation (ASF) under one
- * OrMoreConTrIbutor license agreements. See the NOTICEFile
- * Distributed with this work forDdItional infoRmAtion
- * Regarding copyright ownership. The ASF licenses this file
- * To you under the Apache License, Version 2.0 (
- * \ "License \"); you may not use this fileExCept in compliaNcE
- * With the License. You may obtain a copy of the License
- *
- * Http://www.apache.org/licenses/LICENSE-2.0
- *
- * UnLessRequired by applicable law or agreed to in writing, software
- * Distributed under the License is distributed on an \ "as is \" BASIS,
- * Without warranties or conditions of any kind, eitherExprEss or implied.
- * See the License for the specific language governing permissions and
- * Limitations under the License.
- */
- Package org. apache. hadoop. examples;
- Import java. io. IOException;
- Import java. util. Date;
- Import java. util. Random;