Invokes an operation to put the provided key-value pairs to the partition
record store.

@param keyValueSequence the list of serialised alternating key-value pairs
@return the future representing the pending completion of the put operation
176395
private Future<?> sendOperation(List<Data> keyValueSequence) {
        OperationService operationService = mapServiceContext.getNodeEngine().getOperationService();
        Operation operation = createOperation(keyValueSequence);
        return operationService.invokeOnPartition(MapService.SERVICE_NAME, operation, partitionId);
    }
121467
@Override
	public Long nextValue(NextValueRequest request) {
		String sequenceName = sequenceName( request.getKey() );
		// This method return 2 statements: the first one to acquire a lock and the second one to update the sequence node
		RemoteStatements remoteStatements = updateNextValueQuery( request );

		Number nextValue = nextValue( remoteStatements );

		// sequence nodes are expected to have been created up-front
		if ( request.getKey().getMetadata().getType() == IdSourceType.SEQUENCE ) {
			if ( nextValue == null ) {
				throw logger.sequenceNotFound( sequenceName );
			}
		}
		// The only way I found to make it work in a multi-threaded environment is to first increment the value and then read it.
		// Our API allows for an initial value and to make sure that I'm actually reading the correct one,
		// the first time I need to decrement the value I obtain from the db.
		return nextValue.longValue() - request.getIncrement();
	}
52206
private long nextUnadjustedValue() throws FetchException, PersistException {
        if (mHasReservedValues) {
            long next = mNextValue + mIncrement;
            mNextValue = next;
            if (next < mStoredSequence.getNextValue()) {
                return next;
            }
            mHasReservedValues = false;
        }

        Transaction txn = mRepository.enterTopTransaction(null);
        txn.setForUpdate(true);
        try {
            // Assume that StoredSequence is stale, so reload.
            mStoredSequence.load();
            long next = mStoredSequence.getNextValue();
            long nextStored = next + mReserveAmount * mIncrement;

            if (next >= 0 && nextStored < 0) {
                // Wrapped around. There might be just a few values left.
                long avail = (Long.MAX_VALUE - next) / mIncrement;
                if (avail > 0) {
                    nextStored = next + avail * mIncrement;
                } else {
                    // Throw a PersistException since sequences are applied during
                    // insert operations, and inserts can only throw PersistExceptions.
                    throw new PersistException
                        ("Sequence exhausted: " + mStoredSequence.getName());
                }
            }

            mStoredSequence.setNextValue(nextStored);
            mStoredSequence.update();

            txn.commit();

            mNextValue = next;
            mHasReservedValues = true;
            return next;
        } finally {
            txn.exit();
        }
    }
637054
public static Set<String> simpleSequenceToSet(SimpleSequence simpleSequence)
    {
        if (simpleSequence == null)
            return Collections.emptySet();

        Set<String> result = new HashSet<>();
        for (int i = 0; i < simpleSequence.size(); i++)
        {
            try
            {
                Object sequenceEntry = simpleSequence.get(i);
                if (sequenceEntry instanceof SimpleScalar)
                {
                    result.add(((SimpleScalar) sequenceEntry).getAsString());
                }
                else
                {
                    result.add(simpleSequence.get(i).toString());
                }
            }
            catch (Exception e)
            {
                throw new RuntimeException(e);
            }
        }
        return result;
    }
624833
@Override
    public Object mapSequence(Object sequence) {
        List<List<Long>> seq = (List<List<Long>>) sequence;
        List<Long> ret = new ArrayList<>();
        for (List<Long> l : seq)
            ret.add((Long) map(l));
        return ret;
    }
245509
@Override
  public boolean nextKeyValue() throws IOException, InterruptedException {
    if (!hasMore) {
      key = null;
      value = null;
      return false;
    }
    firstValue = !nextKeyIsSame;
    DataInputBuffer next = input.getKey();
    currentRawKey.set(next.getData(), next.getPosition(), 
                      next.getLength() - next.getPosition());
    buffer.reset(currentRawKey.getBytes(), 0, currentRawKey.getLength());
    key = keyDeserializer.deserialize(key);
    next = input.getValue();
    buffer.reset(next.getData(), next.getPosition(), next.getLength());
    value = valueDeserializer.deserialize(value);
    hasMore = input.next();
    if (hasMore) {
      next = input.getKey();
      nextKeyIsSame = comparator.compare(currentRawKey.getBytes(), 0, 
                                         currentRawKey.getLength(),
                                         next.getData(),
                                         next.getPosition(),
                                         next.getLength() - next.getPosition()
                                         ) == 0;
    } else {
      nextKeyIsSame = false;
    }
    inputValueCounter.increment(1);
    return true;
  }
