/** * Shortcut for {@link Context#indexDatabase()} */ protected IndexDatabase indexDatabase() { return context.indexDatabase(); }
/** * Shortcut for {@link Context#indexDatabase()} */ protected IndexDatabase indexDatabase() { return context.indexDatabase(); }
@Override public IndexDatabase indexDatabase() { return context.indexDatabase(); }
public @Override IndexDatabase indexDatabase() { return context.indexDatabase(); }
@Override public IndexDatabase indexDatabase() { return context.indexDatabase(); }
@Override public IndexDatabase indexDatabase() { return context.indexDatabase(); }
@Override public IndexDatabase indexDatabase() { return context.indexDatabase(); }
@Override public IndexDatabase indexDatabase() { return context.indexDatabase(); }
@SuppressWarnings("unchecked") private Optional<Index>[] resolveIndex(final ObjectId oldCanonical, final ObjectId newCanonical, final String treeName, final String attributeName) { IndexDatabase leftDb = leftRepo.indexDatabase(); IndexDatabase rightDb = rightRepo.indexDatabase(); Optional<Index> leftIndex = resolveIndex(oldCanonical, treeName, attributeName, leftDb); Optional<Index> rightIndex = leftIndex.isPresent() ? resolveIndex(newCanonical, treeName, attributeName, rightDb) : Optional.empty(); if (!leftIndex.isPresent() || !rightIndex.isPresent()) { return NO_INDEX; } Optional<Index>[] indexes = new Optional[2]; indexes[0] = leftIndex; indexes[1] = rightIndex; return indexes; }
@Override public void configure() throws RepositoryConnectionException { context.refDatabase().configure(); context.objectDatabase().configure(); context.indexDatabase().configure(); }
@Override public void configure() throws RepositoryConnectionException { context.refDatabase().configure(); context.objectDatabase().configure(); context.indexDatabase().configure(); }
/** * Closes the repository. */ @Override public synchronized void close() { open = false; close(context.refDatabase()); close(context.objectDatabase()); close(context.indexDatabase()); close(context.configDatabase()); close(context.conflictsDatabase()); for (RepositoryListener l : listeners) { try {// don't let a broken listener mess us up l.closed(); } catch (RuntimeException e) { e.printStackTrace(); } } }
/** * Closes the repository. */ @Override public synchronized void close() { open = false; close(context.refDatabase()); close(context.objectDatabase()); close(context.indexDatabase()); close(context.configDatabase()); close(context.conflictsDatabase()); for (RepositoryListener l : listeners) { try {// don't let a broken listener mess us up l.closed(); } catch (RuntimeException e) { e.printStackTrace(); } } }
private Optional<IndexInfo> createOrUpdateIndexAndVerify(String layerName, String... extraAttributes) throws Exception { Optional<ObjectId> createOrUpdateIndex = dataStore.createOrUpdateIndex(layerName, extraAttributes); assertTrue("IndexInfo ObjectId should be present", createOrUpdateIndex.isPresent()); ObjectId id = createOrUpdateIndex.get(); Context resolveContext = dataStore.resolveContext(Transaction.AUTO_COMMIT); List<IndexInfo> indexInfos = resolveContext.indexDatabase().getIndexInfos(); assertNotNull("No IndexInfo objects found", indexInfos); assertEquals("Expected exactly 1 IndexInfo", 1, indexInfos.size()); IndexInfo index = indexInfos.get(0); assertEquals("Unexpected ObjectID for IndexInfo", id, index.getId()); // verify the index contains all the extra Attributes Set<String> materializedAttributeNames = IndexInfo.getMaterializedAttributeNames(index); for (String attribute : extraAttributes) { assertTrue("Index should have contained " + attribute, materializedAttributeNames.contains(attribute)); } return Optional.of(index); }
private Optional<IndexInfo> createOrUpdateIndexAndVerify(String layerName, String... extraAttributes) throws Exception { Optional<ObjectId> createOrUpdateIndex = dataStore.createOrUpdateIndex(layerName, extraAttributes); assertTrue("IndexInfo ObjectId should be present", createOrUpdateIndex.isPresent()); ObjectId id = createOrUpdateIndex.get(); Context resolveContext = dataStore.resolveContext(Transaction.AUTO_COMMIT); List<IndexInfo> indexInfos = resolveContext.indexDatabase().getIndexInfos(); assertNotNull("No IndexInfo objects found", indexInfos); assertEquals("Expected exactly 1 IndexInfo", 1, indexInfos.size()); IndexInfo index = indexInfos.get(0); assertEquals("Unexpected ObjectID for IndexInfo", id, index.getId()); // verify the index contains all the extra Attributes Set<String> materializedAttributeNames = IndexInfo.getMaterializedAttributeNames(index); for (String attribute : extraAttributes) { assertTrue("Index should have contained " + attribute, materializedAttributeNames.contains(attribute)); } return Optional.of(index); }
/** * List all features in the repository with the given name at the provided ref. * * @param headRef the ref from which to list the features * @param index {@code true} if the {@code headRef} parameter refers to an index tree * @return a multimap that contains all of the feature types and their features */ public SetMultimap<String, String> listRepo(final String headRef, final boolean index) { Context context = geogigCLI.getGeogig().getContext(); ObjectStore source = index ? context.indexDatabase() : context.objectDatabase(); Iterator<NodeRef> featureRefs = context.command(LsTreeOp.class).setReference(headRef) .setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).setSource(source).call(); SetMultimap<String, String> features = HashMultimap.create(); while (featureRefs.hasNext()) { NodeRef ref = featureRefs.next(); features.put(index ? "index" : ref.getParentPath(), ref.name()); } return features; } }
/** * List all features in the repository with the given name at the provided ref. * * @param headRef the ref from which to list the features * @param index {@code true} if the {@code headRef} parameter refers to an index tree * @return a multimap that contains all of the feature types and their features */ public SetMultimap<String, String> listRepo(final String headRef, final boolean index) { Context context = geogigCLI.getGeogig().getContext(); ObjectStore source = index ? context.indexDatabase() : context.objectDatabase(); Iterator<NodeRef> featureRefs = context.command(LsTreeOp.class).setReference(headRef) .setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).setSource(source).call(); SetMultimap<String, String> features = HashMultimap.create(); while (featureRefs.hasNext()) { NodeRef ref = featureRefs.next(); features.put(index ? "index" : ref.getParentPath(), ref.name()); } return features; } }
/** * List all features in the repository with the given name at the provided ref. * * @param headRef the ref from which to list the features * @param index {@code true} if the {@code headRef} parameter refers to an index tree * @return a multimap that contains all of the feature types and their features */ public SetMultimap<String, String> listRepo(final String headRef, final boolean index) { Context context = geogigCLI.getGeogig().getContext(); ObjectStore source = index ? context.indexDatabase() : context.objectDatabase(); Iterator<NodeRef> featureRefs = context.command(LsTreeOp.class).setReference(headRef) .setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).setSource(source).call(); SetMultimap<String, String> features = HashMultimap.create(); while (featureRefs.hasNext()) { NodeRef ref = featureRefs.next(); features.put(index ? "index" : ref.getParentPath(), ref.name()); } return features; } }
@When("^I create a spatial index on \"([^\"]*)\"$") public void i_create_a_spatial_index_on(String storeName) throws Throwable { GeoGigDataStore store = datastoreMap.get(storeName); Optional<ObjectId> createOrUpdateIndex = store.createOrUpdateIndex(currentLayer.getTypeName()); assertTrue("Expected an Index to be created", createOrUpdateIndex.isPresent()); IndexDatabase indexDatabase = store.resolveContext(Transaction.AUTO_COMMIT).indexDatabase(); List<IndexInfo> resolveIndexInfo = indexDatabase.getIndexInfos(currentLayer.getTypeName()); assertEquals("Expected exactly 1 IndexInfo", 1, resolveIndexInfo.size()); IndexInfo info = resolveIndexInfo.get(0); assertEquals("Unexpected Index type", IndexType.QUADTREE, info.getIndexType()); assertEquals("Unexpected Index spatial attribute", "the_geom", info.getAttributeName()); assertEquals("Unexpected Index Path name", currentLayer.getTypeName(), info.getTreeName()); }
@When("^I create a spatial index on \"([^\"]*)\"$") public void i_create_a_spatial_index_on(String storeName) throws Throwable { GeoGigDataStore store = datastoreMap.get(storeName); Optional<ObjectId> createOrUpdateIndex = store.createOrUpdateIndex(currentLayer.getTypeName()); assertTrue("Expected an Index to be created", createOrUpdateIndex.isPresent()); IndexDatabase indexDatabase = store.resolveContext(Transaction.AUTO_COMMIT).indexDatabase(); List<IndexInfo> resolveIndexInfo = indexDatabase.getIndexInfos(currentLayer.getTypeName()); assertEquals("Expected exactly 1 IndexInfo", 1, resolveIndexInfo.size()); IndexInfo info = resolveIndexInfo.get(0); assertEquals("Unexpected Index type", IndexType.QUADTREE, info.getIndexType()); assertEquals("Unexpected Index spatial attribute", "the_geom", info.getAttributeName()); assertEquals("Unexpected Index Path name", currentLayer.getTypeName(), info.getTreeName()); }