
com.redis.lettucemod.search.output.SearchNoContentOutput Maven / Gradle / Ivy
The newest version!
package com.redis.lettucemod.search.output;
import com.redis.lettucemod.search.SearchResults;
import com.redis.lettucemod.search.Document;
import io.lettuce.core.codec.RedisCodec;
import io.lettuce.core.internal.LettuceStrings;
import io.lettuce.core.output.CommandOutput;
import java.nio.ByteBuffer;
public class SearchNoContentOutput extends CommandOutput> {
private Document current;
private final boolean withScores;
public SearchNoContentOutput(RedisCodec codec, boolean withScores) {
super(codec, new SearchResults<>());
this.withScores = withScores;
}
@Override
public void set(ByteBuffer bytes) {
if (current == null) {
current = new Document<>();
if (bytes != null) {
current.setId(codec.decodeKey(bytes));
}
output.add(current);
if (!withScores) {
current = null;
}
} else {
if (withScores) {
current.setScore(LettuceStrings.toDouble(decodeAscii(bytes)));
}
current = null;
}
}
@Override
public void set(long integer) {
output.setCount(integer);
}
@Override
public void set(double number) {
if (withScores) {
current.setScore(number);
}
current = null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy