Skip to content

Commit 6de5ed2

Browse files
committed
Rename ByteSequencer to ByteSequenceProvider
1 parent 26fba68 commit 6de5ed2

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/internal/buffer/ByteSequencer.java renamed to tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/internal/buffer/ByteSequenceProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
*
1111
* @param <T> source of bytes (byte arrays or strings)
1212
*/
13-
public class ByteSequencer<T> implements Iterable<byte[]> {
13+
public class ByteSequenceProvider<T> implements Iterable<byte[]> {
1414

1515
/**
1616
* Constructor
1717
*
1818
* @param source source of data
1919
* @param byteExtractor method that converts one value of the source into a sequence of bytes
2020
*/
21-
public ByteSequencer(NdArray<T> source, Function<T, byte[]> byteExtractor) {
21+
public ByteSequenceProvider(NdArray<T> source, Function<T, byte[]> byteExtractor) {
2222
this.source = source;
2323
this.byteExtractor = byteExtractor;
2424
}

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/internal/buffer/ByteSequenceTensorBuffer.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ public class ByteSequenceTensorBuffer extends AbstractDataBuffer<byte[]> {
5555
/**
5656
* Computes how many bytes are required to store the given data in a string buffer.
5757
*
58-
* @param byteSequencer produces sequences of bytes
58+
* @param byteSequenceProvider produces sequences of bytes
5959
* @return number of bytes required to store the data.
6060
*/
61-
public static <T> long computeSize(ByteSequencer<?> byteSequencer) {
61+
public static <T> long computeSize(ByteSequenceProvider<?> byteSequenceProvider) {
6262
// reserve space to store 64-bit offsets
63-
long size = byteSequencer.numSequences() * Long.BYTES;
63+
long size = byteSequenceProvider.numSequences() * Long.BYTES;
6464

6565
// reserve space to store length and data of each values
66-
for (byte[] elementBytes : byteSequencer) {
66+
for (byte[] elementBytes : byteSequenceProvider) {
6767
size += elementBytes.length + ByteSequenceTensorBuffer.varintLength(elementBytes.length);
6868
}
6969
return size;
@@ -77,11 +77,11 @@ public static <T> long computeSize(ByteSequencer<?> byteSequencer) {
7777
* same set of data, calling {@link #computeSize(NdArray, Function)} priory to make sure there is
7878
* enough space to store it.
7979
*
80-
* @param byteSequencer produces sequences of bytes to use as the tensor data
80+
* @param byteSequenceProvider produces sequences of bytes to use as the tensor data
8181
*/
82-
public <T> void init(ByteSequencer<T> byteSequencer) {
82+
public <T> void init(ByteSequenceProvider<T> byteSequenceProvider) {
8383
InitDataWriter writer = new InitDataWriter();
84-
byteSequencer.forEach(writer::writeNext);
84+
byteSequenceProvider.forEach(writer::writeNext);
8585
}
8686

8787
@Override

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/internal/types/TStringInitializer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.function.Consumer;
44
import java.util.function.Function;
55
import org.tensorflow.internal.buffer.ByteSequenceTensorBuffer;
6-
import org.tensorflow.internal.buffer.ByteSequencer;
6+
import org.tensorflow.internal.buffer.ByteSequenceProvider;
77
import org.tensorflow.internal.types.TStringMapper.TStringInternal;
88
import org.tensorflow.ndarray.NdArray;
99
import org.tensorflow.types.TString;
@@ -16,23 +16,23 @@
1616
public final class TStringInitializer<T> implements Consumer<TString> {
1717

1818
public TStringInitializer(NdArray<T> source, Function<T, byte[]> byteExtractor) {
19-
this.byteSequencer = new ByteSequencer<>(source, byteExtractor);
19+
this.byteSequenceProvider = new ByteSequenceProvider<>(source, byteExtractor);
2020
}
2121

2222
/**
2323
* Compute the minimum size for a tensor to hold all the data provided by the source.
2424
*
2525
* @return minimum tensor size, in bytes
26-
* @see ByteSequenceTensorBuffer#computeSize(ByteSequencer)
26+
* @see ByteSequenceTensorBuffer#computeSize(ByteSequenceProvider)
2727
*/
2828
public long computeRequiredSize() {
29-
return ByteSequenceTensorBuffer.computeSize(byteSequencer);
29+
return ByteSequenceTensorBuffer.computeSize(byteSequenceProvider);
3030
}
3131

3232
@Override
3333
public void accept(TString tensor) {
34-
((TStringInternal)tensor).init(byteSequencer);
34+
((TStringInternal)tensor).init(byteSequenceProvider);
3535
}
3636

37-
private final ByteSequencer<T> byteSequencer;
37+
private final ByteSequenceProvider<T> byteSequenceProvider;
3838
}

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/internal/types/TStringMapper.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
import java.nio.charset.Charset;
44
import java.nio.charset.StandardCharsets;
5-
import java.util.function.Function;
65
import org.tensorflow.DataType;
76
import org.tensorflow.RawTensor;
87
import org.tensorflow.TensorMapper;
98
import org.tensorflow.internal.buffer.ByteSequenceTensorBuffer;
10-
import org.tensorflow.internal.buffer.ByteSequencer;
9+
import org.tensorflow.internal.buffer.ByteSequenceProvider;
1110
import org.tensorflow.internal.buffer.TensorBuffers;
1211
import org.tensorflow.ndarray.NdArray;
1312
import org.tensorflow.ndarray.NdArrays;
@@ -40,17 +39,17 @@ interface TStringInternal extends TString {
4039
/**
4140
* Initialize the buffer of this string tensor using the provided byte sequencer.
4241
*
43-
* @param byteSequencer produces sequences of bytes to use as the tensor data
42+
* @param byteSequenceProvider produces sequences of bytes to use as the tensor data
4443
* @param <T> source of bytes ({@code byte[]} or {@code String})
4544
*/
46-
<T> void init(ByteSequencer<T> byteSequencer);
45+
<T> void init(ByteSequenceProvider<T> byteSequenceProvider);
4746
}
4847

4948
private static final class DenseTString extends DenseNdArray<String> implements TStringInternal {
5049

5150
@Override
52-
public <T> void init(ByteSequencer<T> byteSequencer) {
53-
buffer.init(byteSequencer);
51+
public <T> void init(ByteSequenceProvider<T> byteSequenceProvider) {
52+
buffer.init(byteSequenceProvider);
5453
}
5554

5655
@Override

0 commit comments

Comments
 (0)