summaryrefslogtreecommitdiffstats
path: root/vdslib
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2018-11-21 07:33:54 +0000
committergjoranv <gv@oath.com>2019-01-21 15:09:28 +0100
commit917ce1f13f72094a652a59e19ce2fcb52b2f6816 (patch)
treecb71e23d34305b75733211a70495a417cf771cfb /vdslib
parent683e2f005dea7b0bc11600237f67d120dad7fd49 (diff)
remove unused classes
Diffstat (limited to 'vdslib')
-rw-r--r--vdslib/src/main/java/com/yahoo/vdslib/BinaryDocumentList.java55
-rw-r--r--vdslib/src/main/java/com/yahoo/vdslib/BinaryEntry.java82
-rw-r--r--vdslib/src/main/java/com/yahoo/vdslib/DocumentList.java108
-rw-r--r--vdslib/src/main/java/com/yahoo/vdslib/DynamicDocumentList.java167
-rw-r--r--vdslib/src/main/java/com/yahoo/vdslib/DynamicEntry.java75
-rw-r--r--vdslib/src/main/java/com/yahoo/vdslib/Entry.java159
-rw-r--r--vdslib/src/test/java/com/yahoo/vdslib/DocumentListTestCase.java146
-rw-r--r--vdslib/src/test/java/com/yahoo/vdslib/EntryTestCase.java51
8 files changed, 0 insertions, 843 deletions
diff --git a/vdslib/src/main/java/com/yahoo/vdslib/BinaryDocumentList.java b/vdslib/src/main/java/com/yahoo/vdslib/BinaryDocumentList.java
deleted file mode 100644
index 25b1a6acff4..00000000000
--- a/vdslib/src/main/java/com/yahoo/vdslib/BinaryDocumentList.java
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vdslib;
-
-import com.yahoo.document.DocumentTypeManager;
-import com.yahoo.vespa.objects.Serializer;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
- */
-class BinaryDocumentList extends DocumentList {
-
- private DocumentTypeManager docMan;
- private byte[] buffer;
- private int docCount;
-
- /**
- * Create a new documentlist, using the given buffer.
- *
- * @param buffer buffer containing documents
- */
- BinaryDocumentList(DocumentTypeManager docMan, byte[] buffer) {
- this.docMan = docMan;
- ByteBuffer buf = ByteBuffer.wrap(buffer);
- buf.order(ByteOrder.LITTLE_ENDIAN);
- docCount = buf.getInt();
- this.buffer = buffer;
-
- }
-
- @Override
- public Entry get(int index) throws ArrayIndexOutOfBoundsException {
- if (index < docCount) {
- return Entry.create(docMan, buffer, index);
- } else {
- throw new ArrayIndexOutOfBoundsException(index + " >= " + docCount);
- }
- }
-
- @Override
- public int size() { return docCount; }
-
- @Override
- public int getApproxByteSize() {
- return buffer.length;
- }
-
- @Override
- public void serialize(Serializer buf) {
- buf.put(null, buffer);
- }
-
-}
diff --git a/vdslib/src/main/java/com/yahoo/vdslib/BinaryEntry.java b/vdslib/src/main/java/com/yahoo/vdslib/BinaryEntry.java
deleted file mode 100644
index c11bb009a73..00000000000
--- a/vdslib/src/main/java/com/yahoo/vdslib/BinaryEntry.java
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vdslib;
-
-import com.yahoo.document.*;
-import com.yahoo.document.serialization.DocumentDeserializer;
-import com.yahoo.document.serialization.DocumentDeserializerFactory;
-import com.yahoo.io.GrowableByteBuffer;
-
-/**
- * An entry in serialized form.
- *
- * @author <a href="mailto:thomasg@yahoo-inc.com">Thomas Gundersen</a>, <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
- */
-class BinaryEntry extends Entry {
- private MetaEntry metaEntry;
- private byte[] buffer;
- private DocumentTypeManager docMan;
-
- /**
- * Creates an entry from serialized form.
- * @param docMan The documentmanager to use when deserializing.
- * @param buffer the buffer to read the entry from
- * @param entryIndex the index of the entry in the buffer
- */
- BinaryEntry(DocumentTypeManager docMan, byte[] buffer, int entryIndex) {
- this.buffer = buffer;
- metaEntry = new MetaEntry(buffer, 4 + entryIndex * MetaEntry.SIZE);
- this.docMan = docMan;
- }
-
- @Override
- public boolean valid() { return buffer != null; }
-
- @Override
- public boolean isRemoveEntry() { return (metaEntry.flags & MetaEntry.REMOVE_ENTRY) != 0; }
-
- @Override
- public boolean isBodyStripped() { return (metaEntry.flags & MetaEntry.BODY_STRIPPED) != 0; }
-
- @Override
- public boolean isUpdateEntry() { return (metaEntry.flags & MetaEntry.UPDATE_ENTRY) != 0; }
-
- @Override
- public long getTimestamp() { return metaEntry.timestamp; }
-
- @Override
- public DocumentOperation getDocumentOperation() {
- DocumentDeserializer buf = DocumentDeserializerFactory.create42(
- docMan,
- GrowableByteBuffer.wrap(buffer, metaEntry.headerPos, metaEntry.headerLen),
- (metaEntry.bodyLen > 0) ? GrowableByteBuffer.wrap(buffer, metaEntry.bodyPos, metaEntry.bodyLen) : null
- );
-
- DocumentOperation op;
-
- if ((metaEntry.flags & MetaEntry.UPDATE_ENTRY) != 0) {
- op = new DocumentUpdate(buf);
- } else if ((metaEntry.flags & MetaEntry.REMOVE_ENTRY) != 0) {
- op = new DocumentRemove(new Document(buf).getId());
- } else {
- op = new DocumentPut(new Document(buf));
- ((DocumentPut) op).getDocument().setLastModified(getTimestamp());
-
- }
- return op;
- }
-
- @Override
- public DocumentOperation getHeader() {
- DocumentDeserializer buf = DocumentDeserializerFactory.create42(docMan, GrowableByteBuffer.wrap(buffer, metaEntry.headerPos, metaEntry.headerLen));
- if ((metaEntry.flags & MetaEntry.UPDATE_ENTRY) != 0) {
- return new DocumentUpdate(buf);
- } else if ((metaEntry.flags & MetaEntry.REMOVE_ENTRY) != 0) {
- return new DocumentRemove(new Document(buf).getId());
- } else {
- DocumentPut op = new DocumentPut(new Document(buf));
- op.getDocument().setLastModified(getTimestamp());
- return op;
- }
- }
-
-}
diff --git a/vdslib/src/main/java/com/yahoo/vdslib/DocumentList.java b/vdslib/src/main/java/com/yahoo/vdslib/DocumentList.java
deleted file mode 100644
index 76d320102e3..00000000000
--- a/vdslib/src/main/java/com/yahoo/vdslib/DocumentList.java
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vdslib;
-
-import com.yahoo.document.DocumentId;
-import com.yahoo.document.DocumentTypeManager;
-import com.yahoo.vespa.objects.Serializer;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public abstract class DocumentList {
-
- protected DocumentList() { }
-
- /**
- * Creates a DocumentList from serialized form.
- *
- * @param docMan Documentmanager to use when deserializing
- * @param buffer the buffer to read from
- * @return a DocumentList instance
- */
- public static DocumentList create(DocumentTypeManager docMan, byte[] buffer) {
- return new BinaryDocumentList(docMan, buffer);
- }
-
- /**
- * Creates a DocumentList from a list of entries.
- * @param entries the entries to create a DocumentList from
- * @return a DocumentList instance
- * @see com.yahoo.vdslib.Entry
- */
- public static DocumentList create(List<Entry> entries) {
- return new DynamicDocumentList(entries);
- }
-
- /**
- * Creates a DocumentList containing a single entry.
- *
- * @param entry the entry to create a DocumentList from
- * @return a DocumentList instance
- * @see com.yahoo.vdslib.Entry
- */
- public static DocumentList create(Entry entry) {
- return new DynamicDocumentList(entry);
- }
-
- /**
- * Retrieves the specified Entry from the list.
- *
- * @param index the index of the Entry to return (0-based)
- * @return the entry at the specified position
- * @throws ArrayIndexOutOfBoundsException if index is &lt; 0 or &gt; size()
- * @throws com.yahoo.document.serialization.DeserializationException if the DocumentList is stored in binary form internally and deserialization fails
- */
- public abstract Entry get(int index) throws ArrayIndexOutOfBoundsException;
-
- /**
- * Returns the size of the list.
- *
- * @return the size of the list
- */
- public abstract int size();
-
- /**
- * Returns the byte size of the list. The value returned is exact if the list is stored in
- * binary form internally, otherwise it is approximate.
- *
- * @return the byte size of the list
- */
- public abstract int getApproxByteSize();
-
- /**
- * Serialize the list into the given buffer.
- *
- * @param buf the buffer to serialize into
- */
- public abstract void serialize(Serializer buf);
-
- /**
- * Test if a contains b
- *
- * @param list DocumentList contained
- * @return true if a contains b
- */
- public boolean containsAll(DocumentList list) {
- if( this.size() < list.size()) {
- return false;
- }
-
- Map<DocumentId, Integer> indexes = new HashMap<DocumentId, Integer>();
- for (int i=0; i<this.size(); ++i) {
- indexes.put(this.get(i).getDocumentOperation().getId(), i);
- }
- for (int i=0; i<list.size(); ++i) {
- Integer index = indexes.get(list.get(i).getDocumentOperation().getId());
- if (index == null ||
- list.get(i).getTimestamp() != this.get(index).getTimestamp() ||
- list.get(i).kind() != this.get(index).kind())
- {
- return false;
- }
- }
- return true;
- }
-
-}
-
diff --git a/vdslib/src/main/java/com/yahoo/vdslib/DynamicDocumentList.java b/vdslib/src/main/java/com/yahoo/vdslib/DynamicDocumentList.java
deleted file mode 100644
index a3cb6376b58..00000000000
--- a/vdslib/src/main/java/com/yahoo/vdslib/DynamicDocumentList.java
+++ /dev/null
@@ -1,167 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vdslib;
-
-import com.yahoo.compress.CompressionType;
-import com.yahoo.document.BucketIdFactory;
-import com.yahoo.document.DataType;
-import com.yahoo.document.Document;
-import com.yahoo.document.DocumentPut;
-import com.yahoo.document.DocumentRemove;
-import com.yahoo.document.DocumentUpdate;
-import com.yahoo.document.serialization.DocumentSerializer;
-import com.yahoo.document.serialization.DocumentSerializerFactory;
-import com.yahoo.vespa.objects.Serializer;
-
-import java.nio.ByteOrder;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * A list of document operations.
- *
- * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
- */
-public class DynamicDocumentList extends DocumentList {
- private List<Entry> entries;
-
- DynamicDocumentList(List<Entry> entries) {
- //the entries themselves are of course still modifiable, this is just an internal safeguard:
- this.entries = Collections.unmodifiableList(entries);
- }
-
- DynamicDocumentList(Entry entry) {
- List<Entry> list = new ArrayList<>(1);
- list.add(entry);
- BucketIdFactory factory = new BucketIdFactory();
- //the entry itself is of course still modifiable, this is just an internal safeguard:
- this.entries = Collections.unmodifiableList(list);
- }
-
- @Override
- public Entry get(int index) throws ArrayIndexOutOfBoundsException {
- return entries.get(index);
- }
-
- @Override
- public int size() {
- return entries.size();
- }
-
- @Override
- public int getApproxByteSize() {
- int size = 4;
- for (Entry entry : entries) {
- if (entry.getDocumentOperation() instanceof DocumentPut) {
- Document doc = ((DocumentPut)entry.getDocumentOperation()).getDocument();
- size += MetaEntry.SIZE + doc.getSerializedSize();
- } else if (entry.getDocumentOperation() instanceof DocumentUpdate) {
- //TODO: Implement getSerializedSize() for DocumentUpdate!!!
- size += MetaEntry.SIZE + 1024;
- } else if (entry.getDocumentOperation() instanceof DocumentRemove) {
- //TODO: Implement getSerializedSize() for DocumentRemove!!!
- size += MetaEntry.SIZE + 64;
- }
- }
- return size;
- }
-
- @Override
- public void serialize(Serializer buf) {
- if (buf instanceof DocumentSerializer) {
- serializeInternal((DocumentSerializer) buf);
- } else {
- DocumentSerializer serializer = DocumentSerializerFactory.create42();
- serializeInternal(serializer);
- serializer.getBuf().getByteBuffer().flip();
- buf.put(null, serializer.getBuf().getByteBuffer());
- }
- }
- @SuppressWarnings("deprecation")
- private void serializeInternal(DocumentSerializer buf) {
- ByteOrder originalOrder = buf.getBuf().order();
- buf.getBuf().order(ByteOrder.LITTLE_ENDIAN);
- //save the position before the size
- int posAtBeginning = buf.getBuf().position();
-
- //write the number of entries
- buf.putInt(null, entries.size());
-
- //create a list of metaentries, one for each entry
- List<MetaEntry> metaEntries = new ArrayList<MetaEntry>(entries.size());
-
- //jump past the meta block, we will serialize this afterwards when we know sizes and positions
- byte[] bogusEntry = new byte[entries.size() * MetaEntry.SIZE];
- buf.put(null, bogusEntry);
-
- for (Entry entry : entries) {
- MetaEntry metaEntry = new MetaEntry();
- metaEntries.add(metaEntry);
-
- // is this a remove? in that case, set this flag
- if (entry.isRemoveEntry()) metaEntry.flags |= MetaEntry.REMOVE_ENTRY;
- // is the body stripped? in that case, set this flag
- if (entry.isBodyStripped()) metaEntry.flags |= MetaEntry.BODY_STRIPPED;
- // is this an update? in that case, set this flag
- if (entry.getDocumentOperation() instanceof DocumentUpdate) metaEntry.flags |= MetaEntry.UPDATE_ENTRY;
- // is this a document? in that case, try to set the timestamp
- if (entry.getDocumentOperation() instanceof DocumentPut) {
- Document doc = ((DocumentPut)entry.getDocumentOperation()).getDocument();
- Long lastModified = doc.getLastModified();
- if (lastModified != null) {
- metaEntry.timestamp = lastModified;
- }
-
- if (doc.getDataType().contentStruct().getCompressionConfig() != null
- && doc.getDataType().contentStruct().getCompressionConfig().type != CompressionType.NONE) {
- metaEntry.flags |= MetaEntry.COMPRESSED;
- }
- if (doc.getDataType().getBodyType().getCompressionConfig() != null
- && doc.getDataType().getBodyType().getCompressionConfig().type != CompressionType.NONE) {
- metaEntry.flags |= MetaEntry.COMPRESSED;
- }
- }
-
- metaEntry.headerPos = buf.getBuf().position() - posAtBeginning;
-
- buf.getBuf().order(ByteOrder.BIG_ENDIAN);
- if (entry.getDocumentOperation() instanceof DocumentPut) {
- Document doc = ((DocumentPut)entry.getDocumentOperation()).getDocument();
- //serialize document and save length:
- doc.serializeHeader(buf);
- } else if (entry.getDocumentOperation() instanceof DocumentUpdate) {
- DocumentUpdate docUp = (DocumentUpdate) entry.getDocumentOperation();
- docUp.serialize(buf);
- } else if (entry.getDocumentOperation() instanceof DocumentRemove) {
- new Document(DataType.DOCUMENT, entry.getDocumentOperation().getId()).serialize(buf);
- } else {
- throw new IllegalArgumentException("Can not handle class " + entry.getDocumentOperation().getClass().getName());
- }
-
- metaEntry.headerLen = buf.getBuf().position() - metaEntry.headerPos - posAtBeginning;
-
- if (entry.getDocumentOperation() instanceof DocumentPut) {
- metaEntry.bodyPos = buf.getBuf().position() - posAtBeginning;
- Document doc = ((DocumentPut)entry.getDocumentOperation()).getDocument();
- doc.serializeBody(buf);
- metaEntry.bodyLen = buf.getBuf().position() - metaEntry.bodyPos - posAtBeginning;
- } else {
- metaEntry.bodyPos = 0;
- metaEntry.bodyLen = 0;
- }
- buf.getBuf().order(ByteOrder.LITTLE_ENDIAN);
-
- }
- //save position after payload:
- int posAfterEntries = buf.getBuf().position();
- //go to beginning (after length) to serialize metaentries:
- buf.getBuf().position(posAtBeginning + 4);
- //serialize metaentries
- for (MetaEntry metaEntry : metaEntries) {
- metaEntry.serialize(buf.getBuf());
- }
- //set position to after payload:
- buf.getBuf().position(posAfterEntries);
- buf.getBuf().order(originalOrder);
- }
-}
diff --git a/vdslib/src/main/java/com/yahoo/vdslib/DynamicEntry.java b/vdslib/src/main/java/com/yahoo/vdslib/DynamicEntry.java
deleted file mode 100644
index 81226c64604..00000000000
--- a/vdslib/src/main/java/com/yahoo/vdslib/DynamicEntry.java
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vdslib;
-
-import com.yahoo.document.DocumentOperation;
-import com.yahoo.document.DocumentPut;
-import com.yahoo.document.DocumentRemove;
-import com.yahoo.document.DocumentUpdate;
-
-/**
- * Represents an in-memory entry.
- *
- * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
- */
-class DynamicEntry extends Entry {
- private DocumentOperation op;
- private boolean bodyStripped;
-
- DynamicEntry(DocumentOperation op, boolean bodyStripped) {
- this.op = op;
- this.bodyStripped = bodyStripped;
- }
-
- DynamicEntry(DocumentUpdate op) {
- this.op = op;
- this.bodyStripped = false;
- }
-
- DynamicEntry(DocumentRemove op) {
- this.op = op;
- this.bodyStripped = false;
- }
-
- @Override
- public boolean valid() {
- return true;
- }
-
- @Override
- public boolean isRemoveEntry() {
- return op instanceof DocumentRemove;
- }
-
- @Override
- public boolean isBodyStripped() {
- return bodyStripped;
- }
-
- @Override
- public boolean isUpdateEntry() {
- return op instanceof DocumentUpdate;
- }
-
- @Override
- public long getTimestamp() {
- if (op instanceof DocumentPut) {
- DocumentPut put = (DocumentPut) op;
- final Long lastModified = put.getDocument().getLastModified();
- if (lastModified != null) {
- return lastModified;
- }
- }
- return 0L;
- }
-
- @Override
- public DocumentOperation getDocumentOperation() {
- return op;
- }
-
- @Override
- public DocumentOperation getHeader() {
- return op;
- //TODO: Only return header fields of Document here...?
- }
-}
diff --git a/vdslib/src/main/java/com/yahoo/vdslib/Entry.java b/vdslib/src/main/java/com/yahoo/vdslib/Entry.java
deleted file mode 100644
index 2ce3822f5a9..00000000000
--- a/vdslib/src/main/java/com/yahoo/vdslib/Entry.java
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vdslib;
-
-import com.yahoo.document.DocumentOperation;
-import com.yahoo.document.DocumentRemove;
-import com.yahoo.document.DocumentTypeManager;
-import com.yahoo.document.DocumentUpdate;
-
-/**
- * Represents a document operation in a DocumentList, which can currently be
- * PUT, REMOVE and UPDATE.
- *
- * @author <a href="mailto:thomasg@yahoo-inc.com">Thomas Gundersen</a>, <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
- */
-public abstract class Entry {
-
- protected Entry() { }
-
- /**
- * Creates a new entry from serialized form.
- *
- * @param docMan Documentmanager to use when deserializing
- * @param buffer the buffer to read the entry from
- * @param entryIndex the index of the entry in the buffer
- * @return an Entry reading from the buffer
- */
- public static Entry create(DocumentTypeManager docMan, byte[] buffer, int entryIndex) {
- return new BinaryEntry(docMan, buffer, entryIndex);
- }
-
- /**
- * Creates a new entry from a document operation.
- *
- * @param op the document in the entry
- * @param bodyStripped true if the document contains only header fields
- * @return an Entry for this document
- */
- public static Entry create(DocumentOperation op, boolean bodyStripped) {
- return new DynamicEntry(op, bodyStripped);
- }
-
- /**
- * Creates a new entry from a document operation.
- *
- * @param op the document in the entry
- * @return an Entry for this document
- */
- public static Entry create(DocumentOperation op) {
- return create(op, false);
- }
- /**
- * Creates a new entry from a document remove operation.
- *
- * @param doc the document in the entry
- * @return an Entry for this document
- */
- public static Entry create(DocumentRemove doc) {
- return new DynamicEntry(doc);
- }
-
- /**
- * Creates a new entry from a document update operation.
- *
- * @param doc the document update in the entry
- * @return an Entry for this document update
- */
- public static Entry create(DocumentUpdate doc) {
- return new DynamicEntry(doc);
- }
-
- /**
- * Entries in iterators gotten from DocumentList::end() are invalid.
- * @return true if valid
- */
- public abstract boolean valid();
-
- /**
- * Returns true if the Document represented by this entry has been removed from persistent storage.
- *
- * @return true if the Document has been removed
- */
- public abstract boolean isRemoveEntry();
-
- /**
- * Returns true if the Document represented by this entry has gotten its body fields stripped
- * away (note: the body fields might still be stored in persistent storage).
- *
- * @return true if the Document only has header fields
- */
- public abstract boolean isBodyStripped();
-
- /**
- * Returns true if this entry represents a document update operation.
- *
- * @return true if this is a document update operation
- */
- public abstract boolean isUpdateEntry();
-
-
- public int kind(){
- if (isRemoveEntry()) {
- return 0; //REMOVE
- }
- if (isUpdateEntry()) {
- return 2; //UPDATE
- }
- return 1; // PUT
- }
-
- /**
- * Returns the timestamp (last modified) of this entry, from persistent storage.
- * @return the last modified timestamp of this entry
- */
- public abstract long getTimestamp();
-
- /**
- * Returns the DocumentPut or DocumentUpdate operation in this entry.
- *
- * @return the DocumentOperation in this entry.
- */
- public abstract DocumentOperation getDocumentOperation();
-
- /**
- * Returns the Document header (if this is a DocumentPut or a DocumentRemove operation), otherwise
- * a DocumentUpdate operation.
- *
- * @return a DocumentPut operation containing a Document with only the header fields present
- * @throws RuntimeException if deserialization fails, or if this is a DocumentUpdate operation
- */
- public abstract DocumentOperation getHeader();
-
- @Override
- public boolean equals(Object obj) {
- if ( this == obj ) {
- return true;
- }
- if (!(obj instanceof Entry)) {
- return false;
- }
- Entry entry = (Entry) obj;
- return this.getDocumentOperation().getId().equals(entry.getDocumentOperation().getId()) &&
- this.getTimestamp() == entry.getTimestamp() &&
- this.kind() == entry.kind() &&
- this.isBodyStripped() == entry.isBodyStripped() &&
- this.valid() == entry.valid();
- }
-
- @Override
- public int hashCode() {
- int res = 31;
- res = 31 * res + getDocumentOperation().getId().hashCode();
- res = (int) (31 * res + getTimestamp());
- res = 31 * res + kind()*31;
- res = 31 * res + (isBodyStripped() ? 17 : 249);
- res = 31 * res + (valid() ? 333 : 31);
-
- return res;
- }
-}
diff --git a/vdslib/src/test/java/com/yahoo/vdslib/DocumentListTestCase.java b/vdslib/src/test/java/com/yahoo/vdslib/DocumentListTestCase.java
deleted file mode 100644
index cae51440400..00000000000
--- a/vdslib/src/test/java/com/yahoo/vdslib/DocumentListTestCase.java
+++ /dev/null
@@ -1,146 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vdslib;
-
-import com.yahoo.document.DocumentId;
-import com.yahoo.document.DocumentPut;
-import com.yahoo.document.DocumentRemove;
-import com.yahoo.document.DocumentType;
-import com.yahoo.document.DocumentTypeManager;
-import com.yahoo.document.DocumentTypeManagerConfigurer;
-import com.yahoo.document.DocumentUpdate;
-import com.yahoo.document.Field;
-import com.yahoo.document.datatypes.FloatFieldValue;
-import com.yahoo.document.datatypes.StringFieldValue;
-import com.yahoo.document.serialization.DocumentSerializer;
-import com.yahoo.document.serialization.DocumentSerializerFactory;
-import com.yahoo.document.update.FieldUpdate;
-import org.junit.Test;
-
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class DocumentListTestCase {
-
- @Test
- @SuppressWarnings("deprecation")
- public void testSelfSerializationAndWriteJavaFile() throws Exception {
- DocumentTypeManager docMan = new DocumentTypeManager();
- DocumentTypeManagerConfigurer.configure(docMan, "file:src/test/files/documentmanager.cfg");
-
- DocumentType bmType = docMan.getDocumentType("benchmark");
- DocumentPut put1 = new DocumentPut(bmType, "userdoc:foo:99999999:1");
- put1.getDocument().setFieldValue("headerstring", "foo");
- DocumentRemove doc2 = new DocumentRemove(new DocumentId("userdoc:foo:99999999:2"));
- DocumentPut put3 = new DocumentPut(bmType, "userdoc:foo:99999999:3");
- put3.getDocument().setFieldValue("bodyfloat", new FloatFieldValue(5.5f));
-
-
- Field bodystringField = bmType.getField("bodystring");
- DocumentUpdate docUp = new DocumentUpdate(docMan.getDocumentType("benchmark"), new DocumentId("userdoc:foo:99999999:4"));
- docUp.addFieldUpdate(FieldUpdate.createAssign(bodystringField, new StringFieldValue("ballooooo")));
-
- List<Entry> entries = new ArrayList<>();
- entries.add(Entry.create(put1));
- entries.add(Entry.create(doc2));
- entries.add(Entry.create(put3));
- entries.add(Entry.create(docUp));
-
- DocumentList documentList = DocumentList.create(entries);
-
- DocumentSerializer gbuf = DocumentSerializerFactory.create42();
- gbuf.putInt(null, 1234); // Add some data to avoid special case where position() is 0 for buffer used.
- int startPos = gbuf.getBuf().position();
- documentList.serialize(gbuf);
-
- int size = gbuf.getBuf().position() - startPos;
- byte[] data = new byte[size];
- gbuf.getBuf().position(startPos);
- gbuf.getBuf().get(data);
- FileOutputStream stream = new FileOutputStream("./src/test/files/documentlist-java.dat");
- stream.write(data);
- stream.close();
-
- gbuf.getBuf().position(0);
-
- DocumentList documentList2 = DocumentList.create(docMan, data);
-
- assertEquals(4, documentList2.size());
- Entry entry1 = documentList2.get(0);
- assertEquals(0L, entry1.getTimestamp());
- assertFalse(entry1.isBodyStripped());
- assertFalse(entry1.isRemoveEntry());
- assertFalse(entry1.isUpdateEntry());
- assertTrue(entry1.getDocumentOperation() instanceof DocumentPut);
- assertEquals(new StringFieldValue("foo"), ((DocumentPut) entry1.getDocumentOperation()).getDocument().getFieldValue("headerstring"));
-
- Entry entry2 = documentList2.get(1);
- assertEquals(0L, entry2.getTimestamp());
- assertFalse(entry2.isBodyStripped());
- assertTrue(entry2.isRemoveEntry());
- assertFalse(entry2.isUpdateEntry());
- assertTrue(entry2.getDocumentOperation() instanceof DocumentRemove);
-
- Entry entry3 = documentList2.get(2);
- assertEquals(0L, entry3.getTimestamp());
- assertFalse(entry3.isBodyStripped());
- assertFalse(entry3.isRemoveEntry());
- assertFalse(entry3.isUpdateEntry());
- assertTrue(entry3.getDocumentOperation() instanceof DocumentPut);
- assertEquals(new FloatFieldValue(5.5f), ((DocumentPut) entry3.getDocumentOperation()).getDocument().getFieldValue("bodyfloat"));
-
- Entry entry4 = documentList2.get(3);
- assertEquals(0L, entry4.getTimestamp());
- assertFalse(entry4.isBodyStripped());
- assertFalse(entry4.isRemoveEntry());
- assertTrue(entry4.isUpdateEntry());
- assertTrue(entry4.getDocumentOperation() instanceof DocumentUpdate);
- assertEquals(new StringFieldValue("ballooooo"),((DocumentUpdate) entry4.getDocumentOperation()).getFieldUpdate(bodystringField).getValueUpdate(0).getValue());
- }
-
- @Test
- public void testContains() {
- DocumentTypeManager manager = new DocumentTypeManager();
- DocumentTypeManagerConfigurer.configure(manager, "file:src/test/files/documentmanager.cfg");
-
- DocumentType bmType = manager.getDocumentType("benchmark");
- DocumentPut put1 = new DocumentPut(bmType, "userdoc:foo:99999999:1");
- DocumentRemove remove1 = new DocumentRemove(new DocumentId("userdoc:foo:99999999:2"));
- DocumentPut put2 = new DocumentPut(bmType, "userdoc:foo:99999999:3");
-
- List<Entry> entries = new ArrayList<Entry>();
- entries.add(Entry.create(put1));
- entries.add(Entry.create(remove1));
- entries.add(Entry.create(put2));
-
- DocumentList documentList = DocumentList.create(entries);
-
- DocumentPut put3 = new DocumentPut(bmType, "userdoc:foo:99999999:1");
- DocumentRemove remove2 = new DocumentRemove(new DocumentId("userdoc:foo:99999999:2"));
- DocumentPut put4 = new DocumentPut(bmType, "userdoc:foo:99999999:3");
-
- List<Entry> entries2 = new ArrayList<Entry>();
- entries2.add(Entry.create(put3));
- entries2.add(Entry.create(remove2));
- entries2.add(Entry.create(put4));
-
- DocumentList documentList2 = DocumentList.create(entries2);
-
- assertTrue(documentList.containsAll(documentList2));
-
- Long t = put4.getDocument().getLastModified();
- put4.getDocument().setLastModified(13L);
- assertTrue(!documentList.containsAll(documentList2));
- put4.getDocument().setLastModified(t);
-
- assert(documentList.containsAll(documentList2));
-
- entries.remove(2);
- assertTrue(!documentList.containsAll(documentList2));
- }
-
-}
diff --git a/vdslib/src/test/java/com/yahoo/vdslib/EntryTestCase.java b/vdslib/src/test/java/com/yahoo/vdslib/EntryTestCase.java
deleted file mode 100644
index ccce2ffcbb7..00000000000
--- a/vdslib/src/test/java/com/yahoo/vdslib/EntryTestCase.java
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vdslib;
-
-import com.yahoo.document.DocumentPut;
-import com.yahoo.document.DocumentType;
-import com.yahoo.document.DocumentTypeManager;
-import com.yahoo.document.DocumentTypeManagerConfigurer;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author banino
- */
-public class EntryTestCase {
-
- @Test
- public void testEquals() {
- DocumentTypeManager manager = new DocumentTypeManager();
- DocumentTypeManagerConfigurer.configure(manager, "file:src/test/files/documentmanager.cfg");
-
- DocumentType bmType = manager.getDocumentType("benchmark");
- DocumentPut put1 = new DocumentPut(bmType, "userdoc:foo:99999999:1");
- DocumentPut put2 = new DocumentPut(bmType, "userdoc:foo:99999999:2");
-
- Entry entry1 = Entry.create(put1);
- Entry entry2 = Entry.create(put1);
- assertTrue(entry1.equals(entry2));
-
- Entry entry3 = Entry.create(put2);
- assertTrue(!entry1.equals(entry3));
- }
-
- @Test
- public void testHashCode() {
- DocumentTypeManager manager = new DocumentTypeManager();
- DocumentTypeManagerConfigurer.configure(manager, "file:src/test/files/documentmanager.cfg");
-
- DocumentType bmType = manager.getDocumentType("benchmark");
- DocumentPut put1 = new DocumentPut(bmType, "userdoc:foo:99999999:1");
- DocumentPut put2 = new DocumentPut(bmType, "userdoc:foo:99999999:2");
-
- Entry entry1 = Entry.create(put1);
- Entry entry2 = Entry.create(put1);
- assertTrue(entry1.hashCode() == entry2.hashCode());
-
- Entry entry3 = Entry.create(put2);
- assertTrue(entry1.hashCode() != entry3.hashCode());
- }
-
-}