use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class IndexDefinitionTest method customTikaConfig.
@Test
public void customTikaConfig() throws Exception {
NodeBuilder defnb = newLuceneIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "lucene", of(TYPENAME_STRING));
IndexDefinition defn = new IndexDefinition(root, defnb.getNodeState(), "/foo");
assertFalse(defn.hasCustomTikaConfig());
defnb.child(LuceneIndexConstants.TIKA).child(LuceneIndexConstants.TIKA_CONFIG).child(JcrConstants.JCR_CONTENT).setProperty(JcrConstants.JCR_DATA, "hello".getBytes());
defn = new IndexDefinition(root, defnb.getNodeState(), "/foo");
assertTrue(defn.hasCustomTikaConfig());
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class IndexDefinitionTest method maxExtractLength.
@Test
public void maxExtractLength() throws Exception {
NodeBuilder defnb = newLuceneIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "lucene", of(TYPENAME_STRING));
IndexDefinition defn = new IndexDefinition(root, defnb.getNodeState(), "/foo");
assertEquals(-IndexDefinition.DEFAULT_MAX_EXTRACT_LENGTH * IndexDefinition.DEFAULT_MAX_FIELD_LENGTH, defn.getMaxExtractLength());
defnb.child(TIKA).setProperty(LuceneIndexConstants.TIKA_MAX_EXTRACT_LENGTH, 1000);
defn = new IndexDefinition(root, defnb.getNodeState(), "/foo");
assertEquals(1000, defn.getMaxExtractLength());
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class CompactionEstimatorTest method testGainEstimator.
@Test
public void testGainEstimator() throws Exception {
final int MB = 1024 * 1024;
final int blobSize = 2 * MB;
FileStore fileStore = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(2).withMemoryMapping(false).build();
SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
// 1. Create some blob properties
NodeBuilder builder = nodeStore.getRoot().builder();
NodeBuilder c1 = builder.child("c1");
c1.setProperty("a", createBlob(nodeStore, blobSize));
c1.setProperty("b", "foo");
NodeBuilder c2 = builder.child("c2");
c2.setProperty("a", createBlob(nodeStore, blobSize));
c2.setProperty("b", "foo");
NodeBuilder c3 = builder.child("c3");
c3.setProperty("a", createBlob(nodeStore, blobSize));
c3.setProperty("b", "foo");
nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
// 2. Now remove the property
builder = nodeStore.getRoot().builder();
builder.child("c1").remove();
builder.child("c2").remove();
nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
fileStore.flush();
try {
GCEstimation est = fileStore.estimateCompactionGain();
assertTrue(est.gcNeeded());
} finally {
fileStore.close();
}
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class LargeNumberOfPropertiesTestIT method corruption.
@Test
public void corruption() throws Exception {
FileStore fileStore = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(5).withSegmentCacheSize(0).withStringCacheSize(0).withTemplateCacheSize(0).withMemoryMapping(true).build();
SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
NodeBuilder root = nodeStore.getRoot().builder();
try {
NodeBuilder c = root.child("c" + System.currentTimeMillis());
// have (262144)
for (int i = 0; i < 25; i++) {
LOG.debug("run {}/24", i);
for (int j = 0; j < 10000; j++) {
c.setProperty("int-" + i + "-" + j, i);
}
}
nodeStore.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY);
} finally {
fileStore.close();
}
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class RepeatedRepositoryUpgradeTest method doUpgradeRepository.
protected void doUpgradeRepository(File source, NodeStore target, boolean skipInit) throws RepositoryException, IOException {
final RepositoryConfig config = RepositoryConfig.create(source);
final RepositoryContext context = RepositoryContext.create(config);
try {
final RepositoryUpgrade repositoryUpgrade = new RepositoryUpgrade(context, target);
repositoryUpgrade.setSkipInitialization(skipInit);
repositoryUpgrade.copy(new RepositoryInitializer() {
@Override
public void initialize(@Nonnull NodeBuilder builder) {
builder.child("foo").child("bar");
}
});
} finally {
context.getRepository().shutdown();
}
}
Aggregations