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

Function SIValue_FromBinary

src/value.c:766–826  ·  view source on GitHub ↗

reads SIValue off of binary stream

Source from the content-addressed store, hash-verified

764
765// reads SIValue off of binary stream
766SIValue SIValue_FromBinary
767(
768 FILE *stream // stream to read value from
769) {
770 ASSERT(stream != NULL);
771
772 // read value type
773 SIType t;
774 SIValue v;
775 size_t len; // string length
776
777 bool b;
778 int64_t i;
779 double d;
780 Point p;
781 char *s;
782 struct SIValue *array;
783
784 fread_assert(&t, sizeof(SIType), stream);
785 switch(t) {
786 case T_POINT:
787 // read point from stream
788 fread_assert(&p, sizeof(v.point), stream);
789 v = SI_Point(p.latitude, p.longitude);
790 break;
791 case T_ARRAY:
792 // read array from stream
793 v = SIArray_FromBinary(stream);
794 break;
795 case T_STRING:
796 // read string length from stream
797 fread_assert(&len, sizeof(len), stream);
798 s = rm_malloc(sizeof(char) * len);
799 // read string from stream
800 fread_assert(s, sizeof(char) * len, stream);
801 v = SI_TransferStringVal(s);
802 break;
803 case T_BOOL:
804 // read bool from stream
805 fread_assert(&b, sizeof(b), stream);
806 v = SI_BoolVal(b);
807 break;
808 case T_INT64:
809 // read int from stream
810 fread_assert(&i, sizeof(i), stream);
811 v = SI_LongVal(i);
812 break;
813 case T_DOUBLE:
814 // read double from stream
815 fread_assert(&d, sizeof(d), stream);
816 v = SI_DoubleVal(d);
817 break;
818 case T_NULL:
819 v = SI_NullVal();
820 break;
821 default:
822 assert(false && "unknown SIValue type");
823 }

Callers 4

ReadAttributeSetFunction · 0.85
ApplyUpdateEdgeFunction · 0.85
ApplyUpdateNodeFunction · 0.85
SIArray_FromBinaryFunction · 0.85

Calls 8

SI_PointFunction · 0.85
SIArray_FromBinaryFunction · 0.85
rm_mallocFunction · 0.85
SI_TransferStringValFunction · 0.85
SI_BoolValFunction · 0.85
SI_LongValFunction · 0.85
SI_DoubleValFunction · 0.85
SI_NullValFunction · 0.85

Tested by

no test coverage detected