MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / EffectsBuffer_WriteSIValue

Function EffectsBuffer_WriteSIValue

src/effects/effects.c:134–185  ·  view source on GitHub ↗

writes a binary representation of v into Effect-Buffer

Source from the content-addressed store, hash-verified

132
133// writes a binary representation of v into Effect-Buffer
134static void EffectsBuffer_WriteSIValue
135(
136 const SIValue *v,
137 EffectsBuffer *buff
138) {
139 ASSERT(v != NULL);
140 ASSERT(buff != NULL);
141
142 // format:
143 // type
144 // value
145 bool b;
146 size_t len = 0;
147
148 SIType t = v->type;
149
150 // write type
151 EffectsBuffer_WriteBytes(&t, sizeof(SIType), buff);
152
153 // write value
154 switch(t) {
155 case T_POINT:
156 // write value to stream
157 EffectsBuffer_WriteBytes(&v->point, sizeof(Point), buff);
158 break;
159 case T_ARRAY:
160 // write array to stream
161 EffectsBuffer_WriteSIArray(v, buff);
162 break;
163 case T_STRING:
164 EffectsBuffer_WriteString(v->stringval, buff);
165 break;
166 case T_BOOL:
167 // write bool to stream
168 b = SIValue_IsTrue(*v);
169 EffectsBuffer_WriteBytes(&b, sizeof(bool), buff);
170 break;
171 case T_INT64:
172 // write int to stream
173 EffectsBuffer_WriteBytes(&v->longval, sizeof(v->longval), buff);
174 break;
175 case T_DOUBLE:
176 // write double to stream
177 EffectsBuffer_WriteBytes(&v->doubleval, sizeof(v->doubleval), buff);
178 break;
179 case T_NULL:
180 // no additional data is required to represent NULL
181 break;
182 default:
183 assert(false && "unknown SIValue type");
184 }
185}
186
187// writes a binary representation of arr into Effect-Buffer
188static void EffectsBuffer_WriteSIArray

Calls 4

EffectsBuffer_WriteBytesFunction · 0.85
SIValue_IsTrueFunction · 0.85

Tested by

no test coverage detected