public static @Nullable Envelope getMaxBounds(IndexInfo info) { Envelope maxBounds = (Envelope) info.getMetadata().get(IndexInfo.MD_QUAD_MAX_BOUNDS); return maxBounds; } }
public static @Nullable Envelope getMaxBounds(IndexInfo info) { Envelope maxBounds = (Envelope) info.getMetadata().get(IndexInfo.MD_QUAD_MAX_BOUNDS); return maxBounds; } }
public static Set<String> getMaterializedAttributeNames(IndexInfo info) { Set<String> availableAttNames = ImmutableSet.of(); final @Nullable String[] attNames = (String[]) info.getMetadata() .get(IndexInfo.FEATURE_ATTRIBUTES_EXTRA_DATA); if (attNames != null) { availableAttNames = Sets.newHashSet(attNames); } return availableAttNames; }
public static Set<String> getMaterializedAttributeNames(IndexInfo info) { Set<String> availableAttNames = ImmutableSet.of(); final @Nullable String[] attNames = (String[]) info.getMetadata() .get(IndexInfo.FEATURE_ATTRIBUTES_EXTRA_DATA); if (attNames != null) { availableAttNames = Sets.newHashSet(attNames); } return availableAttNames; }
@Override public boolean equals(Object o) { if (o instanceof IndexInfo) { IndexInfo i = (IndexInfo) o; return Objects.equals(getTreeName(), i.getTreeName()) && Objects.equals(getAttributeName(), i.getAttributeName()) && Objects.equals(getIndexType(), i.getIndexType()) && Objects.equals(getMetadata(), i.getMetadata()); } return false; }
@Override public int hashCode() { return Objects.hash(getTreeName(), getAttributeName(), getIndexType(), getMetadata().size()); }
@Override public boolean equals(Object o) { if (o instanceof IndexInfo) { IndexInfo i = (IndexInfo) o; return Objects.equals(getTreeName(), i.getTreeName()) && Objects.equals(getAttributeName(), i.getAttributeName()) && Objects.equals(getIndexType(), i.getIndexType()) && compareMetadatas(getMetadata(), i.getMetadata()); } return false; }
@Override public int hashCode() { return Objects.hash(getTreeName(), getAttributeName(), getIndexType(), getMetadata()); }
protected @Override void compute() { List<TreeCopyTask> treeTasks = new ArrayList<>(); Set<IndexTreeMapping> mappings = new HashSet<>(); try (AutoCloseableIterator<IndexTreeMapping> indexMappings = src .resolveIndexedTrees(index)) { mappings = Sets.newHashSet(indexMappings); } for (IndexTreeMapping mapping : mappings) { ObjectId indexTreeId = mapping.indexTree; if (!target.exists(indexTreeId)) { TreeCopyTask task = new TreeCopyTask(src.getTree(indexTreeId), src, target); treeTasks.add(task); } } super.invokeAll(treeTasks); IndexInfo targetIndex = target.createIndexInfo(index.getTreeName(), index.getAttributeName(), index.getIndexType(), index.getMetadata()); mappings.forEach(m -> target.addIndexedTree(targetIndex, m.featureTree, m.indexTree)); }
public static void serialize(IndexInfo index, DataOutput out) { try { valueEncoder.encode(FieldType.STRING, index.getTreeName(), out); valueEncoder.encode(FieldType.STRING, index.getAttributeName(), out); valueEncoder.encode(FieldType.STRING, index.getIndexType().toString(), out); valueEncoder.encode(FieldType.MAP, index.getMetadata(), out); } catch (IOException e) { Throwables.propagate(e); } }
public static void serialize(IndexInfo index, DataOutput out) { try { valueEncoder.encode(FieldType.STRING, index.getTreeName(), out); valueEncoder.encode(FieldType.STRING, index.getAttributeName(), out); valueEncoder.encode(FieldType.STRING, index.getIndexType().toString(), out); valueEncoder.encode(FieldType.MAP, index.getMetadata(), out); } catch (IOException e) { throw new RuntimeException(e); } }
@Test public void testCreateIndex() { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("meta1", 5L); metadata.put("meta2", "someValue"); String treeName = "tree"; String attributeName = "attribute"; IndexInfo index = indexDb.createIndexInfo(treeName, attributeName, IndexType.QUADTREE, metadata); assertEquals(treeName, index.getTreeName()); assertEquals(attributeName, index.getAttributeName()); assertEquals(IndexType.QUADTREE, index.getIndexType()); assertEquals(metadata, index.getMetadata()); assertEquals(IndexInfo.getIndexId(treeName, attributeName), index.getId()); }
@Test public void testGetIndex() { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("meta1", 5L); metadata.put("meta2", "someValue"); String treeName = "tree"; String attributeName = "attribute"; indexDb.createIndexInfo(treeName, attributeName, IndexType.QUADTREE, metadata); indexDb.createIndexInfo("otherTree", "someAttribute", IndexType.QUADTREE, null); Optional<IndexInfo> indexOpt = indexDb.getIndexInfo(treeName, attributeName); assertTrue(indexOpt.isPresent()); IndexInfo index = indexOpt.get(); assertEquals(treeName, index.getTreeName()); assertEquals(attributeName, index.getAttributeName()); assertEquals(IndexType.QUADTREE, index.getIndexType()); assertEquals(metadata, index.getMetadata()); assertEquals(IndexInfo.getIndexId(treeName, attributeName), index.getId()); }
@Test public void testCreateIndex() { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("meta1", 5L); metadata.put("meta2", "someValue"); String treeName = "tree"; String attributeName = "attribute"; IndexInfo index = indexDb.createIndexInfo(treeName, attributeName, IndexType.QUADTREE, metadata); assertEquals(treeName, index.getTreeName()); assertEquals(attributeName, index.getAttributeName()); assertEquals(IndexType.QUADTREE, index.getIndexType()); assertEquals(metadata, index.getMetadata()); assertEquals(IndexInfo.getIndexId(treeName, attributeName), index.getId()); }
@Test public void testGetIndex() { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("meta1", 5L); metadata.put("meta2", "someValue"); String treeName = "tree"; String attributeName = "attribute"; indexDb.createIndexInfo(treeName, attributeName, IndexType.QUADTREE, metadata); indexDb.createIndexInfo("otherTree", "someAttribute", IndexType.QUADTREE, null); Optional<IndexInfo> indexOpt = indexDb.getIndexInfo(treeName, attributeName); assertTrue(indexOpt.isPresent()); IndexInfo index = indexOpt.get(); assertEquals(treeName, index.getTreeName()); assertEquals(attributeName, index.getAttributeName()); assertEquals(IndexType.QUADTREE, index.getIndexType()); assertEquals(metadata, index.getMetadata()); assertEquals(IndexInfo.getIndexId(treeName, attributeName), index.getId()); }
@Test public void testNullMetadata() { String treeName = "tree"; String attributeName = "attribute"; IndexInfo index = indexDb.createIndexInfo(treeName, attributeName, IndexType.QUADTREE, null); assertEquals(treeName, index.getTreeName()); assertEquals(attributeName, index.getAttributeName()); assertEquals(IndexType.QUADTREE, index.getIndexType()); assertTrue(index.getMetadata().isEmpty()); assertEquals(IndexInfo.getIndexId(treeName, attributeName), index.getId()); Optional<IndexInfo> indexOpt = indexDb.getIndexInfo(treeName, attributeName); assertTrue(indexOpt.isPresent()); index = indexOpt.get(); assertEquals(treeName, index.getTreeName()); assertEquals(attributeName, index.getAttributeName()); assertEquals(IndexType.QUADTREE, index.getIndexType()); assertTrue(index.getMetadata().isEmpty()); assertEquals(IndexInfo.getIndexId(treeName, attributeName), index.getId()); }
@Test public void testNullMetadata() { String treeName = "tree"; String attributeName = "attribute"; IndexInfo index = indexDb.createIndexInfo(treeName, attributeName, IndexType.QUADTREE, null); assertEquals(treeName, index.getTreeName()); assertEquals(attributeName, index.getAttributeName()); assertEquals(IndexType.QUADTREE, index.getIndexType()); assertTrue(index.getMetadata().isEmpty()); assertEquals(IndexInfo.getIndexId(treeName, attributeName), index.getId()); Optional<IndexInfo> indexOpt = indexDb.getIndexInfo(treeName, attributeName); assertTrue(indexOpt.isPresent()); index = indexOpt.get(); assertEquals(treeName, index.getTreeName()); assertEquals(attributeName, index.getAttributeName()); assertEquals(IndexType.QUADTREE, index.getIndexType()); assertTrue(index.getMetadata().isEmpty()); assertEquals(IndexInfo.getIndexId(treeName, attributeName), index.getId()); }
@Then("^the ([^\"]*) repository's \"([^\"]*)\" index bounds should be \"([^\"]*)\"$") public void verifyIndexBounds(String repositoryName, String headRef, String bbox) throws Throwable { Repository repo = context.getRepo(repositoryName); final NodeRef typeTreeRef = IndexUtils.resolveTypeTreeRef(repo.context(), headRef); String treeName = typeTreeRef.path(); List<IndexInfo> indexInfos = IndexUtils.resolveIndexInfo(repo.indexDatabase(), treeName, null); assertEquals(1, indexInfos.size()); Map<String, Object> metadata = indexInfos.get(0).getMetadata(); assertTrue(metadata.containsKey(IndexInfo.MD_QUAD_MAX_BOUNDS)); Envelope indexBounds = (Envelope) metadata.get(IndexInfo.MD_QUAD_MAX_BOUNDS); Envelope expected = SpatialOps.parseNonReferencedBBOX(bbox); final double EPSILON = 0.00001; assertEquals(expected.getMinX(), indexBounds.getMinX(), EPSILON); assertEquals(expected.getMaxX(), indexBounds.getMaxX(), EPSILON); assertEquals(expected.getMinY(), indexBounds.getMinY(), EPSILON); assertEquals(expected.getMaxY(), indexBounds.getMaxY(), EPSILON); }
@Then("^the repository's \"([^\"]*)\" index bounds should be \"([^\"]*)\"$") public void verifyIndexBounds(String headRef, String bbox) throws Throwable { Repository repo = localRepo.geogigCLI.getGeogig().getRepository(); final NodeRef typeTreeRef = IndexUtils.resolveTypeTreeRef(repo.context(), headRef); assertNotNull(typeTreeRef); String treeName = typeTreeRef.path(); List<IndexInfo> indexInfos = IndexUtils.resolveIndexInfo(repo.indexDatabase(), treeName, null); assertEquals(1, indexInfos.size()); Map<String, Object> metadata = indexInfos.get(0).getMetadata(); assertTrue(metadata.containsKey(IndexInfo.MD_QUAD_MAX_BOUNDS)); Envelope indexBounds = (Envelope) metadata.get(IndexInfo.MD_QUAD_MAX_BOUNDS); Envelope expected = SpatialOps.parseNonReferencedBBOX(bbox); final double EPSILON = 0.00001; assertEquals(expected.getMinX(), indexBounds.getMinX(), EPSILON); assertEquals(expected.getMaxX(), indexBounds.getMaxX(), EPSILON); assertEquals(expected.getMinY(), indexBounds.getMinY(), EPSILON); assertEquals(expected.getMaxY(), indexBounds.getMaxY(), EPSILON); }
@Then("^the repository's \"([^\"]*)\" index bounds should be \"([^\"]*)\"$") public void verifyIndexBounds(String headRef, String bbox) throws Throwable { Repository repo = localRepo.geogigCLI.getGeogig().getRepository(); final NodeRef typeTreeRef = IndexUtils.resolveTypeTreeRef(repo.context(), headRef); assertNotNull(typeTreeRef); String treeName = typeTreeRef.path(); List<IndexInfo> indexInfos = IndexUtils.resolveIndexInfo(repo.indexDatabase(), treeName, null); assertEquals(1, indexInfos.size()); Map<String, Object> metadata = indexInfos.get(0).getMetadata(); assertTrue(metadata.containsKey(IndexInfo.MD_QUAD_MAX_BOUNDS)); Envelope indexBounds = (Envelope) metadata.get(IndexInfo.MD_QUAD_MAX_BOUNDS); Envelope expected = SpatialOps.parseNonReferencedBBOX(bbox); final double EPSILON = 0.00001; assertEquals(expected.getMinX(), indexBounds.getMinX(), EPSILON); assertEquals(expected.getMaxX(), indexBounds.getMaxX(), EPSILON); assertEquals(expected.getMinY(), indexBounds.getMinY(), EPSILON); assertEquals(expected.getMaxY(), indexBounds.getMaxY(), EPSILON); }