Insert a codepoint into the buffer, automatically dealing with surrogate
pairs

@param aSeq
source sequence
@param nIndex
index
@param aCodepoint
codepoint to be inserted
960506
public static void insert (final CharSequence aSeq, final int nIndex, @Nonnull final Codepoint aCodepoint)
  {
    insert (aSeq, nIndex, aCodepoint.getValue ());
  }
25309
final void addPointer(int keyPos, int keySize, int valuePos, int valueSize) {
    assert keyPos + keySize == valuePos;
    int start = memoryBuffer.limit() - POINTER_SIZE_BYTES;
    memoryBuffer.putInt(start, keyPos);
    memoryBuffer.putInt(start + 4, valuePos);
    memoryBuffer.putInt(start + 8, valueSize);
    memoryBuffer.limit(start);
    valuesHeld++;
  }
632220
public void addNewKernelPoint()
    {
        KernelPoint source = points.get(0);
        KernelPoint toAdd = new KernelPoint(k, errorTolerance);
        toAdd.setMaxBudget(maxBudget);
        toAdd.setBudgetStrategy(budgetStrategy);
        
        standardMove(toAdd, source);
        toAdd.kernelAccel = source.kernelAccel;
        toAdd.vecs = source.vecs;
        toAdd.alpha = new DoubleList(source.alpha.size());
        for (int i = 0; i < source.alpha.size(); i++)
            toAdd.alpha.add(0.0);
        points.add(toAdd);
    }
1263076
public static String rejectCodePoint(String string, CodePointPredicate predicate)
    {
        int size = string.length();
        StringBuilder buffer = new StringBuilder(string.length());
        for (int i = 0; i < size; )
        {
            int codePoint = string.codePointAt(i);
            if (!predicate.accept(codePoint))
            {
                buffer.appendCodePoint(codePoint);
            }
            i += Character.charCount(codePoint);
        }
        return buffer.toString();
    }
1206843
private void doCheckpoint() throws IOException {
    long start = AvatarNode.now();
    try {
      InjectionHandler.processEvent(InjectionEvent.STANDBY_ENTER_CHECKPOINT, this.sig);
      
      // Tell the remote namenode to start logging transactions in a new edit file
      // Retuns a token that would be used to upload the merged image.
      if (!checkpointEnabled) {
        checkpointStatus("Disabled");
        // This means the Standby is not meant to checkpoint the primary
        LOG.info("Standby: Checkpointing is disabled - return");
        return;
      }
      CheckpointSignature sig = null;
      InjectionHandler.processEvent(InjectionEvent.STANDBY_BEFORE_ROLL_EDIT);
      try {
        LOG.info("Standby: Checkpointing - Roll edits logs of primary namenode "
            + nameNodeAddr);
        checkpointStatus("Edit log rolled on primary");
        synchronized(ingestStateLock) {
          sig = (CheckpointSignature) primaryNamenode.rollEditLog();
        }
      } catch (IOException ex) {
        // In this case we can return since we did not kill the Ingest thread yet
        // Nothing prevents us from doing the next checkpoint attempt
        checkpointStatus("Checkpoint failed");
        LOG.warn("Standby: Checkpointing - roll Edits on the primary node failed.");
        InjectionHandler.processEvent(
            InjectionEvent.STANDBY_EXIT_CHECKPOINT_FAILED_ROLL, ex);
        return;
      }
      
      setLastRollSignature(sig); 
      
      // consume all finalized log segments up to the required txid
      long checkpointTxId = sig.curSegmentTxId - 1;  
      LOG.info("Standby: Checkpointing - checkpoint txid: " + checkpointTxId);
      checkpointStatus("Quiescing ingest");
      quiesceIngest(checkpointTxId);
      
      if (currentSegmentTxId != checkpointTxId + 1) {
        throw new IOException(
            "Standby: Checkpointing txid mismatch - ingest consumed txns up to "
                + (currentSegmentTxId - 1) + " but should have up to "
                + checkpointTxId);
      }
      
      // if everything is fine, the edit log should be closed now
      LOG.info("Standby: Checkpointing - finished quitting ingest thread just before ckpt.");       
      assertState(StandbyIngestState.NOT_INGESTING);
  
      /**
       * From now on Ingest thread needs to know if the checkpoint was started and never finished.
       * This would mean that it doesn't have to read the edits, since they were already processed
       * to the end as a part of a checkpoint. state = StandbyIngestState.CHECKPOINTING
       */
      fsnamesys.writeLock();
      try {      
        InjectionHandler.processEvent(InjectionEvent.STANDBY_BEFORE_SAVE_NAMESPACE);
        currentIngestState = StandbyIngestState.CHECKPOINTING;
    
        // save a checkpoint of the current namespace of the local Namenode
        // We should ideally use fsnamesystem.saveNamespace but that works
        // only if namenode is not in safemode.
        LOG.info("Standby: Checkpointing - save fsimage on local namenode.");
        checkpointStatus("Saving namespace started");
        // by default checkpoints are compressed if configured
        // manual command can override this setting for one checkpoint
        fsnamesys.getFSImage().saveNamespace(false);
        // get the new signature
        sig.mostRecentCheckpointTxId = fsImage.getEditLog().getLastWrittenTxId();
        sig.imageDigest = fsImage.storage.getCheckpointImageDigest(sig.mostRecentCheckpointTxId);
      } catch (SaveNamespaceCancelledException e) {
        InjectionHandler.processEvent(InjectionEvent.STANDBY_CANCELLED_EXCEPTION_THROWN);
        LOG.info("Standby: Checkpointing - cancelled saving namespace");
        fsnamesys.getFSImage().deleteCheckpoint(checkpointTxId);
        throw e;
      } catch (IOException ex) {
        // Standby failed to save fsimage locally. Need to reinitialize
        String msg = "Standby: Checkpointing - failed to checkpoint itself, so " +
        		"no image can be uploaded to the primary. The only course of action " +
        		"is to start from the very beginning by reinitializing AvatarNode";
        LOG.error(msg, ex);
        fsnamesys.getFSImage().deleteCheckpoint(checkpointTxId);
        throw new RuntimeException(msg, ex);
      } finally {
        currentIngestState = StandbyIngestState.NOT_INGESTING;
        fsnamesys.writeUnlock();
      }
      
      // we can start the ingest again for next segment
      instantiateIngest();
      
      try {
        finalizeCheckpoint(sig);
      } catch (IOException ex) {
        LOG.error("Standby: Checkpointing - rolling the fsimage " +
            "on the Primary node failed.", ex);
        throw new FinalizeCheckpointException(ex.toString());
      }
      setCheckpointFailures(0);
      LOG.info("Standby: Checkpointing - checkpoint completed in "
          + ((AvatarNode.now() - start) / 1000) + " s.");
    } catch (IOException e) {
      LOG.error("Standby: Checkpointing - failed to complete the checkpoint: "
          + StringUtils.stringifyException(e));
      checkpointStatus("Checkpoint failed");    
      if (!checkpointEnabled) {
        // we received instruction to prepare for failover
        return;
      }
      handleCheckpointFailure();
      InjectionHandler.processEvent(InjectionEvent.STANDBY_EXIT_CHECKPOINT_EXCEPTION, e);
      throw e;
    } finally {
      countDownManualLatch(1);
      setLastRollSignature(null);
      InjectionHandler.processEvent(InjectionEvent.STANDBY_EXIT_CHECKPOINT, this.sig);
    }
  }
