List of usage examples for org.apache.hadoop.io WritableUtils writeString
public static void writeString(DataOutput out, String s) throws IOException
From source file:co.cask.cdap.examples.purchase.Purchase.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { WritableUtils.writeString(out, customer); WritableUtils.writeString(out, product); WritableUtils.writeVInt(out, quantity); WritableUtils.writeVInt(out, price); WritableUtils.writeVLong(out, purchaseTime); WritableUtils.writeString(out, catalogId); }
From source file:co.cask.cdap.hive.stream.StreamInputSplit.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { super.write(out); WritableUtils.writeString(out, eventPath.toString()); if (indexPath == null) { out.writeBoolean(false);/*from ww w . java 2s.co m*/ } else { out.writeBoolean(true); WritableUtils.writeString(out, indexPath.toString()); } WritableUtils.writeVLong(out, startTime); WritableUtils.writeVLong(out, endTime); }
From source file:com.asakusafw.bridge.hadoop.directio.Util.java
License:Apache License
static void writeFragment(DataOutput out, DirectInputFragment fragment) throws IOException { WritableUtils.writeString(out, fragment.getPath()); WritableUtils.writeVLong(out, fragment.getOffset()); WritableUtils.writeVLong(out, fragment.getSize()); List<String> ownerNodeNames = fragment.getOwnerNodeNames(); WritableUtils.writeStringArray(out, ownerNodeNames.toArray(new String[ownerNodeNames.size()])); Map<String, String> attributes = fragment.getAttributes(); writeMap(out, attributes);//from ww w . j a v a2 s .c o m }
From source file:com.asakusafw.runtime.stage.input.StageInputSplit.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { writeClassByName(out, mapperClass);//from w w w . j av a 2s . c o m WritableUtils.writeVInt(out, sources.size()); for (Source source : sources) { Class<? extends InputSplit> splitClass = source.getSplit().getClass(); writeClassByName(out, source.getFormatClass()); writeClassByName(out, splitClass); ((Writable) source.getSplit()).write(out); } if (locations == null) { WritableUtils.writeVInt(out, -1); } else { WritableUtils.writeVInt(out, locations.length); for (String string : locations) { WritableUtils.writeString(out, string); } } }
From source file:com.asakusafw.runtime.stage.output.BridgeOutputFormat.java
License:Apache License
private static void save(Configuration conf, List<OutputSpec> specs) { assert conf != null; assert specs != null; for (OutputSpec spec : specs) { if (spec.resolved) { throw new IllegalStateException(); }/* w w w . ja v a 2 s . co m*/ } ByteArrayOutputStream sink = new ByteArrayOutputStream(); try (DataOutputStream output = new DataOutputStream(new GZIPOutputStream(new Base64OutputStream(sink)))) { WritableUtils.writeVLong(output, SERIAL_VERSION); WritableUtils.writeVInt(output, specs.size()); for (OutputSpec spec : specs) { WritableUtils.writeString(output, spec.basePath); WritableUtils.writeVInt(output, spec.deletePatterns.size()); for (String pattern : spec.deletePatterns) { WritableUtils.writeString(output, pattern); } } } catch (IOException e) { throw new IllegalStateException(e); } conf.set(KEY, new String(sink.toByteArray(), ASCII)); }
From source file:com.digitalpebble.behemoth.BehemothDocument.java
License:Apache License
protected void writeAnnotation(Annotation annot, DataOutput out, List<String> atypes) throws IOException { int typePos = atypes.indexOf(annot.getType()); IntWritable intStringPool = new IntWritable(typePos); intStringPool.write(out);// www . j a va 2 s . c o m WritableUtils.writeVLong(out, annot.getStart()); WritableUtils.writeVLong(out, annot.getEnd()); out.writeInt(annot.getFeatureNum()); if (annot.getFeatures() != null) { Iterator<String> featNameIter = annot.getFeatures().keySet().iterator(); while (featNameIter.hasNext()) { String fname = featNameIter.next(); int fnamePos = atypes.indexOf(fname); intStringPool.set(fnamePos); intStringPool.write(out); WritableUtils.writeString(out, annot.getFeatures().get(fname)); } } }
From source file:com.facebook.hiveio.common.HiveTableDesc.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { WritableUtils.writeString(out, databaseName); WritableUtils.writeString(out, tableName); }
From source file:com.facebook.hiveio.common.MetastoreDesc.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { WritableUtils.writeString(out, host); out.writeInt(port); }
From source file:com.facebook.hiveio.common.Writables.java
License:Apache License
/** * Write class name//from www. java2 s . co m * * @param out DataOutput * @param klass Class * @throws IOException I/O errors */ public static void writeClassName(DataOutput out, Class<?> klass) throws IOException { WritableUtils.writeString(out, klass.getName()); }
From source file:com.facebook.hiveio.common.Writables.java
License:Apache License
/** * Write an array of enums/*from w w w . j a va 2s . c o m*/ * * @param enums Enum array * @param out DataOutput * @param <E> type of enum * @throws IOException */ public static <E extends Enum<E>> void writeEnumArray(DataOutput out, Enum<E>[] enums) throws IOException { out.writeInt(enums.length); if (enums.length > 0) { WritableUtils.writeString(out, enums[0].getDeclaringClass().getName()); } for (Enum<E> val : enums) { WritableUtils.writeEnum(out, val); } }