use of org.locationtech.geowave.core.index.InsertionIds in project geowave by locationtech.
the class RoundRobinKeyIndexStrategyTest method testGetInsertionIds.
@Test
public void testGetInsertionIds() {
final List<ByteArray> ids = new ArrayList<>();
final InsertionIds ids2 = sfcIndexStrategy.getInsertionIds(sfcIndexedRange, 1);
final List<byte[]> compositeIds = ids2.getCompositeInsertionIds();
for (int i = 0; i < 3; i++) {
for (final byte[] id2 : compositeIds) {
ids.add(new ByteArray(ByteArrayUtils.combineArrays(new byte[] { (byte) i }, id2)));
}
}
final Set<ByteArray> testIds = new HashSet<>(ids);
final Set<ByteArray> compoundIndexIds = compoundIndexStrategy.getInsertionIds(sfcIndexedRange, 8).getCompositeInsertionIds().stream().map(i -> new ByteArray(i)).collect(Collectors.toSet());
Assert.assertTrue(testIds.containsAll(compoundIndexIds));
final SinglePartitionInsertionIds id2 = ids2.getPartitionKeys().iterator().next();
final MultiDimensionalCoordinates sfcIndexCoordinatesPerDim = sfcIndexStrategy.getCoordinatesPerDimension(id2.getPartitionKey(), id2.getSortKeys().get(0));
// the first 2 bytes are the partition keys
final MultiDimensionalCoordinates coordinatesPerDim = compoundIndexStrategy.getCoordinatesPerDimension(Arrays.copyOfRange(ids.get(0).getBytes(), 0, 2), Arrays.copyOfRange(ids.get(0).getBytes(), 2, ids.get(0).getBytes().length));
Assert.assertTrue(sfcIndexCoordinatesPerDim.equals(coordinatesPerDim));
}
use of org.locationtech.geowave.core.index.InsertionIds in project geowave by locationtech.
the class TextIndexUtils method getInsertionIds.
public static InsertionIds getInsertionIds(final String entry, final EnumSet<TextSearchType> supportedSearchTypes, final EnumSet<CaseSensitivity> supportedCaseSensitivities, final int nGramCharacters) {
if ((entry == null) || entry.isEmpty()) {
LOGGER.info("Cannot index null string, skipping entry");
return new InsertionIds();
}
final Set<TextIndexType> indexTypes = supportedSearchTypes.stream().map(TextSearchType::getIndexType).collect(Collectors.toSet());
final List<SinglePartitionInsertionIds> retVal = new ArrayList<>(indexTypes.size());
for (final TextIndexType indexType : indexTypes) {
for (final CaseSensitivity caseSensitivity : supportedCaseSensitivities) {
final boolean caseSensitive = CaseSensitivity.CASE_SENSITIVE.equals(caseSensitivity);
switch(indexType) {
case FORWARD:
retVal.add(getForwardInsertionIds(entry, caseSensitive));
break;
case REVERSE:
retVal.add(getReverseInsertionIds(entry, caseSensitive));
break;
case NGRAM:
final SinglePartitionInsertionIds i = getNGramInsertionIds(entry, nGramCharacters, indexTypes.contains(TextIndexType.FORWARD), caseSensitive);
if (i != null) {
retVal.add(i);
}
break;
}
}
}
return new InsertionIds(retVal);
}
Aggregations