org.apache.samza.Partition类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(224)

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

Partition介绍

[英]A numbered, ordered partition of a stream.
[中]流的一个编号有序的分区。

代码示例

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

@Override
 public Object deserializeKey(String sspString, DeserializationContext ctxt) throws IOException {
  int idx = sspString.indexOf('.');
  int lastIdx = sspString.lastIndexOf('.');
  if (idx < 0 || lastIdx < 0) {
   throw new IllegalArgumentException("System stream partition expected in format 'system.stream.partition");
  }
  return new SystemStreamPartition(
    new SystemStream(sspString.substring(0, idx), sspString.substring(idx + 1, lastIdx)),
    new Partition(Integer.parseInt(sspString.substring(lastIdx + 1))));
 }
}

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

@Override
public String toString() {
 return "SystemStreamPartition [" + system + ", " + stream + ", " + partition.getPartitionId() + "]";
}

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

@Override
 public int compareTo(SystemStreamPartition that) {
  if (this.system.compareTo(that.system) < 0) {
   return -1;
  } else if (this.system.compareTo(that.system) > 0) {
   return 1;
  }

  if (this.stream.compareTo(that.stream) < 0) {
   return -1;
  } else if (this.stream.compareTo(that.stream) > 0) {
   return 1;
  }

  if (this.partition.compareTo(that.partition) < 0) {
   return -1;
  } else if (this.partition.compareTo(that.partition) > 0) {
   return 1;
  }
  return 0;
 }
}

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

@Override
 public SystemStreamPartition getPreviousSSP(SystemStreamPartition currentSystemStreamPartition, int previousPartitionCount, int currentPartitionCount) {
  Preconditions.checkNotNull(currentSystemStreamPartition);
  Preconditions.checkArgument(currentPartitionCount % previousPartitionCount == 0,
    String.format("New partition count: %d should be a multiple of previous partition count: %d.", currentPartitionCount, previousPartitionCount));
  Partition partition = currentSystemStreamPartition.getPartition();
  Preconditions.checkNotNull(partition, String.format("SystemStreamPartition: %s cannot have null partition", currentSystemStreamPartition));
  int currentPartitionId = partition.getPartitionId();
  int previousPartitionId = currentPartitionId % previousPartitionCount;
  return new SystemStreamPartition(currentSystemStreamPartition.getSystemStream(), new Partition(previousPartitionId));
 }
}

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

private int computeHashCode() {
 final int prime = 31;
 int result = super.hashCode();
 result = prime * result + ((partition == null) ? 0 : partition.hashCode());
 return result;
}

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

@Override
public boolean equals(Object obj) {
 if (this == obj)
  return true;
 if (!super.equals(obj))
  return false;
 if (getClass() != obj.getClass())
  return false;
 SystemStreamPartition other = (SystemStreamPartition) obj;
 if (partition == null) {
  if (other.partition != null)
   return false;
 } else if (!partition.equals(other.partition))
  return false;
 return true;
}

代码示例来源:origin: org.apache.samza/samza-api

private int computeHashCode() {
 final int prime = 31;
 int result = super.hashCode();
 result = prime * result + ((partition == null) ? 0 : partition.hashCode());
 return result;
}

代码示例来源:origin: org.apache.samza/samza-api

@Override
public boolean equals(Object obj) {
 if (this == obj)
  return true;
 if (!super.equals(obj))
  return false;
 if (getClass() != obj.getClass())
  return false;
 SystemStreamPartition other = (SystemStreamPartition) obj;
 if (partition == null) {
  if (other.partition != null)
   return false;
 } else if (!partition.equals(other.partition))
  return false;
 return true;
}

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

@Override
public Map<String, SystemStreamMetadata> getSystemStreamMetadata(Set<String> streamNames) {
 return streamNames.stream()
     .collect(Collectors.toMap(Function.identity(), streamName -> new SystemStreamMetadata(streamName,
         Collections.singletonMap(new Partition(0),
             new SystemStreamMetadata.SystemStreamPartitionMetadata(null, null, null)))));
}

代码示例来源:origin: org.apache.samza/samza-api

@Override
public String toString() {
 return "SystemStreamPartition [" + system + ", " + stream + ", " + partition.getPartitionId() + "]";
}

代码示例来源:origin: org.apache.samza/samza-api

@Override
public int hashCode() {
 int result = taskName.hashCode();
 result = 31 * result + systemStreamPartitions.hashCode();
 result = 31 * result + changelogPartition.hashCode();
 return result;
}

