@Test @UseDataProvider("provideObjectFileOutputStream") public void objectFileOutputStream(final int maxObjects, final int numObjects, final int fileCount) throws IOException { final String prefix = "id"; final String suffix = ".object"; final String prefixFilename = new File(this.folder.getRoot().toString(), prefix).toString(); final OutputStream out = new ObjectFile.ObjectFileOutputStream(prefixFilename, maxObjects, suffix); final ObjectMetadata o = LegacyObjectMetadata .fromMetadata(UUID.randomUUID().toString().replace("-", "") + "0000", 0, 0, (byte)-1, -1); for (int i = 0; i < numObjects; i++) { out.write(o.toBytes()); } out.close(); final List<String> objectFiles = Arrays.asList(this.folder.getRoot().list(new FilenameFilter() { @Override public boolean accept(final File dir, final String name) { return name.endsWith(suffix); } })); assertThat(objectFiles.size(), is(fileCount)); int persistedObjects = 0; for (int i = 0; i < fileCount; i++) { final String filename = String.format("%s%d%s", prefix, i, suffix); assertThat(objectFiles.contains(filename), is(true)); persistedObjects += new File(this.folder.getRoot(), filename).length() / LegacyObjectMetadata.OBJECT_SIZE; } assertThat(persistedObjects, is(numObjects)); }
public static void write(final InputStream in, final OutputStream out, boolean writeVersionHeader) throws IOException { checkNotNull(in); checkNotNull(out); final BufferedReader reader = new BufferedReader(new InputStreamReader(in, Charsets.UTF_8)); String line; if (writeVersionHeader) { ObjectFileUtil.writeObjectFileVersion(out); } line = reader.readLine(); ObjectFileVersion version = null; if (line != null) { version = ObjectFileVersion.fromCharString(line); if (version.getMajorVersion() == 1 && version.getMinorVersion() == 0) { LegacyObjectMetadata objectName = getObjectFromCharString(version.getMajorVersion(), version.getMinorVersion(), line); out.write(objectName.toBytes()); } } ObjectMetadata objectName = null; while ((line = reader.readLine()) != null) { objectName = getObjectFromCharString(version.getMajorVersion(), version.getMinorVersion(), line); out.write(objectName.toBytes()); } }
ObjectFile { public static void write(final InputStream in, final OutputStream out, boolean writeVersionHeader) throws IOException { checkNotNull(in); checkNotNull(out); final BufferedReader reader = new BufferedReader(new InputStreamReader(in, Charsets.UTF_8)); String line; if (writeVersionHeader) { ObjectFileUtil.writeObjectFileVersion(out); } line = reader.readLine(); ObjectFileVersion version = null; if (line != null) { version = ObjectFileVersion.fromCharString(line); if (version.getMajorVersion() == 1 && version.getMinorVersion() == 0) { LegacyObjectMetadata objectName = getObjectFromCharString(version.getMajorVersion(), version.getMinorVersion(), line); out.write(objectName.toBytes()); } } ObjectMetadata objectName = null; while ((line = reader.readLine()) != null) { objectName = getObjectFromCharString(version.getMajorVersion(), version.getMinorVersion(), line); out.write(objectName.toBytes()); } } }
ObjectFile { public static void write(final InputStream in, final OutputStream out, boolean writeVersionHeader) throws IOException { checkNotNull(in); checkNotNull(out); final BufferedReader reader = new BufferedReader(new InputStreamReader(in, Charsets.UTF_8)); String line; if (writeVersionHeader) { ObjectFileUtil.writeObjectFileVersion(out); } line = reader.readLine(); ObjectFileVersion version = null; if (line != null) { version = ObjectFileVersion.fromCharString(line); if (version.getMajorVersion() == 1 && version.getMinorVersion() == 0) { LegacyObjectMetadata objectName = getObjectFromCharString(version.getMajorVersion(), version.getMinorVersion(), line); out.write(objectName.toBytes()); } } ObjectMetadata objectName = null; while ((line = reader.readLine()) != null) { objectName = getObjectFromCharString(version.getMajorVersion(), version.getMinorVersion(), line); out.write(objectName.toBytes()); } } private  ObjectFile(); }
ObjectFile { public static void write(final InputStream in, final OutputStream out, boolean writeVersionHeader) throws IOException { checkNotNull(in); checkNotNull(out); final BufferedReader reader = new BufferedReader(new InputStreamReader(in, Charsets.UTF_8)); String line; if (writeVersionHeader) { ObjectFileUtil.writeObjectFileVersion(out); } line = reader.readLine(); ObjectFileVersion version = null; if (line != null) { version = ObjectFileVersion.fromCharString(line); if (version.getMajorVersion() == 1 && version.getMinorVersion() == 0) { LegacyObjectMetadata objectName = getObjectFromCharString(version.getMajorVersion(), version.getMinorVersion(), line); out.write(objectName.toBytes()); } } ObjectMetadata objectName = null; while ((line = reader.readLine()) != null) { objectName = getObjectFromCharString(version.getMajorVersion(), version.getMinorVersion(), line); out.write(objectName.toBytes()); } } private  ObjectFile(); static void main(final String[] args); static InputStream getInputStream(final File input); static OutputStream getOutputStream(final boolean split, final int splitSize,
      final String output); static OutputStream getOutputStream(final String output); static void write(final InputStream in, final OutputStream out, boolean writeVersionHeader); static void read(final InputStream in, final OutputStream out, boolean writeVersionHeader); static void filter(final InputStream in, final OutputStream out, final long minFilesize,
      final long maxFilesize, final int minContainerSuffix, final int maxContainerSuffix,
      final Set<Integer> containerSuffixes, final int minLegalholds, final int maxLegalHolds,
      final long minRetention, final long maxRetention, boolean writeVersionHeader); static void split(final InputStream in, final OutputStream out); static void upgrade(final InputStream in, final OutputStream out); static boolean readFully(final InputStream in, final byte[] b); static void compactObjectFiles(final HashMap<File, Integer> objectFiles, final int maxcount); static void combineFiles(File f1, File f2); static void randomShuffleObjects(final InputStream in, final OutputStream out); static void shuffle(String prefix, String directory, int maxObjects); }
