use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.
the class SegmentIdTableBenchmark method test.
private static void test() throws IOException {
long time;
int repeat = 10000;
int count = 10000;
long[] array = new long[count];
Random r = new Random(1);
for (int i = 0; i < array.length; i++) {
array[i] = r.nextLong();
}
time = System.currentTimeMillis();
MemoryStore store = new MemoryStore();
SegmentIdFactory maker = newSegmentIdMaker(store);
final SegmentIdTable tbl = new SegmentIdTable();
for (int i = 0; i < repeat; i++) {
for (int j = 0; j < count; j++) {
tbl.newSegmentId(j, array[j], maker);
}
}
time = System.currentTimeMillis() - time;
System.out.println("SegmentIdTable: " + time);
time = System.currentTimeMillis();
ConcurrentTable cm = new ConcurrentTable(store, 16 * 1024);
for (int i = 0; i < repeat; i++) {
for (int j = 0; j < count; j++) {
cm.getSegmentId(j, array[j]);
}
}
time = System.currentTimeMillis() - time;
System.out.println("ConcurrentTable: " + time);
// time = System.currentTimeMillis();
// WeakHashMap<SegmentId, SegmentId> map = new WeakHashMap<SegmentId, SegmentId>(count);
// for (int i = 0; i < repeat; i++) {
// for (int j = 0; j < count; j++) {
// SegmentId id = new SegmentId(tracker, j, j);
// if (map.get(id) == null) {
// map.put(id, id);
// }
// }
// }
// time = System.currentTimeMillis() - time;
// System.out.println("WeakHashMap: " + time);
}
use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.
the class MutableSegmentReferencesTest method shouldContainAddedSegment.
@Test
public void shouldContainAddedSegment() throws Exception {
MemoryStore store = new MemoryStore();
SegmentId id = store.getSegmentIdProvider().newDataSegmentId();
MutableSegmentReferences table = new MutableSegmentReferences();
assertFalse(table.contains(id));
table.addOrReference(id);
assertTrue(table.contains(id));
}
use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.
the class MutableSegmentReferencesTest method shouldNotAddSameSegmentIdTwice.
@Test
public void shouldNotAddSameSegmentIdTwice() throws Exception {
MemoryStore store = new MemoryStore();
SegmentId id = store.getSegmentIdProvider().newDataSegmentId();
MutableSegmentReferences table = new MutableSegmentReferences();
int first = table.addOrReference(id);
int second = table.addOrReference(id);
assertEquals(first, second);
}
use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.
the class BrokenVersionableTest method upgradeRepository.
@Before
public synchronized void upgradeRepository() throws Exception {
targetNodeStore = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
targetRepository = (RepositoryImpl) new Jcr(new Oak(targetNodeStore)).createRepository();
NodeStore source = createSourceContent();
RepositorySidegrade sidegrade = new RepositorySidegrade(source, targetNodeStore);
sidegrade.setCopyOrphanedVersions(null);
sidegrade.copy();
}
use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.
the class BrokenVersionableTest method createSourceContent.
private NodeStore createSourceContent() throws Exception {
SegmentNodeStore source = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
RepositoryImpl repository = (RepositoryImpl) new Jcr(new Oak(source)).createRepository();
Session session = repository.login(CREDENTIALS);
List<String> versionHistoryPaths = new ArrayList<String>();
try {
CndImporter.registerNodeTypes(new StringReader("<test = 'http://jackrabbit.apache.org/ns/test'>\n" + "[test:Versionable] > nt:unstructured, mix:versionable"), session);
Node root = session.getRootNode();
Node versionable1 = root.addNode("versionable1", NT_UNSTRUCTURED);
versionable1.addMixin(MIX_VERSIONABLE);
versionable1.addNode("child", NT_UNSTRUCTURED);
Node versionable2 = root.addNode("versionable2", "test:Versionable");
versionable2.addNode("child", NT_UNSTRUCTURED);
session.save();
VersionManager vMgr = session.getWorkspace().getVersionManager();
vMgr.checkin("/versionable1");
vMgr.checkin("/versionable2");
versionHistoryPaths.add(vMgr.getVersionHistory("/versionable1").getPath());
versionHistoryPaths.add(vMgr.getVersionHistory("/versionable2").getPath());
} finally {
session.logout();
repository.shutdown();
}
// remove version history to corrupt the JCR repository structure
NodeBuilder rootBuilder = source.getRoot().builder();
for (String versionHistoryPath : versionHistoryPaths) {
NodeStateTestUtils.createOrGetBuilder(rootBuilder, versionHistoryPath).remove();
}
source.merge(rootBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
return source;
}
Aggregations