Search in sources :

Example 66 with InMemoryClosableChannel

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

the class InMemoryCountsStoreSnapshotDeserializerTest method correctlyDeserializeIndexStatistics.

@Test
public void correctlyDeserializeIndexStatistics() throws IOException {
    //GIVEN
    long indexId = 1;
    serializedBytes = ByteBuffer.allocate(1000);
    InMemoryClosableChannel logChannel = new InMemoryClosableChannel(serializedBytes.array(), false);
    writeSimpleHeader(logChannel);
    logChannel.put(INDEX_STATISTICS.code);
    logChannel.putLong(indexId);
    logChannel.putLong(1);
    logChannel.putLong(1);
    //WHEN
    IndexStatisticsKey expectedNode = CountsKeyFactory.indexStatisticsKey(indexId);
    CountsSnapshot countsSnapshot = deserialize(logChannel);
    //THEN
    assertNotNull(countsSnapshot.getMap().get(expectedNode));
    assertArrayEquals(new long[] { 1, 1 }, countsSnapshot.getMap().get(expectedNode));
}
Also used : InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) IndexStatisticsKey(org.neo4j.kernel.impl.store.counts.keys.IndexStatisticsKey) Test(org.junit.Test)

Aggregations

InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)66 Test (org.junit.Test)63 Command (org.neo4j.kernel.impl.transaction.command.Command)8 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)5 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)4 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)3 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)3 CommandReader (org.neo4j.storageengine.api.CommandReader)3 Before (org.junit.Before)2 AddRelationshipCommand (org.neo4j.kernel.impl.index.IndexCommand.AddRelationshipCommand)2 CountsKey (org.neo4j.kernel.impl.store.counts.keys.CountsKey)2 SchemaRecord (org.neo4j.kernel.impl.store.record.SchemaRecord)2 SchemaRuleCommand (org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand)2 ReadableClosablePositionAwareChannel (org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)1 EndOfStreamException (org.neo4j.causalclustering.messaging.EndOfStreamException)1