コード例 #1
0
def __generate_property_input_iterator(self, values_iterator, parameters):
    chunk = Properties_pb2.PropertyInputChunk()
    chunk.params.CopyFrom(parameters)
    yield chunk

    for values in values_iterator:
        valmsg = Properties_pb2.PropertyChunk(values=values)
        chunk.values.CopyFrom(valmsg)
        yield chunk
コード例 #2
0
def __generate_property_input_chunks(self, array, parameters):
    index = -1
    while index < len(array):
        chunk = Properties_pb2.PropertyInputChunk()
        if index == -1:
            chunk.params.CopyFrom(parameters)
            index += 1
        else:
            actual_chunk_size = min(len(array) - index + 1, self.chunk_size)
            chunk.values.CopyFrom(
                Properties_pb2.PropertyChunk(values=array[index:index +
                                                          actual_chunk_size]))
            index += actual_chunk_size

        yield chunk
    # Final empty message to signal completion
    chunk = Properties_pb2.PropertyInputChunk()
    yield chunk