summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2023-05-02 15:21:40 +0000
committerGeir Storli <geirst@yahooinc.com>2023-05-02 15:21:40 +0000
commitcde6875d5697545930e0e0c9bda6abf3b365cccc (patch)
tree11e8c6e8aa7422327838591b37f6ea140f8d3722 /vespalib
parentb83cc57a23c24cba060e884ade5f056cd46c5a82 (diff)
Deserialize match features in SearchResult used in streaming search.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp8
-rw-r--r--vespalib/src/vespa/vespalib/util/growablebytebuffer.h8
2 files changed, 15 insertions, 1 deletions
diff --git a/vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp b/vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp
index 424ad7ba470..fa0dc9bf99e 100644
--- a/vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp
+++ b/vespalib/src/vespa/vespalib/util/growablebytebuffer.cpp
@@ -76,6 +76,14 @@ GrowableByteBuffer::putString(vespalib::stringref v)
}
void
+GrowableByteBuffer::put_c_string(vespalib::stringref v)
+{
+ putInt(v.size() + 1);
+ putBytes(v.data(), v.size());
+ putByte(0);
+}
+
+void
GrowableByteBuffer::putByte(uint8_t v)
{
putBytes(reinterpret_cast<const char*>(&v), sizeof(v));
diff --git a/vespalib/src/vespa/vespalib/util/growablebytebuffer.h b/vespalib/src/vespa/vespalib/util/growablebytebuffer.h
index b0fb30606d4..61698868dba 100644
--- a/vespalib/src/vespa/vespalib/util/growablebytebuffer.h
+++ b/vespalib/src/vespa/vespalib/util/growablebytebuffer.h
@@ -68,11 +68,17 @@ public:
void putDouble(double v);
/**
- Adds a string to the buffer.
+ Adds a string to the buffer (without nul-termination).
*/
void putString(vespalib::stringref v);
/**
+ * Adds a string to the buffer (including nul-termination).
+ * This matches com.yahoo.vespa.objects.Deserializer.getString.
+ */
+ void put_c_string(vespalib::stringref v);
+
+ /**
Adds a single byte to the buffer.
*/
void putByte(uint8_t v);