Writes the index entry into memcache/apc DB.
7891
private function write_index()
    {
        if (!$this->db || $this->type == 'db') {
            return;
        }

        $this->load_index();

        // Make sure index contains new keys
        foreach ($this->cache as $key => $value) {
            if ($value !== null && !in_array($key, $this->index)) {
                $this->index[] = $key;
            }
        }

        // new keys added using self::write()
        foreach ($this->cache_sums as $key => $value) {
            if ($value === true && !in_array($key, $this->index)) {
                $this->index[] = $key;
            }
        }

        $data = serialize($this->index);
        $this->add_record($this->ikey(), $data);
    }
880504
public void writeToIndex(Object object) {
        Assert.notNull(object, "no object data given");

        lazyInitWriting();
        BytesRef serialized = bulkEntryWriter.writeBulkEntry(object);
        if (serialized != null) {
            doWriteToIndex(serialized);
        }
    }
530207
private void loadIndexInMemory() throws Exception {
		// create the memory objects with the appropriate initial size
		if (numProductCentroids <= 256) {
			pqByteCodes = new TByteArrayList(maxNumVectors * numSubVectors);
		} else {
			pqShortCodes = new TShortArrayList(maxNumVectors * numSubVectors);
		}
		long start = System.currentTimeMillis();
		System.out.println("Loading persistent index in memory.");

		DatabaseEntry foundKey = new DatabaseEntry();
		DatabaseEntry foundData = new DatabaseEntry();

		ForwardCursor cursor = null;
		if (useDiskOrderedCursor) { // disk ordered cursor
			DiskOrderedCursorConfig docc = new DiskOrderedCursorConfig();
			cursor = iidToPqDB.openCursor(docc);
		} else {
			cursor = iidToPqDB.openCursor(null, null);
		}

		int counter = 0;
		while (cursor.getNext(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS
				&& counter < maxNumVectors) {
			TupleInput input = TupleBinding.entryToInput(foundData);

			if (numProductCentroids <= 256) {
				byte[] code = new byte[numSubVectors];
				for (int i = 0; i < numSubVectors; i++) {
					code[i] = input.readByte();
				}
				pqByteCodes.add(code); // update ram based index
			} else {
				short[] code = new short[numSubVectors];
				for (int i = 0; i < numSubVectors; i++) {
					code[i] = input.readShort();
				}
				pqShortCodes.add(code); // update ram based index
			}
			counter++;
			if (counter % 1000 == 0) {
				System.out.println(counter + " vectors loaded in memory!");
			}
		}
		cursor.close();
		long end = System.currentTimeMillis();
		System.out.println(counter + " vectors loaded in " + (end - start) + " ms!");
	}
706001
@Override
    public void write(byte[] b, int off, int len) throws IOException {
        if (currentEntry != null && !currentEntry.isDirectory()) {
            if (currentEntry.getSize() < currentFileSize + len) {
                throw new IOException( "The current entry[" + currentEntry.getName() + "] size["
                        + currentEntry.getSize() + "] is smaller than the bytes[" + ( currentFileSize + len )
                        + "] being written." );
            }
        }

        out.write( b, off, len );
        
        bytesWritten += len;

        if (currentEntry != null) {
            currentFileSize += len;
        }        
    }
1156172
def write_index(fn, index):
    
    with open(fn, "wb") as o_file:
        o_file.write(_CHECK_STRING)
        o_file.write(zlib.compress(bytes(
            index.to_csv(None, index=False, encoding="utf-8"),
            encoding="utf-8",
        )))
182835
private void handleWrites(final MemcachedNode node) throws IOException {
    node.fillWriteBuffer(shouldOptimize);
    boolean canWriteMore = node.getBytesRemainingToWrite() > 0;
    while (canWriteMore) {
      int wrote = node.writeSome();
      metrics.updateHistogram(OVERALL_AVG_BYTES_WRITE_METRIC, wrote);
      node.fillWriteBuffer(shouldOptimize);
      canWriteMore = wrote > 0 && node.getBytesRemainingToWrite() > 0;
    }
  }
341154
private void loadIndexInMemory() throws Exception {
		long start = System.currentTimeMillis();
		System.out.println("Loading persistent index in memory.");

		DatabaseEntry foundKey = new DatabaseEntry();
		DatabaseEntry foundData = new DatabaseEntry();

		ForwardCursor cursor = null;
		if (useDiskOrderedCursor) { // disk ordered cursor
			DiskOrderedCursorConfig docc = new DiskOrderedCursorConfig();
			cursor = iidToIvfpqDB.openCursor(docc);
		} else {
			cursor = iidToIvfpqDB.openCursor(null, null);
		}

		int counter = 0;
		while (cursor.getNext(foundKey, foundData, LockMode.DEFAULT) == OperationStatus.SUCCESS
				&& counter < maxNumVectors) {
			TupleInput input = TupleBinding.entryToInput(foundData);
			int listId = input.readInt();
			// The following code assumes that internal ids are consequtive (as they should be).
			// It is possible, however, tha an indexed with non-consequtive ids was constructed.
			// invertedLists[listId].add(counter); // update ram based index
			// The following code works for non-consequitve internal ids as well.
			int iid = IntegerBinding.entryToInt(foundKey);
			invertedLists[listId].add(iid); // update ram based index

			if (numProductCentroids <= 256) {
				byte[] code = new byte[numSubVectors];
				for (int i = 0; i < numSubVectors; i++) {
					code[i] = input.readByte();
				}
				pqByteCodes[listId].add(code); // update ram based index
			} else {
				short[] code = new short[numSubVectors];
				for (int i = 0; i < numSubVectors; i++) {
					code[i] = input.readShort();
				}
				pqShortCodes[listId].add(code); // update ram based index
			}
			counter++;
			if (counter % 1000 == 0) {
				System.out.println(counter + " vectors loaded in memory!");
			}
		}
		cursor.close();
		long end = System.currentTimeMillis();
		System.out.println(counter + " images loaded in " + (end - start) + " ms!");
	}
1053510
protected void writeEntry(final GZIPArchive.Entry entry) throws IOException {

		// ID1 ID2 CM FLG

		this.output.write(GZIPArchive.GZIP_START);

		// MTIME

		writeLEInt(this.output, entry.mtime);

		// XFL OS

		this.output.write(GZIPArchive.XFL_OS);

		/* EXTRA begin */

		// XLEN

		writeLEShort(this.output, GZIPArchive.XLEN);

		// SI1 SI2 (as in warc spec)

		this.output.write(GZIPArchive.SKIP_LEN);

		// LEN

		writeLEShort(this.output, GZIPArchive.SUB_LEN);

		// compressed-skip-length (as in warc spec)

		writeLEInt(this.output, entry.compressedSkipLength);

		// uncompressed length (as in warc spec)

		writeLEInt(this.output, entry.uncompressedSkipLength);

		/* EXTRA end */

		// NAME

		this.output.write(entry.name);
		this.output.write(0);

		// COMMENT

		this.output.write(entry.comment);
		this.output.write(0);

		// compressed blocks

		this.output.write(deflaterStream.array, 0, deflaterStream.length);

		// CRC32

		writeLEInt(this.output, entry.crc32);

		// ISIZE

		writeLEInt(this.output, entry.uncompressedSkipLength);

	}
1291461
private void loadIndexInMemory() throws Exception {
		long start = System.currentTimeMillis();
		System.out.println("Loading persistent index in memory.");

		DatabaseEntry foundKey = new DatabaseEntry();
		DatabaseEntry foundData = new DatabaseEntry();

		ForwardCursor cursor = null;
		if (useDiskOrderedCursor) { // disk ordered cursor
			DiskOrderedCursorConfig docc = new DiskOrderedCursorConfig();
			cursor = iidToVectorDB.openCursor(docc);
		} else {
			cursor = iidToVectorDB.openCursor(null, null);
		}

		int counter = 0;
		while (cursor.getNext(foundKey, foundData, null) == OperationStatus.SUCCESS
				&& counter < maxNumVectors) {
			TupleInput input = TupleBinding.entryToInput(foundData);
			double[] vector = new double[vectorLength];
			for (int i = 0; i < vectorLength; i++) {
				vector[i] = input.readDouble();
			}
			// update ram based index
			vectorsList.add(vector);
			counter++;
			if (counter % 1000 == 0) {
				System.out.println(counter + " vectors loaded in memory!");
			}
		}
		cursor.close();
		long end = System.currentTimeMillis();
		System.out.println(counter + " vectors loaded in " + (end - start) + " ms!");
	}
243105
public function write()
    {
        if ($this->isModified && $this->cacheKey) {
            $this->cache->set($this->cacheKey, $this->queried);
            $this->isModified = false;
        }
    }
1150906
def update_index(entries):
    
    context = GLOBAL_TEMPLATE_CONTEXT.copy()
    context['entries'] = entries
    context['last_build'] = datetime.datetime.now().strftime(
        "%Y-%m-%dT%H:%M:%SZ")

    list(map(lambda x: _render(context, x[0],
                               os.path.join(CONFIG['output_to'], x[1])),
             (('entry_index.html', 'index.html'), ('atom.xml', 'atom.xml'))))
399413
public void writeDataBlock( int blockIndex , long blockOffset , byte[] blockData ) throws JournalException
    {
    	// Refuse any further operation in case of previous failure
    	if (failing)
    		throw new JournalException("Store journal is failing");
    	
        synchronized (journalWriteQueue)
        {
        	if (traceEnabled)
        		log.trace("["+baseName+"] #"+currentTransactionId+" Queueing data block write : ["+blockIndex+"] offset="+blockOffset+" size="+blockData.length+" / queueSize="+(journalWriteQueue.size()+1));
        	
        	DataBlockWriteOperation op = 
        		new DataBlockWriteOperation(currentTransactionId,
		        							blockIndex, 
		    		                        blockOffset, 
		    		                        blockData);
            journalWriteQueue.addLast(op);
            unflushedJournalSize += op.size();
            totalPendingOperations++;
        }
    }
1162341
def write_index(self, overwrite: bool = False, mock: bool = False) -> None:
        
        write_if_allowed(self.index_filename, self.index_content(),
                         overwrite=overwrite, mock=mock)
302651
public void write(final AbstractIndex index)
		throws IOException
	{

		StringBuilder cmd;

		while (index.size() > 0) {

			System.out.println("Transmit Index [" + index + "]");

			cmd = index.remove();
			// System.out.println(cmd.toString());

			cmd.append("\r\n");
			writer.write(cmd.toString());
		}

		writer.flush();
	}
233815
def init_write_index(es_write, es_write_index):
    
    logging.info("Initializing index: " + es_write_index)
    es_write.indices.delete(es_write_index, ignore=[400, 404])
    es_write.indices.create(es_write_index, body=MAPPING_GIT)
69668
private void writeToDiskCache(
      final CacheKey key,
      final EncodedImage encodedImage) {
    FLog.v(TAG, "About to write to disk-cache for key %s", key.getUriString());
    try {
      mFileCache.insert(
          key, new WriterCallback() {
            @Override
            public void write(OutputStream os) throws IOException {
              mPooledByteStreams.copy(encodedImage.getInputStream(), os);
            }
          }
      );
      FLog.v(TAG, "Successful disk-cache write for key %s", key.getUriString());
    } catch (IOException ioe) {
      // Log failure
      // TODO: 3697790
      FLog.w(TAG, ioe, "Failed to write to disk-cache for key %s", key.getUriString());
    }
  }
31210
protected void setReadWrite() throws IOException
   {
      // Release all the current threads
      synchronized (updateMonitor)
      {
         indexUpdateMonitor.setUpdateInProgress(false, true);
         updateMonitor.notifyAll();
         releaseMultiReader();
      }

      this.redoLog = new RedoLog(indexDir);
      redoLogApplied = redoLog.hasEntries();

      // run recovery
      Recovery.run(this, redoLog);

      // enqueue unused segments for deletion
      enqueueUnusedSegments();
      attemptDelete();

      // now that we are ready, start index merger
      initMerger();

      if (redoLogApplied)
      {
         // wait for the index merge to finish pending jobs
         try
         {
            merger.waitUntilIdle();
         }
         catch (InterruptedException e)
         {
            // move on
         }
         flush();
      }

      if (indexNames.size() > 0)
      {
         scheduleFlushTask();
      }
   }