Class Memory

java.lang.Object
com.swiftmq.impl.streams.comp.memory.Memory
Direct Known Subclasses:
HeapMemory, QueueMemory

public abstract class Memory extends Object
Abstract base class for Memories.
Author:
IIT Software GmbH, Muenster/Germany, (c) 2016, All Rights Reserved
  • Method Details

    • name

      public String name()
      Returns the name of this Memory
      Returns:
      Name
    • limit

      public LimitBuilder limit()
      Returns a new LimitBuilder
      Returns:
      LimitBuilder
    • addLimit

      public Limit addLimit(Limit limit)
      Internal use.
    • orderBy

      public Memory orderBy(String orderByProperty)
      Sets the Property name that is used to order this Memory. This is useful to order a Memory by event time instead of processing time. Default is processing time which is the time at which the Message is added to the Memory.
      Parameters:
      orderByProperty - Name of the Property
      Returns:
      this
    • orderBy

      public String orderBy()
      Returns the orderBy Property name.
      Returns:
      Property name
    • inactivityTimeout

      public InactivityTimeout inactivityTimeout()
      Sets and returns the InactivityTimeout for this Memory. An InactivityTimeout can be attached to a Memory and specifies a time of inactivity (no adds to Memory) after which all Messages in that Memory will retire. Inactivity is checked during Memory.checkLimit() and thus needs to be regularly called from a Timer.
      Returns:
    • dropLateArrivals

      public Memory dropLateArrivals(boolean dropLateArrivals)
      Specifies whether late arrivals should be dropped (default is false). Late arrivals are only respected if orderBy(propName) is set (thus, event time processing). A late arrival is defined as an event time that is less the time of the maximum event time of the previous window close (onRetire).
      Parameters:
      dropLateArrivals - true/false
      Returns:
      this
    • isLate

      protected boolean isLate(Message message)
    • getStoreTime

      protected long getStoreTime(Message message)
    • getStoreTimes

      public List<Object> getStoreTimes() throws Exception
      Internal use.
      Throws:
      Exception
    • getStoreTime

      public abstract long getStoreTime(int index)
      Internal use.
    • createIndex

      public Memory createIndex(String propName)
      Creates an Index over a Property
      Parameters:
      propName - Property Name
      Returns:
      Memory
    • index

      public Index index(String propName)
      Returns the Index of the specific Property name
      Parameters:
      propName - Property Name
      Returns:
      Index
    • newKey

      protected String newKey()
    • addToIndexes

      protected void addToIndexes(String key, Message message)
    • removeFromIndexes

      protected void removeFromIndexes(String key, Message message)
    • clearIndexes

      protected void clearIndexes()
    • reload

      public abstract void reload() throws Exception
      Internal use.
      Throws:
      Exception
    • add

      public abstract Memory add(Message message) throws Exception
      Add a Message to the Memory.
      Parameters:
      message - Message
      Returns:
      Memory
      Throws:
      Exception
    • remove

      public abstract Memory remove(int index) throws Exception
      Removes the Message at the index.
      Parameters:
      index - index
      Returns:
      Memory
      Throws:
      Exception
    • removeOlderThan

      public abstract Memory removeOlderThan(long time) throws Exception
      Removes all Messages with a store time older than time.
      Parameters:
      time - Time
      Returns:
      Memory
      Throws:
      Exception
    • removeOlderThan

      public abstract Memory removeOlderThan(long time, boolean executeCallback) throws Exception
      Internal use.
      Throws:
      Exception
    • at

      public abstract Message at(int index) throws Exception
      Returns the Message at the index.
      Parameters:
      index - index
      Returns:
      Message
      Throws:
      Exception
    • size

      public abstract int size() throws Exception
      Returns the number of Messages stored in this Memory.
      Returns:
      Number Messages
      Throws:
      Exception
    • clear

      public abstract Memory clear() throws Exception
      Removes all Messages from this Memory.
      Returns:
      Memory
      Throws:
      Exception
    • select

      public abstract Memory select(String selector) throws Exception
      Applies a JMS message selector to all Messages in this Memory and returns a new non-queue Memory with the result.
      Parameters:
      selector - JMS Message Selector
      Returns:
      Result
      Throws:
      Exception
    • remove

      public abstract Memory remove(String selector) throws Exception
      Removes all Messages from this Memory that matches the JMS message selector and returns this Memory.
      Parameters:
      selector - JMS Message Selector
      Returns:
      Memory (this)
      Throws:
      Exception
    • checkLimit

      public Memory checkLimit()
      Checks the limit of the Memory and retires Messages, if necessary. These retired Messages will be passed to the RetirementListener, if set. The method checks also if there is an inactivity timeout and retires all Messages when a timeout occurs.
      Returns:
      Memory (this)
    • first

      public Message first() throws Exception
      Returns the first Message of this Memory.
      Returns:
      Message
      Throws:
      Exception
    • last

      public Message last() throws Exception
      Returns the last Message of this Memory.
      Returns:
      Message
      Throws:
      Exception
    • reverse

      public Memory reverse() throws Exception
      Reverses the Message order of this Memory and returns a new Memory with the result.
      Returns:
      Result
      Throws:
      Exception
    • values

      public List<Object> values(String propName) throws Exception
      Returns all values of a Property in the Message order.
      Parameters:
      propName - Property Name
      Returns:
      List of values
      Throws:
      Exception
    • group

      public GroupResult group(String propName) throws Exception
      Groups all Messages over a Property and returns a Group Result.
      Parameters:
      propName - Property Name
      Returns:
      GroupResult
      Throws:
      Exception
    • sort

      public Memory sort(String propName) throws Exception
      Sorts all Messages of this Memory over a Property and returns a new Memory with the result.
      Parameters:
      propName - Property Name
      Returns:
      Result
      Throws:
      Exception
    • min

      public Message min(String propName) throws Exception
      Returns the Message with the minimum value of a Property.
      Parameters:
      propName - Property Name
      Returns:
      Message
      Throws:
      Exception
    • max

      public Message max(String propName) throws Exception
      Returns the Message with the maximum value of a Property.
      Parameters:
      propName - Property Name
      Returns:
      Message
      Throws:
      Exception
    • sum

      public double sum(String propName) throws Exception
      Returns the sum of all values of a Property.
      Parameters:
      propName - Property Name
      Returns:
      sum
      Throws:
      Exception
    • average

      public double average(String propName) throws Exception
      Returns the average of all values of a Property.
      Parameters:
      propName - Property Name
      Returns:
      average
      Throws:
      Exception
    • ascendingSeries

      public boolean ascendingSeries(String propName) throws Exception
      Returns true if all values of a Property are greater than the previous value.
      Parameters:
      propName - Property Name
      Returns:
      true/false
      Throws:
      Exception
    • descendingSeries

      public boolean descendingSeries(String propName) throws Exception
      Returns true if all values of a Property are less than the previous value.
      Parameters:
      propName - Property Name
      Returns:
      true/false
      Throws:
      Exception
    • join

      public Memory join(Memory right, String joinProp) throws Exception
      Performs an inner join with the right Memory over the named join Property name which must exists in the Messages of both Memories.

      Result is a Memory which contains Messages where each Message at the left side (this Memory) matches with a Message on the right side. The result Message will contain the left result Message enriched with all Properties of the right result Message.

      Parameters:
      right - Memory to join with
      joinProp - Name of the Property to join over
      Returns:
      result Memory
      Throws:
      Exception
    • join

      public Memory join(Memory right, String leftJoinProp, String rightJoinProp) throws Exception
      Performs an inner join with the right Memory. Use this method to join 2 Memories over different Property names.
      Parameters:
      right - Memory to join with
      leftJoinProp - left join Property name
      rightJoinProp - right join Property name
      Returns:
      result Memory
      Throws:
      Exception
    • forEach

      public void forEach(ForEachMessageCallback callback) throws Exception
      Executes the Callback for each Message in this Memory
      Parameters:
      callback - Callback
      Throws:
      Exception
    • onRetire

      public Memory onRetire(RetirementCallback callback)
      Sets a callback which is called for each Message that is retired (removed by a Limit).
      Parameters:
      callback - Callback
      Returns:
    • retirementCallback

      public RetirementCallback retirementCallback()
      Returns the RetirementCallback.
      Returns:
      RetirementCallback
    • collect

      public void collect(long interval)
      Internal use.
    • deferredClose

      public void deferredClose()
      Internal use.
    • isMarkedAsClose

      public boolean isMarkedAsClose()
      Internal use.
    • close

      public void close()
      Closes this Memory.