@Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeInt(numDocs);
   out.writeInt(termsList.size());
   for (TermInfo ti : termsList) ti.writeTo(out);
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   out.writeString(term);
   out.writeInt(startOffset);
   out.writeInt(endOffset);
   out.writeVInt(position);
   out.writeOptionalString(type);
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeString(index);
   out.writeInt(shardId);
   timeout.writeTo(out);
 }
Example #4
0
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   if (out.getVersion().onOrAfter(version1)) {
     out.writeInt(value2);
   }
 }
 @Override
 protected void doWriteTo(StreamOutput out) throws IOException {
   out.writeString(queryText);
   out.writeInt(fieldsAndWeights.size());
   for (Map.Entry<String, Float> entry : fieldsAndWeights.entrySet()) {
     out.writeString(entry.getKey());
     out.writeFloat(entry.getValue());
   }
   out.writeInt(flags);
   out.writeOptionalString(analyzer);
   defaultOperator.writeTo(out);
   out.writeBoolean(settings.lowercaseExpandedTerms());
   out.writeBoolean(settings.lenient());
   out.writeBoolean(settings.analyzeWildcard());
   out.writeString(settings.locale().toLanguageTag());
   out.writeOptionalString(minimumShouldMatch);
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeInt(simple.size());
   for (String t : simple) {
     out.writeString(t);
   }
 }
Example #7
0
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   out.writeLong(refreshInterval);
   out.writeInt(availableProcessors);
   out.writeInt(allocatedProcessors);
   out.writeOptionalString(name);
   out.writeOptionalString(arch);
   out.writeOptionalString(version);
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   if (states != null) {
     out.writeInt(states.size());
     for (KnapsackState state : states) {
       state.writeTo(out);
     }
   }
 }
Example #9
0
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   out.writeVInt(userData.size());
   for (Map.Entry<String, String> entry : userData.entrySet()) {
     out.writeString(entry.getKey());
     out.writeString(entry.getValue());
   }
   out.writeLong(generation);
   out.writeOptionalString(id);
   out.writeInt(numDocs);
 }
 public static void writeTo(IndexTemplateMetaData indexTemplateMetaData, StreamOutput out)
     throws IOException {
   out.writeUTF(indexTemplateMetaData.name());
   out.writeInt(indexTemplateMetaData.order());
   out.writeUTF(indexTemplateMetaData.template());
   ImmutableSettings.writeSettingsToStream(indexTemplateMetaData.settings(), out);
   out.writeVInt(indexTemplateMetaData.mappings().size());
   for (Map.Entry<String, CompressedString> entry :
       indexTemplateMetaData.mappings().entrySet()) {
     out.writeUTF(entry.getKey());
     entry.getValue().writeTo(out);
   }
 }
  @Override
  public void writeTo(StreamOutput out) throws IOException {
    out.writeUTF(name);
    out.writeByte(comparatorType.id());
    out.writeVInt(requiredSize);
    out.writeVLong(missing);

    out.writeVInt(entries.size());
    for (IntEntry entry : entries) {
      out.writeInt(entry.term);
      out.writeVInt(entry.count());
    }
  }
 @Override
 protected void doWriteTo(StreamOutput out) throws IOException {
   ValueFormatterStreams.writeOptional(valueFormatter, out);
   out.writeInt(keys.length);
   for (int i = 0; i < keys.length; ++i) {
     out.writeDouble(keys[i]);
   }
   out.writeLong(state.getHighestToLowestValueRatio());
   ByteBuffer stateBuffer = ByteBuffer.allocate(state.getNeededByteBufferCapacity());
   state.encodeIntoCompressedByteBuffer(stateBuffer);
   out.writeByteArray(stateBuffer.array());
   out.writeBoolean(keyed);
 }
  @Override
  public void writeTo(StreamOutput out) throws IOException {
    // Encode flag
    out.writeBoolean(this.isPruned());

    // Encode size of list
    out.writeInt(set.size());

    // Encode BytesRefs
    BytesRef reusable = new BytesRef();
    for (int i = 0; i < this.set.size(); i++) {
      this.set.get(i, reusable);
      out.writeBytesRef(reusable);
    }
  }
