Java Code Examples for com.esotericsoftware.kryo.io.Output#write()

The following examples show how to use com.esotericsoftware.kryo.io.Output#write() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Cardinality.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Override
public void write(Kryo kryo, Output output, Boolean reducedResponse) {
    super.writeMetadata(kryo, output, reducedResponse);
    
    output.writeString(this.content.lower);
    output.writeString(this.content.upper);
    byte[] cardArray;
    try {
        cardArray = this.content.estimate.getBytes();
        output.writeInt(cardArray.length);
        output.write(cardArray);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    
}
 
Example 2
Source File: CpxVariantCanonicalRepresentation.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void serialize(final Kryo kryo, final Output output) {
    output.writeString(affectedRefRegion.getContig());
    output.writeInt(affectedRefRegion.getStart());
    output.writeInt(affectedRefRegion.getEnd());

    output.writeInt(referenceSegments.size());
    for (final SimpleInterval segment : referenceSegments){
        output.writeString(segment.getContig());
        output.writeInt(segment.getStart());
        output.writeInt(segment.getEnd());
    }

    output.writeInt(eventDescriptions.size());
    for (final String description: eventDescriptions)
        output.writeString(description);

    output.writeInt(altSeq.length);
    output.write(altSeq);
}
 
Example 3
Source File: PercentileCounterSerializer.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Kryo kryo, Output output, PercentileCounter counter) {
    int length = counter.getRegisters().byteSize();
    ByteBuffer buffer = ByteBuffer.allocate(length);
    counter.getRegisters().asSmallBytes(buffer);
    output.writeDouble(counter.getCompression());
    output.writeDouble(counter.getQuantileRatio());
    output.writeInt(buffer.position());
    output.write(buffer.array(), 0, buffer.position());
}
 
Example 4
Source File: PyObjectSerializer.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public void write(Kryo kryo, Output output, PyObject po) {
	try {
		byte[] serPo = SerializationUtils.serializeObject(po);
		output.writeInt(serPo.length);
		output.write(serPo);
	} catch (IOException e) {
		throw new KryoException("Failed to serialize object.", e);
	}
}
 
Example 5
Source File: PercentileCounterSerializer.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Kryo kryo, Output output, PercentileCounter counter) {
    int length = counter.getRegisters().byteSize();
    ByteBuffer buffer = ByteBuffer.allocate(length);
    counter.getRegisters().asSmallBytes(buffer);
    output.writeDouble(counter.getCompression());
    output.writeDouble(counter.getQuantileRatio());
    output.writeInt(buffer.position());
    output.write(buffer.array(), 0, buffer.position());
}
 
Example 6
Source File: AffixSerde.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(T object, Output output)
{
  if (prefix != null && prefix.length > 0) {
    output.write(prefix);
  }
  serde.serialize(object, output);
  if (suffix != null && suffix.length > 0) {
    output.write(suffix);
  }
}
 
Example 7
Source File: PercentileCounterSerializer.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Kryo kryo, Output output, PercentileCounter counter) {
    int length = counter.getRegisters().byteSize();
    ByteBuffer buffer = ByteBuffer.allocate(length);
    counter.getRegisters().asSmallBytes(buffer);
    output.writeDouble(counter.getCompression());
    output.writeDouble(counter.getQuantileRatio());
    output.writeInt(buffer.position());
    output.write(buffer.array(), 0, buffer.position());
}
 
Example 8
Source File: EventFields.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Kryo kryo, Output output) {
    // Write out the number of entries;
    output.writeInt(map.size(), true);
    
    for (Entry<String,FieldValue> entry : map.entries()) {
        // Write the key
        output.writeString(entry.getKey());
        
        // Write the fields in the value
        byte[] vis = entry.getValue().getVisibility().getExpression();
        
        if (vis == null) {
            vis = new byte[0];
        }
        
        output.writeInt(vis.length, true);
        output.write(vis);
        
        output.writeInt(entry.getValue().getValue().length, true);
        output.write(entry.getValue().getValue());
        
        if (null != entry.getValue().getContext()) {
            output.writeBoolean(true);
            output.writeString(entry.getValue().getContext());
        } else {
            output.writeBoolean(false);
        }
        
        if (null != entry.getValue().isHit()) {
            output.writeBoolean(true);
            output.writeBoolean(entry.getValue().isHit());
        } else {
            output.writeBoolean(false);
        }
    }
}
 
Example 9
Source File: PersistableSerializer.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public void write(final Kryo kryo, final Output output, final Persistable object) {

  // Persistence utils includes classId as short in front of persistable
  // object.
  final byte[] serializedObj = PersistenceUtils.toBinary(object);
  final int objLength = serializedObj.length;
  output.writeInt(objLength);
  output.write(serializedObj);
}
 
Example 10
Source File: JSONKryoSerializer.java    From opensoc-streaming with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Kryo kryo, Output output, JSONObject json) {

	byte[] bytes = jsonSerde.toBytes(json);
	output.writeInt(bytes.length);
	output.write(bytes);
}
 
