/** * Creates a coordinate from a Json map with with "~table" and "~id". This is the inverse of {@link #asJson()}. */ public static Coordinate fromJson(Map<String, ?> json) { return Coordinate.of(Intrinsic.getTable(json), Intrinsic.getId(json)); }
return new Text(Coordinate.of(table, id).toString());
@Override public List<Role> getRolesByGroup(@Nullable String group) { String groupKey = checkGroup(group); List<Role> roles = null; validateTables(); Map<String, Object> record = _dataStore.get(_groupTableName, groupKey); if (!Intrinsic.isDeleted(record)) { //noinspection unchecked List<String> names = (List<String>) record.get(IDS_ATTR); if (names != null && !names.isEmpty()) { List<Coordinate> coordinates = names.stream() .map(name -> Coordinate.of(_roleTableName, new RoleIdentifier(group, name).toString())) .collect(Collectors.toList()); Iterator<Map<String, Object>> records = _dataStore.multiGet(coordinates, ReadConsistency.STRONG); roles = StreamSupport.stream(Spliterators.spliteratorUnknownSize(records, 0), false) .map(this::convertRecordToRole) .filter(Objects::nonNull) .collect(Collectors.toList()); } } return roles != null ? roles : ImmutableList.of(); }
@Override public List<Role> getRolesByGroup(@Nullable String group) { String groupKey = checkGroup(group); List<Role> roles = null; validateTables(); Map<String, Object> record = _dataStore.get(_groupTableName, groupKey); if (!Intrinsic.isDeleted(record)) { //noinspection unchecked List<String> names = (List<String>) record.get(IDS_ATTR); if (names != null && !names.isEmpty()) { List<Coordinate> coordinates = names.stream() .map(name -> Coordinate.of(_roleTableName, new RoleIdentifier(group, name).toString())) .collect(Collectors.toList()); Iterator<Map<String, Object>> records = _dataStore.multiGet(coordinates, ReadConsistency.STRONG); roles = StreamSupport.stream(Spliterators.spliteratorUnknownSize(records, 0), false) .map(this::convertRecordToRole) .filter(Objects::nonNull) .collect(Collectors.toList()); } } return roles != null ? roles : ImmutableList.of(); }
@Override public Status accept(EventData rawEvent) { // Parse the raw event data into table/key/changeId/tags. UpdateRef ref = UpdateRefSerializer.fromByteBuffer(rawEvent.getData()); // Consolidate events that refer to the same item. Coordinate contentKey = Coordinate.of(ref.getTable(), ref.getKey()); EventList eventList = _eventMap.get(contentKey); if (eventList == null) { if (_eventMap.size() == _limit) { return Status.REJECTED_STOP; } _eventMap.put(contentKey, eventList = new EventList()); } eventList.add(rawEvent.getId(), ref.getChangeId(), ref.getTags()); if (eventList.size() == MAX_EVENTS_TO_CONSOLIDATE) { return Status.ACCEPTED_STOP; } return Status.ACCEPTED_CONTINUE; }
@Override public Status accept(EventData rawEvent) { // Parse the raw event data into table/key/changeId/tags. UpdateRef ref = UpdateRefSerializer.fromByteBuffer(rawEvent.getData()); // Consolidate events that refer to the same item. Coordinate contentKey = Coordinate.of(ref.getTable(), ref.getKey()); EventList eventList = _eventMap.get(contentKey); if (eventList == null) { if (_eventMap.size() == _limit) { return Status.REJECTED_STOP; } _eventMap.put(contentKey, eventList = new EventList()); } eventList.add(rawEvent.getId(), ref.getChangeId(), ref.getTags()); if (eventList.size() == MAX_EVENTS_TO_CONSOLIDATE) { return Status.ACCEPTED_STOP; } return Status.ACCEPTED_CONTINUE; }