RemoteBlobMetadata { public static RemoteSegmentArchiveEntry toIndexEntry(Map<String, String> metadata, int length) { UUID uuid = UUID.fromString(metadata.get(METADATA_SEGMENT_UUID)); long msb = uuid.getMostSignificantBits(); long lsb = uuid.getLeastSignificantBits(); int position = Integer.parseInt(metadata.get(METADATA_SEGMENT_POSITION)); int generation = Integer.parseInt(metadata.get(METADATA_SEGMENT_GENERATION)); int fullGeneration = Integer.parseInt(metadata.get(METADATA_SEGMENT_FULL_GENERATION)); boolean compacted = Boolean.parseBoolean(metadata.get(METADATA_SEGMENT_COMPACTED)); return new RemoteSegmentArchiveEntry(msb, lsb, position, length, generation, fullGeneration, compacted); }  static HashMap<String, String> toSegmentMetadata(RemoteSegmentArchiveEntry indexEntry); static RemoteSegmentArchiveEntry toIndexEntry(Map<String, String> metadata, int length); static boolean isSegment(Map<String, String> metadata); static final String METADATA_TYPE; static final String METADATA_SEGMENT_UUID; static final String METADATA_SEGMENT_POSITION; static final String METADATA_SEGMENT_GENERATION; static final String METADATA_SEGMENT_FULL_GENERATION; static final String METADATA_SEGMENT_COMPACTED; static final String TYPE_SEGMENT; }
@Test public void toIndexEntry() { HashMap<String, String> metadata = new HashMap<>(); metadata.put(RemoteBlobMetadata.METADATA_SEGMENT_UUID, "97290085-b1a5-4fb9-ae77-db6d13177537"); metadata.put(RemoteBlobMetadata.METADATA_SEGMENT_POSITION, "3"); metadata.put(RemoteBlobMetadata.METADATA_SEGMENT_GENERATION, "50"); metadata.put(RemoteBlobMetadata.METADATA_SEGMENT_FULL_GENERATION, "60"); metadata.put(RemoteBlobMetadata.METADATA_SEGMENT_COMPACTED, "true"); RemoteSegmentArchiveEntry azureSegmentArchiveEntry = RemoteBlobMetadata.toIndexEntry(metadata, 5); System.out.println(azureSegmentArchiveEntry); assertEquals(-7554506325726244935L, azureSegmentArchiveEntry.getMsb()); assertEquals(-5874985927363300041L, azureSegmentArchiveEntry.getLsb()); assertEquals(3, azureSegmentArchiveEntry.getPosition()); assertEquals(5, azureSegmentArchiveEntry.getLength()); assertEquals(50, azureSegmentArchiveEntry.getGeneration()); assertEquals(60, azureSegmentArchiveEntry.getFullGeneration()); assertTrue(azureSegmentArchiveEntry.isCompacted()); }