280109
private AbstractPlanNode recursivelyApply(AbstractPlanNode plan, int childIdx) {
        // If this is an insert plan node, then try to
        // inline it.  There will only ever by one insert
        // node, so if we can't inline it we just return the
        // given plan.
        if (plan instanceof InsertPlanNode) {
            InsertPlanNode insertNode = (InsertPlanNode)plan;
            assert(insertNode.getChildCount() == 1);
            AbstractPlanNode abstractChild = insertNode.getChild(0);
            ScanPlanNodeWhichCanHaveInlineInsert targetNode
                  = (abstractChild instanceof ScanPlanNodeWhichCanHaveInlineInsert)
                        ? ((ScanPlanNodeWhichCanHaveInlineInsert)abstractChild)
                        : null;
            // If we have a sequential/index scan node without an inline aggregate
            // node then we can inline the insert node.
            if ( targetNode != null
                 && ! insertNode.isUpsert()
                 && ! targetNode.hasInlineAggregateNode()
                 // If INSERT INTO and SELECT FROM have the same target table name,
                 // then it could be a recursive insert into select.
                 // Currently, our scan executor implementations cannot handle it well. (ENG-13036)
                 && ! targetNode.getTargetTableName().equalsIgnoreCase(insertNode.getTargetTableName()) ) {
                AbstractPlanNode parent = (insertNode.getParentCount() > 0) ? insertNode.getParent(0) : null;
                AbstractPlanNode abstractTargetNode = targetNode.getAbstractNode();
                abstractTargetNode.addInlinePlanNode(insertNode);
                // Don't call removeFromGraph.  That
                // screws up the order of the children.
                insertNode.clearChildren();
                insertNode.clearParents();
                // Remvoe all the abstractTarget node's parents.
                // It used to be the insertNode, which is now
                // dead to us.
                abstractTargetNode.clearParents();
                if (parent != null) {
                    parent.setAndLinkChild(childIdx, abstractTargetNode);
                }
                plan = abstractTargetNode;
            }
            return plan;
        }
        for (int idx = 0; idx < plan.getChildCount(); idx += 1) {
            AbstractPlanNode child = plan.getChild(idx);
            recursivelyApply(child, idx);
        }
        return plan;
    }
