com.hazelcast.ringbuffer.impl
Class ReadResultSetImpl<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by com.hazelcast.ringbuffer.impl.ReadResultSetImpl<E>
Type Parameters:
E -
All Implemented Interfaces:
HazelcastInstanceAware, DataSerializable, IdentifiedDataSerializable, ReadResultSet<E>, Iterable<E>, Collection<E>, List<E>

public class ReadResultSetImpl<E>
extends AbstractList<E>
implements IdentifiedDataSerializable, HazelcastInstanceAware, ReadResultSet<E>

A list for the ReadManyOperation. The problem with a regular list is that if you store Data objects, then on the receiving side you get a list with data objects. If you hand this list out to the caller, you have a problem because he sees data objects instead of deserialized objects.


Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ReadResultSetImpl()
           
ReadResultSetImpl(int minSize, int maxSize, HazelcastInstance hz, IFunction<Object,Boolean> filter)
           
 
Method Summary
 boolean add(Object o)
           
 void addItem(Object item)
           
 E get(int index)
          Gets the item at the given index.
 int getFactoryId()
          Returns DataSerializableFactory factory id for this class.
 int getId()
          Returns type identifier for this class.
 boolean isMaxSizeReached()
           
 boolean isMinSizeReached()
           
 int readCount()
          Returns the number of items that have been read before filtering.
 void readData(ObjectDataInput in)
          Reads fields from the input stream
 void setHazelcastInstance(HazelcastInstance hz)
          Gets the HazelcastInstance reference when submitting a Runnable/Callable using Hazelcast ExecutorService.
 int size()
           
 void writeData(ObjectDataOutput out)
          Writes object fields to output stream
 
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Iterable
iterator
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

ReadResultSetImpl

public ReadResultSetImpl()

ReadResultSetImpl

public ReadResultSetImpl(int minSize,
                         int maxSize,
                         HazelcastInstance hz,
                         IFunction<Object,Boolean> filter)
Method Detail

isMaxSizeReached

public boolean isMaxSizeReached()

isMinSizeReached

public boolean isMinSizeReached()

readCount

public int readCount()
Description copied from interface: ReadResultSet
Returns the number of items that have been read before filtering. If no filter is set, then the readCount will be the same as size. But if a filter is applied, it could be that items are read, but are filtered out. So if you are trying to make another read based on the ReadResultSet then you should increment the sequence by readCount and not by size. Otherwise you will be re-reading the same filtered messages.

Specified by:
readCount in interface ReadResultSet<E>
Returns:
the number of items read (including the filtered ones).

setHazelcastInstance

public void setHazelcastInstance(HazelcastInstance hz)
Description copied from interface: HazelcastInstanceAware
Gets the HazelcastInstance reference when submitting a Runnable/Callable using Hazelcast ExecutorService.

Specified by:
setHazelcastInstance in interface HazelcastInstanceAware
Parameters:
hz - the HazelcastInstance reference

get

public E get(int index)
Description copied from interface: ReadResultSet
Gets the item at the given index.

Specified by:
get in interface ReadResultSet<E>
Specified by:
get in interface List<E>
Specified by:
get in class AbstractList<E>
Parameters:
index - the index
Returns:
the found item.

addItem

public void addItem(Object item)

add

public boolean add(Object o)
Specified by:
add in interface Collection<E>
Specified by:
add in interface List<E>
Overrides:
add in class AbstractList<E>

size

public int size()
Specified by:
size in interface Collection<E>
Specified by:
size in interface List<E>
Specified by:
size in class AbstractCollection<E>

getFactoryId

public int getFactoryId()
Description copied from interface: IdentifiedDataSerializable
Returns DataSerializableFactory factory id for this class.

Specified by:
getFactoryId in interface IdentifiedDataSerializable
Returns:
factory id

getId

public int getId()
Description copied from interface: IdentifiedDataSerializable
Returns type identifier for this class. Id should be unique per DataSerializableFactory.

Specified by:
getId in interface IdentifiedDataSerializable
Returns:
type id

writeData

public void writeData(ObjectDataOutput out)
               throws IOException
Description copied from interface: DataSerializable
Writes object fields to output stream

Specified by:
writeData in interface DataSerializable
Parameters:
out - output
Throws:
IOException

readData

public void readData(ObjectDataInput in)
              throws IOException
Description copied from interface: DataSerializable
Reads fields from the input stream

Specified by:
readData in interface DataSerializable
Parameters:
in - input
Throws:
IOException


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.