public static int writeLabelIndex(Configuration conf, Path indexPath,
Iterable<Pair<Text,IntWritable>> labels) throws IOException {
FileSystem fs = FileSystem.get(indexPath.toUri(), conf);
Collection<String> seen = new HashSet<>();
int i = 0;
<BUG>try (SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf, indexPath, Text.class, IntWritable.class)){
for (Object label : labels) {</BUG>
String theLabel = SLASH.split(((Pair<?, ?>) label).getFirst().toString())[1];
if (!seen.contains(theLabel)) {
writer.append(new Text(theLabel), new IntWritable(i++));

public static int writeLabelIndex(Configuration conf, Path indexPath,
Iterable<Pair<Text,IntWritable>> labels) throws IOException {
FileSystem fs = FileSystem.get(indexPath.toUri(), conf);
Collection<String> seen = new HashSet<>();
int i = 0;
try (SequenceFile.Writer writer =
SequenceFile.createWriter(fs.getConf(), SequenceFile.Writer.file(indexPath),
SequenceFile.Writer.keyClass(Text.class), SequenceFile.Writer.valueClass(IntWritable.class))){
for (Object label : labels) {
String theLabel = SLASH.split(((Pair<?, ?>) label).getFirst().toString())[1];
if (!seen.contains(theLabel)) {
writer.append(new Text(theLabel), new IntWritable(i++));