Example #14
0
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   out.writeLong(pid);
   out.writeString(version);
   out.writeString(vmName);
   out.writeString(vmVersion);
   out.writeString(vmVendor);
   out.writeLong(startTime);
   out.writeInt(inputArguments.length);
   for (String inputArgument : inputArguments) {
     out.writeString(inputArgument);
   }
   out.writeString(bootClassPath);
   out.writeString(classPath);
   out.writeInt(systemProperties.size());
   for (Map.Entry<String, String> entry : systemProperties.entrySet()) {
     out.writeString(entry.getKey());
     out.writeString(entry.getValue());
   }
   mem.writeTo(out);
   out.writeStringArray(gcCollectors);
   out.writeStringArray(memoryPools);
   out.writeString(useCompressedOops);
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeUTF(cause);
   out.writeUTF(name);
   out.writeUTF(template);
   out.writeInt(order);
   out.writeBoolean(create);
   writeSettingsToStream(settings, out);
   timeout.writeTo(out);
   out.writeVInt(mappings.size());
   for (Map.Entry<String, String> entry : mappings.entrySet()) {
     out.writeUTF(entry.getKey());
     out.writeUTF(entry.getValue());
   }
 }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeString(cause);
   out.writeString(name);
   out.writeString(template);
   out.writeInt(order);
   out.writeBoolean(create);
   writeSettingsToStream(settings, out);
   timeout.writeTo(out);
   out.writeVInt(mappings.size());
   for (Map.Entry<String, String> entry : mappings.entrySet()) {
     out.writeString(entry.getKey());
     out.writeString(entry.getValue());
   }
   out.writeVInt(customs.size());
   for (Map.Entry<String, IndexMetaData.Custom> entry : customs.entrySet()) {
     out.writeString(entry.getKey());
     IndexMetaData.lookupFactorySafe(entry.getKey()).writeTo(entry.getValue(), out);
   }
 }
Example #17
0
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   out.writeString(name);
   out.writeString(type);
   out.writeInt(min);
   out.writeInt(max);
   if (keepAlive == null) {
     out.writeBoolean(false);
   } else {
     out.writeBoolean(true);
     keepAlive.writeTo(out);
   }
   if (queueSize == null) {
     out.writeBoolean(false);
   } else {
     out.writeBoolean(true);
     queueSize.writeTo(out);
   }
   out.writeBoolean(false); // here to conform with removed waitTime
   out.writeBoolean(false); // here to conform with removed rejected setting
   out.writeBoolean(false); // here to conform with queue type
 }
Example #18
0
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   super.writeTo(out);
   out.writeInt(value1);
 }
