/** * Set configuration for the writer. * * @param cfg * configuration for the writer. * @return {@code this} */ public ReftableWriter setConfig(ReftableConfig cfg) { this.config = cfg != null ? cfg : new ReftableConfig(); return this; }
/** * Initialize a writer with a default configuration. */ public ReftableWriter() { this(new ReftableConfig()); }
/** * Get configuration to write new reftables with. * * @return configuration to write new reftables with. */ public ReftableConfig getReftableConfig() { return new ReftableConfig(getRepository().getConfig()); }
static ReftableConfig configureReftable(ReftableConfig cfg, DfsOutputStream out) { int bs = out.blockSize(); if (bs > 0) { cfg = new ReftableConfig(cfg); cfg.setRefBlockSize(bs); cfg.setAlignBlocks(true); } return cfg; }
@Override public ReftableConfig getReftableConfig() { ReftableConfig cfg = new ReftableConfig(); cfg.setAlignBlocks(false); cfg.setIndexObjects(false); cfg.fromConfig(getRepository().getConfig()); return cfg; }
/** * References to convert into a reftable * * @param refs * references to convert into a reftable; may be empty. * @return a reader for the supplied references. */ public static Reftable from(Collection<Ref> refs) { try { ReftableConfig cfg = new ReftableConfig(); cfg.setIndexObjects(false); cfg.setAlignBlocks(false); ByteArrayOutputStream buf = new ByteArrayOutputStream(); new ReftableWriter() .setConfig(cfg) .begin(buf) .sortAndWriteRefs(refs) .finish(); return new ReftableReader(BlockSource.from(buf.toByteArray())); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Set configuration for the writer. * * @param cfg * configuration for the writer. * @return {@code this} */ public ReftableWriter setConfig(ReftableConfig cfg) { this.config = cfg != null ? cfg : new ReftableConfig(); return this; }
/** * Initialize a writer with a default configuration. */ public ReftableWriter() { this(new ReftableConfig()); }
/** * Get configuration to write new reftables with. * * @return configuration to write new reftables with. */ public ReftableConfig getReftableConfig() { return new ReftableConfig(getRepository().getConfig()); }
static ReftableConfig configureReftable(ReftableConfig cfg, DfsOutputStream out) { int bs = out.blockSize(); if (bs > 0) { cfg = new ReftableConfig(cfg); cfg.setRefBlockSize(bs); cfg.setAlignBlocks(true); } return cfg; }
@Override public ReftableConfig getReftableConfig() { ReftableConfig cfg = new ReftableConfig(); cfg.setAlignBlocks(false); cfg.setIndexObjects(false); cfg.fromConfig(getRepository().getConfig()); return cfg; }
/** * References to convert into a reftable * * @param refs * references to convert into a reftable; may be empty. * @return a reader for the supplied references. */ public static Reftable from(Collection<Ref> refs) { try { ReftableConfig cfg = new ReftableConfig(); cfg.setIndexObjects(false); cfg.setAlignBlocks(false); ByteArrayOutputStream buf = new ByteArrayOutputStream(); new ReftableWriter() .setConfig(cfg) .begin(buf) .sortAndWriteRefs(refs) .finish(); return new ReftableReader(BlockSource.from(buf.toByteArray())); } catch (IOException e) { throw new RuntimeException(e); } }