Search in sources :

Example 1 with NegativeInfinityPartitionKey

use of uk.gov.gchq.gaffer.parquetstore.partitioner.NegativeInfinityPartitionKey in project Gaffer by gchq.

the class PartitionKeySerialiserTest method testWithInfinitePartitionKey.

@Test
public void testWithInfinitePartitionKey(@TempDir java.nio.file.Path tempDir) throws IOException {
    // Given
    final PartitionKey negativeInfinity = new NegativeInfinityPartitionKey();
    final PartitionKey positiveInfinity = new PositiveInfinityPartitionKey();
    final PartitionKeySerialiser serialiser = new PartitionKeySerialiser();
    // When
    final String filename = tempDir.resolve("test").toString();
    final DataOutputStream dos = new DataOutputStream(new FileOutputStream(filename));
    serialiser.write(negativeInfinity, dos);
    serialiser.write(positiveInfinity, dos);
    dos.close();
    final DataInputStream dis = new DataInputStream(new FileInputStream(filename));
    final PartitionKey readPartitionKey1 = serialiser.read(dis);
    final PartitionKey readPartitionKey2 = serialiser.read(dis);
    dis.close();
    // Then
    assertEquals(negativeInfinity, readPartitionKey1);
    assertEquals(positiveInfinity, readPartitionKey2);
}
Also used : NegativeInfinityPartitionKey(uk.gov.gchq.gaffer.parquetstore.partitioner.NegativeInfinityPartitionKey) PositiveInfinityPartitionKey(uk.gov.gchq.gaffer.parquetstore.partitioner.PositiveInfinityPartitionKey) DataOutputStream(java.io.DataOutputStream) FileOutputStream(java.io.FileOutputStream) PartitionKey(uk.gov.gchq.gaffer.parquetstore.partitioner.PartitionKey) PositiveInfinityPartitionKey(uk.gov.gchq.gaffer.parquetstore.partitioner.PositiveInfinityPartitionKey) NegativeInfinityPartitionKey(uk.gov.gchq.gaffer.parquetstore.partitioner.NegativeInfinityPartitionKey) DataInputStream(java.io.DataInputStream) FileInputStream(java.io.FileInputStream) Test(org.junit.jupiter.api.Test)

Aggregations

DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 Test (org.junit.jupiter.api.Test)1 NegativeInfinityPartitionKey (uk.gov.gchq.gaffer.parquetstore.partitioner.NegativeInfinityPartitionKey)1 PartitionKey (uk.gov.gchq.gaffer.parquetstore.partitioner.PartitionKey)1 PositiveInfinityPartitionKey (uk.gov.gchq.gaffer.parquetstore.partitioner.PositiveInfinityPartitionKey)1