use of org.locationtech.geowave.core.store.entities.GeoWaveRowImpl in project geowave by locationtech.
the class PartitionsStatisticTest method testIngest.
@Test
public void testIngest() {
final PartitionsStatistic statistic = new PartitionsStatistic();
final PartitionsValue value = statistic.createEmpty();
for (long i = 0; i < 10000; i++) {
final GeoWaveRow row = new GeoWaveRowImpl(genKey(i), new GeoWaveValue[] {});
value.entryIngested(null, 1, row);
}
assertEquals(32, value.getValue().size());
for (byte i = 0; i < 32; i++) {
Assert.assertTrue(value.getValue().contains(new ByteArray(new byte[] { i })));
}
}
use of org.locationtech.geowave.core.store.entities.GeoWaveRowImpl in project geowave by locationtech.
the class RowRangeHistogramStatisticTest method testIngest.
@Test
public void testIngest() {
final RowRangeHistogramStatistic stats = new RowRangeHistogramStatistic("indexName");
final RowRangeHistogramValue value = stats.createEmpty();
for (long i = 0; i < 10000; i++) {
final GeoWaveRow row = new GeoWaveRowImpl(genKey(i), new GeoWaveValue[] {});
value.entryIngested(null, 1, row);
}
System.out.println(stats.toString());
assertEquals(1.0, value.cdf(genKey(10000).getSortKey()), 0.00001);
assertEquals(0.0, value.cdf(genKey(0).getSortKey()), 0.00001);
assertEquals(0.5, value.cdf(genKey(5000).getSortKey()), 0.04);
final RowRangeHistogramValue value2 = stats.createEmpty();
for (long j = 10000; j < 20000; j++) {
final GeoWaveRow row = new GeoWaveRowImpl(genKey(j), new GeoWaveValue[] {});
value2.entryIngested(null, 1, row);
}
assertEquals(0.0, value2.cdf(genKey(10000).getSortKey()), 0.00001);
value.merge(value2);
assertEquals(0.5, value.cdf(genKey(10000).getSortKey()), 0.15);
value2.fromBinary(value.toBinary());
assertEquals(0.5, value2.cdf(genKey(10000).getSortKey()), 0.15);
}
use of org.locationtech.geowave.core.store.entities.GeoWaveRowImpl in project geowave by locationtech.
the class DataStoreUtils method mergeSingleRowValues.
public static GeoWaveRow mergeSingleRowValues(final GeoWaveRow singleRow, final RowTransform rowTransform) {
if (singleRow.getFieldValues().length < 2) {
return singleRow;
}
// merge all values into a single value
Mergeable merged = null;
for (final GeoWaveValue fieldValue : singleRow.getFieldValues()) {
final Mergeable mergeable = rowTransform.getRowAsMergeableObject(singleRow.getAdapterId(), new ByteArray(fieldValue.getFieldMask()), fieldValue.getValue());
if (merged == null) {
merged = mergeable;
} else {
merged.merge(mergeable);
}
}
final GeoWaveValue[] mergedFieldValues = new GeoWaveValue[] { new GeoWaveValueImpl(singleRow.getFieldValues()[0].getFieldMask(), singleRow.getFieldValues()[0].getVisibility(), rowTransform.getBinaryFromMergedObject(merged)) };
return new GeoWaveRowImpl(new GeoWaveKeyImpl(singleRow.getDataId(), singleRow.getAdapterId(), singleRow.getPartitionKey(), singleRow.getSortKey(), singleRow.getNumberOfDuplicates()), mergedFieldValues);
}
use of org.locationtech.geowave.core.store.entities.GeoWaveRowImpl in project geowave by locationtech.
the class ChooseBestMatchIndexQueryStrategyTest method testChooseSpatialTemporalWithStats.
@Test
public void testChooseSpatialTemporalWithStats() {
final Index temporalindex = new SpatialTemporalIndexBuilder().createIndex();
final Index spatialIndex = new SpatialIndexBuilder().createIndex();
final RowRangeHistogramStatistic rangeTempStats = new RowRangeHistogramStatistic(temporalindex.getName());
rangeTempStats.setBinningStrategy(new CompositeBinningStrategy(new DataTypeBinningStrategy(), new PartitionBinningStrategy()));
rangeTempStats.setInternal();
final RowRangeHistogramStatistic rangeStats = new RowRangeHistogramStatistic(spatialIndex.getName());
rangeStats.setBinningStrategy(new CompositeBinningStrategy(new DataTypeBinningStrategy(), new PartitionBinningStrategy()));
rangeStats.setInternal();
final Map<StatisticId<?>, Map<ByteArray, StatisticValue<?>>> statsMap = new HashMap<>();
final ChooseBestMatchIndexQueryStrategy strategy = new ChooseBestMatchIndexQueryStrategy();
final ConstraintSet cs1 = new ConstraintSet();
cs1.addConstraint(LatitudeDefinition.class, new ConstraintData(new ConstrainedIndexValue(0.3, 0.5), true));
cs1.addConstraint(LongitudeDefinition.class, new ConstraintData(new ConstrainedIndexValue(0.4, 0.7), true));
final ConstraintSet cs2a = new ConstraintSet();
cs2a.addConstraint(TimeDefinition.class, new ConstraintData(new ConstrainedIndexValue(0.1, 0.2), true));
final ConstraintsByClass constraints = new ConstraintsByClass(Arrays.asList(cs2a)).merge(Collections.singletonList(cs1));
final BasicQueryByClass query = new BasicQueryByClass(constraints);
final NumericIndexStrategy temporalIndexStrategy = new SpatialTemporalIndexBuilder().createIndex().getIndexStrategy();
final Random r = new Random(SEED);
for (int i = 0; i < ROWS; i++) {
final double x = r.nextDouble();
final double y = r.nextDouble();
final double t = r.nextDouble();
final InsertionIds id = temporalIndexStrategy.getInsertionIds(new BasicNumericDataset(new NumericData[] { new NumericValue(x), new NumericValue(y), new NumericValue(t) }));
for (final SinglePartitionInsertionIds range : id.getPartitionKeys()) {
Map<ByteArray, StatisticValue<?>> binValues = statsMap.get(rangeTempStats.getId());
if (binValues == null) {
binValues = Maps.newHashMap();
statsMap.put(rangeTempStats.getId(), binValues);
}
final ByteArray bin = CompositeBinningStrategy.getBin(DataTypeBinningStrategy.getBin((String) null), PartitionBinningStrategy.getBin(range.getPartitionKey()));
RowRangeHistogramValue value = (RowRangeHistogramValue) binValues.get(bin);
if (value == null) {
value = rangeTempStats.createEmpty();
value.setBin(bin);
binValues.put(bin, value);
}
((StatisticsIngestCallback) value).entryIngested(null, null, new GeoWaveRowImpl(new GeoWaveKeyImpl(new byte[] { 1 }, (short) 1, range.getPartitionKey(), range.getSortKeys().get(0), 0), new GeoWaveValue[] {}));
}
}
final Index index = new SpatialIndexBuilder().createIndex();
final NumericIndexStrategy indexStrategy = index.getIndexStrategy();
for (int i = 0; i < ROWS; i++) {
final double x = r.nextDouble();
final double y = r.nextDouble();
final double t = r.nextDouble();
final InsertionIds id = indexStrategy.getInsertionIds(new BasicNumericDataset(new NumericData[] { new NumericValue(x), new NumericValue(y), new NumericValue(t) }));
for (final SinglePartitionInsertionIds range : id.getPartitionKeys()) {
Map<ByteArray, StatisticValue<?>> binValues = statsMap.get(rangeStats.getId());
if (binValues == null) {
binValues = Maps.newHashMap();
statsMap.put(rangeStats.getId(), binValues);
}
final ByteArray bin = CompositeBinningStrategy.getBin(DataTypeBinningStrategy.getBin((String) null), PartitionBinningStrategy.getBin(range.getPartitionKey()));
RowRangeHistogramValue value = (RowRangeHistogramValue) binValues.get(bin);
if (value == null) {
value = rangeStats.createEmpty();
value.setBin(bin);
binValues.put(bin, value);
}
((StatisticsIngestCallback) value).entryIngested(null, null, new GeoWaveRowImpl(new GeoWaveKeyImpl(new byte[] { 1 }, (short) 1, range.getPartitionKey(), range.getSortKeys().get(0), 0), new GeoWaveValue[] {}));
}
}
final Iterator<Index> it = getIndices(new TestDataStatisticsStore(Lists.newArrayList(rangeStats, rangeTempStats), statsMap), query, strategy);
assertTrue(it.hasNext());
assertEquals(temporalindex.getName(), it.next().getName());
assertFalse(it.hasNext());
}
use of org.locationtech.geowave.core.store.entities.GeoWaveRowImpl in project geowave by locationtech.
the class FileSystemRowDeleter method delete.
@Override
public void delete(final GeoWaveRow row) {
final FileSystemIndexTable table = tableCache.get(new CacheKey(row.getAdapterId(), internalAdapterStore.getTypeName(row.getAdapterId()), indexName, row.getPartitionKey()));
if (row instanceof GeoWaveRowImpl) {
final GeoWaveKey key = ((GeoWaveRowImpl) row).getKey();
if (key instanceof FileSystemRow) {
deleteRow(table, (FileSystemRow) key);
} else {
LOGGER.info("Unable to convert scanned row into FileSystemRow for deletion. Row is of type GeoWaveRowImpl.");
table.delete(key.getSortKey(), key.getDataId());
}
} else if (row instanceof FileSystemRow) {
deleteRow(table, (FileSystemRow) row);
} else {
LOGGER.info("Unable to convert scanned row into FileSystemRow for deletion. Row is of type " + row.getClass());
table.delete(row.getSortKey(), row.getDataId());
}
}
Aggregations