Record Class SchemaCacheEntry

java.lang.Object
java.lang.Record
org.elasticsearch.xpack.esql.datasources.cache.SchemaCacheEntry

public record SchemaCacheEntry(String[] columnNames, DataType[] columnTypes, Nullability[] columnNullabilities, boolean[] columnSynthetics, String sourceType, String location, Map<String,Object> safeMetadata, long cachedAtMillis) extends Record
Cache entry for schema inference results. Stores raw schema data (names, types, nullabilities) instead of Attribute objects to avoid NameId sharing across queries. Each call to toAttributes() reconstructs fresh ReferenceAttribute instances with fresh NameIds, ensuring safe concurrent use.
  • Constructor Details

    • SchemaCacheEntry

      public SchemaCacheEntry(String[] columnNames, DataType[] columnTypes, Nullability[] columnNullabilities, boolean[] columnSynthetics, String sourceType, String location, Map<String,Object> safeMetadata, long cachedAtMillis)
      Creates an instance of a SchemaCacheEntry record class.
      Parameters:
      columnNames - the value for the columnNames record component
      columnTypes - the value for the columnTypes record component
      columnNullabilities - the value for the columnNullabilities record component
      columnSynthetics - the value for the columnSynthetics record component
      sourceType - the value for the sourceType record component
      location - the value for the location record component
      safeMetadata - the value for the safeMetadata record component
      cachedAtMillis - the value for the cachedAtMillis record component
  • Method Details

    • from

      public static SchemaCacheEntry from(List<Attribute> schema, String sourceType, String location, Map<String,Object> metadata)
    • toAttributes

      public List<Attribute> toAttributes()
      Reconstructs fresh Attributes with fresh NameIds -- safe for concurrent queries
    • estimatedBytes

      public long estimatedBytes()
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • columnNames

      public String[] columnNames()
      Returns the value of the columnNames record component.
      Returns:
      the value of the columnNames record component
    • columnTypes

      public DataType[] columnTypes()
      Returns the value of the columnTypes record component.
      Returns:
      the value of the columnTypes record component
    • columnNullabilities

      public Nullability[] columnNullabilities()
      Returns the value of the columnNullabilities record component.
      Returns:
      the value of the columnNullabilities record component
    • columnSynthetics

      public boolean[] columnSynthetics()
      Returns the value of the columnSynthetics record component.
      Returns:
      the value of the columnSynthetics record component
    • sourceType

      public String sourceType()
      Returns the value of the sourceType record component.
      Returns:
      the value of the sourceType record component
    • location

      public String location()
      Returns the value of the location record component.
      Returns:
      the value of the location record component
    • safeMetadata

      public Map<String,Object> safeMetadata()
      Returns the value of the safeMetadata record component.
      Returns:
      the value of the safeMetadata record component
    • cachedAtMillis

      public long cachedAtMillis()
      Returns the value of the cachedAtMillis record component.
      Returns:
      the value of the cachedAtMillis record component