use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.
the class LengthCachingDataStoreTest method referenceHandling.
@Test
public void referenceHandling() throws Exception {
int minSize = new FileDataStore().getMinRecordLength();
LengthCachingDataStore fds = new LengthCachingDataStore();
fds.setDelegateClass(FileDataStore.class.getName());
fds.init(tempFolder.newFolder().getAbsolutePath());
fds.setReadOnly(false);
DataRecord dr1 = fds.addRecord(byteStream(minSize + 10));
assertNotNull(fds.getRecordFromReference(dr1.getReference()));
assertEquals(dr1.getIdentifier(), fds.getRecordFromReference(dr1.getReference()).getIdentifier());
}
use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.
the class LengthCachingDataStoreTest method delegateRecordTest.
@Test
public void delegateRecordTest() throws Exception {
FileDataStore ds = new FileDataStore();
byte[] data = bytes(ds.getMinRecordLength() + 10);
ds.init(tempFolder.getRoot().getAbsolutePath());
DataRecord dr = ds.addRecord(new ByteArrayInputStream(data));
File mappingFile = new File(tempFolder.getRoot(), "mapping.txt");
String text = String.format("%s|%s", data.length, dr.getIdentifier().toString());
Files.write(text, mappingFile, Charset.defaultCharset());
LengthCachingDataStore fds = new LengthCachingDataStore();
fds.setDelegateClass(FileDataStore.class.getName());
fds.setMappingFilePath(mappingFile.getAbsolutePath());
fds.init(tempFolder.getRoot().getAbsolutePath());
DataRecord dr2 = fds.getRecordIfStored(dr.getIdentifier());
assertEquals(dr, dr2);
assertEquals(dr.getLength(), dr2.getLength());
assertTrue(supplier(dr).contentEquals(supplier(dr2)));
}
use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.
the class ExternalBlobIT method createFileDataStore.
private FileDataStore createFileDataStore() {
FileDataStore fds = new FileDataStore();
fds.setMinRecordLength(4092);
fds.init(getWorkDir().getAbsolutePath());
return fds;
}
use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.
the class OakFileDataStoreTest method testGetAllIdentifiers.
private void testGetAllIdentifiers(String path, String unnormalizedPath) throws Exception {
File testDir = new File(path);
FileUtils.touch(new File(testDir, "ab/cd/ef/abcdef"));
FileUtils.touch(new File(testDir, "bc/de/fg/bcdefg"));
FileUtils.touch(new File(testDir, "cd/ef/gh/cdefgh"));
FileUtils.touch(new File(testDir, "c"));
FileDataStore fds = new OakFileDataStore();
fds.setPath(unnormalizedPath);
fds.init(null);
Iterator<DataIdentifier> dis = fds.getAllIdentifiers();
Set<String> fileNames = Sets.newHashSet(Iterators.transform(dis, new Function<DataIdentifier, String>() {
@Override
public String apply(@Nullable DataIdentifier input) {
return input.toString();
}
}));
Set<String> expectedNames = Sets.newHashSet("abcdef", "bcdefg", "cdefgh");
assertEquals(expectedNames, fileNames);
FileUtils.cleanDirectory(testDir);
}
use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.
the class LuceneWritesOnSegmentStatsTest method createBlobStore.
private BlobStore createBlobStore() {
FileDataStore fds = new OakFileDataStore();
fdsDir = "target/fds-" + codec + copyOnRW + minRecordLength + mergePolicy;
fds.setPath(fdsDir);
if (minRecordLength > 0) {
fds.setMinRecordLength(minRecordLength);
}
fds.init(null);
dataStoreBlobStore = new DataStoreBlobStore(fds);
StatisticsProvider sp = new DefaultStatisticsProvider(scheduledExecutorService);
BlobStatsCollector collector = new BlobStoreStats(sp);
dataStoreBlobStore.setBlobStatsCollector(collector);
return dataStoreBlobStore;
}
Aggregations