ObjectFile { public static void write(final InputStream in, final OutputStream out, boolean writeVersionHeader) throws IOException { checkNotNull(in); checkNotNull(out); final BufferedReader reader = new BufferedReader(new InputStreamReader(in, Charsets.UTF_8)); String line; if (writeVersionHeader) { ObjectFileUtil.writeObjectFileVersion(out); } line = reader.readLine(); ObjectFileVersion version = null; if (line != null) { version = ObjectFileVersion.fromCharString(line); if (version.getMajorVersion() == 1 && version.getMinorVersion() == 0) { LegacyObjectMetadata objectName = getObjectFromCharString(version.getMajorVersion(), version.getMinorVersion(), line); out.write(objectName.toBytes()); } } ObjectMetadata objectName = null; while ((line = reader.readLine()) != null) { objectName = getObjectFromCharString(version.getMajorVersion(), version.getMinorVersion(), line); out.write(objectName.toBytes()); } } private  ObjectFile(); static void main(final String[] args); static InputStream getInputStream(final File input); static OutputStream getOutputStream(final boolean split, final int splitSize,
      final String output); static OutputStream getOutputStream(final String output); static void write(final InputStream in, final OutputStream out, boolean writeVersionHeader); static void read(final InputStream in, final OutputStream out, boolean writeVersionHeader); static void filter(final InputStream in, final OutputStream out, final long minFilesize,
      final long maxFilesize, final int minContainerSuffix, final int maxContainerSuffix,
      final Set<Integer> containerSuffixes, final int minLegalholds, final int maxLegalHolds,
      final long minRetention, final long maxRetention, boolean writeVersionHeader); static void split(final InputStream in, final OutputStream out); static void upgrade(final InputStream in, final OutputStream out); static boolean readFully(final InputStream in, final byte[] b); static void compactObjectFiles(final HashMap<File, Integer> objectFiles, final int maxcount); static void combineFiles(File f1, File f2); static void randomShuffleObjects(final InputStream in, final OutputStream out); static void shuffle(String prefix, String directory, int maxObjects);  }