@NotThreadSafe public class ContentStoreDirUtf8 extends ContentStoreDirAbstract
ContentStore.DocTask
Modifier and Type | Field and Description |
---|---|
protected int |
newEntryBlockSizeCharacters
What block size to use when adding a new document to the content store.
|
dir
Constructor and Description |
---|
ContentStoreDirUtf8(File dir) |
ContentStoreDirUtf8(File dir,
boolean create) |
Modifier and Type | Method and Description |
---|---|
void |
addToBlock(String contentPart)
Add a piece of content to the current block
|
void |
clear()
Delete all content in the document store
|
void |
close()
Close the content store.
|
protected String |
decodeBlock(byte[] buf,
int offset,
int length)
Convert the byte buffer representation of a block back to the original String
|
void |
delete(int id)
Delete a document from the content store.
|
int |
docLength(int id)
Returns the document length in characters
|
protected byte[] |
encodeBlock(String block)
Convert the String representation of a block to a byte buffer
|
Set<Integer> |
idSet()
Returns the set of doc ids in the store.
|
void |
initialize() |
boolean |
isDeleted(int id)
Return true iff the entry with this id was deleted.
|
String |
retrieve(int id)
Retrieve content with given id
|
String[] |
retrieveParts(int contentId,
int[] start,
int[] end)
Retrieve one or more substrings from the specified content.
|
void |
setBlockSizeCharacters(int size)
Set the desired block size for new entries
|
void |
setDataFileSizeHint(long dataFileSizeHint)
Indicate preferred maximum size of data files (defaults to 10M)
|
protected void |
setStoreType()
Writes an empty file that indicates the type of store.
|
void |
setWriteMapReserve(int writeMapReserve)
Set the size of the write reserve (the amount of space allocated at the end
of the file).
|
int |
store(String content)
Store the given content and assign an id to it
|
void |
storePart(String content)
Store part of a piece of large content.
|
void |
writeCurrentBlock(OutputStream os)
Encode and write the block we've compiled so far and reset for next block
|
getStoreTypeVersion, setStoreType, toString
forEachDocument, open, retrievePart
protected int newEntryBlockSizeCharacters
public ContentStoreDirUtf8(File dir)
dir
- content store dirpublic ContentStoreDirUtf8(File dir, boolean create)
dir
- content store dircreate
- if true, create a new content storepublic void setWriteMapReserve(int writeMapReserve)
writeMapReserve
- size of the reserve in bytes.public void setBlockSizeCharacters(int size)
size
- the fixed block size in charactersprotected void setStoreType()
public void clear()
clear
in class ContentStore
public void close()
close
in class ContentStore
public void setDataFileSizeHint(long dataFileSizeHint)
dataFileSizeHint
- public void addToBlock(String contentPart)
contentPart
- content to addpublic void writeCurrentBlock(OutputStream os)
os
- where to write to block topublic void storePart(String content)
storePart
in class ContentStore
content
- the content to storeprotected byte[] encodeBlock(String block)
block
- the block contentprotected String decodeBlock(byte[] buf, int offset, int length)
buf
- the byte bufferoffset
- offset in the bufferlength
- length of the block in bytespublic int store(String content)
store
in class ContentStore
content
- the content to storepublic String retrieve(int id)
retrieve
in class ContentStore
id
- the idpublic String[] retrieveParts(int contentId, int[] start, int[] end)
retrieveParts
in class ContentStore
contentId
- id of the entry to get substrings fromstart
- the starting points of the substrings (in characters). -1 means
"start of document"end
- the end points of the substrings (in characters). -1 means "end of
document"public void delete(int id)
ContentStore
delete
in class ContentStore
id
- content store id of the document to deletepublic boolean isDeleted(int id)
ContentStore
isDeleted
in class ContentStore
id
- the entry to checkpublic int docLength(int id)
ContentStore
docLength
in class ContentStore
id
- the documentpublic Set<Integer> idSet()
ContentStore
idSet
in class ContentStore
public void initialize()
initialize
in class ContentStore
Copyright © 2020 Instituut voor Nederlandse Taal (INT). All rights reserved.