aboutsummaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-04-30 12:56:55 +0200
committerJon Bratseth <bratseth@oath.com>2018-04-30 12:56:55 +0200
commit4ece955f7e12196bb31171e9898428b9a252ed02 (patch)
tree461f327a850ddd97b8ed7b7e2c9f9ed1121585e8 /container-search
parent0033ab506c660dfe176d2f4bd3d77d6e7338add5 (diff)
Reorganize - no functional changes
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java188
1 files changed, 77 insertions, 111 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
index 1f7bc9a2918..8056e0a02bc 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
@@ -56,34 +56,8 @@ public class FastHit extends Hit {
setPartId(0);
}
- @Override
- public String toString() {
- return super.toString() + " [fasthit, globalid: " + globalId + ", partId: "
- + partId + ", distributionkey: " + distributionKey + "]";
- }
-
- public static String asHexString(GlobalId gid) {
- StringBuilder sb = new StringBuilder();
- byte[] rawGid = gid.getRawId();
- for (byte b : rawGid) {
- String hex = Integer.toHexString(0xFF & b);
- if (hex.length() == 1) {
- sb.append('0');
- }
- sb.append(hex);
- }
- return sb.toString();
- }
-
- @Override
- public int hashCode() {
- if (getId() == null) {
- throw new IllegalStateException("This hit must have a 'uri' field, and this fild must be filled through " +
- "Execution.fill(Result)) before hashCode() is accessed.");
- } else {
- return super.hashCode();
- }
- }
+ /** Returns false - this is a concrete hit containing requested content */
+ public boolean isMeta() { return false; }
@Override
public URI getId() {
@@ -107,45 +81,77 @@ public class FastHit extends Hit {
return super.getId();
}
- return getIndexUri();
- }
-
- /**
- * The uri of the index location of this hit ("index:[source]/[partid]/[id]").
- * This is the uri if no other uri is assigned
- *
- * @return uri to the index.
- */
- private URI getIndexUri() {
+ // Fallback to index:[source]/[partid]/[id]
if (indexUri != null) return indexUri;
-
indexUri = new URI("index:" + getSourceNumber() + "/" + getPartId() + "/" + asHexString(getGlobalId()));
return indexUri;
}
/** Returns the global id of this document in the backend node which produced it */
- public GlobalId getGlobalId() {
- return globalId;
- }
+ public GlobalId getGlobalId() { return globalId; }
- public void setGlobalId(GlobalId globalId) {
- this.globalId = globalId;
- }
+ public void setGlobalId(GlobalId globalId) { this.globalId = globalId; }
- public int getPartId() {
- return partId;
- }
+ public int getPartId() { return partId; }
/**
* Sets the part id number, which specifies the node where this hit is
* found. The row count is used to decode the part id into a column and a
* row number: the number of n least significant bits required to hold the
* highest row number are the row bits, the rest are column bits.
- *
- * @param partId partition id
*/
public void setPartId(int partId) { this.partId = partId; }
+ /** Returns the index of the node this hit originated at */
+ public int getDistributionKey() { return distributionKey; }
+
+ /** Returns the index of the node this hit originated at */
+ public void setDistributionKey(int distributionKey) { this.distributionKey = distributionKey; }
+
+ /**
+ * Add the binary data common for the query packet to a Vespa backend and a
+ * summary fetch packet to a Vespa backend. This method can only be called
+ * once for a single hit.
+ *
+ * @param queryPacketData binary data from a query packet resulting in this hit
+ * @throws IllegalStateException if the method is called more than once
+ * @throws NullPointerException if trying to set query packet data to null
+ */
+ public void setQueryPacketData(QueryPacketData queryPacketData) {
+ if (this.queryPacketData != null)
+ throw new IllegalStateException("Query packet data already set to "
+ + this.queryPacketData + ", tried to set it to " + queryPacketData);
+ if (queryPacketData == null)
+ throw new NullPointerException("Query packet data reference can not be set to null.");
+ this.queryPacketData = queryPacketData;
+ }
+
+ /**
+ * Fetch binary data from the query packet which produced this hit. These
+ * data may not be available, this method will then return null.
+ *
+ * @return wrapped binary data from a query packet, or null
+ */
+ public QueryPacketData getQueryPacketData() { return queryPacketData; }
+
+ CacheKey getCacheKey() { return cacheKey; }
+
+ void setCacheKey(CacheKey cacheKey) { this.cacheKey = cacheKey; }
+
+ /** For internal use */
+ public void addSummary(DocsumDefinition docsumDef, Inspector value) {
+ reserve(docsumDef.getFieldCount());
+ for (DocsumField field : docsumDef.getFields()) {
+ String fieldName = field.getName();
+ Inspector f = value.field(fieldName);
+ if (field.getEmulConfig().forceFillEmptyFields() || f.valid()) {
+ if (super.getField(fieldName) == null) {
+ setField(fieldName, field.convert(f));
+ }
+ }
+ }
+ }
+
/**
* <p>Returns a field value from this Hit. The value is either a stored value from the Document represented by
* this Hit, or a generated value added during later processing.</p>
@@ -182,73 +188,33 @@ public class FastHit extends Hit {
return super.getField(key);
}
- /** Returns false - this is a concrete hit containing requested content */
- public boolean isMeta() {
- return false;
- }
-
- /** Returns the index of the node this hit originated at */
- public int getDistributionKey() {
- return distributionKey;
- }
-
- /** Returns the index of the node this hit originated at */
- public void setDistributionKey(int distributionKey) {
- this.distributionKey = distributionKey;
+ @Override
+ public String toString() {
+ return super.toString() + " [fasthit, globalid: " + globalId + ", partId: "
+ + partId + ", distributionkey: " + distributionKey + "]";
}
- /** For internal use */
- public void addSummary(DocsumDefinition docsumDef, Inspector value) {
- reserve(docsumDef.getFieldCount());
- for (DocsumField field : docsumDef.getFields()) {
- String fieldName = field.getName();
- Inspector f = value.field(fieldName);
- if (field.getEmulConfig().forceFillEmptyFields() || f.valid()) {
- setDocsumFieldIfNotPresent(fieldName, field.convert(f));
- }
+ @Override
+ public int hashCode() {
+ if (getId() == null) {
+ throw new IllegalStateException("This hit must have a 'uri' field, and this fild must be filled through " +
+ "Execution.fill(Result)) before hashCode() is accessed.");
+ } else {
+ return super.hashCode();
}
}
- private void setDocsumFieldIfNotPresent(String fieldName, Object value) {
- if (super.getField(fieldName) == null) {
- setField(fieldName, value);
+ public static String asHexString(GlobalId gid) {
+ StringBuilder sb = new StringBuilder();
+ byte[] rawGid = gid.getRawId();
+ for (byte b : rawGid) {
+ String hex = Integer.toHexString(0xFF & b);
+ if (hex.length() == 1) {
+ sb.append('0');
+ }
+ sb.append(hex);
}
- }
-
- /**
- * Add the binary data common for the query packet to a Vespa backend and a
- * summary fetch packet to a Vespa backend. This method can only be called
- * once for a single hit.
- *
- * @param queryPacketData binary data from a query packet resulting in this hit
- * @throws IllegalStateException if the method is called more than once
- * @throws NullPointerException if trying to set query packet data to null
- */
- public void setQueryPacketData(QueryPacketData queryPacketData) {
- if (this.queryPacketData != null)
- throw new IllegalStateException("Query packet data already set to "
- + this.queryPacketData + ", tried to set it to " + queryPacketData);
- if (queryPacketData == null)
- throw new NullPointerException("Query packet data reference can not be set to null.");
- this.queryPacketData = queryPacketData;
- }
-
- /**
- * Fetch binary data from the query packet which produced this hit. These
- * data may not be available, this method will then return null.
- *
- * @return wrapped binary data from a query packet, or null
- */
- public QueryPacketData getQueryPacketData() {
- return queryPacketData;
- }
-
- CacheKey getCacheKey() {
- return cacheKey;
- }
-
- void setCacheKey(CacheKey cacheKey) {
- this.cacheKey = cacheKey;
+ return sb.toString();
}
}