code
stringlengths
73
34.1k
label
stringclasses
1 value
public Set<PermissionDetails> list(AuthenticatedUser performer, Set<Permission> permissions, IResource resource, String of) throws RequestValidationException, RequestExecutionException { if (!performer.isSuper() && !performer.getName().equals(of)) throw new UnauthorizedException(String.forma...
java
public void revokeAll(String droppedUser) { try { process(String.format("DELETE FROM %s.%s WHERE username = '%s'", Auth.AUTH_KS, PERMISSIONS_CF, escape(droppedUser))); } catch (RequestExecutionException e) { logger.warn("CassandraAuthorizer failed to r...
java
public void submitSynchronous(Runnable task) { lock.writeLock().lock(); try { awaitInner(); task.run(); } catch (InterruptedException e) { Log.error(e, "Task queue isolated submission interrupted"); throw new RuntimeException(e); } catch (E...
java
public static int getfd(FileDescriptor descriptor) { Field field = FBUtilities.getProtectedField(descriptor.getClass(), "fd"); if (field == null) return -1; try { return field.getInt(descriptor); } catch (Exception e) { JV...
java
public boolean accepts(OpOrder.Group opGroup, ReplayPosition replayPosition) { // if the barrier hasn't been set yet, then this memtable is still taking ALL writes OpOrder.Barrier barrier = this.writeBarrier; if (barrier == null) return true; // if the barrier has been se...
java
long put(DecoratedKey key, ColumnFamily cf, SecondaryIndexManager.Updater indexer, OpOrder.Group opGroup) { AtomicBTreeColumns previous = rows.get(key); if (previous == null) { AtomicBTreeColumns empty = cf.cloneMeShallow(AtomicBTreeColumns.factory, false); final Dec...
java
public static void loadSchemas(boolean updateVersion) { ColumnFamilyStore schemaCFS = SystemKeyspace.schemaCFS(SystemKeyspace.SCHEMA_KEYSPACES_CF); // if keyspace with definitions is empty try loading the old way if (schemaCFS.estimateKeys() == 0) { logger.info("Couldn't...
java
public static void createAllDirectories() { try { if (conf.data_file_directories.length == 0) throw new ConfigurationException("At least one DataFileDirectory must be specified"); for (String dataFileDirectory : conf.data_file_directories) { ...
java
public static long getTimeout(MessagingService.Verb verb) { switch (verb) { case READ: return getReadRpcTimeout(); case RANGE_SLICE: return getRangeRpcTimeout(); case TRUNCATE: return getTruncateRpcTimeout(); ...
java
public static SSLSocket getSocket(EncryptionOptions options, InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException { SSLContext ctx = createSSLContext(options, true); SSLSocket socket = (SSLSocket) ctx.getSocketFactory().createSocket(address, port, localAddress, ...
java
public void collateOnDiskAtom(ColumnFamily returnCF, Iterator<? extends OnDiskAtom> toCollate, int gcBefore) { filter.collectReducedColumns(returnCF, gatherTombstones(returnCF, toCollate), gcBefore, timestamp); }
java
public static QueryFilter getIdentityFilter(DecoratedKey key, String cfName, long timestamp) { return new QueryFilter(key, cfName, new IdentityQueryFilter(), timestamp); }
java
public Memtable getMemtableFor(OpOrder.Group opGroup, ReplayPosition replayPosition) { // since any new memtables appended to the list after we fetch it will be for operations started // after us, we can safely assume that we will always find the memtable that 'accepts' us; // if the barrier...
java
public void replaceWithNewInstances(Collection<SSTableReader> toReplace, Collection<SSTableReader> replaceWith) { replaceReaders(toReplace, replaceWith, true); }
java
public void replaceEarlyOpenedFiles(Collection<SSTableReader> toReplace, Collection<SSTableReader> replaceWith) { for (SSTableReader s : toReplace) assert s.openReason.equals(SSTableReader.OpenReason.EARLY); // note that we can replace an early opened file with a real one replace...
java
public void unreferenceSSTables() { Set<SSTableReader> notCompacting; View currentView, newView; do { currentView = view.get(); notCompacting = currentView.nonCompactingSStables(); newView = currentView.replace(notCompacting, Collections.<SSTableR...
java
void removeUnreadableSSTables(File directory) { View currentView, newView; Set<SSTableReader> remaining = new HashSet<>(); do { currentView = view.get(); for (SSTableReader r : currentView.nonCompactingSStables()) if (!r.descriptor.directory.eq...
java
public static SettingsCommandUser build(String[] params) { GroupedOptions options = GroupedOptions.select(params, new Options(new Uncertainty()), new Options(new Duration()), new Options(new Count())); if (options == null) { printHe...
java
public void addComparator(Comparator<T> comparator, boolean reverse) { checkLocked(); comparatorChain.add(comparator); if (reverse == true) { orderingBits.set(comparatorChain.size() - 1); } }
java
public void setComparator(int index, Comparator<T> comparator) throws IndexOutOfBoundsException { setComparator(index, comparator, false); }
java
public void setComparator(int index, Comparator<T> comparator, boolean reverse) { checkLocked(); comparatorChain.set(index, comparator); if (reverse == true) { orderingBits.set(index); } else { orderingBits.clear(index); } }
java
public static KSMetaData fromSchema(Row row, Iterable<CFMetaData> cfms, UTMetaData userTypes) { UntypedResultSet.Row result = QueryProcessor.resultify("SELECT * FROM system.schema_keyspaces", row).one(); try { return new KSMetaData(result.getString("keyspace_name"), ...
java
public static KSMetaData fromSchema(Row serializedKs, Row serializedCFs, Row serializedUserTypes) { Map<String, CFMetaData> cfs = deserializeColumnFamilies(serializedCFs); UTMetaData userTypes = new UTMetaData(UTMetaData.fromSchema(serializedUserTypes)); return fromSchema(serializedKs, cfs.v...
java
public static Map<String, CFMetaData> deserializeColumnFamilies(Row row) { if (row.cf == null) return Collections.emptyMap(); Map<String, CFMetaData> cfms = new HashMap<>(); UntypedResultSet results = QueryProcessor.resultify("SELECT * FROM system.schema_columnfamilies", row); ...
java
static TimingInterval merge(Iterable<TimingInterval> intervals, int maxSamples, long start) { ThreadLocalRandom rnd = ThreadLocalRandom.current(); long operationCount = 0, partitionCount = 0, rowCount = 0, errorCount = 0; long maxLatency = 0, totalLatency = 0; List<SampleOfLongs> lat...
java
public boolean supersedes(RangeTombstone rt, Comparator<Composite> comparator) { if (rt.data.markedForDeleteAt > data.markedForDeleteAt) return false; return comparator.compare(min, rt.min) <= 0 && comparator.compare(max, rt.max) >= 0; }
java
public static String string(ByteBuffer buffer, int position, int length) throws CharacterCodingException { return string(buffer, position, length, StandardCharsets.UTF_8); }
java
public static int compareSubArrays(ByteBuffer bytes1, int offset1, ByteBuffer bytes2, int offset2, int length) { if (bytes1 == null) return bytes2 == null ? 0 : -1; if (bytes2 == null) return 1; assert bytes1.limit() >= offset1 + length : "The first byte array isn't long enough ...
java
public static ByteBuffer minimalBufferFor(ByteBuffer buf) { return buf.capacity() > buf.remaining() || !buf.hasArray() ? ByteBuffer.wrap(getArray(buf)) : buf; }
java
public static int getShortLength(ByteBuffer bb, int position) { int length = (bb.get(position) & 0xFF) << 8; return length | (bb.get(position + 1) & 0xFF); }
java
@Override public ArrayList<InetAddress> getNaturalEndpoints(RingPosition searchPosition) { ArrayList<InetAddress> l = new ArrayList<InetAddress>(1); l.add(FBUtilities.getBroadcastAddress()); return l; }
java
public static synchronized void removeTruncationRecord(UUID cfId) { String req = "DELETE truncated_at[?] from system.%s WHERE key = '%s'"; executeInternal(String.format(req, LOCAL_CF, LOCAL_KEY), cfId); truncationRecords = null; forceBlockingFlush(LOCAL_CF); }
java
public static synchronized void updateTokens(InetAddress ep, Collection<Token> tokens) { if (ep.equals(FBUtilities.getBroadcastAddress())) { removeEndpoint(ep); return; } String req = "INSERT INTO system.%s (peer, tokens) VALUES (?, ?)"; executeIntern...
java
public static synchronized void removeEndpoint(InetAddress ep) { String req = "DELETE FROM system.%s WHERE peer = ?"; executeInternal(String.format(req, PEERS_CF), ep); }
java
public static synchronized void updateTokens(Collection<Token> tokens) { assert !tokens.isEmpty() : "removeEndpoint should be used instead"; String req = "INSERT INTO system.%s (key, tokens) VALUES ('%s', ?)"; executeInternal(String.format(req, LOCAL_CF, LOCAL_KEY), tokensAsSet(tokens)); ...
java
public static synchronized Collection<Token> updateLocalTokens(Collection<Token> addTokens, Collection<Token> rmTokens) { Collection<Token> tokens = getSavedTokens(); tokens.removeAll(rmTokens); tokens.addAll(addTokens); updateTokens(tokens); return tokens; }
java
public static SetMultimap<InetAddress, Token> loadTokens() { SetMultimap<InetAddress, Token> tokenMap = HashMultimap.create(); for (UntypedResultSet.Row row : executeInternal("SELECT peer, tokens FROM system." + PEERS_CF)) { InetAddress peer = row.getInetAddress("peer"); ...
java
public static Map<InetAddress, UUID> loadHostIds() { Map<InetAddress, UUID> hostIdMap = new HashMap<InetAddress, UUID>(); for (UntypedResultSet.Row row : executeInternal("SELECT peer, host_id FROM system." + PEERS_CF)) { InetAddress peer = row.getInetAddress("peer"); ...
java
public static InetAddress getPreferredIP(InetAddress ep) { String req = "SELECT preferred_ip FROM system.%s WHERE peer=?"; UntypedResultSet result = executeInternal(String.format(req, PEERS_CF), ep); if (!result.isEmpty() && result.one().has("preferred_ip")) return result.one().g...
java
public static Map<InetAddress, Map<String,String>> loadDcRackInfo() { Map<InetAddress, Map<String, String>> result = new HashMap<InetAddress, Map<String, String>>(); for (UntypedResultSet.Row row : executeInternal("SELECT peer, data_center, rack from system." + PEERS_CF)) { InetA...
java
public static UUID setLocalHostId(UUID hostId) { String req = "INSERT INTO system.%s (key, host_id) VALUES ('%s', ?)"; executeInternal(String.format(req, LOCAL_CF, LOCAL_KEY), hostId); return hostId; }
java
public static void clearSSTableReadMeter(String keyspace, String table, int generation) { String cql = "DELETE FROM system.%s WHERE keyspace_name=? AND columnfamily_name=? and generation=?"; executeInternal(String.format(cql, SSTABLE_ACTIVITY_CF), keyspace, table, generation); }
java
public static void updateSizeEstimates(String keyspace, String table, Map<Range<Token>, Pair<Long, Long>> estimates) { long timestamp = FBUtilities.timestampMicros(); CFMetaData estimatesTable = CFMetaData.SizeEstimatesCf; Mutation mutation = new Mutation(Keyspace.SYSTEM_KS, UTF8Type.instanc...
java
public void maybeAddLatency(IAsyncCallback cb, InetAddress address, long latency) { if (cb.isLatencyForSnitch()) addLatency(address, latency); }
java
public void listen(InetAddress localEp) throws ConfigurationException { callbacks.reset(); // hack to allow tests to stop/restart MS for (ServerSocket ss : getServerSockets(localEp)) { SocketThread th = new SocketThread(ss, "ACCEPT-" + localEp); th.start(); ...
java
public void registerVerbHandlers(Verb verb, IVerbHandler verbHandler) { assert !verbHandlers.containsKey(verb); verbHandlers.put(verb, verbHandler); }
java
public int sendRR(MessageOut message, InetAddress to, IAsyncCallback cb, long timeout, boolean failureCallback) { int id = addCallback(cb, message, to, timeout, failureCallback); sendOneWay(failureCallback ? message.withParameter(FAILURE_CALLBACK_PARAM, ONE_BYTE) : message, id, to); return i...
java
public void sendOneWay(MessageOut message, int id, InetAddress to) { if (logger.isTraceEnabled()) logger.trace(FBUtilities.getBroadcastAddress() + " sending " + message.verb + " to " + id + "@" + to); if (to.equals(FBUtilities.getBroadcastAddress())) logger.trace("Message-to...
java
private static ByteBuffer min(ByteBuffer b1, ByteBuffer b2, AbstractType<?> comparator) { if (b1 == null) return b2; if (b2 == null) return b1; if (comparator.compare(b1, b2) >= 0) return b2; return b1; }
java
private static ByteBuffer max(ByteBuffer b1, ByteBuffer b2, AbstractType<?> comparator) { if (b1 == null) return b2; if (b2 == null) return b1; if (comparator.compare(b1, b2) >= 0) return b1; return b2; }
java
public static List<ByteBuffer> mergeMin(List<ByteBuffer> minColumnNames, List<ByteBuffer> candidates, CellNameType comparator) { if (minColumnNames.isEmpty()) return minimalBuffersFor(candidates); if (candidates.isEmpty()) return minColumnNames; List<ByteBuffer> big...
java
public static List<ByteBuffer> mergeMax(List<ByteBuffer> maxColumnNames, List<ByteBuffer> candidates, CellNameType comparator) { if (maxColumnNames.isEmpty()) return minimalBuffersFor(candidates); if (candidates.isEmpty()) return maxColumnNames; List<ByteBuffer> big...
java
public static CounterCell createLocal(CellName name, long value, long timestamp, long timestampOfLastDelete) { return new BufferCounterCell(name, contextManager.createLocal(value), timestamp, timestampOfLastDelete); }
java
private void addColumnsToCF(List<?> row, ColumnFamily cfamily) { CFMetaData cfm = cfamily.metadata(); assert cfm != null; for (Object c : row) { JsonColumn col = new JsonColumn<List>((List) c, cfm); if (col.isRangeTombstone()) { Co...
java
public int importJson(String jsonFile, String keyspace, String cf, String ssTablePath) throws IOException { ColumnFamily columnFamily = ArrayBackedSortedColumns.factory.create(keyspace, cf); IPartitioner partitioner = DatabaseDescriptor.getPartitioner(); int importedKeys = (isSorted) ? impo...
java
private AbstractType<?> getKeyValidator(ColumnFamily columnFamily) { // this is a fix to support backward compatibility // which allows to skip the current key validator // please, take a look onto CASSANDRA-7498 for more details if ("true".equals(System.getProperty("skip.key.validator",...
java
public static void main(String[] args) throws ParseException, ConfigurationException { CommandLineParser parser = new PosixParser(); try { cmd = parser.parse(options, args); } catch (org.apache.commons.cli.ParseException e) { System.err.printl...
java
public void updateHostId(UUID hostId, InetAddress endpoint) { assert hostId != null; assert endpoint != null; lock.writeLock().lock(); try { InetAddress storedEp = endpointToHostIdMap.inverse().get(hostId); if (storedEp != null) { ...
java
public UUID getHostId(InetAddress endpoint) { lock.readLock().lock(); try { return endpointToHostIdMap.get(endpoint); } finally { lock.readLock().unlock(); } }
java
public InetAddress getEndpointForHostId(UUID hostId) { lock.readLock().lock(); try { return endpointToHostIdMap.inverse().get(hostId); } finally { lock.readLock().unlock(); } }
java
public void addMovingEndpoint(Token token, InetAddress endpoint) { assert endpoint != null; lock.writeLock().lock(); try { movingEndpoints.add(Pair.create(token, endpoint)); } finally { lock.writeLock().unlock(); } }
java
public TokenMetadata cloneOnlyTokenMap() { lock.readLock().lock(); try { return new TokenMetadata(SortedBiMultiValMap.<Token, InetAddress>create(tokenToEndpointMap, null, inetaddressCmp), HashBiMap.create(endpointToHostIdMap), ...
java
public TokenMetadata cachedOnlyTokenMap() { TokenMetadata tm = cachedTokenMap.get(); if (tm != null) return tm; // synchronize to prevent thundering herd (CASSANDRA-6345) synchronized (this) { if ((tm = cachedTokenMap.get()) != null) r...
java
public TokenMetadata cloneAfterAllLeft() { lock.readLock().lock(); try { TokenMetadata allLeftMetadata = cloneOnlyTokenMap(); for (InetAddress endpoint : leavingEndpoints) allLeftMetadata.removeEndpoint(endpoint); return allLeftMetadata; ...
java
public TokenMetadata cloneAfterAllSettled() { lock.readLock().lock(); try { TokenMetadata metadata = cloneOnlyTokenMap(); for (InetAddress endpoint : leavingEndpoints) metadata.removeEndpoint(endpoint); for (Pair<Token, InetAddress> pai...
java
private void tickIfNecessary() { final long oldTick = lastTick.get(); final long newTick = clock.tick(); final long age = newTick - oldTick; if (age > TICK_INTERVAL) { final long newIntervalStartTick = newTick - age % TICK_INTERVAL; if (lastTick.compareAndSet(oldT...
java
public synchronized void beginSampling(int capacity) { if (!enabled) { summary = new StreamSummary<T>(capacity); hll = new HyperLogLogPlus(14); enabled = true; } }
java
public synchronized SamplerResult<T> finishSampling(int count) { List<Counter<T>> results = Collections.EMPTY_LIST; long cardinality = 0; if (enabled) { enabled = false; results = summary.topK(count); cardinality = hll.cardinality(); } ...
java
public void addSample(final T item, final long hash, final int value) { if (enabled) { final Object lock = this; samplerExecutor.execute(new Runnable() { public void run() { // samplerExecutor is single threaded ...
java
public Tuple getNext() throws IOException { try { // load the next pair if (!reader.nextKeyValue()) return null; CfInfo cfInfo = getCfInfo(loadSignature); CfDef cfDef = cfInfo.cfDef; Row row = reader.getCurrentValue(); ...
java
private Object cqlColumnToObj(Cell col, CfDef cfDef) throws IOException { // standard Map<ByteBuffer,AbstractType> validators = getValidatorMap(cfDef); ByteBuffer cellName = col.name().toByteBuffer(); if (validators.get(cellName) == null) return cassandraToObj(getDefaultM...
java
protected List<ColumnDef> getColumnMetadata(Cassandra.Client client) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException, CharacterCodingException, org.apache.cassandra.except...
java
private Map<String, ByteBuffer> tupleToKeyMap(Tuple t) throws IOException { Map<String, ByteBuffer> keys = new HashMap<String, ByteBuffer>(); for (int i = 0; i < t.size(); i++) { if (t.getType(i) == DataType.TUPLE) { Tuple inner = (Tuple) t.get(i); ...
java
private void cqlQueryFromTuple(Map<String, ByteBuffer> key, Tuple t, int offset) throws IOException { for (int i = offset; i < t.size(); i++) { if (t.getType(i) == DataType.TUPLE) { Tuple inner = (Tuple) t.get(i); if (inner.size() > 0) ...
java
private List<ByteBuffer> bindedVariablesFromTuple(Tuple t) throws IOException { List<ByteBuffer> variables = new ArrayList<ByteBuffer>(); for (int i = 0; i < t.size(); i++) variables.add(objToBB(t.get(i))); return variables; }
java
private void sendCqlQuery(Map<String, ByteBuffer> key, List<ByteBuffer> bindedVariables) throws IOException { try { writer.write(key, bindedVariables); } catch (InterruptedException e) { throw new IOException(e); } }
java
private String getWhereClauseForPartitionFilter() { UDFContext context = UDFContext.getUDFContext(); Properties property = context.getUDFProperties(AbstractCassandraStorage.class); return property.getProperty(PARTITION_FILTER_SIGNATURE); }
java
private BigInteger bigForBytes(byte[] bytes, int sigbytes) { byte[] b; if (sigbytes != bytes.length) { b = new byte[sigbytes]; System.arraycopy(bytes, 0, b, 0, bytes.length); } else b = bytes; return new BigInteger(1, b); }
java
public static void shutdownNow() { for (Stage stage : Stage.values()) { StageManager.stages.get(stage).shutdownNow(); } }
java
public static Pair<BigInteger,Boolean> midpoint(BigInteger left, BigInteger right, int sigbits) { BigInteger midpoint; boolean remainder; if (left.compareTo(right) < 0) { BigInteger sum = left.add(right); remainder = sum.testBit(0); midpoint = sum....
java
public static <T> T construct(String classname, String readable) throws ConfigurationException { Class<T> cls = FBUtilities.classForName(classname, readable); try { return cls.newInstance(); } catch (IllegalAccessException e) { throw new Config...
java
public static void exec(ProcessBuilder pb) throws IOException { Process p = pb.start(); try { int errCode = p.waitFor(); if (errCode != 0) { BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); ...
java
public static void removeUnreadableSSTables(File directory) { for (Keyspace keyspace : Keyspace.all()) { for (ColumnFamilyStore baseCfs : keyspace.getColumnFamilyStores()) { for (ColumnFamilyStore cfs : baseCfs.concatWithIndexes()) cfs.mayb...
java
public void snapshot(String snapshotName, String columnFamilyName) throws IOException { assert snapshotName != null; boolean tookSnapShot = false; for (ColumnFamilyStore cfStore : columnFamilyStores.values()) { if (columnFamilyName == null || cfStore.name.equals(columnFam...
java
public boolean snapshotExists(String snapshotName) { assert snapshotName != null; for (ColumnFamilyStore cfStore : columnFamilyStores.values()) { if (cfStore.snapshotExists(snapshotName)) return true; } return false; }
java
public static void clearSnapshot(String snapshotName, String keyspace) { List<File> snapshotDirs = Directories.getKSChildDirectories(keyspace); Directories.clearSnapshot(snapshotName, snapshotDirs); }
java
public void dropCf(UUID cfId) { assert columnFamilyStores.containsKey(cfId); ColumnFamilyStore cfs = columnFamilyStores.remove(cfId); if (cfs == null) return; // wait for any outstanding reads/writes that might affect the CFS cfs.keyspace.writeOrder.awaitNewBarri...
java
public void initCf(UUID cfId, String cfName, boolean loadSSTables) { ColumnFamilyStore cfs = columnFamilyStores.get(cfId); if (cfs == null) { // CFS being created for the first time, either on server startup or new CF being added. // We don't worry about races here; ...
java
public void apply(Mutation mutation, boolean writeCommitLog, boolean updateIndexes) { try (OpOrder.Group opGroup = writeOrder.start()) { // write the mutation to the commitlog and memtables ReplayPosition replayPosition = null; if (writeCommitLog) { ...
java
public static Function.Factory factory(final Function fun) { return new Function.Factory() { public Function create(String ksName, String cfName) { return fun; } }; }
java
private void initSocket() { socket = new Socket(); try { socket.setSoLinger(false, 0); socket.setTcpNoDelay(true); socket.setSoTimeout(timeout); } catch (SocketException sx) { LOGGER.error("Could not configure socket.", sx); } }
java
public void setTimeout(int timeout) { this.timeout = timeout; try { socket.setSoTimeout(timeout); } catch (SocketException sx) { LOGGER.warn("Could not set socket timeout.", sx); } }
java
public void open() throws TTransportException { if (isOpen()) { throw new TTransportException(TTransportException.ALREADY_OPEN, "Socket already connected."); } if (host.length() == 0) { throw new TTransportException(TTransportException.NOT_OPEN, "Cannot open null host."); } if (port <= ...
java
public ByteBuffer[] split(ByteBuffer name) { List<ByteBuffer> l = new ArrayList<ByteBuffer>(); ByteBuffer bb = name.duplicate(); readIsStatic(bb); int i = 0; while (bb.remaining() > 0) { getComparator(i++, bb); l.add(ByteBufferUtil.readBytesWit...
java
public static <K extends IMeasurableMemory, V extends IMeasurableMemory> ConcurrentLinkedHashCache<K, V> create(long weightedCapacity, EntryWeigher<K, V> entryWeiger) { ConcurrentLinkedHashMap<K, V> map = new ConcurrentLinkedHashMap.Builder<K, V>() .weigher(entryW...
java
public void onSuccess(StreamState state) { logger.info(String.format("[repair #%s] streaming task succeed, returning response to %s", desc.sessionId, request.initiator)); MessagingService.instance().sendOneWay(new SyncComplete(desc, request.src, request.dst, true).createMessage(), request.initiator)...
java
public void onFailure(Throwable t) { MessagingService.instance().sendOneWay(new SyncComplete(desc, request.src, request.dst, false).createMessage(), request.initiator); }
java
public ByteBuffer createLocal(long count) { ContextState state = ContextState.allocate(0, 1, 0); state.writeLocal(CounterId.getLocalId(), 1L, count); return state.context; }
java
public ByteBuffer createRemote(CounterId id, long clock, long count) { ContextState state = ContextState.allocate(0, 0, 1); state.writeRemote(id, clock, count); return state.context; }
java
public Relationship diff(ByteBuffer left, ByteBuffer right) { Relationship relationship = Relationship.EQUAL; ContextState leftState = ContextState.wrap(left); ContextState rightState = ContextState.wrap(right); while (leftState.hasRemaining() && rightState.hasRemaining()) {...
java