Search in sources :

Example 1 with ReadableClosableChannel

use of org.neo4j.kernel.impl.transaction.log.ReadableClosableChannel in project neo4j by neo4j.

the class InputEntityReader method readHeader.

private void readHeader(StoreChannel header) throws IOException {
    try (ReadableClosableChannel reader = reader(header, (int) ByteUnit.kibiBytes(8))) {
        int[] tokenIds = new int[HIGH_TOKEN_TYPE];
        byte type;
        while ((type = reader.get()) != END_OF_HEADER) {
            int tokenId = tokenIds[type]++;
            String name = (String) ValueType.stringType().read(reader);
            tokens[type].put(tokenId, name);
        }
    }
}
Also used : ReadableClosableChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosableChannel)

Example 2 with ReadableClosableChannel

use of org.neo4j.kernel.impl.transaction.log.ReadableClosableChannel in project neo4j by neo4j.

the class StateRecoveryManager method readLastEntryFrom.

private STATE readLastEntryFrom(File file) throws IOException {
    try (ReadableClosableChannel channel = new ReadAheadChannel<>(fileSystem.open(file, "r"))) {
        STATE result = null;
        STATE lastRead;
        try {
            while ((lastRead = marshal.unmarshal(channel)) != null) {
                result = lastRead;
            }
        } catch (EndOfStreamException e) {
        // ignore; just use previous complete entry
        }
        return result;
    }
}
Also used : ReadableClosableChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosableChannel) EndOfStreamException(org.neo4j.causalclustering.messaging.EndOfStreamException) ReadAheadChannel(org.neo4j.kernel.impl.transaction.log.ReadAheadChannel)

Aggregations

ReadableClosableChannel (org.neo4j.kernel.impl.transaction.log.ReadableClosableChannel)2 EndOfStreamException (org.neo4j.causalclustering.messaging.EndOfStreamException)1 ReadAheadChannel (org.neo4j.kernel.impl.transaction.log.ReadAheadChannel)1