diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-02-06 14:32:41 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2018-02-06 14:32:41 +0100 |
commit | 327ba6c9942613212ae4048553d439f7ff6e4938 (patch) | |
tree | f8670bcdaae4de0d9ca7e74105ebd9ef136fcb04 /container-search | |
parent | 37e988b3d6cd77f8235ec530d2c68b3b4f38933a (diff) |
GC unused and always enabled features. Add new feature for reporting nodes queried and replied.
Diffstat (limited to 'container-search')
-rw-r--r-- | container-search/src/main/java/com/yahoo/fs4/QueryResultPacket.java | 66 | ||||
-rw-r--r-- | container-search/src/test/java/com/yahoo/fs4/test/QueryResultTestCase.java | 68 |
2 files changed, 76 insertions, 58 deletions
diff --git a/container-search/src/main/java/com/yahoo/fs4/QueryResultPacket.java b/container-search/src/main/java/com/yahoo/fs4/QueryResultPacket.java index 17f3ca2655f..a7d5de751b9 100644 --- a/container-search/src/main/java/com/yahoo/fs4/QueryResultPacket.java +++ b/container-search/src/main/java/com/yahoo/fs4/QueryResultPacket.java @@ -1,14 +1,11 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.fs4; -import com.yahoo.search.Query; - import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.logging.Logger; /** @@ -30,12 +27,13 @@ public class QueryResultPacket extends Packet { private boolean datasetFeature=false; /** Whether coverage information is included in this result */ - private boolean coverageFeature = false; - private boolean coverageExtendedFeature = false; - private long coverageDocs = 0; - private long activeDocs = 0; - private long soonActiveDocs = 0; - private int degradedReason = 0; + private boolean coverageNodes = false; + private long coverageDocs = 0; + private long activeDocs = 0; + private long soonActiveDocs = 0; + private int degradedReason = 0; + private short nodesQueried = 0; + private short nodesReplied = 0; /** Whether the result contains grouping results **/ private boolean groupDataFeature = false; @@ -59,8 +57,7 @@ public class QueryResultPacket extends Packet { private int offset; - private QueryResultPacket() { - } + private QueryResultPacket() { } public static QueryResultPacket create() { return new QueryResultPacket(); @@ -76,9 +73,7 @@ public class QueryResultPacket extends Packet { /** Returns whether this result has the dataset feature */ public boolean getDatasetFeature() { return datasetFeature; } - public boolean getCoverageFeature() { - return coverageFeature; - } + public boolean getCoverageFeature() { return true; } public long getCoverageDocs() { return coverageDocs; } @@ -120,17 +115,16 @@ public class QueryResultPacket extends Packet { groupData = new byte[len]; buffer.get(groupData); } - if (coverageFeature) { - coverageDocs = buffer.getLong(); - activeDocs = buffer.getLong(); - } - if (coverageExtendedFeature) { - soonActiveDocs = buffer.getLong(); - degradedReason = buffer.getInt(); - } else { - soonActiveDocs = activeDocs; - degradedReason = 0; + + coverageDocs = buffer.getLong(); + activeDocs = buffer.getLong(); + soonActiveDocs = buffer.getLong(); + degradedReason = buffer.getInt(); + if (coverageNodes) { + nodesQueried = buffer.getShort(); + nodesReplied = buffer.getShort(); } + decodeDocuments(buffer,documentCount); if (propsFeature) { int numMaps = buffer.getInt(); @@ -149,12 +143,14 @@ public class QueryResultPacket extends Packet { /** * feature bits */ - public static final int QRF_MLD = 0x00000001; - public static final int QRF_SORTDATA = 0x00000010; - public static final int QRF_EXTENDED_COVERAGE = 0x00000020; - public static final int QRF_COVERAGE = 0x00000040; - public static final int QRF_GROUPDATA = 0x00000200; - public static final int QRF_PROPERTIES = 0x00000400; + public static final int QRF_MLD = 0x00000001; + public static final int QRF_DATASETS = 0x00000002; + public static final int QRF_COVERAGE_NODES = 0x00000004; + public static final int QRF_SORTDATA = 0x00000010; + public static final int QRF_UNUSED_1 = 0x00000020; + public static final int QRF_UNUSED_2 = 0x00000040; + public static final int QRF_GROUPDATA = 0x00000200; + public static final int QRF_PROPERTIES = 0x00000400; /** * Sets the features of this package. @@ -166,16 +162,15 @@ public class QueryResultPacket extends Packet { case 217: int features=buffer.get(); mldFeature = (QRF_MLD & features) != 0; - datasetFeature = (0x002 & features) != 0; + datasetFeature = (QRF_DATASETS & features) != 0; // Data given by sortFeature not currently used by QRS: // sortFeature = (QRF_SORTDATA & features) != 0; - coverageExtendedFeature = (QRF_EXTENDED_COVERAGE & features) != 0; - coverageFeature = (QRF_COVERAGE & features) != 0; + coverageNodes = (QRF_COVERAGE_NODES & features) != 0; groupDataFeature = (QRF_GROUPDATA & features) != 0; propsFeature = (QRF_PROPERTIES & features) != 0; break; default: - throw new RuntimeException("Programming error"); + throw new RuntimeException("Programming error, packet " + getCode() + "Not expected."); } } @@ -221,4 +216,7 @@ public class QueryResultPacket extends Packet { public int getDataset() { return dataset; } + public short getNodesQueried() { return nodesQueried; } + public short getNodesReplied() { return nodesReplied; } + } diff --git a/container-search/src/test/java/com/yahoo/fs4/test/QueryResultTestCase.java b/container-search/src/test/java/com/yahoo/fs4/test/QueryResultTestCase.java index cdd2dc7e921..1a72216bf49 100644 --- a/container-search/src/test/java/com/yahoo/fs4/test/QueryResultTestCase.java +++ b/container-search/src/test/java/com/yahoo/fs4/test/QueryResultTestCase.java @@ -24,18 +24,24 @@ public class QueryResultTestCase extends junit.framework.TestCase { private static GlobalId gid2 = new GlobalId(new byte[] {2,2,2,2,2,2,2,2,2,2,2,2}); public void testDecodeQueryResultX() { - byte[] packetData=new byte[] {0,0,0,100, - 0,0,0,217-256, - 0,0,0,1, - 0,0,0,15, - 0,0,0,0, - 0,0,0,2, - 0,0,0,0,0,0,0,5, - 0x40,0x39,0,0,0,0,0,0, - 0,0,0,111, - 0,0,0,97, - 1,1,1,1,1,1,1,1,1,1,1,1, 0x40,0x37,0,0,0,0,0,0, 0,0,0,7, 0,0,0,36, - 2,2,2,2,2,2,2,2,2,2,2,2, 0x40,0x35,0,0,0,0,0,0, 0,0,0,8, 0,0,0,37}; + byte[] packetData=new byte[] { + 0,0,0,100, + 0,0,0,217-256, + 0,0,0,1, + 0,0,0,3, + 0,0,0,0, + 0,0,0,2, + 0,0,0,0,0,0,0,5, + 0x40,0x39,0,0,0,0,0,0, + 0,0,0,111, + 0,0,0,97, + 0,0,0,0,0,0,0,89, + 0,0,0,0,0,0,0,90, + 0,0,0,0,0,0,0,91, + 0,0,0,1, + 1,1,1,1,1,1,1,1,1,1,1,1, 0x40,0x37,0,0,0,0,0,0, 0,0,0,7, 0,0,0,36, + 2,2,2,2,2,2,2,2,2,2,2,2, 0x40,0x35,0,0,0,0,0,0, 0,0,0,8, 0,0,0,37 + }; ByteBuffer buffer=ByteBuffer.allocate(200); buffer.put(packetData); buffer.flip(); @@ -50,6 +56,10 @@ public class QueryResultTestCase extends junit.framework.TestCase { assertEquals(25,result.getMaxRank()); assertEquals(111,result.getDocstamp()); assertEquals(97,result.getDataset()); + assertEquals(89, result.getCoverageDocs()); + assertEquals(90, result.getActiveDocs()); + assertEquals(91, result.getSoonActiveDocs()); + assertEquals(1, result.getDegradedReason()); assertEquals(2,result.getDocuments().size()); DocumentInfo document1= result.getDocuments().get(0); @@ -65,18 +75,26 @@ public class QueryResultTestCase extends junit.framework.TestCase { } public void testDecodeQueryResultMoreHits() { - byte[] packetData=new byte[] {0,0,0,100, - 0,0,0,217-256, - 0,0,0,1, - 0,0,0,15, - 0,0,0,0, - 0,0,0,2, - 0,0,0,0,0,0,0,5, - 0x40,0x39,0,0,0,0,0,0, - 0,0,0,111, - 0,0,0,97, - 1,1,1,1,1,1,1,1,1,1,1,1, 0x40,0x37,0,0,0,0,0,0, 0,0,0,7, 0,0,0,36, - 2,2,2,2,2,2,2,2,2,2,2,2, 0x40,0x35,0,0,0,0,0,0, 0,0,0,8, 0,0,0,37}; + byte[] packetData=new byte[] { + 0,0,0,100, + 0,0,0,217-256, + 0,0,0,1, + 0,0,0,7, + 0,0,0,0, + 0,0,0,2, + 0,0,0,0,0,0,0,5, + 0x40,0x39,0,0,0,0,0,0, + 0,0,0,111, + 0,0,0,97, + 0,0,0,0,0,0,0,89, + 0,0,0,0,0,0,0,90, + 0,0,0,0,0,0,0,91, + 0,0,0,1, + 0,6, + 0,5, + 1,1,1,1,1,1,1,1,1,1,1,1, 0x40,0x37,0,0,0,0,0,0, 0,0,0,7, 0,0,0,36, + 2,2,2,2,2,2,2,2,2,2,2,2, 0x40,0x35,0,0,0,0,0,0, 0,0,0,8, 0,0,0,37 + }; ByteBuffer buffer=ByteBuffer.allocate(200); buffer.put(packetData); buffer.flip(); @@ -89,5 +107,7 @@ public class QueryResultTestCase extends junit.framework.TestCase { assertEquals(gid1,document1.getGlobalId()); DocumentInfo document2= result.getDocuments().get(1); assertEquals(gid2,document2.getGlobalId()); + assertEquals(6, result.getNodesQueried()); + assertEquals(5, result.getNodesReplied()); } } |