aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/main/java/com/yahoo/document/serialization/FieldWriter.java
blob: 244aa0d5a0def8bd1b586bfbc276c958863b69fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.document.serialization;

import com.yahoo.document.Document;
import com.yahoo.document.annotation.AnnotationReference;
import com.yahoo.document.datatypes.Array;
import com.yahoo.document.datatypes.ByteFieldValue;
import com.yahoo.document.datatypes.CollectionFieldValue;
import com.yahoo.document.datatypes.DoubleFieldValue;
import com.yahoo.document.datatypes.FieldValue;
import com.yahoo.document.datatypes.FloatFieldValue;
import com.yahoo.document.datatypes.IntegerFieldValue;
import com.yahoo.document.datatypes.LongFieldValue;
import com.yahoo.document.datatypes.MapFieldValue;
import com.yahoo.document.datatypes.PredicateFieldValue;
import com.yahoo.document.datatypes.Raw;
import com.yahoo.document.datatypes.StringFieldValue;
import com.yahoo.document.datatypes.Struct;
import com.yahoo.document.datatypes.StructuredFieldValue;
import com.yahoo.document.datatypes.TensorFieldValue;
import com.yahoo.document.datatypes.WeightedSet;
import com.yahoo.vespa.objects.FieldBase;
import com.yahoo.vespa.objects.Serializer;

/**
 * Interface for writing out com.yahoo.document.datatypes.FieldValue.
 *
 * @author <a href="mailto:ravishar@yahoo-inc.com">ravishar</a>
 *
 */
public interface FieldWriter extends Serializer {

    /**
     * Write out the value of field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    void write(FieldBase field, FieldValue value);

    /**
     * Write out the value of field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    public void write(FieldBase field, Document value);

    /**
     * Write out the value of array field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    <T extends FieldValue> void write(FieldBase field, Array<T> value);

    /**
     * Write the value of a map field
     */
    <K extends FieldValue, V extends FieldValue> void write(FieldBase field,
            MapFieldValue<K, V> map);

    /**
     * Write out the value of byte field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    void write(FieldBase field, ByteFieldValue value);

    /**
     * Write out the value of collection field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    <T extends FieldValue> void write(FieldBase field,
            CollectionFieldValue<T> value);

    /**
     * Write out the value of double field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    void write(FieldBase field, DoubleFieldValue value);

    /**
     * Write out the value of float field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    void write(FieldBase field, FloatFieldValue value);

    /**
     * Write out the value of integer field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    void write(FieldBase field, IntegerFieldValue value);

    /**
     * Write out the value of long field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    void write(FieldBase field, LongFieldValue value);

    /**
     * Write out the value of raw field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    void write(FieldBase field, Raw value);

    /**
     * Write out the value of predicate field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    void write(FieldBase field, PredicateFieldValue value);

    /**
     * Write out the value of string field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    void write(FieldBase field, StringFieldValue value);

    /**
     * Write out the value of the given tensor field value.
     *
     * @param field field description (name and data type)
     * @param value tensor field value
     */
    void write(FieldBase field, TensorFieldValue value);

    /**
     * Write out the value of struct field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    void write(FieldBase field, Struct value);

    /**
     * Write out the value of structured field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    void write(FieldBase field, StructuredFieldValue value);

    /**
     * Write out the value of weighted set field
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    <T extends FieldValue> void write(FieldBase field, WeightedSet<T> value);

    /**
     * Write out the value of annotation data.
     *
     * @param field
     *            field description (name and data type)
     * @param value
     *            field value
     */
    void write(FieldBase field, AnnotationReference value);
}