1247943
private void storeOriginal(Pair<String, Object> keyValue) {
		String key = SharedPreferenceUtils.keyTestMode + keyValue.first;

		if (!preferenceUtils.isValueExistForKey(key)) {
			preferenceUtils.put(key, keyValue.second);

		}
	}
781999
private KeyValuePair<CacheTransaction, Object> waitForTransactionsToComplete(Collection<PendingTransaction> transactionsToCheck,
                                                            long expectedEndTime) throws InterruptedException {
      if (transactionsToCheck.isEmpty()) {
         return null;
      }
      for (PendingTransaction tx : transactionsToCheck) {
         for (Map.Entry<Object, CompletableFuture<Void>> entry : tx.keyReleased.entrySet()) {
            long remaining = timeService.remainingTime(expectedEndTime, TimeUnit.MILLISECONDS);
            //CF.get(time) return TimeoutException when remaining is <= 0.
            if (!CompletableFutures.await(entry.getValue(), remaining, TimeUnit.MILLISECONDS)) {
               return new KeyValuePair<>(tx.cacheTransaction, entry.getKey());
            }
         }
      }
      return null;
   }
456030
private void sequenceQuery(QueryEntry entry, CompletableFuture<QueryResponse> future) {
    // Get the client's server session. If the session doesn't exist, return an unknown session error.
    ServerSessionContext session = context.getStateMachine().executor().context().sessions().getSession(entry.getSession());
    if (session == null) {
      future.complete(logResponse(QueryResponse.builder()
        .withStatus(Response.Status.ERROR)
        .withError(CopycatError.Type.UNKNOWN_SESSION_ERROR)
        .build()));
    } else {
      sequenceQuery(entry, session, future);
    }
  }
617839
public ICompletableFuture<Map<K, Object>> submitToKeys(Set<K> keys, EntryProcessor entryProcessor) {
        checkNotNull(keys, NULL_KEY_IS_NOT_ALLOWED);
        if (keys.isEmpty()) {
            return new SimpleCompletedFuture<Map<K, Object>>(Collections.<K, Object>emptyMap());
        }

        Collection<Data> dataCollection = objectToDataCollection(keys, getSerializationService());

        ClientMessage request = MapExecuteOnKeysCodec.encodeRequest(name, toData(entryProcessor), dataCollection);
        ClientInvocationFuture future = new ClientInvocation(getClient(), request, getName()).invoke();
        return new ClientDelegatingFuture<Map<K, Object>>(future, getSerializationService(), submitToKeysResponseDecoder);
    }
608561
public FastqBuilder withSequence(final String sequence)
	{
		if (sequence == null)
		{
			throw new IllegalArgumentException("sequence must not be null");
		}
		if (this.sequence == null)
		{
			this.sequence = new StringBuilder(sequence.length());
		}
		this.sequence.replace(0, this.sequence.length(), sequence);
		return this;
	}
536930
public List<Writable> executeSequenceToSingle(List<List<Writable>> inputSequence){
        return execute(null, inputSequence).getLeft();
    }
791254
static public void put( Key key, Value val, Futures fs ) {
    assert !val.isLockable();
    Value res = DKV.put(key,val,fs);
    assert res == null || !res.isLockable();
  }
260153
private void addSequence(String sequenceName, HighLowSequence seq)
    {
        // lookup the sequence map for calling DB
        String jcdAlias = getBrokerForClass()
                .serviceConnectionManager().getConnectionDescriptor().getJcdAlias();
        Map mapForDB = (Map) sequencesDBMap.get(jcdAlias);
        if(mapForDB == null)
        {
            mapForDB = new HashMap();
        }
        mapForDB.put(sequenceName, seq);
        sequencesDBMap.put(jcdAlias, mapForDB);
    }
1349892
private void createSequences(Collection<Sequence> sequences, SchemaDescriptor schemaDescriptor, Store store) {
        for (Sequence sequence : sequences) {
            SequenceDesriptor sequenceDesriptor = store.create(SequenceDesriptor.class);
            sequenceDesriptor.setName(sequence.getName());
            sequenceDesriptor.setIncrement(sequence.getIncrement());
            sequenceDesriptor.setMinimumValue(sequence.getMinimumValue().longValue());
            sequenceDesriptor.setMaximumValue(sequence.getMaximumValue().longValue());
            sequenceDesriptor.setCycle(sequence.isCycle());
            schemaDescriptor.getSequences().add(sequenceDesriptor);
        }
    }
956265
public List<List<Writable>> executeSequence(List<List<Writable>> inputSequence) {
        return executeSequenceToSequence(inputSequence);
    }
774618
public static void annotateRoot(String... keyValueSequence) {
        TracyThreadContext ctx = threadContext.get();
        if (isValidContext(ctx)) {
            ctx.annotateRoot(keyValueSequence);
        }
    }