@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 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); }
@Override public List<Long> highests(TenantIdAndCentricId tenantIdAndCentricId, ObjectId objectId, String[] fields) { return updatedStore.multiGet(tenantIdAndCentricId, objectId, fields, null, null); }
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); }
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); }
@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 commit(Transaction transaction) { ObjectId objectInstanceId = transaction.objectInstanceId; if (!transaction.addedFieldNames.isEmpty()) { String[] takeAddedFieldNames = transaction.takeAddedFieldNames(); OpaqueFieldValue[] takeAddedValues = transaction.takeAddedValues(); String[] fields = Arrays.copyOf(takeAddedFieldNames, takeAddedFieldNames.length + 1); fields[fields.length - 1] = "deleted"; concurrencyStore.updated(transaction.tenantIdAndCentricId, objectInstanceId, fields, transaction.addAtTimestamp - 1); eventValueStore.multiAdd( transaction.tenantIdAndCentricId, objectInstanceId, takeAddedFieldNames, takeAddedValues, null, new ConstantTimestamper(transaction.addAtTimestamp)); concurrencyStore.updated(transaction.tenantIdAndCentricId, objectInstanceId, fields, transaction.addAtTimestamp); } if (!transaction.removedFieldNames.isEmpty()) { String[] takeRemovedFieldNames = transaction.takeRemovedFieldNames(); String[] fields = Arrays.copyOf(takeRemovedFieldNames, takeRemovedFieldNames.length + 1); fields[fields.length - 1] = "deleted"; concurrencyStore.updated(transaction.tenantIdAndCentricId, objectInstanceId, fields, transaction.removeAtTimestamp - 1); eventValueStore.multiRemove( transaction.tenantIdAndCentricId, objectInstanceId, takeRemovedFieldNames, new ConstantTimestamper(transaction.removeAtTimestamp)); concurrencyStore.updated(transaction.tenantIdAndCentricId, objectInstanceId, fields, transaction.removeAtTimestamp); } }
@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); }
public void remove(TenantId tenantId, Id userId, Id[] ids, long removeAtTimestamp) { modifierStore.multiRemove(tenantId, userId, ids, new ConstantTimestamper(removeAtTimestamp)); }
public ColumnValueAndTimestamp<String, OpaqueFieldValue, Long>[] get( TenantIdAndCentricId tenantIdAndCentricId, ObjectId objectId, String[] fieldNames) { return eventValueStore.multiGetEntries(tenantIdAndCentricId, objectId, fieldNames, null, null); }
@Override public Set<ObjectId> getExistence(TenantIdAndCentricId tenantId, Set<ObjectId> objectIds) { List<ObjectId> orderObjectIds = new ArrayList<>(objectIds); List<Long> multiRowGet = updatedStore.multiRowGet(tenantId, orderObjectIds, EXISTS, null, null); Set<ObjectId> existence = new HashSet<>(); for (int i = 0; i < orderObjectIds.size(); i++) { if (multiRowGet.get(i) != null) { existence.add(orderObjectIds.get(i)); if (LOG.isTraceEnabled()) { LOG.trace("Check existence {} TRUE", new Object[]{orderObjectIds.get(i)}); } } else { if (LOG.isTraceEnabled()) { LOG.trace("Check existence {} FALSE", new Object[]{orderObjectIds.get(i)}); } } } return existence; }
multiBackLinks.multiRowGetAll(tenantIdAndCentricId, callbacks);
multiLinks.multiRowsMultiAdd(links); multiBackLinks.multiRowsMultiAdd(backLinks);
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 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 void multiStreamRefs(List<RefStreamRequestContext> refStreamRequests) throws Exception { List<TenantKeyedColumnValueCallbackStream<TenantIdAndCentricId, ClassAndField_IdKey, ObjectId, byte[], Long>> fowardRefStreams = new ArrayList<>(); List<TenantKeyedColumnValueCallbackStream<TenantIdAndCentricId, ClassAndField_IdKey, ObjectId, byte[], Long>> backRefStreams = new ArrayList<>(); for (RefStreamRequestContext refStreamRequest : refStreamRequests) { for (String className : refStreamRequest.getReferringClassNames()) { ClassAndField_IdKey cafik = new ClassAndField_IdKey(className, refStreamRequest.getReferringFieldName(), refStreamRequest.getReferringObjectId()); if (refStreamRequest.isBackRefStream()) { backRefStreams.add(new TenantKeyedColumnValueCallbackStream<>(refStreamRequest.getTenantIdAndCentricId(), cafik, new NullSwallowingCallbackStream(refStreamRequest))); } else { fowardRefStreams.add(new TenantKeyedColumnValueCallbackStream<>(refStreamRequest.getTenantIdAndCentricId(), cafik, new NullSwallowingCallbackStream(refStreamRequest))); } } } if (!fowardRefStreams.isEmpty()) { multiLinks.multiRowGetAll(fowardRefStreams); } if (!backRefStreams.isEmpty()) { multiBackLinks.multiRowGetAll(backRefStreams); } for (RefStreamRequestContext refStreamRequest : refStreamRequests) { refStreamRequest.callback(null); // EOS } }
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); }
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; }
@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 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; }