代码示例来源:origin: org.apache.samza/samza-api

@Override
public boolean equals(Object o) {
 if (this == o) {
  return true;
 }
 if (o == null || getClass() != o.getClass()) {
  return false;
 }
 TaskModel taskModel = (TaskModel) o;
 if (!changelogPartition.equals(taskModel.changelogPartition)) {
  return false;
 }
 if (!systemStreamPartitions.equals(taskModel.systemStreamPartitions)) {
  return false;
 }
 if (!taskName.equals(taskModel.taskName)) {
  return false;
 }
 return true;
}

代码示例来源:origin: org.apache.samza/samza-api

@Override
 public int compareTo(SystemStreamPartition that) {
  if (this.system.compareTo(that.system) < 0) {
   return -1;
  } else if (this.system.compareTo(that.system) > 0) {
   return 1;
  }

  if (this.stream.compareTo(that.stream) < 0) {
   return -1;
  } else if (this.stream.compareTo(that.stream) > 0) {
   return 1;
  }

  if (this.partition.compareTo(that.partition) < 0) {
   return -1;
  } else if (this.partition.compareTo(that.partition) > 0) {
   return 1;
  }
  return 0;
 }
}

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

public static Map<Partition, List<String>> getDescriptorMapFromJson(String json) {
 try {
  @SuppressWarnings("unchecked")
  Map<String, String> rawMap = new ObjectMapper().readValue(json, HashMap.class);
  Map<Partition, List<String>> descriptorMap = new HashMap<>();
  rawMap.forEach((key, value) -> descriptorMap.put(new Partition(Integer.valueOf(key)), getPathsFromString(value)));
  return descriptorMap;
 } catch (IOException | NumberFormatException e) {
  throw new SamzaException("Failed to convert json: " + json, e);
 }
}

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

@Override
 public void serialize(Partition partition, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException, JsonProcessingException {
  jsonGenerator.writeObject(Integer.valueOf(partition.getPartitionId()));
 }
}

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

@Override
public int hashCode() {
 int result = taskName.hashCode();
 result = 31 * result + systemStreamPartitions.hashCode();
 result = 31 * result + changelogPartition.hashCode();
 result = 31 * result + taskMode.hashCode();
 return result;
}

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

@Override
public boolean equals(Object o) {
 if (this == o) {
  return true;
 }
 if (o == null || getClass() != o.getClass()) {
  return false;
 }
 TaskModel taskModel = (TaskModel) o;
 if (!changelogPartition.equals(taskModel.changelogPartition)) {
  return false;
 }
 if (!systemStreamPartitions.equals(taskModel.systemStreamPartitions)) {
  return false;
 }
 if (!taskName.equals(taskModel.taskName)) {
  return false;
 }
 if (!taskMode.equals(taskModel.taskMode)) {
  return false;
 }
 return true;
}

代码示例来源:origin: org.apache.samza/samza-core_2.11

@Override
 public Object deserializeKey(String sspString, DeserializationContext ctxt) throws IOException {
  int idx = sspString.indexOf('.');
  int lastIdx = sspString.lastIndexOf('.');
  if (idx < 0 || lastIdx < 0) {
   throw new IllegalArgumentException("System stream partition expected in format 'system.stream.partition");
  }
  return new SystemStreamPartition(
    new SystemStream(sspString.substring(0, idx), sspString.substring(idx + 1, lastIdx)),
    new Partition(Integer.parseInt(sspString.substring(lastIdx + 1))));
 }
}

代码示例来源:origin: org.apache.samza/samza-core_2.11

@Override
 public void serialize(Partition partition, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException, JsonProcessingException {
  jsonGenerator.writeObject(Integer.valueOf(partition.getPartitionId()));
 }
}

代码示例来源:origin: org.apache.samza/samza-core_2.12

@Override
 public Object deserializeKey(String sspString, DeserializationContext ctxt) throws IOException {
  int idx = sspString.indexOf('.');
  int lastIdx = sspString.lastIndexOf('.');
  if (idx < 0 || lastIdx < 0) {
   throw new IllegalArgumentException("System stream partition expected in format 'system.stream.partition");
  }
  return new SystemStreamPartition(
    new SystemStream(sspString.substring(0, idx), sspString.substring(idx + 1, lastIdx)),
    new Partition(Integer.parseInt(sspString.substring(lastIdx + 1))));
 }
}

相关文章