org.apache.flink.types.Value.read()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中org.apache.flink.types.Value.read()方法的一些代码示例,展示了Value.read()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Value.read()方法的具体详情如下:
包路径:org.apache.flink.types.Value
类名称:Value
方法名:read

Value.read介绍

暂无

代码示例

代码示例来源:origin: apache/flink

@Override
public T deserialize(T reuse, DataInputView source) throws IOException {
  reuse.read(source);
  return reuse;
}

代码示例来源:origin: apache/flink

@Override
public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
  if (reference == null) {
    reference = InstantiationUtil.instantiate(type, Value.class);
  }
  if (tempReference == null) {
    tempReference = InstantiationUtil.instantiate(type, Value.class);
  }
  
  reference.read(firstSource);
  tempReference.read(secondSource);
  int comp = reference.compareTo(tempReference);
  return ascendingComparison ? comp : -comp;
}

代码示例来源:origin: apache/flink

@Override
public void read(final DataInputView in) throws IOException {
  int size = in.readInt();
  this.map.clear();
  try {
    for (; size > 0; size--) {
      final K key = this.keyClass.newInstance();
      final V val = this.valueClass.newInstance();
      key.read(in);
      val.read(in);
      this.map.put(key, val);
    }
  } catch (final InstantiationException | IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: apache/flink

@Override
public void read(final DataInputView in) throws IOException {
  int size = in.readInt();
  this.list.clear();
  try {
    for (; size > 0; size--) {
      final V val = this.valueClass.newInstance();
      val.read(in);
      this.list.add(val);
    }
  } catch (final InstantiationException e) {
    throw new RuntimeException(e);
  } catch (final IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: apache/flink

/**
 * Deserializes the given object from the binary string, starting at the given position.
 * If the deserialization asks for more that <code>limit - offset</code> bytes, than 
 * an exception is thrown.
 * 
 * @param <T> The generic type of the value to be deserialized.
 * @param target The object to deserialize the data into.
 * @param offset The offset in the binary string.
 * @param limit The limit in the binary string.
 */
private <T extends Value> void deserialize(T target, int offset, int limit, int fieldNumber) {
  final InternalDeSerializer serializer = this.serializer;
  serializer.memory = this.binaryData;
  serializer.position = offset;
  serializer.end = limit;
  try {
    target.read(serializer);
  }
  catch (Exception e) {
    throw new DeserializationException("Error reading field " + fieldNumber + " as " + target.getClass().getName(), e);
  }
}

代码示例来源:origin: apache/flink

@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
  if (this.copyInstance == null) {
    this.copyInstance = InstantiationUtil.instantiate(type);
  }
  
  this.copyInstance.read(source);
  this.copyInstance.write(target);
}

代码示例来源:origin: org.apache.flink/flink-core

@Override
public T deserialize(T reuse, DataInputView source) throws IOException {
  reuse.read(source);
  return reuse;
}

代码示例来源:origin: com.alibaba.blink/flink-core

@Override
public T deserialize(T reuse, DataInputView source) throws IOException {
  reuse.read(source);
  return reuse;
}

代码示例来源:origin: org.apache.flink/flink-core

@Override
public void read(final DataInputView in) throws IOException {
  int size = in.readInt();
  this.map.clear();
  try {
    for (; size > 0; size--) {
      final K key = this.keyClass.newInstance();
      final V val = this.valueClass.newInstance();
      key.read(in);
      val.read(in);
      this.map.put(key, val);
    }
  } catch (final InstantiationException | IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.apache.flink/flink-core

@Override
public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
  if (reference == null) {
    reference = InstantiationUtil.instantiate(type, Value.class);
  }
  if (tempReference == null) {
    tempReference = InstantiationUtil.instantiate(type, Value.class);
  }
  
  reference.read(firstSource);
  tempReference.read(secondSource);
  int comp = reference.compareTo(tempReference);
  return ascendingComparison ? comp : -comp;
}

代码示例来源:origin: com.alibaba.blink/flink-core

@Override
public void read(final DataInputView in) throws IOException {
  int size = in.readInt();
  this.map.clear();
  try {
    for (; size > 0; size--) {
      final K key = this.keyClass.newInstance();
      final V val = this.valueClass.newInstance();
      key.read(in);
      val.read(in);
      this.map.put(key, val);
    }
  } catch (final InstantiationException | IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.alibaba.blink/flink-core

@Override
public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
  if (reference == null) {
    reference = InstantiationUtil.instantiate(type, Value.class);
  }
  if (tempReference == null) {
    tempReference = InstantiationUtil.instantiate(type, Value.class);
  }
  
  reference.read(firstSource);
  tempReference.read(secondSource);
  int comp = reference.compareTo(tempReference);
  return ascendingComparison ? comp : -comp;
}

代码示例来源:origin: com.alibaba.blink/flink-core

@Override
public void read(final DataInputView in) throws IOException {
  int size = in.readInt();
  this.list.clear();
  try {
    for (; size > 0; size--) {
      final V val = this.valueClass.newInstance();
      val.read(in);
      this.list.add(val);
    }
  } catch (final InstantiationException e) {
    throw new RuntimeException(e);
  } catch (final IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.apache.flink/flink-core

@Override
public void read(final DataInputView in) throws IOException {
  int size = in.readInt();
  this.list.clear();
  try {
    for (; size > 0; size--) {
      final V val = this.valueClass.newInstance();
      val.read(in);
      this.list.add(val);
    }
  } catch (final InstantiationException e) {
    throw new RuntimeException(e);
  } catch (final IllegalAccessException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.alibaba.blink/flink-core

/**
 * Deserializes the given object from the binary string, starting at the given position.
 * If the deserialization asks for more that <code>limit - offset</code> bytes, than 
 * an exception is thrown.
 * 
 * @param <T> The generic type of the value to be deserialized.
 * @param target The object to deserialize the data into.
 * @param offset The offset in the binary string.
 * @param limit The limit in the binary string.
 */
private <T extends Value> void deserialize(T target, int offset, int limit, int fieldNumber) {
  final InternalDeSerializer serializer = this.serializer;
  serializer.memory = this.binaryData;
  serializer.position = offset;
  serializer.end = limit;
  try {
    target.read(serializer);
  }
  catch (Exception e) {
    throw new DeserializationException("Error reading field " + fieldNumber + " as " + target.getClass().getName(), e);
  }
}

代码示例来源:origin: org.apache.flink/flink-core

/**
 * Deserializes the given object from the binary string, starting at the given position.
 * If the deserialization asks for more that <code>limit - offset</code> bytes, than 
 * an exception is thrown.
 * 
 * @param <T> The generic type of the value to be deserialized.
 * @param target The object to deserialize the data into.
 * @param offset The offset in the binary string.
 * @param limit The limit in the binary string.
 */
private <T extends Value> void deserialize(T target, int offset, int limit, int fieldNumber) {
  final InternalDeSerializer serializer = this.serializer;
  serializer.memory = this.binaryData;
  serializer.position = offset;
  serializer.end = limit;
  try {
    target.read(serializer);
  }
  catch (Exception e) {
    throw new DeserializationException("Error reading field " + fieldNumber + " as " + target.getClass().getName(), e);
  }
}

代码示例来源:origin: com.alibaba.blink/flink-core

@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
  if (this.copyInstance == null) {
    this.copyInstance = InstantiationUtil.instantiate(type);
  }
  
  this.copyInstance.read(source);
  this.copyInstance.write(target);
}

代码示例来源:origin: org.apache.flink/flink-core

@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
  if (this.copyInstance == null) {
    this.copyInstance = InstantiationUtil.instantiate(type);
  }
  
  this.copyInstance.read(source);
  this.copyInstance.write(target);
}

代码示例来源:origin: dbs-leipzig/gradoop

public static <T extends Value> T writeAndReadValue(Class<T> clazz, T in) throws Exception {
 // write to byte[]
 java.io.ByteArrayOutputStream outStream = new java.io.ByteArrayOutputStream();
 DataOutputView dataOutputView = new DataOutputViewStreamWrapper(outStream);
 in.write(dataOutputView);
 T out;
 try {
  out = clazz.newInstance();
 } catch (Exception e) {
  e.printStackTrace();
  throw new IOException("Cannot initialize the class: " + clazz);
 }
 // read from byte[]
 ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
 DataInputView dataInputView = new DataInputViewStreamWrapper(inStream);
 out.read(dataInputView);
 return out;
}

代码示例来源:origin: dbs-leipzig/gradoop

public static <T extends Value> T writeAndReadFields(Class<T> clazz, T in) throws IOException {
 // write to byte[]
 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 DataOutputView outputView = new DataOutputViewStreamWrapper(outputStream);
 in.write(outputView);
 outputStream.flush();
 T out;
 try {
  out = clazz.newInstance();
 } catch (Exception e) {
  e.printStackTrace();
  throw new IOException("Cannot initialize the class: " + clazz);
 }
 // read from byte[]
 ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
 DataInputView inputView = new DataInputViewStreamWrapper(inputStream);
 out.read(inputView);
 return out;
}

相关文章

微信公众号

最新文章

更多