private String getIndexType(String indexPath) { NodeState idxState = NodeStateUtils.getNode(nodeStore.getRoot(), indexPath); String type = idxState.getString(IndexConstants.TYPE_PROPERTY_NAME); if (type == null || "disabled".equals(type)){ return null; } return type; }
private String getIndexType(String indexPath) { NodeState idxState = NodeStateUtils.getNode(nodeStore.getRoot(), indexPath); String type = idxState.getString(IndexConstants.TYPE_PROPERTY_NAME); if (type == null || "disabled".equals(type)){ return null; } return type; }
@Override public CompositeData getStatsForSpecificIndex(String path, int maxValueCount, int maxDepth, int maxPathCount) throws OpenDataException { NodeState idx = NodeStateUtils.getNode(store.getRoot(), path); return getStatsForIndex(path, idx, maxValueCount, maxDepth, maxPathCount); }
@Override public CompositeData getStatsForSpecificIndex(String path, int maxValueCount, int maxDepth, int maxPathCount) throws OpenDataException { NodeState idx = NodeStateUtils.getNode(store.getRoot(), path); return getStatsForIndex(path, idx, maxValueCount, maxDepth, maxPathCount); }
@Override public CompositeData getStatsForSpecificIndex(String path, int maxValueCount, int maxDepth, int maxPathCount) throws OpenDataException { NodeState idx = NodeStateUtils.getNode(store.getRoot(), path); return getStatsForIndex(path, idx, maxValueCount, maxDepth, maxPathCount); }
List<String> getSyncIndexPaths() { List<String> indexPaths = new ArrayList<>(); NodeState root = nodeStore.getRoot(); for (String indexPath : indexPathService.getIndexPaths()) { NodeState idx = getNode(root, indexPath); if (TYPE_LUCENE.equals(idx.getString(TYPE_PROPERTY_NAME)) && idx.hasChildNode(PROPERTY_INDEX)) { indexPaths.add(indexPath); } } return indexPaths; }
@Override public IndexInfo getInfo(String indexPath) throws IOException { NodeState idxState = NodeStateUtils.getNode(nodeStore.getRoot(), indexPath); checkArgument(PropertyIndexEditorProvider.TYPE.equals(idxState.getString(IndexConstants.TYPE_PROPERTY_NAME)), "Index definition at [%s] is not of type 'property'", indexPath); PropertyIndexInfo info = new PropertyIndexInfo(indexPath); computeCountEstimate(info, idxState); return info; }
@Override public IndexInfo getInfo(String indexPath) throws IOException { NodeState idxState = NodeStateUtils.getNode(nodeStore.getRoot(), indexPath); checkArgument(PropertyIndexEditorProvider.TYPE.equals(idxState.getString(IndexConstants.TYPE_PROPERTY_NAME)), "Index definition at [%s] is not of type 'property'", indexPath); PropertyIndexInfo info = new PropertyIndexInfo(indexPath); computeCountEstimate(info, idxState); return info; }
@Override public String getHybridIndexInfo(String indexPath) { NodeState idx = NodeStateUtils.getNode(nodeStore.getRoot(), indexPath); return new HybridPropertyIndexInfo(idx).getInfoAsJson(); }
@Override public String getHybridIndexInfo(String indexPath) { NodeState idx = NodeStateUtils.getNode(nodeStore.getRoot(), indexPath); return new HybridPropertyIndexInfo(idx).getInfoAsJson(); }
private static PropertyState getValue(NodeState node, String propertyRelativePath) { int depth = PathUtils.getDepth(propertyRelativePath); NodeState propNode = node; String propName = propertyRelativePath; if (depth > 1) { propName = PathUtils.getName(propertyRelativePath); String parentPath = PathUtils.getParentPath(propertyRelativePath); propNode = NodeStateUtils.getNode(node, parentPath); } return propNode.getProperty(propName); } }
@Override public IndexInfo getInfo(String indexPath) throws IOException { NodeState idxState = NodeStateUtils.getNode(nodeStore.getRoot(), indexPath); checkArgument(LuceneIndexConstants.TYPE_LUCENE.equals(idxState.getString(IndexConstants.TYPE_PROPERTY_NAME)), "Index definition at [%s] is not of type 'lucene'", indexPath); LuceneIndexInfo info = new LuceneIndexInfo(indexPath); computeSize(idxState, info); computeIndexDefinitionChange(idxState, info); computeLastUpdatedTime(idxState, info); computeAsyncIndexInfo(idxState, indexPath, info); return info; }
@Override public String diffStoredIndexDefinition(@Name("indexPath") String indexPath) { NodeState stored = NodeStateUtils.getNode(indexTracker.getRoot(), indexPath + "/" + INDEX_DEFINITION_NODE); NodeState current = NodeStateUtils.getNode(indexTracker.getRoot(), indexPath); if (stored.exists()){ current = NodeStateCloner.cloneVisibleState(current); JsopDiff diff = new JsopDiff(); current.compareAgainstBaseState(stored, diff); return JsopBuilder.prettyPrint(diff.toString()); } return "No stored index definition found at given path"; }
private List<String> getIndexDirNames(String indexName){ NodeState idxDefn = NodeStateUtils.getNode(nodeStore.getRoot(), "/oak:index/"+indexName); List<String> names = new ArrayList<>(); for (String childName : idxDefn.getChildNodeNames()){ if (MultiplexersLucene.isIndexDirName(childName)){ names.add(childName); } } return names; }
private void assertJsonInfo(String indexPath, String expectedJson) throws ParseException { NodeState idx = NodeStateUtils.getNode(nodeStore.getRoot(), indexPath); String json = new HybridPropertyIndexInfo(idx).getInfoAsJson(); JsonObject j1 = (JsonObject) new JsonParser().parse(json); JsonObject j2 = (JsonObject) new JsonParser().parse(expectedJson); if (!j1.equals(j2)){ assertEquals(j1, j2); } }
@Test public void recursiveDelete() throws Exception{ int actualCount = createSubtree(10000); assertEquals(actualCount, getSubtreeCount(getNode(nodeStore.getRoot(), testNodePath))); RecursiveDelete rd = new RecursiveDelete(nodeStore, EmptyHook.INSTANCE, () -> CommitInfo.EMPTY); rd.setBatchSize(100); rd.run(testNodePath); assertEquals(actualCount, rd.getNumRemoved()); assertFalse(getNode(nodeStore.getRoot(), testNodePath).exists()); System.out.println(rd.getMergeCount()); System.out.println(actualCount); }
@Test public void regexProperty() throws Exception{ builder.indexRule("nt:base") .property(FulltextIndexConstants.REGEX_ALL_PROPS, true); NodeState state = builder.build(); assertTrue(NodeStateUtils.getNode(state, "indexRules/nt:base/properties/prop") .getBoolean(FulltextIndexConstants.PROP_IS_REGEX)); }
private void indexBarPropertyAlso(RepositoryFixture fixture2) throws IOException, RepositoryException { Session session = fixture2.getAdminSession(); NodeState idxState = NodeStateUtils.getNode(fixture2.getNodeStore().getRoot(), TEST_INDEX_PATH); IndexDefinitionBuilder idxb = new IndexDefinitionBuilder( new MemoryNodeBuilder(idxState), false); idxb.indexRule("nt:base").property("bar").propertyIndex(); Node idxNode = session.getNode(TEST_INDEX_PATH); idxb.build(idxNode); session.save(); session.logout(); }
@Test public void noInitWhenJcrSystemNotPresent() throws Exception{ NodeBuilder builder = EMPTY_NODE.builder(); BundlingConfigInitializer.INSTANCE.initialize(builder); NodeState state = builder.getNodeState(); NodeState bundlor = NodeStateUtils.getNode(state, BundlingConfigHandler.CONFIG_PATH); assertFalse(bundlor.exists()); } }
@Test public void noPropertiesNodeForEmptyRule() throws Exception{ builder.nodeTypeIndex(); builder.indexRule("nt:file").sync(); NodeState state = builder.build(); assertFalse(NodeStateUtils.getNode(state, "/indexRules/nt:file/properties").exists()); } }