use of com.yahoo.document.fieldpathupdate.FieldPathUpdate in project vespa by vespa-engine.
the class VespaDocumentSerializerHead method write.
@Override
public void write(DocumentUpdate update) {
update.getId().serialize(this);
update.getDocumentType().serialize(this);
putInt(null, update.getFieldUpdates().size());
for (FieldUpdate up : update.getFieldUpdates()) {
up.serialize(this);
}
DocumentUpdateFlags flags = new DocumentUpdateFlags();
flags.setCreateIfNonExistent(update.getCreateIfNonExistent());
putInt(null, flags.injectInto(update.getFieldPathUpdates().size()));
for (FieldPathUpdate up : update.getFieldPathUpdates()) {
up.serialize(this);
}
}
use of com.yahoo.document.fieldpathupdate.FieldPathUpdate in project vespa by vespa-engine.
the class PathUpdateToDocumentTestCase method requireThatArrayFieldsAreConverted.
@SuppressWarnings({ "unchecked" })
@Test
public void requireThatArrayFieldsAreConverted() {
DocumentType docType = new DocumentType("my_type");
ArrayDataType arrType = DataType.getArray(DataType.INT);
docType.addField(new Field("my_arr", arrType));
Array<IntegerFieldValue> arrVal = arrType.createFieldValue();
arrVal.add(new IntegerFieldValue(6));
arrVal.add(new IntegerFieldValue(9));
FieldPathUpdate upd = new AssignFieldPathUpdate(docType, "my_arr", "", arrVal);
Document doc = FieldPathUpdateHelper.newPartialDocument(null, upd);
assertNotNull(doc);
FieldValue obj = doc.getFieldValue("my_arr");
assertTrue(obj instanceof Array);
Array arr = (Array) obj;
assertEquals(2, arr.size());
assertEquals(new IntegerFieldValue(6), arr.get(0));
assertEquals(new IntegerFieldValue(9), arr.get(1));
}
use of com.yahoo.document.fieldpathupdate.FieldPathUpdate in project vespa by vespa-engine.
the class PathUpdateToDocumentTestCase method requireThatWsetKeysAreConverted.
@Test
public void requireThatWsetKeysAreConverted() {
DocumentType docType = new DocumentType("my_type");
WeightedSetDataType wsetType = DataType.getWeightedSet(DataType.STRING);
docType.addField(new Field("my_wset", wsetType));
FieldPathUpdate upd = new AssignFieldPathUpdate(docType, "my_wset{69}", "", new IntegerFieldValue(96));
Document doc = FieldPathUpdateHelper.newPartialDocument(null, upd);
assertNotNull(doc);
FieldValue obj = doc.getFieldValue("my_wset");
assertTrue(obj instanceof WeightedSet);
WeightedSet wset = (WeightedSet) obj;
assertEquals(1, wset.size());
assertEquals(96, wset.get(new StringFieldValue("69")).intValue());
}
use of com.yahoo.document.fieldpathupdate.FieldPathUpdate in project vespa by vespa-engine.
the class PathUpdateToDocumentTestCase method requireThatStringFieldsAreConverted.
@Test
public void requireThatStringFieldsAreConverted() {
DocumentType docType = new DocumentType("my_type");
docType.addField(new Field("my_str", DataType.STRING));
FieldPathUpdate upd = new AssignFieldPathUpdate(docType, "my_str", "", new StringFieldValue("69"));
Document doc = FieldPathUpdateHelper.newPartialDocument(null, upd);
assertNotNull(doc);
assertEquals("69", ((StringFieldValue) doc.getFieldValue("my_str")).getString());
}
use of com.yahoo.document.fieldpathupdate.FieldPathUpdate in project vespa by vespa-engine.
the class PathUpdateToDocumentTestCase method requireThatIntegerFieldsAreConverted.
@Test
public void requireThatIntegerFieldsAreConverted() {
DocumentType docType = new DocumentType("my_type");
docType.addField(new Field("my_int", DataType.INT));
FieldPathUpdate upd = new AssignFieldPathUpdate(docType, "my_int", "", new IntegerFieldValue(69));
Document doc = FieldPathUpdateHelper.newPartialDocument(null, upd);
assertNotNull(doc);
assertEquals(69, ((IntegerFieldValue) doc.getFieldValue("my_int")).getInteger());
}
Aggregations