org.locationtech.geowave.core.store.api.DataStore类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.locationtech.geowave.core.store.api.DataStore类的一些代码示例,展示了DataStore类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataStore类的具体详情如下:
包路径:org.locationtech.geowave.core.store.api.DataStore
类名称:DataStore

DataStore介绍

[英]A DataStore can both ingest and query data based on persisted indices and data type adapters. When the data is ingested it is explicitly given an index and a data type adapter which is then persisted to be used in subsequent queries. Also, implicitly statistics are maintained associated with all data ingested. These statistics can be queried. Furthermore, aggregations can be applied directly to the data which are similar to statistics, but are more dynamic in that any query criteria can be applied as the input of the aggregation. Datastores that support serverside processing will run the aggregation within the scope of iterating through the results for additional efficiency.

Here is a simple snippets of pseudocode showing how a data store can be used to store and retrieve your data.
[中]数据存储可以基于持久化索引和数据类型适配器摄取和查询数据。当数据被摄取时,显式地给它一个索引和一个数据类型适配器,然后将其持久化以在后续查询中使用。此外,隐式地维护与所摄取的所有数据相关联的统计信息。可以查询这些统计数据。此外,聚合可以直接应用于与统计数据类似的数据,但更具动态性,因为任何查询条件都可以作为聚合的输入。支持服务器端处理的数据存储将在迭代结果的范围内运行聚合,以提高效率。
下面是一个简单的伪代码片段,展示了如何使用数据存储来存储和检索数据。

代码示例

代码示例来源:origin: locationtech/geowave

@Override
public synchronized Writer<?> create(final TypeNameKeyWithIndices adapterWithIndices)
  throws Exception {
 dataStore.addType(
   adapterStore.getAdapter(adapterWithIndices.typeName),
   adapterWithIndices.indices);
 return dataStore.createWriter(adapterWithIndices.typeName);
}

代码示例来源:origin: locationtech/geowave

protected long delete(
  final GeotoolsFeatureDataAdapter adapter,
  final String typeName,
  final String indexName,
  final DataStore dataStore,
  final boolean debug) {
 long missed = 0;
 final VectorQueryBuilder bldr = VectorQueryBuilder.newBuilder();
 final Query<SimpleFeature> query =
   bldr.addTypeName(typeName).indexName(indexName).constraints(
     bldr.constraintsFactory().cqlConstraints(cqlStr)).build();
 final boolean success = dataStore.delete(query);
 if (debug) {
  LOGGER.debug("CQL Delete " + (success ? "Success" : "Failure"));
 }
 // Verify delete by running the CQL query
 if (debug) {
  try (final CloseableIterator<SimpleFeature> it = dataStore.query(query)) {
   while (it.hasNext()) {
    it.next();
    missed++;
   }
  }
 }
 return missed;
}

代码示例来源:origin: locationtech/geowave

private ArrayList<DataAdapterInfo> getStoreAdapterInfo(
  final String storeName,
  final String adapterId) {
 final DataStorePluginOptions dsPlugin = getStorePlugin(storeName);
 final DataStore dataStore = dsPlugin.createDataStore();
 final ArrayList<DataAdapterInfo> adapterInfoList = new ArrayList<>();
 LOGGER.debug("Adapter list for " + storeName + " with adapterId = " + adapterId + ": ");
 for (final DataTypeAdapter<?> adapter : dataStore.getTypes()) {
  final DataAdapterInfo info = getAdapterInfo(adapterId, adapter);
  if (info != null) {
   adapterInfoList.add(info);
   LOGGER.debug("> '" + info.typeName + "' adapter passed filter");
  }
 }
 LOGGER.debug("getStoreAdapterInfo(" + storeName + ") got " + adapterInfoList.size() + " ids");
 if (dataStore instanceof Closeable) {
  try {
   ((Closeable) dataStore).close();
  } catch (final IOException e) {
   LOGGER.error("Unable to close datastore");
  }
 }
 return adapterInfoList;
}

代码示例来源:origin: locationtech/geowave

