Cambridge SMT System
HFilePrint.java
Go to the documentation of this file.
1 /*******************************************************************************
2  * Licensed under the Apache License, Version 2.0 (the "License");
3  * you may not use these files except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  *
14  * Copyright 2014 - Juan Pino, Aurelien Waite, William Byrne
15  *******************************************************************************/
16 
17 package uk.ac.cam.eng.extraction.hadoop.util;
18 
19 import java.io.IOException;
20 
21 import org.apache.hadoop.conf.Configuration;
22 import org.apache.hadoop.fs.FileSystem;
23 import org.apache.hadoop.fs.Path;
24 import org.apache.hadoop.hbase.io.hfile.CacheConfig;
25 import org.apache.hadoop.hbase.io.hfile.HFile;
26 
27 import uk.ac.cam.eng.extraction.Rule;
30 import uk.ac.cam.eng.util.Pair;
31 
36 public class HFilePrint {
37 
38  public static void main(String[] args) throws IOException {
39  if (args.length != 1) {
40  System.err.println("Args: <HFile to be printed>");
41  System.exit(1);
42  }
43  Configuration conf = new Configuration();
44  CacheConfig cacheConf = new CacheConfig(conf);
45  HFile.Reader hfReader = HFile.createReader(FileSystem.get(conf),
46  new Path(args[0]), cacheConf);
47  HFileRuleReader reader = new HFileRuleReader(hfReader);
48  for (Pair<Rule, RuleData> entry : reader) {
49  System.out.println(entry);
50  }
51  }
52 
53 }