@Override public long highest(TenantIdAndCentricId tenantIdAndCentricId, ObjectId objectId, String field, long defaultTimestamp) { Long got = updatedStore.get(tenantIdAndCentricId, objectId, field, null, null); if (got == null) { return defaultTimestamp; } return got; }
public ColumnValueAndTimestamp<String, OpaqueFieldValue, Long>[] get( TenantIdAndCentricId tenantIdAndCentricId, ObjectId objectId, String[] fieldNames) { return eventValueStore.multiGetEntries(tenantIdAndCentricId, objectId, fieldNames, null, null); }
@Override public List<Long> highests(TenantIdAndCentricId tenantIdAndCentricId, ObjectId objectId, String[] fields) { return updatedStore.multiGet(tenantIdAndCentricId, objectId, fields, null, null); }
public void remove(TenantIdAndCentricId tenantIdAndCentricId, List<ViewWriteFieldChange> removes) throws IOException { MultiRemove<ImmutableByteArray, ImmutableByteArray> rawRemoves = new MultiRemove<>(); for (ViewWriteFieldChange change : removes) { rawRemoves.add(rowKey(change.getViewObjectId()), columnKey(change.getModelPathIdHashcode(), change.getModelPathInstanceIds()), new ConstantTimestamper(change.getTimestamp())); LOG.debug("VVS:REMOVED {}", change); } List<RowColumnTimestampRemove<ImmutableByteArray, ImmutableByteArray>> took = rawRemoves.take(); viewValueStore.multiRowsMultiRemove(tenantIdAndCentricId, took); }
public void add(TenantIdAndCentricId tenantIdAndCentricId, List<ViewWriteFieldChange> adds) throws IOException { MultiAdd<ImmutableByteArray, ImmutableByteArray, ViewValue> rawAdds = new MultiAdd<>(); for (ViewWriteFieldChange change : adds) { rawAdds.add(rowKey(change.getViewObjectId()), columnKey(change.getModelPathIdHashcode(), change.getModelPathInstanceIds()), change.getValue(), new ConstantTimestamper(change.getTimestamp())); LOG.debug("VVS:ADD {}", change); } List<RowColumValueTimestampAdd<ImmutableByteArray, ImmutableByteArray, ViewValue>> took = rawAdds.take(); viewValueStore.multiRowsMultiAdd(tenantIdAndCentricId, took); }
@Override public ColumnValueAndTimestamp<ImmutableByteArray, ViewValue, Long> callback(ColumnValueAndTimestamp<ImmutableByteArray, ViewValue, Long> v) throws Exception { if (v != null && v.getTimestamp() < timestamp) { removes.add(new RowColumnTimestampRemove<>(rowKey, v.getColumn(), constantTimestamper)); } return v; } });
@Override public void removeObjectId(List<ExistenceUpdate> existenceUpdates) { List<TenantRowColumnTimestampRemove<TenantIdAndCentricId, ObjectId, String>> batch = new ArrayList<>(); for (ExistenceUpdate existenceUpdate : existenceUpdates) { batch.add(new TenantRowColumnTimestampRemove<>(existenceUpdate.tenantId, existenceUpdate.objectId, EXISTS, new ConstantTimestamper(existenceUpdate.timestamp))); if (LOG.isTraceEnabled()) { LOG.trace("Object REMOVED:{} time:{}", new Object[]{existenceUpdate.objectId, existenceUpdate.timestamp}); } } updatedStore.multiRowsMultiRemove(batch); }
@Override public void addObjectId(List<ExistenceUpdate> existenceUpdates) { List<TenantRowColumValueTimestampAdd<TenantIdAndCentricId, ObjectId, String, Long>> batch = new ArrayList<>(); for (ExistenceUpdate existenceUpdate : existenceUpdates) { batch.add(new TenantRowColumValueTimestampAdd<>(existenceUpdate.tenantId, existenceUpdate.objectId, EXISTS, existenceUpdate.timestamp, new ConstantTimestamper(existenceUpdate.timestamp))); if (LOG.isTraceEnabled()) { LOG.trace("Object EXISTS:{} time:{}", new Object[]{existenceUpdate.objectId, existenceUpdate.timestamp}); } } updatedStore.multiRowsMultiAdd(batch); }
public void clear(TenantIdAndCentricId tenantIdAndCentricId, ObjectId viewId, final long timestamp) throws IOException { final List<RowColumnTimestampRemove<ImmutableByteArray, ImmutableByteArray>> removes = new ArrayList<>(); final ConstantTimestamper constantTimestamper = new ConstantTimestamper(timestamp - 1); final ImmutableByteArray rowKey = rowKey(viewId); viewValueStore.getEntrys(tenantIdAndCentricId, rowKey(viewId), null, Long.MAX_VALUE, 1000, false, null, null, new CallbackStream<ColumnValueAndTimestamp<ImmutableByteArray, ViewValue, Long>>() { @Override public ColumnValueAndTimestamp<ImmutableByteArray, ViewValue, Long> callback(ColumnValueAndTimestamp<ImmutableByteArray, ViewValue, Long> v) throws Exception { if (v != null && v.getTimestamp() < timestamp) { removes.add(new RowColumnTimestampRemove<>(rowKey, v.getColumn(), constantTimestamper)); } return v; } }); viewValueStore.multiRowsMultiRemove(tenantIdAndCentricId, removes); }
@Override public void updated(TenantIdAndCentricId tenantIdAndCentricId, ObjectId objectId, String[] fields, long timestamp) { Long[] values = new Long[fields.length]; Arrays.fill(values, timestamp); updatedStore.multiAdd(tenantIdAndCentricId, objectId, fields, values, null, new ConstantTimestamper(timestamp)); }
public void remove(TenantId tenantId, Id userId, Id[] ids, long removeAtTimestamp) { modifierStore.multiRemove(tenantId, userId, ids, new ConstantTimestamper(removeAtTimestamp)); }
@Override public void stream(ViewDescriptor viewDescriptor, ColumnValueAndTimestamp<ImmutableByteArray, ViewValue, Long> value) { if (value != null && value.getTimestamp() < System.currentTimeMillis() - removeUndeclaredFieldsAfterNMillis) { try { ImmutableByteArray rowKey = viewValueStore.rowKey(viewDescriptor.getViewId()); viewValueStore.remove(viewDescriptor.getTenantIdAndCentricId(), rowKey, value.getColumn(), value.getTimestamp() + 1); } catch (IOException x) { LOG.warn("Failed trying to cleanup stale fields for:{} ", viewDescriptor); } } } };
public void remove(TenantIdAndCentricId tenantIdAndCentricId, ImmutableByteArray rowKey, ImmutableByteArray columnKey, long when) throws IOException { viewValueStore.remove(tenantIdAndCentricId, rowKey, columnKey, new ConstantTimestamper(when)); } }
public void multiGet(List<? extends ViewCollector> viewCollectors) throws IOException { List<TenantKeyedColumnValueCallbackStream<TenantIdAndCentricId, ImmutableByteArray, ImmutableByteArray, ViewValue, Long>> keyCallbackPairs = Lists. newArrayList(); for (ViewCollector viewCollector : viewCollectors) { ViewDescriptor viewDescriptor = viewCollector.getViewDescriptor(); keyCallbackPairs.add(new TenantKeyedColumnValueCallbackStream<>(viewDescriptor.getTenantIdAndCentricId(), rowKey(viewDescriptor.getViewId()), viewCollector)); } viewValueStore.multiRowGetAll(keyCallbackPairs); }
public static ViewValueWriter initializeViewWriter(ViewWriterServiceConfig config, SetOfSortedMapsImplInitializer<Exception> setOfSortedMapsImplInitializer, ViewPathKeyProvider viewPathKeyProvider) throws Exception { RowColumnValueStore<TenantIdAndCentricId, ImmutableByteArray, ImmutableByteArray, ViewValue, RuntimeException> store = new NeverAcceptsFailureSetOfSortedMaps<>(setOfSortedMapsImplInitializer.initialize(config.getTableNameSpace(), "tasmo.views", "v", new DefaultRowColumnValueStoreMarshaller<>( new TenantIdAndCentricIdMarshaller(), new ImmutableByteArrayMarshaller(), new ImmutableByteArrayMarshaller(), new ViewValueMarshaller()), new CurrentTimestamper())); ViewValueWriter viewValueWriter = new ViewValueWriter(new ViewValueStore(store, viewPathKeyProvider)); return viewValueWriter; } }
public void add(TenantId tenantId, Id userId, Set<Id> ids, long timestamp) { String[] values = new String[ids.size()]; Arrays.fill(values, ""); modifierStore.multiAdd(tenantId, userId, ids.toArray(new Id[ids.size()]), values, Integer.MIN_VALUE, null); }
public void pump() { List<ReferenceRequest> batch = new ArrayList<>(); while (batch.size() < maxBatchSize) { ReferenceRequest referenceRequest = referenceRequests.poll(); if (referenceRequest == null) { break; } batch.add(referenceRequest); } // TODO multiGet(); List<TenantKeyedColumnValueCallbackStream> get = new ArrayList<>(); get.add(new TenantKeyedColumnValueCallbackStream(get, get, null)); }
public void removeObjectId(TenantIdAndCentricId tenantIdAndCentricId, long removeAtTimestamp, ObjectId objectId, String[] fieldNames) { String[] fields = Arrays.copyOf(fieldNames, fieldNames.length + 1); fields[fields.length - 1] = "deleted"; concurrencyStore.updated(tenantIdAndCentricId, objectId, fields, removeAtTimestamp - 1); if (fieldNames.length > 0) { eventValueStore.multiRemove(tenantIdAndCentricId, objectId, fieldNames, new ConstantTimestamper(removeAtTimestamp + 1)); } concurrencyStore.updated(tenantIdAndCentricId, objectId, fields, removeAtTimestamp); }
public ViewValue get(TenantIdAndCentricId tenantIdAndCentricId, ObjectId viewObjectId, long modelPathId, ObjectId[] modelPathInstanceState) throws IOException { ImmutableByteArray rowKey = rowKey(viewObjectId); ImmutableByteArray columnKey = columnKey(modelPathId, modelPathInstanceState); ViewValue got = viewValueStore.get(tenantIdAndCentricId, rowKey, columnKey, null, null); return got; }
public List<Id> get(TenantId tenantId, Id userId, Id[] ids) { List<Id> had = new ArrayList<>(); List<String> got = modifierStore.multiGet(tenantId, userId, ids, null, null); for (int i = 0; i < ids.length; i++) { if (got.get(i) != null) { had.add(ids[i]); } } return had; }