public Iterator<GeoWaveRow> getRows(final byte[][] dataIds, final short adapterId) { final Map<byte[], byte[]> results = getCurrentSyncCollection().getAll(new HashSet<>(Arrays.asList(dataIds))); return Arrays.stream(dataIds).map( dataId -> DataIndexUtils.deserializeDataIndexRow( dataId, adapterId, results.get(dataId), visibilityEnabled)).iterator(); }
public synchronized void add(final byte[] dataId, final GeoWaveValue value) { put(dataId, DataIndexUtils.serializeDataIndexValue(value, visibilityEnabled)); }
public boolean createIndex(final Index index) throws IOException { final String indexName = index.getName(); return createTable(getQualifiedTableName(indexName), DataIndexUtils.isDataIndex(indexName)); } }
new AdapterStoreWrapper(adapterStore, internalAdapterStore); final DataIndexRetrieval dataIndexRetrieval = DataIndexUtils.getDataIndexRetrieval( operations, persistentAdapterStore,
public boolean adapterSupportsDataIndex() { return DataIndexUtils.adapterSupportsDataIndex(getDataAdapter()); }
public static GeoWaveRow deserializeDataIndexRow( final byte[] dataId, final short adapterId, final byte[] serializedValue, final boolean visibilityEnabled) { return new GeoWaveRowImpl( new GeoWaveKeyImpl(dataId, adapterId, new byte[0], new byte[0], 0), new GeoWaveValue[] {deserializeDataIndexValue(serializedValue, visibilityEnabled)}); }
statisticsStore, sanitizedQueryOptions.getAuthorizations()), DataIndexUtils.getDataIndexRetrieval( baseOperations, adapterStore,
if (secondaryIndex && DataIndexUtils.adapterSupportsDataIndex(adapter) && !dataIdIndex) { byte[] indexModelVisibility = new byte[0]; if (visibilityEnabled) {
private BatchGetItemResult getResults( final Map<String, KeysAndAttributes> requestItems, final short adapterId, final Map<ByteArray, GeoWaveRow> resultMap) { final BatchGetItemRequest request = new BatchGetItemRequest(requestItems); final BatchGetItemResult result = client.batchGetItem(request); result.getResponses().values().forEach(results -> results.stream().forEach(objMap -> { final byte[] dataId = objMap.get(DynamoDBRow.GW_PARTITION_ID_KEY).getB().array(); final AttributeValue valueAttr = objMap.get(DynamoDBRow.GW_VALUE_KEY); final byte[] value = valueAttr == null ? null : valueAttr.getB().array(); resultMap.put( new ByteArray(dataId), DataIndexUtils.deserializeDataIndexRow(dataId, adapterId, value, false)); })); return result; }
public void add(final byte[] dataId, final GeoWaveValue value) { preAdd(); getCurrentAsyncCollection().putAsync( dataId, DataIndexUtils.serializeDataIndexValue(value, visibilityEnabled)); }
final String[] additionalAuthorizations, final int dataIndexBatchSize) { if ((dataIndexBatchSize > 0) && !isDataIndex(index.getName())) {
differingVisibilityCounts, visibilityCounts, DataIndexUtils.getDataIndexRetrieval( baseOperations, adapterStore,
private <T> Writer<T> createWriter(final InternalDataAdapter<T> adapter, final Index... indices) { boolean secondaryIndex = baseOptions.isSecondaryIndexing() && DataIndexUtils.adapterSupportsDataIndex(adapter); final Writer<T>[] writers = new Writer[secondaryIndex ? indices.length + 1 : indices.length];
public synchronized CloseableIterator<GeoWaveRow> dataIndexIterator(final byte[][] dataIds) { final RocksDB readDb = getReadDb(); if (readDb == null) { return new CloseableIterator.Empty<>(); } try { final List<byte[]> dataIdsList = Arrays.asList(dataIds); final Map<byte[], byte[]> dataIdxResults = readDb.multiGet(dataIdsList); return new CloseableIterator.Wrapper( dataIdsList.stream().map( dataId -> DataIndexUtils.deserializeDataIndexRow( dataId, adapterId, dataIdxResults.get(dataId), visibilityEnabled)).iterator()); } catch (final RocksDBException e) { LOGGER.error("Unable to get values by data ID", e); } return new CloseableIterator.Empty<>(); } }
retVal[i].set( CassandraField.GW_VALUE_KEY.getBindMarkerName(), ByteBuffer.wrap(DataIndexUtils.serializeDataIndexValue(value, visibilityEnabled)), ByteBuffer.class); i++;
private boolean createTable(final String indexName) { synchronized (CREATE_TABLE_MUTEX) { try { if (!indexExists(indexName)) { final String tableName = getCassandraSafeName(indexName); final Create create = getCreateTable(tableName); CassandraField[] fields = CassandraField.values(); if (DataIndexUtils.isDataIndex(tableName)) { fields = Arrays.stream(fields).filter(f -> f.isDataIndexColumn()).toArray( i -> new CassandraField[i]); } for (final CassandraField f : fields) { f.addColumn(create); } executeCreateTable(create, tableName); return true; } } catch (final IOException e) { LOGGER.error("Unable to create table '" + indexName + "'", e); } } return false; }
statisticsStore, sanitizedQueryOptions.getAuthorizations()), DataIndexUtils.getDataIndexRetrieval( baseOperations, adapterStore,
public Iterator<GeoWaveRow> getDataIndexResults( final byte[][] rows, final short adapterId, final String... additionalAuthorizations) { Result[] results = null; final byte[] family = StringUtils.stringToBinary(ByteArrayUtils.shortToString(adapterId)); try (final Table table = conn.getTable(getTableName(DataIndexUtils.DATA_ID_INDEX.getName()))) { results = table.get(Arrays.stream(rows).map(r -> { final Get g = new Get(r); g.addFamily(family); if ((additionalAuthorizations != null) && (additionalAuthorizations.length > 0)) { g.setAuthorizations(new Authorizations(additionalAuthorizations)); } return g; }).collect(Collectors.toList())); } catch (final IOException e) { LOGGER.error("Unable to close HBase table", e); } if (results != null) { return Arrays.stream(results).map( r -> DataIndexUtils.deserializeDataIndexRow( r.getRow(), adapterId, r.getValue(family, new byte[0]), false)).iterator(); } return Collections.emptyIterator(); }
private RowMutations rowToMutation(final GeoWaveRow row) { final RowMutations mutation = new RowMutations(row.getDataId()); for (final GeoWaveValue value : row.getFieldValues()) { final Put put = new Put(row.getDataId()); // visibility is in the visibility column so no need to serialize it with the value put.addColumn( StringUtils.stringToBinary(ByteArrayUtils.shortToString(row.getAdapterId())), new byte[0], DataIndexUtils.serializeDataIndexValue(value, false)); if ((value.getVisibility() != null) && (value.getVisibility().length > 0)) { put.setCellVisibility( new CellVisibility(StringUtils.stringFromBinary(value.getVisibility()))); } try { mutation.add(put); } catch (final IOException e) { LOGGER.error("Error creating HBase row mutation: " + e.getMessage()); } } return mutation; } }
@Override public RowWriter createWriter(final Index index, final InternalDataAdapter<?> adapter) { final boolean isDataIndex = DataIndexUtils.isDataIndex(index.getName()); final String qName = getQualifiedTableName(index.getName()); final DynamoDBWriter writer = new DynamoDBWriter(client, qName, isDataIndex); createTable(qName, isDataIndex); return writer; }