private DataFileWriter<D> setMetaInternal(String key, String value) { return setMetaInternal(key, value.getBytes(StandardCharsets.UTF_8)); }
private DataFileWriter<D> setMetaInternal(String key, String value) { try { return setMetaInternal(key, value.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
/** Set a metadata property. */ public DataFileWriter<D> setMeta(String key, byte[] value) { if (isReservedMeta(key)) { throw new AvroRuntimeException("Cannot set reserved meta key: " + key); } return setMetaInternal(key, value); }
/** Set a metadata property. */ public DataFileWriter<D> setMeta(String key, byte[] value) { if (isReservedMeta(key)) { throw new AvroRuntimeException("Cannot set reserved meta key: " + key); } return setMetaInternal(key, value); }
/** * Configures this writer to use the given codec. * May not be reset after writes have begun. */ public DataFileWriter<D> setCodec(CodecFactory c) { assertNotOpen(); this.codec = c.createInstance(); setMetaInternal(DataFileConstants.CODEC, codec.getName()); return this; }
/** * Configures this writer to use the given codec. * May not be reset after writes have begun. */ public DataFileWriter<D> setCodec(CodecFactory c) { assertNotOpen(); this.codec = c.createInstance(); setMetaInternal(DataFileConstants.CODEC, codec.getName()); return this; }
/** Open a new file for data matching a schema with an explicit sync. */ public DataFileWriter<D> create(Schema schema, OutputStream outs, byte[] sync) throws IOException { assertNotOpen(); this.schema = schema; setMetaInternal(DataFileConstants.SCHEMA, schema.toString()); if (sync == null ) { this.sync = generateSync(); } else if (sync.length == 16) { this.sync = sync; } else { throw new IOException("sync must be exactly 16 bytes"); } init(outs); vout.writeFixed(DataFileConstants.MAGIC); // write magic vout.writeMapStart(); // write metadata vout.setItemCount(meta.size()); for (Map.Entry<String,byte[]> entry : meta.entrySet()) { vout.startItem(); vout.writeString(entry.getKey()); vout.writeBytes(entry.getValue()); } vout.writeMapEnd(); vout.writeFixed(this.sync); // write initial sync vout.flush(); //vout may be buffered, flush before writing to out return this; }
/** Open a new file for data matching a schema with an explicit sync. */ public DataFileWriter<D> create(Schema schema, OutputStream outs, byte[] sync) throws IOException { assertNotOpen(); this.schema = schema; setMetaInternal(DataFileConstants.SCHEMA, schema.toString()); if (sync == null ) { this.sync = generateSync(); } else if (sync.length == 16) { this.sync = sync; } else { throw new IOException("sync must be exactly 16 bytes"); } init(outs); vout.writeFixed(DataFileConstants.MAGIC); // write magic vout.writeMapStart(); // write metadata vout.setItemCount(meta.size()); for (Map.Entry<String,byte[]> entry : meta.entrySet()) { vout.startItem(); vout.writeString(entry.getKey()); vout.writeBytes(entry.getValue()); } vout.writeMapEnd(); vout.writeFixed(this.sync); // write initial sync vout.flush(); //vout may be buffered, flush before writing to out return this; }
public DataFileWriter<D> setMetaInternal(String key, String value) { try { return setMetaInternal(key, value.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
private DataFileWriter<D> setMetaInternal(String key, String value) { try { return setMetaInternal(key, value.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
public DataFileWriter<D> setMetaInternal(String key, String value) { try { return setMetaInternal(key, value.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
private DataFileWriter<D> setMetaInternal(String key, String value) { try { return setMetaInternal(key, value.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
/** Set a metadata property. */ public DataFileWriter<D> setMeta(String key, byte[] value) { if (isReserved(key)) { throw new AvroRuntimeException("Cannot set reserved meta key: " + key); } return setMetaInternal(key, value); }
/** Set a metadata property. */ public DataFileWriter<D> setMeta(String key, byte[] value) { if (isReservedMeta(key)) { throw new AvroRuntimeException("Cannot set reserved meta key: " + key); } return setMetaInternal(key, value); }
/** Set a metadata property. */ public DataFileWriter<D> setMeta(String key, byte[] value) { if (isReserved(key)) { throw new AvroRuntimeException("Cannot set reserved meta key: " + key); } return setMetaInternal(key, value); }
/** Set a metadata property. */ public DataFileWriter<D> setMeta(String key, byte[] value) { if (isReservedMeta(key)) { throw new AvroRuntimeException("Cannot set reserved meta key: " + key); } return setMetaInternal(key, value); }
/** * Configures this writer to use the given codec. * May not be reset after writes have begun. */ public DataFileWriter<D> setCodec(CodecFactory c) { assertNotOpen(); this.codec = c.createInstance(); setMetaInternal(DataFileConstants.CODEC, codec.getName()); return this; }
/** * Configures this writer to use the given codec. * May not be reset after writes have begun. */ public DataFileWriter<D> setCodec(CodecFactory c) { assertNotOpen(); this.codec = c.createInstance(); setMetaInternal(DataFileConstants.CODEC, codec.getName()); return this; }
/** * Configures this writer to use the given codec. * May not be reset after writes have begun. */ public DataFileWriter<D> setCodec(CodecFactory c) { assertNotOpen(); this.codec = c.createInstance(); setMetaInternal(DataFileConstants.CODEC, codec.getName()); return this; }
/** * Configures this writer to use the given codec. * May not be reset after writes have begun. */ public DataFileWriter<D> setCodec(CodecFactory c) { assertNotOpen(); this.codec = c.createInstance(); setMetaInternal(DataFileConstants.CODEC, codec.getName()); return this; }