Search in sources :

Example 61 with DocumentType

use of com.yahoo.document.DocumentType in project vespa by vespa-engine.

the class CallbackTestCase method setUp.

public void setUp() {
    service = new DocprocService("callback");
    service.setCallStack(new CallStack().addNext(new TestCallbackDp()));
    service.setInService(true);
    // Create documents
    DocumentType type = new DocumentType("test");
    type.addField("status", DataType.STRING);
    put1 = new DocumentPut(type, new DocumentId("doc:callback:test:1"));
    put2 = new DocumentPut(type, new DocumentId("doc:callback:test:2"));
    operations.add(new DocumentPut(type, new DocumentId("doc:callback:test:3")));
    operations.add(new DocumentPut(type, new DocumentId("doc:callback:test:4")));
}
Also used : DocumentPut(com.yahoo.document.DocumentPut) DocumentId(com.yahoo.document.DocumentId) DocumentType(com.yahoo.document.DocumentType)

Example 62 with DocumentType

use of com.yahoo.document.DocumentType in project vespa by vespa-engine.

the class JsonReaderTestCase method testDocumentRemove.

@Test
public final void testDocumentRemove() {
    InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("{\"remove\": \"id:unittest:smoke::whee\"" + " }}"));
    JsonReader r = new JsonReader(types, rawDoc, parserFactory);
    DocumentType docType = r.readDocumentType(new DocumentId("id:unittest:smoke::whee"));
    assertEquals("smoke", docType.getName());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DocumentId(com.yahoo.document.DocumentId) DocumentType(com.yahoo.document.DocumentType) Test(org.junit.Test)

Example 63 with DocumentType

use of com.yahoo.document.DocumentType in project vespa by vespa-engine.

the class JsonReaderTestCase method smokeTest.

@Test
public final void smokeTest() throws IOException {
    InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("{\"put\": \"id:unittest:smoke::whee\"," + " \"fields\": { \"something\": \"smoketest\"," + " \"nalle\": \"bamse\"}}"));
    JsonReader r = new JsonReader(types, rawDoc, parserFactory);
    DocumentParseInfo parseInfo = r.parseDocument().get();
    DocumentType docType = r.readDocumentType(parseInfo.documentId);
    DocumentPut put = new DocumentPut(new Document(docType, parseInfo.documentId));
    new VespaJsonDocumentReader().readPut(parseInfo.fieldsBuffer, put);
    smokeTestDoc(put.getDocument());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DocumentPut(com.yahoo.document.DocumentPut) DocumentType(com.yahoo.document.DocumentType) Document(com.yahoo.document.Document) DocumentParseInfo(com.yahoo.document.json.readers.DocumentParseInfo) VespaJsonDocumentReader(com.yahoo.document.json.readers.VespaJsonDocumentReader) Test(org.junit.Test)

Example 64 with DocumentType

use of com.yahoo.document.DocumentType in project vespa by vespa-engine.

the class JsonReaderTestCase method docIdLookaheadTest.

@Test
public final void docIdLookaheadTest() throws IOException {
    InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("{" + " \"fields\": { \"something\": \"smoketest\"," + " \"nalle\": \"bamse\"}," + "\"put\": \"id:unittest:smoke::whee\"" + "}"));
    JsonReader r = new JsonReader(types, rawDoc, parserFactory);
    DocumentParseInfo parseInfo = r.parseDocument().get();
    DocumentType docType = r.readDocumentType(parseInfo.documentId);
    DocumentPut put = new DocumentPut(new Document(docType, parseInfo.documentId));
    new VespaJsonDocumentReader().readPut(parseInfo.fieldsBuffer, put);
    smokeTestDoc(put.getDocument());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DocumentPut(com.yahoo.document.DocumentPut) DocumentType(com.yahoo.document.DocumentType) Document(com.yahoo.document.Document) DocumentParseInfo(com.yahoo.document.json.readers.DocumentParseInfo) VespaJsonDocumentReader(com.yahoo.document.json.readers.VespaJsonDocumentReader) Test(org.junit.Test)

Example 65 with DocumentType

use of com.yahoo.document.DocumentType in project vespa by vespa-engine.

the class JsonReaderTestCase method testWeightedSet.

@Test
public final void testWeightedSet() throws IOException {
    InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("{\"put\": \"id:unittest:testset::whee\"," + " \"fields\": { \"actualset\": {" + " \"nalle\": 2," + " \"tralle\": 7 }}}"));
    JsonReader r = new JsonReader(types, rawDoc, parserFactory);
    DocumentParseInfo parseInfo = r.parseDocument().get();
    DocumentType docType = r.readDocumentType(parseInfo.documentId);
    DocumentPut put = new DocumentPut(new Document(docType, parseInfo.documentId));
    new VespaJsonDocumentReader().readPut(parseInfo.fieldsBuffer, put);
    Document doc = put.getDocument();
    FieldValue f = doc.getFieldValue(doc.getField("actualset"));
    assertSame(WeightedSet.class, f.getClass());
    WeightedSet<?> w = (WeightedSet<?>) f;
    assertEquals(2, w.size());
    assertEquals(new Integer(2), w.get(new StringFieldValue("nalle")));
    assertEquals(new Integer(7), w.get(new StringFieldValue("tralle")));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DocumentPut(com.yahoo.document.DocumentPut) DocumentType(com.yahoo.document.DocumentType) Document(com.yahoo.document.Document) DocumentParseInfo(com.yahoo.document.json.readers.DocumentParseInfo) VespaJsonDocumentReader(com.yahoo.document.json.readers.VespaJsonDocumentReader) ByteArrayInputStream(java.io.ByteArrayInputStream) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) TensorFieldValue(com.yahoo.document.datatypes.TensorFieldValue) MapFieldValue(com.yahoo.document.datatypes.MapFieldValue) WeightedSet(com.yahoo.document.datatypes.WeightedSet) Test(org.junit.Test)

Aggregations

DocumentType (com.yahoo.document.DocumentType)98 Test (org.junit.Test)45 Document (com.yahoo.document.Document)41 DocumentPut (com.yahoo.document.DocumentPut)35 Field (com.yahoo.document.Field)24 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)24 DocumentId (com.yahoo.document.DocumentId)20 ByteArrayInputStream (java.io.ByteArrayInputStream)19 InputStream (java.io.InputStream)19 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)17 DocumentParseInfo (com.yahoo.document.json.readers.DocumentParseInfo)17 VespaJsonDocumentReader (com.yahoo.document.json.readers.VespaJsonDocumentReader)17 DocumentUpdate (com.yahoo.document.DocumentUpdate)15 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)15 StructDataType (com.yahoo.document.StructDataType)14 TensorDataType (com.yahoo.document.TensorDataType)12 TensorFieldValue (com.yahoo.document.datatypes.TensorFieldValue)11 ArrayDataType (com.yahoo.document.ArrayDataType)10 MapDataType (com.yahoo.document.MapDataType)10 ReferenceDataType (com.yahoo.document.ReferenceDataType)10