public boolean verifyAdapter(final short internalAdapterId) { if ((this.dataAdapter == null) || (internalAdapterId == 0)) { return false; } this.adapterVerified = (internalAdapterId == dataAdapter.getAdapterId()) ? true : false; return this.adapterVerified; }
@Override public void addAdapter(final InternalDataAdapter<?> InternalDataadapter) { adapterMap.put(InternalDataadapter.getAdapterId(), InternalDataadapter); }
public MemoryPersistentAdapterStore(final InternalDataAdapter<?>[] adapters) { adapterMap = Collections.synchronizedMap(new HashMap<Short, InternalDataAdapter<?>>()); for (final InternalDataAdapter<?> adapter : adapters) { adapterMap.put(adapter.getAdapterId(), adapter); } }
public <T> DeleteCallback<T, GeoWaveRow> getDeleteCallback( final InternalDataAdapter<T> writableAdapter, final Index index) { if (!dcache.containsKey(writableAdapter.getAdapterId())) { final DataStoreStatisticsProvider<T> statsProvider = new DataStoreStatisticsProvider<>(writableAdapter, index, captureAdapterStats); final List<DeleteCallback<T, GeoWaveRow>> callbackList = new ArrayList<>(); if ((writableAdapter.getAdapter() instanceof StatisticsProvider) && persistStats) { callbackList.add( new StatsCompositionTool<>(statsProvider, statsStore, index, writableAdapter)); } dcache.put(writableAdapter.getAdapterId(), new DeleteCallbackList<>(callbackList)); } return (DeleteCallback<T, GeoWaveRow>) dcache.get(writableAdapter.getAdapterId()); }
public <T> IngestCallback<T> getIngestCallback( final InternalDataAdapter<T> writableAdapter, final Index index) { if (!icache.containsKey(writableAdapter.getAdapterId())) { final DataStoreStatisticsProvider<T> statsProvider = new DataStoreStatisticsProvider<>(writableAdapter, index, captureAdapterStats); final List<IngestCallback<T>> callbackList = new ArrayList<>(); if ((writableAdapter.getAdapter() instanceof StatisticsProvider) && persistStats) { callbackList.add( new StatsCompositionTool<>(statsProvider, statsStore, index, writableAdapter)); } icache.put(writableAdapter.getAdapterId(), new IngestCallbackList<>(callbackList)); } return (IngestCallback<T>) icache.get(writableAdapter.getAdapterId()); }
public StatsCompositionTool( final DataStoreStatisticsProvider<T> statisticsProvider, final DataStatisticsStore statisticsStore, final Index index, final InternalDataAdapter<T> adapter, final boolean overwrite) { this.statisticsStore = statisticsStore; this.overwrite = overwrite; this.adapterId = adapter.getAdapterId(); this.init(index, adapter.getAdapter(), statisticsProvider); }
private <T> void deleteEntries( final InternalDataAdapter<T> adapter, final Index index, final String... additionalAuthorizations) throws IOException { statisticsStore.removeAllStatistics(adapter.getAdapterId(), additionalAuthorizations); // cannot delete because authorizations are not used // this.indexMappingStore.remove(adapter.getAdapterId()); baseOperations.deleteAll( index.getName(), adapter.getTypeName(), adapter.getAdapterId(), additionalAuthorizations); }
@Override public RowWriter createDataIndexWriter(final InternalDataAdapter<?> adapter) { return new RockDBDataIndexWriter(client, adapter.getAdapterId(), adapter.getTypeName()); }
protected synchronized void store(final InternalDataAdapter<?> adapter) { if (!adapterStore.adapterExists(adapter.getAdapterId())) { adapterStore.addAdapter(adapter); } }
@Override protected ByteArray getPrimaryId(final InternalDataAdapter<?> persistedObject) { return new ByteArray(ByteArrayUtils.shortToByteArray(persistedObject.getAdapterId())); }
private Short[] getAdaptersForIndex(final String indexName) { final ArrayList<Short> markedAdapters = new ArrayList<>(); // remove the given index for all types try (final CloseableIterator<InternalDataAdapter<?>> it = adapterStore.getAdapters()) { while (it.hasNext()) { final InternalDataAdapter<?> dataAdapter = it.next(); final AdapterToIndexMapping adapterIndexMap = indexMappingStore.getIndicesForAdapter(dataAdapter.getAdapterId()); final String[] indexNames = adapterIndexMap.getIndexNames(); for (int i = 0; i < indexNames.length; i++) { if (indexNames[i].equals(indexName)) { // check if it is the only index for the current adapter if (indexNames.length == 1) { throw new IllegalStateException( "Index removal failed. Adapters require at least one index."); } else { // mark the index for removal markedAdapters.add(adapterIndexMap.getAdapterId()); } } } } } final Short[] adapters = new Short[markedAdapters.size()]; return markedAdapters.toArray(adapters); }
@Override public RowWriter createWriter(final Index index, final InternalDataAdapter<?> adapter) { return new RocksDBWriter( client, adapter.getAdapterId(), adapter.getTypeName(), index.getName(), RocksDBUtils.isSortByTime(adapter)); }
protected enum DeletionMode { DONT_DELETE, DELETE, DELETE_WITH_DUPLICATES; }
public static void addDataAdapter( final Configuration config, final InternalDataAdapter<?> adapter) { JobContextAdapterStore.addDataAdapter(config, adapter.getAdapter()); JobContextInternalAdapterStore.addTypeName( config, adapter.getTypeName(), adapter.getAdapterId()); }
@Override protected boolean performStatsCommand( final DataStorePluginOptions storeOptions, final InternalDataAdapter<?> adapter, final StatsCommandLineOptions statsOptions) throws IOException { // Remove the stat final DataStatisticsStore statStore = storeOptions.createDataStatisticsStore(); final String[] authorizations = getAuthorizations(statsOptions.getAuthorizations()); if (!statStore.removeStatistics( adapter.getAdapterId(), fieldName, new BaseStatisticsType<>(statType), authorizations)) { throw new RuntimeException("Unable to remove statistic: " + statType); } return true; }
if (rowMerging) { if (!((HBaseOperations) baseOperations).isRowMergingEnabled( adapter.getAdapterId(), indexName)) { ((HBaseOperations) baseOperations).createTable( index.getName(), false, adapter.getAdapterId()); if (baseOptions.isServerSideLibraryEnabled()) { ((HBaseOperations) baseOperations).ensureServerSideOperationsObserverAttached( ServerOpHelper.addServerSideRowMerging( ((RowMergingDataAdapter<?, ?>) adapter.getAdapter()), adapter.getAdapterId(), (ServerSideOperations) baseOperations, RowMergingServerOp.class.getName(), adapter.getAdapterId(), false, indexName,
public BaseInsertionIdQuery( final InternalDataAdapter<?> adapter, final Index index, final InsertionIdQuery query, final ScanCallback<T, ?> scanCallback, final DedupeFilter dedupeFilter, final DifferingFieldVisibilityEntryCount differingVisibilityCounts, final FieldVisibilityCount visibilityCounts, final DataIndexRetrieval dataIndexRetrieval, final String[] authorizations) { super( new short[] {adapter.getAdapterId()}, index, query, dedupeFilter, scanCallback, null, null, null, null, differingVisibilityCounts, visibilityCounts, dataIndexRetrieval, authorizations); this.ranges = new InsertionIds( query.getPartitionKey(), Lists.newArrayList(query.getSortKey())).asQueryRanges(); }
if (index != null) { if (statisticsType.equals(RowRangeHistogramStatistics.STATS_TYPE)) { return new RowRangeHistogramStatisticsSet(adapter.getAdapterId(), index.getName()); return new PartitionStatistics(adapter.getAdapterId(), index.getName()); adapter.getAdapterId(), index.getName(), index.getIndexStrategy()); return new DifferingFieldVisibilityEntryCount(adapter.getAdapterId(), index.getName()); return new FieldVisibilityCount(adapter.getAdapterId(), index.getName()); return new DuplicateEntryCount(adapter.getAdapterId(), index.getName()); ((StatisticsProvider) adapter.getAdapter()).createDataStatistics(statisticsId); if (stats != null) { stats.setAdapterId(adapter.getAdapterId()); return stats;
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 void internalAddIndices( final InternalDataAdapter<?> adapter, final Index[] indices, final boolean updateAdapter) { if (adapter.getAdapter() instanceof InitializeWithIndicesDataAdapter) { if (((InitializeWithIndicesDataAdapter) adapter.getAdapter()).init(indices) && updateAdapter) { adapterStore.removeAdapter(adapter.getAdapterId()); adapterStore.addAdapter(adapter); } } indexMappingStore.addAdapterIndexMapping( new AdapterToIndexMapping( internalAdapterStore.addTypeName(adapter.getTypeName()), indices)); for (final Index index : indices) { store(index); initOnIndexWriterCreate(adapter, index); } }