@Override protected ByteArray shortToByteArrayId(final short internalAdapterId) { return new ByteArray(ByteArrayUtils.shortToString(internalAdapterId)); }
@Override public Map<String, String> getOptions(final Map<String, String> existingOptions) { final Map<String, String> newOptions = adapter.getOptions(internalAdapterId, existingOptions); String nextAdapterIdsValue = ByteArrayUtils.shortToString(internalAdapterId); if ((existingOptions != null) && existingOptions.containsKey(ADAPTER_IDS_OPTION)) { final String existingAdapterIds = existingOptions.get(ADAPTER_IDS_OPTION); final Set<String> nextAdapters = new HashSet<String>(); for (final String id : nextAdapterIdsValue.split(",")) { nextAdapters.add(id); } final StringBuffer str = new StringBuffer(nextAdapterIdsValue); for (final String id : existingAdapterIds.split(",")) { if (!nextAdapters.contains(id)) { str.append(","); str.append(id); } } nextAdapterIdsValue = str.toString(); } newOptions.put(ADAPTER_IDS_OPTION, nextAdapterIdsValue); newOptions.put( ROW_TRANSFORM_KEY, ByteArrayUtils.byteArrayToString(PersistenceUtils.toBinary(adapter.getTransform()))); return newOptions; } }
public void deleteRowsFromDataIndex(final byte[][] rows, final short adapterId) { try { final BufferedMutator mutator = getBufferedMutator(getTableName(DataIndexUtils.DATA_ID_INDEX.getName())); final byte[] family = StringUtils.stringToBinary(ByteArrayUtils.shortToString(adapterId)); mutator.mutate(Arrays.stream(rows).map(r -> { final Delete delete = new Delete(r); delete.addFamily(family); return delete; }).collect(Collectors.toList())); } catch (final IOException e) { LOGGER.warn("Unable to delete from data index", e); } }
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(); }
public void createTable( final byte[][] preSplits, final String indexName, final boolean enableVersioning, final short internalAdapterId) { final TableName tableName = getTableName(indexName); final GeoWaveColumnFamily[] columnFamilies = new GeoWaveColumnFamily[1]; columnFamilies[0] = new StringColumnFamily(ByteArrayUtils.shortToString(internalAdapterId)); try { createTable( preSplits, columnFamilies, StringColumnFamilyFactory.getSingletonInstance(), enableVersioning, tableName); } catch (final IOException e) { LOGGER.error("Error creating table: " + indexName, e); } }
public boolean verifyColumnFamily( final short columnFamily, final boolean enableVersioning, final String tableNameStr, final boolean addIfNotExist) { final TableName tableName = getTableName(tableNameStr); final GeoWaveColumnFamily[] columnFamilies = new GeoWaveColumnFamily[1]; columnFamilies[0] = new StringColumnFamily(ByteArrayUtils.shortToString(columnFamily)); try { return verifyColumnFamilies( columnFamilies, StringColumnFamilyFactory.getSingletonInstance(), enableVersioning, tableName, addIfNotExist); } catch (final IOException e) { LOGGER.error( "Error verifying column family " + columnFamily + " on table " + tableNameStr, e); } return false; }
StringUtils.stringToBinary(ByteArrayUtils.shortToString(row.getAdapterId())), value.getFieldMask(), value.getValue());
private RowWriter internalCreateWriter( final Index index, final InternalDataAdapter<?> adapter, final Function<BufferedMutator, RowWriter> writerSupplier) { final TableName tableName = getTableName(index.getName()); try { final GeoWaveColumnFamily[] columnFamilies = new GeoWaveColumnFamily[1]; columnFamilies[0] = new StringColumnFamily(ByteArrayUtils.shortToString(adapter.getAdapterId())); createTable( index.getIndexStrategy().getPredefinedSplits(), columnFamilies, StringColumnFamilyFactory.getSingletonInstance(), options.isServerSideLibraryEnabled(), tableName); verifyColumnFamilies( columnFamilies, StringColumnFamilyFactory.getSingletonInstance(), true, tableName, true); return writerSupplier.apply(getBufferedMutator(tableName)); } catch (final TableNotFoundException e) { LOGGER.error("Table does not exist", e); } catch (final IOException e) { LOGGER.error("Error creating table: " + index.getName(), e); } return null; }
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; } }
while (buf.hasRemaining()) { short adapterId = buf.getShort(); adapterIds.add(StringUtils.stringToBinary(ByteArrayUtils.shortToString(adapterId)));
scan.addFamily(StringUtils.stringToBinary(ByteArrayUtils.shortToString(internalAdapterId)));
readerParams.getIndex().getName(), false)) { families.add(StringUtils.stringToBinary(ByteArrayUtils.shortToString(adapterId))); } else { LOGGER.warn(