final DataTypeAdapter<?>[] destTypes = other.getTypes();
for (int i = 0; i < typesToCopy.size(); i++) {
 boolean found = false;
  other.addType(typesToCopy.get(i));
    indexMappingStore.getIndicesForAdapter(adapterId);
  final Index[] indices = indicesForAdapter.getIndices(indexStore);
  other.addIndex(typeName, indices);
      query.getQueryConstraints());
  try (CloseableIterator<?> it = query(qb.build())) {
   try (Writer writer = other.createWriter(typeName)) {
    while (it.hasNext()) {
     writer.write(it.next());
  other.addIndex(typesToCopy.get(i).getTypeName(), indexToCopy);
      indexToCopy.getName()).constraints(query.getQueryConstraints());
  try (CloseableIterator<?> it = query(qb.build())) {
   try (Writer writer = other.createWriter(adapter.getTypeName())) {
    while (it.hasNext()) {
     writer.write(it.next());

代码示例来源:origin: locationtech/geowave

GeoWaveOutputFormat.addIndex(job.getConfiguration(), index);
final DataStore store = outputStoreOptions.createDataStore();
store.addType(newAdapter, index);
final short newInternalAdapterId =
  outputStoreOptions.createInternalAdapterStore().addTypeName(newAdapter.getTypeName());
  outputStoreOptions.createDataStore().query(
    QueryBuilder.newBuilder().addTypeName(
      rasterResizeOptions.getOutputCoverageName()).indexName(index.getName()).build());

代码示例来源:origin: locationtech/geowave

private static void executeCQLQuery() throws IOException, CQLException {
 System.out.println("Executing query, expecting to match two points...");
 final VectorQueryBuilder bldr = VectorQueryBuilder.newBuilder();
 try (final CloseableIterator<SimpleFeature> iterator =
   dataStore.query(
     bldr.indexName(index.getName()).addTypeName(ADAPTER.getTypeName()).constraints(
       bldr.constraintsFactory().cqlConstraints(
         "BBOX(geometry,-77.6167,38.6833,-76.6,38.9200) and locationName like 'W%'")).build())) {
  while (iterator.hasNext()) {
   System.out.println("Query match: " + iterator.next().getID());
  }
 }
}

代码示例来源:origin: locationtech/geowave

typeName).indexName(indexName);
final Long countResult =
  dataStore.aggregate(
    bldr.constraints(bldr.constraintsFactory().cqlConstraints(cqlStr)).build());
if (countResult != null) {
  dataStore.query(
    bldr.constraints(bldr.constraintsFactory().cqlConstraints(cqlStr)).build())) {
 while (it.hasNext()) {

代码示例来源:origin: locationtech/geowave

public static void deleteAll(final DataStorePluginOptions dataStore) {
 dataStore.createDataStore().delete(QueryBuilder.newBuilder().build());
}

代码示例来源:origin: locationtech/geowave

@Override
 public CloseableIterator<SimpleFeature> query(final Index index, final BasicQuery query) {
  VectorAggregationQueryBuilder<Persistable, Long> bldr =
    (VectorAggregationQueryBuilder) VectorAggregationQueryBuilder.newBuilder().count(
      components.getAdapter().getTypeName()).indexName(index.getName()).setAuthorizations(
        transaction.composeAuthorizations()).constraints(
          OptimalCQLQuery.createOptimalQuery(
            filter,
            components.getAdapter(),
            index,
            query));
  if (limit != null) {
   bldr = bldr.limit(limit);
  }
  final Long count = components.getDataStore().aggregate(bldr.build());
  if (count != null) {
   this.count = count;
  }
  return null;
 }
}

代码示例来源:origin: locationtech/geowave

final DataTypeAdapter<?>[] destTypes = other.getTypes();
for (int i = 0; i < sourceTypes.length; i++) {
 boolean found = false;
  other.addType(sourceTypes[i]);
   indexMappingStore.getIndicesForAdapter(adapterId);
 final Index[] indices = indicesForAdapter.getIndices(indexStore);
 other.addIndex(typeName, indices);
  try (final Writer writer = other.createWriter(typeName)) {
   while (it.hasNext()) {
    writer.write(it.next());

代码示例来源:origin: locationtech/geowave

store.addType(dataAdapter, indices);
String typeName = dataAdapter.getTypeName();
try (CloseableIterator<?> it =
  store.query(QueryBuilder.newBuilder().addTypeName(typeName).limit(1).build())) {
 if (!it.hasNext()) {
  if (adapterStore == null) {

代码示例来源:origin: locationtech/geowave

@Override
 protected long runQuery(
   final GeotoolsFeatureDataAdapter adapter,
   final String typeName,
   final String indexName,
   final DataStore dataStore,
   final boolean debug,
   DataStorePluginOptions pluginOptions) {
  long count = 0;
  try (final CloseableIterator<Object> it =
    dataStore.query(
      QueryBuilder.newBuilder().addTypeName(typeName).indexName(indexName).build())) {
   while (it.hasNext()) {
    if (debug) {
     System.out.println(it.next());
    } else {
     it.next();
    }
    count++;
   }
  }
  return count;
 }
}

代码示例来源:origin: locationtech/geowave

typeName).indexName(indexName);
final Long countResult =
  dataStore.aggregate(
    bldr.constraints(
      bldr.constraintsFactory().spatialTemporalConstraints().spatialConstraints(
  dataStore.query(
    bldr.constraints(
      bldr.constraintsFactory().spatialTemporalConstraints().spatialConstraints(

代码示例来源:origin: locationtech/geowave

@Override
 public Void computeResults(final OperationParams params) {
  // Ensure we have all the required arguments
  if (parameters.size() != 2) {
   throw new ParameterException("Requires arguments: <store name> <type name>");
  }

  final String inputStoreName = parameters.get(0);
  final String typeName = parameters.get(1);

  // Attempt to load store.
  final File configFile = getGeoWaveConfigFile(params);

  final StoreLoader inputStoreLoader = new StoreLoader(inputStoreName);
  if (!inputStoreLoader.loadFromConfig(configFile)) {
   throw new ParameterException("Cannot find store name: " + inputStoreLoader.getStoreName());
  }
  inputStoreOptions = inputStoreLoader.getDataStorePlugin();

  LOGGER.info("Deleting everything in store: " + inputStoreName + " with type name: " + typeName);
  inputStoreOptions.createDataStore().delete(
    QueryBuilder.newBuilder().addTypeName(typeName).build());
  return null;
 }
}

代码示例来源:origin: locationtech/geowave

@Override
 public CloseableIterator<SimpleFeature> query(final Index index, final BasicQuery query) {
  final VectorAggregationQueryBuilder<DistributedRenderOptions, DistributedRenderResult> bldr =
    (VectorAggregationQueryBuilder) VectorAggregationQueryBuilder.newBuilder().indexName(
      index.getName()).setAuthorizations(transaction.composeAuthorizations());
  bldr.aggregate(
    components.getAdapter().getTypeName(),
    new DistributedRenderAggregation(renderOptions)).constraints(
      OptimalCQLQuery.createOptimalQuery(filter, components.getAdapter(), index, query));
  final DistributedRenderResult result = components.getDataStore().aggregate(bldr.build());
  return new CloseableIterator.Wrapper(
    Iterators.singletonIterator(
      SimpleFeatureBuilder.build(
        GeoWaveFeatureCollection.getDistributedRenderFeatureType(),
        new Object[] {result, renderOptions},
        "render")));
 }
}

代码示例来源:origin: locationtech/geowave

private void ingest(
  final FeatureDataAdapter adapter,
  final Index index,
  final List<SimpleFeature> features) {
 dataStore.addType(adapter, index);
 try (Writer<SimpleFeature> indexWriter = dataStore.createWriter(adapter.getTypeName())) {
  for (final SimpleFeature sf : features) {
   indexWriter.write(sf);
  }
 }
}

代码示例来源:origin: locationtech/geowave

@Override
 protected long runQuery(
   final GeotoolsFeatureDataAdapter adapter,
   final String typeName,
   final String indexName,
   final DataStore dataStore,
   final boolean debug,
   DataStorePluginOptions pluginOptions) {
  getFilter();

  long count = 0;
  try (final CloseableIterator<Object> it =
    dataStore.query(
      QueryBuilder.newBuilder().addTypeName(typeName).indexName(indexName).build())) {
   while (it.hasNext()) {
    final Object o = it.next();
    if (o instanceof SimpleFeature) {
     if (filter.evaluate(o)) {
      if (debug) {
       System.out.println(o);
      }
      count++;
     }
    }
   }
  }
  return count;
 }
}

代码示例来源:origin: locationtech/geowave

@Override
 public Void computeResults(final OperationParams params) {
  if (parameters.size() < 1) {
   throw new ParameterException("Must specify store name");
  }

  final String inputStoreName = parameters.get(0);

  // Attempt to load store.
  final File configFile = getGeoWaveConfigFile(params);

  // Attempt to load input store.
  final StoreLoader inputStoreLoader = new StoreLoader(inputStoreName);
  if (!inputStoreLoader.loadFromConfig(configFile)) {
   throw new ParameterException("Cannot find store name: " + inputStoreLoader.getStoreName());
  }
  inputStoreOptions = inputStoreLoader.getDataStorePlugin();

  LOGGER.info("Deleting everything in store: " + inputStoreName);

  inputStoreOptions.createDataStore().delete(QueryBuilder.newBuilder().build());
  return null;
 }
}

代码示例来源:origin: locationtech/geowave

public synchronized Writer getIndexWriter(
  final DataTypeAdapter<?> adapter,
  final Index... requiredIndices) throws MismatchedIndexToAdapterMapping {
 Writer indexWriter = adapterIdToWriterCache.get(adapter.getTypeName());
 if (indexWriter == null) {
  dataStore.addType(adapter, requiredIndices);
  indexWriter = dataStore.createWriter(adapter.getTypeName());
  adapterIdToWriterCache.put(adapter.getTypeName(), indexWriter);
 }
 return indexWriter;
}

代码示例来源:origin: locationtech/geowave

dataStore.query(
  bldr.addTypeName(typeName).indexName("SPATIAL_IDX").addAuthorization(
    "root").constraints(

相关文章