Java Client

Interact with TiKV using Java.

This document, like our Java API, is still a work in progress. In the meantime, you can track development at tikv/client-java repository.

You should not use the Java client for production use until it is released.

Parse SST file

import java.io.File;
import java.util.Iterator;
import java.util.List;

import org.tikv.br.BackupDecoder;
import org.tikv.br.BackupMetaDecoder;
import org.tikv.br.SSTDecoder;
import org.tikv.common.util.Pair;

BackupMetaDecoder metaDecoder = BackupMetaDecoder.parse("/path/to/sst/backupmeta");
BackupDecoder sstBackup = new BackupDecoder(metaDecoder.getBackupMeta());
File folder = new File("/path/to/sst");
File[] listOfFiles = folder.listFiles();

for (File file : listOfFiles) {
    if (file.getName().endsWith("sst")) {
        SSTDecoder decoder = sstBackup.decodeSST(file.getAbsolutePath());
        Iterator<Pair<ByteString, ByteString>> iter = decoder.getIterator();
        // Do something with iter
    }
}