1 package com.kodexa.client.store; 2 3 import com.kodexa.client.Document; 4 import com.kodexa.client.KodexaException; 5 import lombok.extern.slf4j.Slf4j; 6 import org.apache.commons.io.FileUtils; 7 8 import java.io.IOException; 9 10 @Slf4j 11 public class MsgPackDocumentStore extends AbstractFileSystemDocumentStore { 12 13 @Override 14 protected String getExtension() { 15 return "msgpack"; 16 } 17 18 public MsgPackDocumentStore(String path) { 19 super(path, false); 20 } 21 22 public MsgPackDocumentStore(String path, boolean forceInitialize) { 23 super(path, forceInitialize); 24 } 25 26 @Override 27 public Document getDocument(int position) { 28 try { 29 byte[] msgPack = FileUtils.readFileToByteArray(getFile(index.get(position))); 30 return Document.fromMsgPack(msgPack); 31 } 32 catch (IOException e) { 33 throw new KodexaException("Unable to read the document at index " + position, e); 34 } 35 } 36 }