code: @InService(SegmentServiceImpl.class)
    public
    Page writePage(Page page,
                   long oldSequence,
                   int saveLength,
                   int saveTail,
                   int saveSequence,
                   Result<Integer> result)
    {
      if (isClosed()) {
        return null;
      }
      
      // Type type = page.getType();
      int pid = page.getId();
      int nextPid = page.getNextId();
      
      WriteStream out = out();
      
      int head = (int) out.position();
      
      try {
        int available = getAvailable();
        
        if (available < head + page.size()) {
          return null;
        }
        
        Page newPage = page.writeCheckpoint(_table, this, oldSequence,
                                            saveLength, saveTail, saveSequence);
  
        if (newPage == null) {
          return null;
        }
        
        newPage.setSequence(getSequence());
        
        out = out();
        
        int tail = (int) out.position();
  
        if (addIndex(out, page, newPage,
                     saveSequence, newPage.getLastWriteType(), 
                     pid, nextPid, head, tail - head,
                     result)) {
          return newPage;
        }
        else {
          return null;
        }
      } catch (Exception e) {
        e.printStackTrace();
        return null;
      }
    }
docs: Writes the page to the segment.
  
  @param page
  @param oldSequence
  @param saveLength
  @param saveTail
  @param saveSequence
  @return