Example 11
Source File: PTContainer.java    From Bats with Apache License 2.0 5 votes vote down vote up
@Override
public void write(final Output out) throws KryoException
{
  out.writeInt(container.getId());
  // state
  out.writeInt(container.getState().ordinal());
  // external id
  out.writeString(container.getExternalId());
  // resource priority
  out.writeInt(container.getResourceRequestPriority());
  // memory required
  out.writeInt(container.getRequiredMemoryMB());
  // memory allocated
  out.writeInt(container.getAllocatedMemoryMB());
  // vcores required
  out.writeInt(container.getRequiredVCores());
  // vcores allocated
  out.writeInt(container.getAllocatedVCores());
  // buffer server address
  InetSocketAddress addr = container.bufferServerAddress;
  if (addr != null) {
    out.writeString(addr.getHostName());
    out.writeInt(addr.getPort());
  } else {
    out.writeString(null);
  }
  // host
  out.writeString(container.host);
  out.writeString(container.nodeHttpAddress);
  out.writeInt((container.bufferServerToken == null) ? -1 : container.bufferServerToken.length);
  if (container.bufferServerToken != null) {
    out.write(container.bufferServerToken);
  }
}
 
Example 12
Source File: FeatureSerializer.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public void write(final Kryo arg0, final Output arg1, final SimpleFeature arg2) {
  final FeatureWritable fw = new FeatureWritable(arg2.getFeatureType());
  fw.setFeature(arg2);
  final ByteArrayOutputStream bos = new ByteArrayOutputStream();
  try (DataOutputStream os = new DataOutputStream(bos)) {
    fw.write(os);
    os.flush();
    final byte[] data = bos.toByteArray();
    arg1.writeInt(data.length);
    arg1.write(data);
  } catch (final IOException e) {
    LOGGER.error("Cannot serialize Simple Feature", e);
  }
}
 
Example 13
Source File: MatcherList.java    From yauaa with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Kryo kryo, Output output, MatcherList object) {
    if (object.size > 0) {
        throw new IllegalStateException("Cannot serialize MatcherList with a non-zero size.");
    }

    output.write(object.maxSize);
}
 
Example 14
Source File: GridCoverageWritableSerializer.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public void write(final Kryo arg0, final Output arg1, final GridCoverageWritable arg2) {
  final ByteArrayOutputStream bos = new ByteArrayOutputStream();
  try (DataOutputStream os = new DataOutputStream(bos)) {
    arg2.write(os);
    os.flush();
    final byte[] data = bos.toByteArray();
    arg1.writeInt(data.length);
    arg1.write(data);
  } catch (final IOException e) {
    LOGGER.error("Cannot serialize GridCoverageWritable", e);
  }
}
 
Example 15
Source File: PTContainer.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void write(final Output out) throws KryoException
{
  out.writeInt(container.getId());
  // state
  out.writeInt(container.getState().ordinal());
  // external id
  out.writeString(container.getExternalId());
  // resource priority
  out.writeInt(container.getResourceRequestPriority());
  // memory required
  out.writeInt(container.getRequiredMemoryMB());
  // memory allocated
  out.writeInt(container.getAllocatedMemoryMB());
  // vcores required
  out.writeInt(container.getRequiredVCores());
  // vcores allocated
  out.writeInt(container.getAllocatedVCores());
  // buffer server address
  InetSocketAddress addr = container.bufferServerAddress;
  if (addr != null) {
    out.writeString(addr.getHostName());
    out.writeInt(addr.getPort());
  } else {
    out.writeString(null);
  }
  // host
  out.writeString(container.host);
  out.writeString(container.nodeHttpAddress);
  out.writeInt((container.bufferServerToken == null) ? -1 : container.bufferServerToken.length);
  if (container.bufferServerToken != null) {
    out.write(container.bufferServerToken);
  }
}
 
Example 16
Source File: AbstractUserAgentAnalyzer.java    From yauaa with Apache License 2.0 4 votes vote down vote up
@Override
public void write(Kryo kryo, Output output, AbstractUserAgentAnalyzerDirect object) {
    output.write(((AbstractUserAgentAnalyzer)object).cacheSize);
}
 
Example 17
Source File: UTF8String.java    From Mycat2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void write(Kryo kryo, Output out) {
  byte[] bytes = getBytes();
  out.writeInt(bytes.length);
  out.write(bytes);
}
 
Example 18
Source File: KryoByteBufferSerializer.java    From jstorm with Apache License 2.0 4 votes vote down vote up
@Override
public void write(Kryo kryo, Output output, ByteBuffer object) {
    output.writeInt(object.array().length);
    output.write(object.array());
}
 
Example 19
Source File: UserSerializer.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public void write(Kryo kryo, Output output, User user) {
    output.writeString(user.getEmail());
    output.writeString(user.getUsername());
    output.write(user.getAge());
}
 
Example 20
Source File: KryoClearedBufferTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void write(Kryo kryo, Output output, TestRecord object) {
	output.writeInt(object.buffer.length);
	output.write(object.buffer);
}