Example #19
0
  public static void writeTopDocs(StreamOutput out, TopDocs topDocs, int from) throws IOException {
    if (topDocs.scoreDocs.length - from < 0) {
      out.writeBoolean(false);
      return;
    }
    out.writeBoolean(true);
    if (topDocs instanceof TopFieldDocs) {
      out.writeBoolean(true);
      TopFieldDocs topFieldDocs = (TopFieldDocs) topDocs;

      out.writeVInt(topDocs.totalHits);
      out.writeFloat(topDocs.getMaxScore());

      out.writeVInt(topFieldDocs.fields.length);
      for (SortField sortField : topFieldDocs.fields) {
        if (sortField.getField() == null) {
          out.writeBoolean(false);
        } else {
          out.writeBoolean(true);
          out.writeString(sortField.getField());
        }
        if (sortField.getComparatorSource() != null) {
          writeSortType(
              out,
              ((IndexFieldData.XFieldComparatorSource) sortField.getComparatorSource())
                  .reducedType());
        } else {
          writeSortType(out, sortField.getType());
        }
        out.writeBoolean(sortField.getReverse());
      }

      out.writeVInt(topDocs.scoreDocs.length - from);
      int index = 0;
      for (ScoreDoc doc : topFieldDocs.scoreDocs) {
        if (index++ < from) {
          continue;
        }
        FieldDoc fieldDoc = (FieldDoc) doc;
        out.writeVInt(fieldDoc.fields.length);
        for (Object field : fieldDoc.fields) {
          if (field == null) {
            out.writeByte((byte) 0);
          } else {
            Class type = field.getClass();
            if (type == String.class) {
              out.writeByte((byte) 1);
              out.writeString((String) field);
            } else if (type == Integer.class) {
              out.writeByte((byte) 2);
              out.writeInt((Integer) field);
            } else if (type == Long.class) {
              out.writeByte((byte) 3);
              out.writeLong((Long) field);
            } else if (type == Float.class) {
              out.writeByte((byte) 4);
              out.writeFloat((Float) field);
            } else if (type == Double.class) {
              out.writeByte((byte) 5);
              out.writeDouble((Double) field);
            } else if (type == Byte.class) {
              out.writeByte((byte) 6);
              out.writeByte((Byte) field);
            } else if (type == Short.class) {
              out.writeByte((byte) 7);
              out.writeShort((Short) field);
            } else if (type == Boolean.class) {
              out.writeByte((byte) 8);
              out.writeBoolean((Boolean) field);
            } else if (type == BytesRef.class) {
              out.writeByte((byte) 9);
              out.writeBytesRef((BytesRef) field);
            } else {
              throw new IOException("Can't handle sort field value of type [" + type + "]");
            }
          }
        }

        out.writeVInt(doc.doc);
        out.writeFloat(doc.score);
      }
    } else {
      out.writeBoolean(false);
      out.writeVInt(topDocs.totalHits);
      out.writeFloat(topDocs.getMaxScore());

      out.writeVInt(topDocs.scoreDocs.length - from);
      int index = 0;
      for (ScoreDoc doc : topDocs.scoreDocs) {
        if (index++ < from) {
          continue;
        }
        out.writeVInt(doc.doc);
        out.writeFloat(doc.score);
      }
    }
  }
 @Override
 public void writeTo(StreamOutput out) throws IOException {
   out.writeOptionalText(field);
   out.writeInt(offset);
   out.writeOptionalStreamable(child);
 }
  public void writeTo(StreamOutput out, InternalSearchHits.StreamContext context)
      throws IOException {
    out.writeFloat(score);
    out.writeText(id);
    out.writeText(type);
    out.writeOptionalStreamable(nestedIdentity);
    out.writeLong(version);
    out.writeBytesReference(source);
    if (explanation == null) {
      out.writeBoolean(false);
    } else {
      out.writeBoolean(true);
      writeExplanation(out, explanation);
    }
    if (fields == null) {
      out.writeVInt(0);
    } else {
      out.writeVInt(fields.size());
      for (SearchHitField hitField : fields().values()) {
        hitField.writeTo(out);
      }
    }
    if (highlightFields == null) {
      out.writeVInt(0);
    } else {
      out.writeVInt(highlightFields.size());
      for (HighlightField highlightField : highlightFields.values()) {
        highlightField.writeTo(out);
      }
    }

    if (sortValues.length == 0) {
      out.writeVInt(0);
    } else {
      out.writeVInt(sortValues.length);
      for (Object sortValue : sortValues) {
        if (sortValue == null) {
          out.writeByte((byte) 0);
        } else {
          Class type = sortValue.getClass();
          if (type == String.class) {
            out.writeByte((byte) 1);
            out.writeString((String) sortValue);
          } else if (type == Integer.class) {
            out.writeByte((byte) 2);
            out.writeInt((Integer) sortValue);
          } else if (type == Long.class) {
            out.writeByte((byte) 3);
            out.writeLong((Long) sortValue);
          } else if (type == Float.class) {
            out.writeByte((byte) 4);
            out.writeFloat((Float) sortValue);
          } else if (type == Double.class) {
            out.writeByte((byte) 5);
            out.writeDouble((Double) sortValue);
          } else if (type == Byte.class) {
            out.writeByte((byte) 6);
            out.writeByte((Byte) sortValue);
          } else if (type == Short.class) {
            out.writeByte((byte) 7);
            out.writeShort((Short) sortValue);
          } else if (type == Boolean.class) {
            out.writeByte((byte) 8);
            out.writeBoolean((Boolean) sortValue);
          } else if (sortValue instanceof Text) {
            out.writeByte((byte) 9);
            out.writeText((Text) sortValue);
          } else {
            throw new IOException("Can't handle sort field value of type [" + type + "]");
          }
        }
      }
    }

    if (matchedQueries.length == 0) {
      out.writeVInt(0);
    } else {
      out.writeVInt(matchedQueries.length);
      for (String matchedFilter : matchedQueries) {
        out.writeString(matchedFilter);
      }
    }

    if (context.streamShardTarget() == InternalSearchHits.StreamContext.ShardTargetType.STREAM) {
      if (shard == null) {
        out.writeBoolean(false);
      } else {
        out.writeBoolean(true);
        shard.writeTo(out);
      }
    } else if (context.streamShardTarget()
        == InternalSearchHits.StreamContext.ShardTargetType.LOOKUP) {
      if (shard == null) {
        out.writeVInt(0);
      } else {
        out.writeVInt(context.shardHandleLookup().get(shard));
      }
    }

    if (innerHits == null) {
      out.writeVInt(0);
    } else {
      out.writeVInt(innerHits.size());
      for (Map.Entry<String, InternalSearchHits> entry : innerHits.entrySet()) {
        out.writeString(entry.getKey());
        entry
            .getValue()
            .writeTo(
                out,
                InternalSearchHits.streamContext()
                    .streamShardTarget(InternalSearchHits.StreamContext.ShardTargetType.NO_STREAM));
      }
    }
  }