794920
public void insertTable(Table aTable, Point aLocation) {
        
        if (aTable == null) { 
        	throw new NullPointerException("insertTable - table has null-value");
        }
        if (aLocation == null) {
        	throw new NullPointerException("insertTable - point has null-value");
        }
        mTableInserted = true;
        aTable.complete();
        
        if (aLocation.y > columns) {
        	throw new IllegalArgumentException("insertTable -- wrong columnposition("+ aLocation.y + ") of location; max =" + columns);
        }
        
        int rowCount = aLocation.x + 1 - rows.size();
        int i = 0;
        if ( rowCount > 0 ) {   //create new rows ?
            for (; i < rowCount; i++) {
                rows.add(new Row(columns));
            }
        }
        
        rows.get(aLocation.x).setElement(aTable,aLocation.y);
        
        setCurrentLocationToNextValidPosition(aLocation);
    }
815023
private static void appendCodePoint(Appendable app, int c) {
        assert 0 <= c && c <= 0x10ffff;
        try {
            if (c <= 0xffff) {
                app.append((char) c);
            } else {
                app.append(UTF16.getLeadSurrogate(c)).append(UTF16.getTrailSurrogate(c));
            }
        } catch (IOException e) {
            throw new ICUUncheckedIOException(e);
        }
    }
180894
public void insert(final AbstractInsnNode location,
            final AbstractInsnNode insn) {
        ++size;
        AbstractInsnNode next = location.next;
        if (next == null) {
            last = insn;
        } else {
            next.prev = insn;
        }
        location.next = insn;
        insn.next = next;
        insn.prev = location;
        cache = null;
        insn.index = 0; // insn now belongs to an InsnList
    }
413755
def insertBPoint(self, index, type=None, anchor=None, bcpIn=None, bcpOut=None, bPoint=None):
        
        if bPoint is not None:
            if type is None:
                type = bPoint.type
            if anchor is None:
                anchor = bPoint.anchor
            if bcpIn is None:
                bcpIn = bPoint.bcpIn
            if bcpOut is None:
                bcpOut = bPoint.bcpOut
        index = normalizers.normalizeIndex(index)
        type = normalizers.normalizeBPointType(type)
        anchor = normalizers.normalizeCoordinateTuple(anchor)
        if bcpIn is None:
            bcpIn = (0, 0)
        bcpIn = normalizers.normalizeCoordinateTuple(bcpIn)
        if bcpOut is None:
            bcpOut = (0, 0)
        bcpOut = normalizers.normalizeCoordinateTuple(bcpOut)
        self._insertBPoint(index=index, type=type, anchor=anchor,
                           bcpIn=bcpIn, bcpOut=bcpOut)
442675
@OverrideOnDemand
  protected void onInsertAtIndex (@Nonnegative final int nIndex, @Nonnull final AbstractMicroNode aChildNode)
  {
    throw new MicroException ("Cannot insert children in class " + getClass ().getName ());
  }
111651
public static void setChar (@Nonnull final CharSequence aSeq, final int nIndex, @Nonnull final Codepoint aCodepoint)
  {
    setChar (aSeq, nIndex, aCodepoint.getValue ());
  }
920243
@Override
    protected void forwardNumCodePoints(int num) {
        while(num > 0 && pos != limit) {
            char c = seq.charAt(pos++);
            --num;
            if(Character.isHighSurrogate(c) && pos != limit &&
                    Character.isLowSurrogate(seq.charAt(pos))) {
                ++pos;
            }
        }
    }
1065707
@Override
    public void add(int idx, double val) {
        int i = Arrays.binarySearch(indices, 0, used, idx);
        if (i >= 0) {
            // Just add to the existing value.
            values[i] += val;
            return;
        } 
        int insertionPoint = -(i + 1);
        indices = insert(indices, insertionPoint, idx);
        values = insert(values, insertionPoint, val);
        used++;
    }
133446
@Nonnull
  public final HCHead addJSAt (@Nonnegative final int nIndex, @Nonnull final IHCNode aJS)
  {
    ValueEnforcer.notNull (aJS, "JS");
    if (!HCJSNodeDetector.isJSNode (aJS))
      throw new IllegalArgumentException (aJS + " is not a valid JS node!");
    m_aJS.add (nIndex, aJS);
    return this;
  }
776038
@Override
	public T visitPSeq(PSeqContext ctx) {
//		on(ctx);
		appendAst(ctx, tok(PARAM_SEQUENCE));
		return super.visitPSeq(ctx);
	}
279512
private static void insertAddressUsingCallable(AddressClient client, String newAddressName)
      throws InterruptedException, ExecutionException {
    // Begin samplegen code for insertAddress().
    ProjectRegionName region = ProjectRegionName.of(PROJECT_NAME, REGION);
    Address address = Address.newBuilder().build();
    InsertAddressHttpRequest request =
        InsertAddressHttpRequest.newBuilder()
            .setRegion(region.toString())
            .setAddressResource(address)
            .build();
    ApiFuture<Operation> future = client.insertAddressCallable().futureCall(request);
    // Do something
    Operation response = future.get();

    // End samplegen code for insertAddress().
    System.out.format("Result of insert: %s\n", response.toString());
  }