core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/twoq/O2QCache.java
private static void storeQueueState(final OWriteCache writeCache, final Set<Long> filesToStore,
      final DataOutputStream dataOutputStream, final LRUList queue) throws IOException {
    final Iterator<OCacheEntry> queueIterator = queue.reverseIterator();

    while (queueIterator.hasNext()) {
      final OCacheEntry cacheEntry = queueIterator.next();

      final long fileId = cacheEntry.getFileId();
      if (filesToStore.contains(fileId)) {
        final int internalId = writeCache.internalFileId(fileId);
        dataOutputStream.writeInt(internalId);

        dataOutputStream.writeLong(cacheEntry.getPageIndex());
      }
    }
  }
private static void storeQueueState(final OWriteCache writeCache, final Set<Long> filesToStore,
      final DataOutputStream dataOutputStream, final LRUList queue) throws IOException {
    final Iterator<OCacheEntry> queueIterator = queue.reverseIterator();

    while (queueIterator.hasNext()) {
      final OCacheEntry cacheEntry = queueIterator.next();

      final long fileId = cacheEntry.getFileId();
      if (filesToStore.contains(fileId)) {
        final int internalId = writeCache.internalFileId(fileId);
        dataOutputStream.writeInt(internalId);

        dataOutputStream.writeLong(cacheEntry.getPageIndex());
      }
    }
  }
private static void storeQueueState ( final OWriteCache writeCache , final Set < Long > filesToStore , final DataOutputStream dataOutputStream , final LRUList queue ) throws IOException { final Iterator < OCacheEntry > queueIterator = queue . reverseIterator ( ) ; while ( queueIterator . hasNext ( ) ) { final OCacheEntry cacheEntry = queueIterator . next ( ) ; final long fileId = cacheEntry . getFileId ( ) ; if ( filesToStore . contains ( fileId ) ) { final int internalId = writeCache . internalFileId ( fileId ) ; dataOutputStream . writeInt ( internalId ) ; dataOutputStream . writeLong ( cacheEntry . getPageIndex ( ) ) ; } } }
Stores state of single queue to the {@link OutputStream} . Items are stored from least recently used to most recently used, so
in case of sequential read of data we will restore the same state of queue.
Not all queue items are stored, only ones which contains pages of selected files.
Following format is used to store queue state:
<ol>
<li>File id or -1 if end of queue is reached (int)</li>
<li>Page index (long), is absent if end of the queue is reached</li>
</ol>

@param writeCache       Write cache is used to convert external file ids to internal ones.
@param filesToStore     List of files state of which should be stored.
@param dataOutputStream Output stream for state file
@param queue            Queue state of which should be stored
Stores state of single queue to the { @link OutputStream } . Items are stored from least recently used to most recently used so in case of sequential read of data we will restore the same state of queue . Not all queue items are stored only ones which contains pages of selected files . Following format is used to store queue state : <ol > <li > File id or - 1 if end of queue is reached ( int ) < / li > <li > Page index ( long ) is absent if end of the queue is reached< / li > < / ol >