Exemplo n.º 1
0
 protected int entrySize() {
   Serializer serializer = new Serializer();
   serializer.register(TestEntry.class);
   Buffer buffer = DirectBuffer.allocate(1000);
   TestEntry entry = new TestEntry();
   entry.setPadding(entryPadding);
   serializer.writeObject(entry, buffer);
   return (int) buffer.position() + Short.BYTES + Long.BYTES;
 }
Exemplo n.º 2
0
 /**
  * Appends {@code numEntries} increasingly numbered ByteBuffer wrapped entries to the log,
  * starting at the {@code startingId}.
  */
 protected List<Long> appendEntries(int numEntries, int startingId, Compaction.Mode mode) {
   List<Integer> entryIds =
       IntStream.range(startingId, startingId + numEntries).boxed().collect(Collectors.toList());
   return entryIds
       .stream()
       .map(
           entryId -> {
             try (TestEntry entry = log.create(TestEntry.class)) {
               entry.setTerm(1).setCompactionMode(mode).setPadding(entryPadding);
               return log.append(entry);
             }
           })
       .collect(Collectors.toList());
 }