[TARGET allocateId(IncompleteKey)]
778605
public Key allocateIdSingle() {
    // [START allocateIdSingle]
    KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind");
    IncompleteKey incompleteKey = keyFactory.newKey();

    // let cloud datastore automatically assign an id
    Key key = datastore.allocateId(incompleteKey);
    // [END allocateIdSingle]
    return key;
  }
205292
@GuardedBy("maxNumberInvariant")
   private void resetNumberOfKeys() {
      maxNumberOfKeys.set(address2key.keySet().size() * bufferSize);
      existingKeyCount.set(0);
      if (trace) {
         log.tracef("resetNumberOfKeys ends with: maxNumberOfKeys=%s, existingKeyCount=%s",
                    maxNumberOfKeys.get(), existingKeyCount.get());
      }
   }
557918
private int allocateNode(int d) {
        int id = 1;
        int initial = - (1 << d); // has last d bits = 0 and rest all = 1
        byte val = value(id);
        if (val > d) { // unusable
            return -1;
        }
        while (val < d || (id & initial) == 0) { // id & initial == 1 << d for all ids at depth d, for < d it is 0
            id <<= 1;
            val = value(id);
            if (val > d) {
                id ^= 1;
                val = value(id);
            }
        }
        byte value = value(id);
        assert value == d && (id & initial) == 1 << d : String.format("val = %d, id & initial = %d, d = %d",
                value, id & initial, d);
        setValue(id, unusable); // mark as unusable
        updateParentsAlloc(id);
        return id;
    }
167496
protected void insertNewKeyValueAt(int i, short key, Container value) {
    extendArray(1);
    System.arraycopy(keys, i, keys, i + 1, size - i);
    keys[i] = key;
    System.arraycopy(values, i, values, i + 1, size - i);
    values[i] = value;
    size++;
  }
147856
@Override public synchronized Long sadd(final String key, final String member, final String ... members) throws WrongTypeException {
        checkType(key, "set");
        Long count = 0L;
        if (!setCache.exists(key) || !setCache.get(key).contains(member)) {
            setCache.set(key, member);
            count += 1L;
        }
        for (String memb : members) {
            if (!setCache.exists(key) || !setCache.get(key).contains(memb)) {
                setCache.set(key, memb);
                count += 1L;
            }
        }
        if (count > 0L) {
            keyModified(key);
        }
        return count;
    }
1104544
function _allocate(bytes) {
  var address = Module._malloc(bytes.length);
  Module.HEAPU8.set(bytes, address);

  return address;
}
167264
public static void putDecimalNormalizedKey(
			Decimal record, MemorySegment target, int offset, int len) {
		assert record.getPrecision() <= Decimal.MAX_COMPACT_PRECISION;
		putLongNormalizedKey(record.toUnscaledLong(), target, offset, len);
	}
621176
public void setKey(int index, byte[] key) throws IOException {
        if (index >= structure.keySizes.size()) {
            throw new IOException("Index " + index + " is out of range.");
        }
        int length = structure.keySizes.get(index);
        if (key.length != length) {
            throw new IOException("The length of the given key is not equal to the expected one. (" + key.length
                    + "!=" + length + ")");
        }
        Bytes.putBytes(this.key, structure.keyByteOffsets.get(index), key, 0, key.length);
    }
584234
private static int getMapperId(long key, int numReducers, int maxKeySpace) {
    key = key - getFirstSumKey(numReducers, maxKeySpace);
    return (int) (key / numReducers);
  }
295809
protected void doDelete(String spaceId, String key) throws IOException {
        Term termDelete = buildIdTerm(spaceId, key);
        IndexWriter indexWriter = getIndexWriter();
        indexWriter.deleteDocuments(termDelete);
        if (!isAsyncWrite()) {
            indexWriter.commit();
        } else if (getIndexManager().getBackgroundCommitIndexPeriodMs() <= 0) {
            LOGGER.warn("Async-write is enable, autoCommitPeriodMs must be larger than 0!");
        }
    }
1097874
public static void maxNormalizedKey(MemorySegment target, int offset, int numBytes) {
		//write max value.
		for (int i = 0; i < numBytes; i++) {
			target.put(offset + i, (byte) -1);
		}
	}
839135
private void allocateNormal(PooledByteBuf<T> buf, int reqCapacity, int normCapacity) {
        if (q050.allocate(buf, reqCapacity, normCapacity) || q025.allocate(buf, reqCapacity, normCapacity) ||
            q000.allocate(buf, reqCapacity, normCapacity) || qInit.allocate(buf, reqCapacity, normCapacity) ||
            q075.allocate(buf, reqCapacity, normCapacity)) {
            return;
        }

        // Add a new chunk.
        PoolChunk<T> c = newChunk(pageSize, maxOrder, pageShifts, chunkSize);
        boolean success = c.allocate(buf, reqCapacity, normCapacity);
        assert success;
        qInit.add(c);
    }
292403
def set key, value
      @reverse_cache[value.object_id] = key
      @cache[key]                     = value.object_id
      ObjectSpace.define_finalizer(value, @finalize)
    end
1014051
private IncompleteKey getIncompleteKey(Object entity) {
    EntityMetadata entityMetadata = EntityIntrospector.introspect(entity.getClass());
    String kind = entityMetadata.getKind();
    ParentKeyMetadata parentKeyMetadata = entityMetadata.getParentKeyMetadata();
    DatastoreKey parentKey = null;
    IncompleteKey incompleteKey = null;
    if (parentKeyMetadata != null) {
      parentKey = (DatastoreKey) IntrospectionUtils.getFieldValue(parentKeyMetadata, entity);
    }
    if (parentKey != null) {
      incompleteKey = IncompleteKey.newBuilder(parentKey.nativeKey(), kind).build();
    } else {
      incompleteKey = IncompleteKey.newBuilder(datastore.getOptions().getProjectId(), kind)
          .setNamespace(getEffectiveNamespace()).build();
    }
    return incompleteKey;
  }
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;
   }
598340
def allocate(self, handles, initial=False, params={}):
        """"""
        assert all(re.search('^\d+$', h) for h in handles), "All handles must be numbers: {}".format(handles)
        self.requests.put(('allocate', (handles, initial, params)))
327933
def _allocate_specified_segment(self, session, seg_id, source):
        
        try:
            with session.begin(subtransactions=True):
                alloc = (session.query(self.model).filter_by(
                    segmentation_id=seg_id).first())
                if alloc:
                    if alloc.allocated:
                        # Segment already allocated
                        return
                    else:
                        # Segment not allocated
                        count = (session.query(self.model).
                                 filter_by(allocated=False,
                                           segmentation_id=seg_id).update(
                                               {"allocated": True}))
                        if count:
                            return alloc

                # Segment to create or already allocated
                alloc = self.model(segmentation_id=seg_id,
                                   allocated=True, source=source)
                session.add(alloc)

        except db_exc.DBDuplicateEntry:
            # Segment already allocated (insert failure)
            alloc = None

        return alloc