package org.apache.cassandra.index.sasi.sa;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import org.apache.cassandra.index.sasi.disk.OnDiskIndexBuilder.Mode;
import org.apache.cassandra.index.sasi.disk.TokenTreeBuilder;
import org.apache.cassandra.db.marshal.AbstractType;
public abstract class SA<T extends Buffer>
{
protected final AbstractType<?> comparator;
protected final Mode mode;
protected final List<Term<T>> terms = new ArrayList<>();
protected int charCount = 0;
public SA(AbstractType<?> comparator, Mode mode)
{
this.comparator = comparator;
this.mode = mode;
}
public Mode getMode()
{
return mode;
}
public void add(ByteBuffer termValue, TokenTreeBuilder tokens)
{
Term<T> term = getTerm(termValue, tokens);
terms.add(term);
charCount += term.length();
}
public abstract TermIterator finish();
protected abstract Term<T> getTerm(ByteBuffer termValue, TokenTreeBuilder tokens);
}