All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kolibrifx.plovercrest.server.streams.Stream Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2010-2017, KolibriFX AS. Licensed under the Apache License, version 2.0.
 */

package com.kolibrifx.plovercrest.server.streams;

import com.kolibrifx.plovercrest.client.TableMetadata;

public interface Stream {
    PollableReader createReaderFromTimestamp(long timestamp, StreamObserver observer);

    PollableReader createReaderFromIndex(long index, StreamObserver observer);

    String getName();

    Class getElementClass();

    /**
     * Should return a valid writer, or throw a
     * {@link com.kolibrifx.plovercrest.client.PlovercrestException} if this stream does not
     * support writing.
     */
    StreamWriter getWriter();

    /**
     * Returns the first timestamp, or -1 if the stream is empty.
     * 

* Non-materialized streams should return the earliest possible timestamp that can be generated, * typically zero, but not a negative value. */ long getFirstTimestamp(); /** * Returns the last timestamp, or -1 if the stream is empty. *

* Non-materialized streams should return the largest value that can be generated. (Maybe * {@link System#currentTimeMillis()}?) */ long getLastTimestamp(); /** * Returns the data size on disk, in bytes, not including metadata. Non-materialized streams * should return 0. */ long getDataLengthInBytes(); /** * Returns the number of entries in this stream. *

* Non-materialized streams should return the number of entries that can be generated if known, * or -1 if unknown. */ long getEntryCount(); /** * Get a key-value map of metadata. */ TableMetadata getMetadata(); /** * Returns the "last valid timestamp", which is usually the same as {@link #getLastTimestamp()}, * but can also be larger. *

* The stream must guarantee that the next timestamp after {@link #getLastTimestamp()} will not * be smaller than {@link #getLastValidTimestamp()}. */ long getLastValidTimestamp(); /** * Is the stream frozen? (write-protected) */ boolean isFrozen(); /** * Delete the stream, if possible. Return true if successful, false if * deletion is not possible or supported. */ boolean delete(); /** * Rename the stream, if possible. Return true if successful, false if * renaming is not possible or supported. */ boolean rename(String newName); /** * Returns the largest timestamp ≤ targetTimestamp, if such a timestamp exists. If the first * timestamp is larger than the target, the first timestamp should be returned. If the stream is * empty, -1 should be returned. */ long seekPreviousTimestamp(long targetTimestamp); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy