List of usage examples for org.apache.hadoop.util StringUtils split
public static String[] split(String str, char escapeChar, char separator)
From source file:com.moz.fiji.schema.tools.LsTool.java
License:Apache License
/** * Parses a table name for a fiji instance name. * * @param fijiTableName The table name to parse * @return instance name (or null if none found) *///from ww w. j a v a 2s . c o m protected static String parseInstanceName(String fijiTableName) { final String[] parts = StringUtils.split(fijiTableName, '\u0000', '.'); if (parts.length < 3 || !FijiURI.FIJI_SCHEME.equals(parts[0])) { return null; } return parts[1]; }
From source file:org.apache.accumulo.core.client.BatchWriterConfig.java
License:Apache License
@Override public void readFields(DataInput in) throws IOException { byte[] len = new byte[7]; in.readFully(len);/* w w w. jav a 2s .co m*/ String strLen = new String(len, UTF_8); if (!strLen.endsWith("#")) throw new IllegalStateException("length was not encoded correctly"); byte[] bytes = new byte[Integer.parseInt(strLen.substring(strLen.lastIndexOf(' ') + 1, strLen.length() - 1), 36)]; in.readFully(bytes); String strFields = new String(bytes, UTF_8); String[] fields = StringUtils.split(strFields, '\\', ','); for (String field : fields) { String[] keyValue = StringUtils.split(field, '\\', '='); String key = keyValue[0]; String value = keyValue[1]; if ("maxMemory".equals(key)) { maxMemory = Long.valueOf(value); } else if ("maxLatency".equals(key)) { maxLatency = Long.valueOf(value); } else if ("maxWriteThreads".equals(key)) { maxWriteThreads = Integer.valueOf(value); } else if ("timeout".equals(key)) { timeout = Long.valueOf(value); } else if ("durability".equals(key)) { durability = DurabilityImpl.fromString(value); } else { /* ignore any other properties */ } } }
From source file:org.huahinframework.examples.wordcount.natural.WordFilter.java
License:Apache License
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { for (String s : StringUtils.split(value.toString(), StringUtils.ESCAPE_CHAR, ' ')) { context.write(new Text(s), ONE); }/*from www .ja va2 s.c o m*/ }
From source file:org.kiji.schema.tools.LsTool.java
License:Apache License
/** * Parses a table name for a kiji instance name. * * @param kijiTableName The table name to parse * @return instance name (or null if none found) *//* w ww . j a v a 2s . c o m*/ protected static String parseInstanceName(String kijiTableName) { final String[] parts = StringUtils.split(kijiTableName, '\u0000', '.'); if (parts.length < 3 || !KijiURI.KIJI_SCHEME.equals(parts[0])) { return null; } return parts[1]; }
From source file:uk.ac.cam.eng.extraction.hadoop.features.lexical.TTableServer.java
License:Apache License
private void loadModel(String modelFile, byte prov) throws FileNotFoundException, IOException { try (BufferedReader br = new BufferedReader( new InputStreamReader(new GZIPInputStream(new FileInputStream(modelFile))))) { String line;/*from ww w .ja v a 2 s . co m*/ int count = 1; while ((line = br.readLine()) != null) { if (count % 1000000 == 0) { System.err.println("Processed " + count + " lines"); } count++; line = line.replace("NULL", "0"); String[] parts = StringUtils.split(line, '\\', ' '); try { int sourceWord = Integer.parseInt(parts[0]); int targetWord = Integer.parseInt(parts[1]); double model1Probability = Double.parseDouble(parts[2]); if (model1Probability < minLexProb) { continue; } if (!model.get(prov).containsKey(sourceWord)) { model.get(prov).put(sourceWord, new HashMap<Integer, Double>()); } model.get(prov).get(sourceWord).put(targetWord, model1Probability); } catch (NumberFormatException e) { System.out.println("Unable to parse line: " + e.getMessage() + "\n" + line); } } } }