Class InPlaceEntryView

java.lang.Object
com.j_spaces.core.cache.blobStore.InPlaceEntryView
All Implemented Interfaces:
ServerEntry

public class InPlaceEntryView extends Object implements ServerEntry
A few of an entry's property values, read out of the block the entry occupies rather than out of a decoded copy of it, for a caller that wants to compare them and not to have the entry.

A scan applying a condition to a non-indexed property is that caller: today it copies the block and decodes every property into an Object[] to look at one of them, and throws the result away for every entry the condition rejects.

The values are read eagerly, and the segment never leaves the lock that guards the block. That is not an implementation detail. A block's lifetime and content are guarded by the entry's state lock - flush writes it and freeOffHeap releases it under that lock - so the first cut of this class, which held the segment and read from it lazily as the matcher asked for values, read freed memory as soon as another thread took the entry: the length header of a released block reads as zero, the payload comes back as a zero-length segment, and the read fails with IndexOutOfBoundsException out of the middle of an operation. It cost three FIFO-group and three local-view tests in the mx-off-heap suite (PIC-6305, 2026-09-06). Reading the values under the lock and matching afterwards also keeps the values consistent with each other, and keeps whatever equals or compareTo the matcher calls - user code - out of that lock.

Not every property can be answered for, and that is a property of the format rather than a gap to be filled: values outside BlobStoreEntryLayout's serializer registry go through one object stream shared by the whole payload, so their bytes are not self-contained and cannot be read from an offset. Anything this view could not supply sets isUndecided(), and a caller must discard whatever it concluded when that is set.

Reused across the entries of one scan, by Context, so that looking at a million entries allocates nothing per entry.

Since:
18.0.0
  • Constructor Details

    • InPlaceEntryView

      public InPlaceEntryView()
  • Method Details

    • view

      public void view(IServerTypeDesc typeDesc, int numOfFixedProperties)
      Points this view at one entry and clears isUndecided(). Values are supplied afterwards by read(MemorySegment, int); anything not supplied answers as undecided rather than as null.
    • readHeader

      public boolean readHeader(MemorySegment payload)
      Reads the entry's own bookkeeping - its version, when it expires, which entry type it was written as and whether it is transient - out of the block header. Called with the entry's state lock held, for the same reason read(MemorySegment, int) is.

      Only a caller that has to hand back something shaped like the entry needs this; one that only compares property values does not, and leaves these answering as undecided.

      Returns:
      false if the block cannot answer for the header, in which case the view is undecided
    • getEntryTypeCode

      public byte getEntryTypeCode()
      The entry type this entry was written as, valid once readHeader(MemorySegment) has answered true.
    • isTransientEntry

      public boolean isTransientEntry()
      Whether this entry is transient, valid once readHeader(MemorySegment) has answered true.
    • read

      public boolean read(MemorySegment payload, int position)
      Reads one property out of the block into this view. Called with the entry's state lock held, so that the segment is known to be the entry's own memory for the duration.
      Returns:
      false if the block cannot answer for this property, in which case the view is undecided and the caller can stop
    • markUndecided

      public void markUndecided()
      Marks the view undecided, for a caller that could not get at the block at all.
    • isUndecided

      public boolean isUndecided()
      Whether anything asked of this view since view(IServerTypeDesc, int) could not be answered out of the block. Set for a property whose bytes are not self-contained, for a property nobody read, and for every question this view cannot answer at all.
    • getFixedPropertyValue

      public Object getFixedPropertyValue(int position)
      Description copied from interface: ServerEntry
      Gets the specified fixed property's value. The returned value is a reference to the actual property kept in the space.
      Specified by:
      getFixedPropertyValue in interface ServerEntry
      Parameters:
      position - Position of requested property.
      Returns:
      Requested property's value in current entry.
    • getSpaceTypeDescriptor

      public SpaceTypeDescriptor getSpaceTypeDescriptor()
      Description copied from interface: ServerEntry
      Gets the entry's type descriptor.
      Specified by:
      getSpaceTypeDescriptor in interface ServerEntry
      Returns:
      Current entry's type descriptor.
    • getVersion

      public int getVersion()
      The entry's version, once readHeader(MemorySegment) has read it. A caller that never asked for the header gets the same answer as for anything else outside the property table: undecided.
      Specified by:
      getVersion in interface ServerEntry
      Returns:
      the entry version.
    • getExpirationTime

      public long getExpirationTime()
      The entry's expiration time, on the same terms as getVersion().
      Specified by:
      getExpirationTime in interface ServerEntry
      Returns:
      the entry expiration time.
    • getPropertyValue

      public Object getPropertyValue(String name)
      Description copied from interface: ServerEntry
      Gets the specified property's value. The returned value is a reference to the actual property kept in the space.
      Specified by:
      getPropertyValue in interface ServerEntry
      Parameters:
      name - Name of requested property.
      Returns:
      Requested property's value in current entry.
    • getPathValue

      public Object getPathValue(String path)
      Description copied from interface: ServerEntry
      Gets the specified path's value. The returned value is a reference to the actual property kept in the space.
      Specified by:
      getPathValue in interface ServerEntry
      Parameters:
      path - Path pointing to the requested property.
      Returns:
      Requested path's value in current entry.