Package org.apache.solr.client.solrj.io

## Class Tuple

- java.lang.Object
- - org.apache.solr.client.solrj.io.Tuple

All Implemented Interfaces:
  `Cloneable`, `MapSerializable`, `MapWriter`, `NavigableObject`

Direct Known Subclasses:
  `DbscanEvaluator.ClusterTuple`, `KmeansEvaluator.ClusterTuple`, `KnnRegressionEvaluator.KnnRegressionTuple`, `LoessEvaluator.LoessRegressionTuple`, `OLSRegressionEvaluator.MultipleRegressionTuple`, `RegressionEvaluator.RegressionTuple`

    public class Tuple
    extends Object
    implements Cloneable, MapWriter

A simple abstraction of a record containing key/value pairs. Convenience methods are provided for returning single and multiValue String, Long and Double values. Note that ints and floats are treated as longs and doubles respectively.

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.solr.common.MapWriter

`MapWriter.EntryWriter`

### Field Summary

Fields
`boolean` `EOF` When EOF field is true the Tuple marks the end of the stream.
`boolean` `EXCEPTION` When EXCEPTION field is true the Tuple marks an exception in the stream and the corresponding "EXCEPTION" field contains a related message.
`Map<String,​String>` `fieldLabels` Deprecated. use `getFieldLabels()` instead of this public field.
`List<String>` `fieldNames` Deprecated. use `getFieldNames()` instead of this public field.
`Map<String,​Object>` `fields` Deprecated. use `getFields()` instead of this public field.

### Constructor Summary

Constructors
`Tuple()`
`Tuple​(String k1, Object v1)`
`Tuple​(String k1, Object v1, String k2, Object v2)`
`Tuple​(Map<String,​?> fields)` A copy constructor.
`Tuple​(Tuple original)` A copy constructor

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`Tuple` `clone()`
`static Tuple` `EOF()` Create a new empty tuple marked as EOF.
`static Tuple` `EXCEPTION​(String msg, boolean eof)` Create a new empty tuple marked as EXCEPTION, and optionally EOF.
`static Tuple` `EXCEPTION​(Throwable t, boolean eof)` Create a new empty tuple marked as EXCEPTION and optionally EOF.
`Object` `get​(String key)`
`Boolean` `getBool​(String key)`
`List<Boolean>` `getBools​(String key)`
`Date` `getDate​(String key)`
`List<Date>` `getDates​(String key)`
`Double` `getDouble​(String key)`
`List<Double>` `getDoubles​(String key)`
`String` `getException()`
`Map<String,​String>` `getFieldLabels()` This represents the mapping of external field labels to the tuple's internal field names if they are different from field names.
`List<String>` `getFieldNames()` A list of field names to serialize.
`Map<String,​Object>` `getFields()` Return all tuple fields and their values.
`Long` `getLong​(String key)`
`List<Long>` `getLongs​(String key)`
`Map<String,​Object>` `getMap()` Deprecated. use `getFields()` instead.
`List<Map<?,​?>>` `getMaps​(String key)`
`Map<String,​Map<?,​?>>` `getMetrics()`
`String` `getString​(String key)`
`List<String>` `getStrings​(String key)`
`void` `merge​(Tuple other)` The other tuples fields and fieldLabels will be putAll'd directly to this's fields and fieldLabels while other's fieldNames will be added such that duplicates aren't present.
`void` `put​(String key, Object value)`
`void` `putAll​(Map<String,​?> fields)`
`void` `remove​(String key)`
`void` `setFieldLabels​(Map<String,​String> fieldLabels)`
`void` `setFieldNames​(List<String> fieldNames)`
`void` `setMaps​(String key, List<Map<?,​?>> maps)`
`void` `setMetrics​(Map<String,​Map<?,​?>> metrics)`
`void` `writeMap​(MapWriter.EntryWriter ew)`

### Methods inherited from class java.lang.Object

