本文整理汇总了Java中mil.nga.giat.geowave.core.store.CloseableIterator.close方法的典型用法代码示例。如果您正苦于以下问题:Java CloseableIterator.close方法的具体用法?Java CloseableIterator.close怎么用?Java CloseableIterator.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mil.nga.giat.geowave.core.store.CloseableIterator
的用法示例。
在下文中一共展示了CloseableIterator.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testQuery
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
private int testQuery(
final DataAdapter<?> adapter,
final Query query )
throws Exception {
final mil.nga.giat.geowave.core.store.DataStore geowaveStore = dataStorePluginOptions.createDataStore();
final CloseableIterator<?> accumuloResults = geowaveStore.query(
new QueryOptions(
adapter,
TestUtils.DEFAULT_SPATIAL_INDEX),
query);
int resultCount = 0;
while (accumuloResults.hasNext()) {
accumuloResults.next();
resultCount++;
}
accumuloResults.close();
return resultCount;
}
示例2: transferBatch
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void transferBatch(
final String fromBatchId,
final String groupID )
throws IOException {
final CloseableIterator<T> it = getRawCentroids(
fromBatchId,
groupID);
int count = 0;
try (final IndexWriter indexWriter = dataStore.createWriter(
adapter,
index)) {
while (it.hasNext()) {
final AnalyticItemWrapper<T> item = centroidFactory.create(it.next());
item.setBatchID(this.batchId);
count++;
indexWriter.write(item.getWrappedItem());
}
it.close();
// indexWriter.close();
}
LOGGER.info("Transfer " + count + " centroids");
}
示例3: getExpectedResults
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
public static ExpectedResults getExpectedResults(
final CloseableIterator<?> results )
throws IOException {
final Set<Long> hashedCentroids = new HashSet<Long>();
int expectedResultCount = 0;
try {
while (results.hasNext()) {
final Object obj = results.next();
if (obj instanceof SimpleFeature) {
expectedResultCount++;
final SimpleFeature feature = (SimpleFeature) obj;
hashedCentroids.add(hashCentroid((Geometry) feature.getDefaultGeometry()));
}
}
}
finally {
results.close();
}
return new ExpectedResults(
hashedCentroids,
expectedResultCount);
}
示例4: testQuery
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
private int testQuery(
final DataAdapter<?> adapter,
final Query query )
throws Exception {
final mil.nga.giat.geowave.core.store.DataStore geowaveStore = dataStore.createDataStore();
final CloseableIterator<?> accumuloResults = geowaveStore.query(
new QueryOptions(
adapter,
TestUtils.DEFAULT_SPATIAL_INDEX),
query);
int resultCount = 0;
while (accumuloResults.hasNext()) {
accumuloResults.next();
resultCount++;
}
accumuloResults.close();
return resultCount;
}
示例5: listVectors
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
public static String[] listVectors(final ProviderProperties providerProperties) throws IOException
{
initConnectionInfo();
List<String> results = new ArrayList<String>();
for (String storeName : getConnectionInfo().getStoreNames())
{
initDataSource(null, storeName);
DataSourceEntry entry = getDataSourceEntry(storeName);
CloseableIterator<DataAdapter<?>> iter = entry.adapterStore.getAdapters();
try
{
while (iter.hasNext())
{
DataAdapter<?> adapter = iter.next();
if (adapter != null)
{
ByteArrayId adapterId = adapter.getAdapterId();
if (checkAuthorizations(adapterId, storeName, providerProperties))
{
results.add(adapterId.getString());
}
}
}
}
finally
{
if (iter != null)
{
iter.close();
}
}
}
String[] resultArray = new String[results.size()];
return results.toArray(resultArray);
}
示例6: testIngest
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
@Test
public void testIngest()
throws IOException {
final URL toIngest = this.getClass().getClassLoader().getResource(
filePath);
assertTrue(GeoLifeUtils.validate(toIngest));
final Collection<ByteArrayId> indexIds = new ArrayList<ByteArrayId>();
indexIds.add(new ByteArrayId(
"123".getBytes(StringUtils.UTF8_CHAR_SET)));
final CloseableIterator<GeoWaveData<SimpleFeature>> features = ingester.toGeoWaveData(
toIngest,
indexIds,
"");
assertTrue((features != null) && features.hasNext());
int featureCount = 0;
while (features.hasNext()) {
final GeoWaveData<SimpleFeature> feature = features.next();
if (isValidGeoLifeFeature(feature)) {
featureCount++;
}
}
features.close();
final boolean readExpectedCount = (featureCount == expectedCount);
if (!readExpectedCount) {
System.out.println("Expected " + expectedCount + " features, ingested " + featureCount);
}
assertTrue(readExpectedCount);
}
示例7: testDeleteCQL
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
protected void testDeleteCQL(
final String cqlStr,
final PrimaryIndex index )
throws Exception {
LOGGER.warn("bulk deleting from " + index.getId() + " index using CQL: '" + cqlStr + "'");
final mil.nga.giat.geowave.core.store.DataStore geowaveStore = getDataStorePluginOptions().createDataStore();
// Retrieve the feature adapter for the CQL query generator
AdapterStore adapterStore = getDataStorePluginOptions().createAdapterStore();
final CloseableIterator<DataAdapter<?>> it = adapterStore.getAdapters();
GeotoolsFeatureDataAdapter adapter = (GeotoolsFeatureDataAdapter) it.next();
it.close();
// Create the CQL query
Query query = CQLQuery.createOptimalQuery(
cqlStr,
adapter,
null,
null);
deleteInternal(
geowaveStore,
index,
query);
}
示例8: testIngest
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
@Test
public void testIngest()
throws IOException {
final URL toIngest = this.getClass().getClassLoader().getResource(
filePath);
assertTrue(validate(toIngest));
final Collection<ByteArrayId> indexIds = new ArrayList<ByteArrayId>();
indexIds.add(new ByteArrayId(
"123".getBytes(StringUtils.UTF8_CHAR_SET)));
final CloseableIterator<GeoWaveData<SimpleFeature>> features = ingester.toGeoWaveData(
toIngest,
indexIds,
"");
assertTrue((features != null) && features.hasNext());
int featureCount = 0;
while (features.hasNext()) {
final GeoWaveData<SimpleFeature> feature = features.next();
if (isValidAVROFeature(feature)) {
featureCount++;
}
}
features.close();
final boolean readExpectedCount = (featureCount == expectedCount);
if (!readExpectedCount) {
System.out.println("Expected " + expectedCount + " features, ingested " + featureCount);
}
assertTrue(readExpectedCount);
}
示例9: createTypeNames
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
@Override
protected List<Name> createTypeNames()
throws IOException {
final List<Name> names = new ArrayList<>();
final CloseableIterator<DataAdapter<?>> adapters = adapterStore.getAdapters();
while (adapters.hasNext()) {
final DataAdapter<?> adapter = adapters.next();
if (adapter instanceof GeotoolsFeatureDataAdapter) {
names.add(((GeotoolsFeatureDataAdapter) adapter).getFeatureType().getName());
}
}
adapters.close();
return names;
}
示例10: hasAtLeastOne
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
private static boolean hasAtLeastOne(
final CloseableIterator<?> it ) {
try {
return it.hasNext();
}
finally {
try {
it.close();
}
catch (final IOException e) {
e.printStackTrace();
}
}
}
示例11: verifyResults
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
private void verifyResults(
final CloseableIterator<SimpleFeature> results,
final int numExpectedResults,
final Collection<String> attributesExpected )
throws IOException {
int numResults = 0;
SimpleFeature currentFeature;
Object currentAttributeValue;
while (results.hasNext()) {
currentFeature = results.next();
numResults++;
for (final String currentAttribute : ALL_ATTRIBUTES) {
currentAttributeValue = currentFeature.getAttribute(currentAttribute);
if (attributesExpected.contains(currentAttribute)) {
Assert.assertNotNull(
"Expected non-null " + currentAttribute + " value!",
currentAttributeValue);
}
else {
Assert.assertNull(
"Expected null " + currentAttribute + " value!",
currentAttributeValue);
}
}
}
results.close();
Assert.assertEquals(
"Unexpected number of query results",
numExpectedResults,
numResults);
}
示例12: test
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
@Test
public void test()
throws IOException {
final Set<String> expectedSet = HelperClass.buildSet(expectedResults);
final GpxIngestPlugin pluggin = new GpxIngestPlugin();
pluggin.init(new File(
this.getClass().getClassLoader().getResource(
"metadata.xml").getPath()).getParentFile().toURI().toURL());
final ByteArrayId indexId = new ByteArrayId(
"123".getBytes(StringUtils.GEOWAVE_CHAR_SET));
final Collection<ByteArrayId> indexIds = new ArrayList<ByteArrayId>();
indexIds.add(indexId);
final CloseableIterator<GeoWaveData<SimpleFeature>> consumer = pluggin.toGeoWaveData(
this.getClass().getClassLoader().getResource(
"12345.xml"),
indexIds,
"");
int totalCount = 0;
while (consumer.hasNext()) {
final GeoWaveData<SimpleFeature> data = consumer.next();
expectedSet.remove(data.getValue().getID());
final ValidateObject<SimpleFeature> tester = expectedResults.get(data.getValue().getID());
if (tester != null) {
assertTrue(
data.getValue().toString(),
tester.validate(data.getValue()));
}
totalCount++;
}
consumer.close();
assertEquals(
9,
totalCount);
// did everything get validated?
if (expectedSet.size() > 0) {
System.out.println("Failed matches:");
System.out.println(expectedSet);
}
assertEquals(
"All expected data set should be matched; zero unmatched data expected",
0,
expectedSet.size());
}
示例13: testIngest
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
@Test
public void testIngest()
throws IOException {
final URL toIngest = this.getClass().getClassLoader().getResource(
filePath);
assertTrue(GDELTUtils.validate(toIngest));
final Collection<ByteArrayId> indexIds = new ArrayList<ByteArrayId>();
indexIds.add(new ByteArrayId(
"123".getBytes(StringUtils.UTF8_CHAR_SET)));
final CloseableIterator<GeoWaveData<SimpleFeature>> features = ingester.toGeoWaveData(
toIngest,
indexIds,
"");
assertTrue((features != null) && features.hasNext());
int featureCount = 0;
while (features.hasNext()) {
final GeoWaveData<SimpleFeature> feature = features.next();
if (isValidGDELTFeature(feature)) {
featureCount++;
}
}
features.close();
final CloseableIterator<GeoWaveData<SimpleFeature>> featuresExt = ingesterExt.toGeoWaveData(
toIngest,
indexIds,
"");
assertTrue((featuresExt != null) && featuresExt.hasNext());
int featureCountExt = 0;
while (featuresExt.hasNext()) {
final GeoWaveData<SimpleFeature> featureExt = featuresExt.next();
if (isValidGDELTFeatureExt(featureExt)) {
featureCountExt++;
}
}
featuresExt.close();
final boolean readExpectedCount = (featureCount == expectedCount);
if (!readExpectedCount) {
System.out.println("Expected " + expectedCount + " features, ingested " + featureCount);
}
final boolean readExpectedCountExt = (featureCountExt == expectedCount);
if (!readExpectedCount) {
System.out.println("Expected " + expectedCount + " features, ingested " + featureCountExt);
}
assertTrue(readExpectedCount);
assertTrue(readExpectedCountExt);
}
示例14: interweaveTransaction
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
@Override
public CloseableIterator<SimpleFeature> interweaveTransaction(
final Integer limit,
final Filter filter,
final CloseableIterator<SimpleFeature> it ) {
return new CloseableIterator<SimpleFeature>() {
Iterator<SimpleFeature> addedIt = addedFeatures.values().iterator();
SimpleFeature feature = null;
long count = 0;
@Override
public boolean hasNext() {
if (limit != null && limit.intValue() > 0 && count > limit) return false;
while (addedIt.hasNext() && (feature == null)) {
feature = addedIt.next();
if (!filter.evaluate(feature)) feature = null;
}
while (it.hasNext() && (feature == null)) {
feature = it.next();
final ModifiedFeature modRecord = modifiedFeatures.get(feature.getID());
// exclude removed features
// and include updated features not written yet.
final Collection<SimpleFeature> oldFeatures = removedFeatures.get(feature.getID());
if (modRecord != null) {
feature = modRecord.newFeature;
}
else if ((oldFeatures != null) && !oldFeatures.isEmpty()) {
// need to check if the removed feature
// was just moved meaning its original matches the
// boundaries of this 'feature'. matchesOne(oldFeatures,
// feature))
feature = null;
}
}
return feature != null;
}
@Override
public SimpleFeature next()
throws NoSuchElementException {
if (feature == null) {
throw new NoSuchElementException();
}
final SimpleFeature retVal = feature;
feature = null;
count++;
return retVal;
}
@Override
public void remove() {
removedFeatures.put(
feature.getID(),
feature);
}
@Override
public void close()
throws IOException {
it.close();
}
};
}
示例15: computeResults
import mil.nga.giat.geowave.core.store.CloseableIterator; //导入方法依赖的package包/类
@Override
public String 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.
if (inputStoreOptions == null) {
final StoreLoader inputStoreLoader = new StoreLoader(
inputStoreName);
if (!inputStoreLoader.loadFromConfig(configFile)) {
throw new ParameterException(
"Cannot find store name: " + inputStoreLoader.getStoreName());
}
inputStoreOptions = inputStoreLoader.getDataStorePlugin();
}
final CloseableIterator<DataAdapter<?>> it = inputStoreOptions.createAdapterStore().getAdapters();
final StringBuffer buffer = new StringBuffer();
while (it.hasNext()) {
final DataAdapter<?> adapter = it.next();
buffer.append(
adapter.getAdapterId().getString()).append(
' ');
}
try {
it.close();
}
catch (final IOException e) {
LOGGER.error(
"Unable to close Iterator",
e);
}
return buffer.toString();
}