`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.solr.common.MapWriter

`jsonStr, toMap`

### Methods inherited from interface org.apache.solr.common.NavigableObject

`_forEachEntry, _forEachEntry, _forEachEntry, _get, _get, _getStr, _getStr, _size`

### Field Detail

#### EOF

    public boolean EOF

When EOF field is true the Tuple marks the end of the stream. The EOF Tuple will not contain a record from the stream, but it may contain metrics/aggregates gathered by underlying streams.

#### EXCEPTION

    public boolean EXCEPTION

When EXCEPTION field is true the Tuple marks an exception in the stream and the corresponding "EXCEPTION" field contains a related message.

#### fields

    @Deprecated
    public Map<String,​Object> fields

Deprecated.
use `getFields()` instead of this public field.
Tuple fields.

#### fieldNames

    @Deprecated
    public List<String> fieldNames

Deprecated.
use `getFieldNames()` instead of this public field.
External serializable field names.

#### fieldLabels

    @Deprecated
    public Map<String,​String> fieldLabels

Deprecated.
use `getFieldLabels()` instead of this public field.
Mapping of external field names to internal tuple field names.

### Constructor Detail

#### Tuple

    public Tuple()

#### Tuple

    public Tuple​(String k1,
                 Object v1)

#### Tuple

    public Tuple​(String k1,
                 Object v1,
                 String k2,
                 Object v2)

#### Tuple

    public Tuple​(Map<String,​?> fields)

A copy constructor.

Parameters:
  `fields` - map containing keys and values to be copied to this tuple

#### Tuple

    public Tuple​(Tuple original)

A copy constructor

Parameters:
  `original` - Tuple that will be copied

### Method Detail

#### get

    public Object get​(String key)

#### put

    public void put​(String key,
                    Object value)

#### putAll

    public void putAll​(Map<String,​?> fields)

#### remove

    public void remove​(String key)

#### getString

    public String getString​(String key)

#### getException

    public String getException()

#### getLong

    public Long getLong​(String key)

#### getBool

    public Boolean getBool​(String key)

#### getBools

    public List<Boolean> getBools​(String key)

#### getDate

    public Date getDate​(String key)

#### getDates

    public List<Date> getDates​(String key)

#### getDouble

    public Double getDouble​(String key)

#### getStrings

    public List<String> getStrings​(String key)

#### getLongs

    public List<Long> getLongs​(String key)

#### getDoubles

    public List<Double> getDoubles​(String key)

#### getFields

    public Map<String,​Object> getFields()

Return all tuple fields and their values.

#### getMap

    @Deprecated(since="8.6.0")
    public Map<String,​Object> getMap()

Deprecated.
use `getFields()` instead.
Return all tuple fields.

#### getFieldLabels

    public Map<String,​String> getFieldLabels()

This represents the mapping of external field labels to the tuple's internal field names if they are different from field names.

Returns:
  field labels or null

#### setFieldLabels

    public void setFieldLabels​(Map<String,​String> fieldLabels)

#### getFieldNames

    public List<String> getFieldNames()

A list of field names to serialize. This list (together with the mapping in `getFieldLabels()` determines what tuple values are serialized and their external (serialized) names.

Returns:
  list of external field names or null

#### setFieldNames

    public void setFieldNames​(List<String> fieldNames)

#### getMaps

    public List<Map<?,​?>> getMaps​(String key)

#### setMaps

    public void setMaps​(String key,
                        List<Map<?,​?>> maps)

#### getMetrics

    public Map<String,​Map<?,​?>> getMetrics()

#### setMetrics

    public void setMetrics​(Map<String,​Map<?,​?>> metrics)

#### clone

    public Tuple clone()

Overrides:
  `clone` in class `Object`

#### merge

    public void merge​(Tuple other)

The other tuples fields and fieldLabels will be putAll'd directly to this's fields and fieldLabels while other's fieldNames will be added such that duplicates aren't present.

Parameters:
  `other` - Tuple to be merged into this.

#### writeMap

    public void writeMap​(MapWriter.EntryWriter ew)
                  throws IOException

Specified by:
  `writeMap` in interface `MapWriter`
Throws:
  `IOException`

#### EOF

    public static Tuple EOF()

Create a new empty tuple marked as EOF.

#### EXCEPTION

    public static Tuple EXCEPTION​(String msg,
                                  boolean eof)

Create a new empty tuple marked as EXCEPTION, and optionally EOF.

Parameters:
  `msg` - exception message
  `eof` - if true the tuple will be marked as EOF

#### EXCEPTION

    public static Tuple EXCEPTION​(Throwable t,
                                  boolean eof)

Create a new empty tuple marked as EXCEPTION and optionally EOF.

Parameters:
  `t` - exception - full stack trace will be used as an exception message
  `eof` - if true the tuple will be marked as EOF