Defines a Storable prepare method, which assumes that a support field
exists and a single-argument constructor exists which accepts a support
instance.

@param cf file to which to add the prepare method
@since 1.2
9268
public static void definePrepareMethod(ClassFile cf,
                                           Class storableClass,
                                           TypeDesc supportCtorType,
                                           String supportFieldName,
                                           TypeDesc supportFieldType)
    {
        TypeDesc storableType = TypeDesc.forClass(storableClass);

        if (!isPublicMethodFinal(storableClass, PREPARE_METHOD_NAME, storableType, null)) {
            MethodInfo mi = cf.addMethod
                (Modifiers.PUBLIC, PREPARE_METHOD_NAME, cf.getType(), null);

            CodeBuilder b = new CodeBuilder(mi);
            b.newObject(cf.getType());
            b.dup();
            b.loadThis();
            b.loadField(supportFieldName, supportFieldType);
            if (supportFieldType != supportCtorType) {
                b.checkCast(supportCtorType);
            }
            b.invokeConstructor(new TypeDesc[] {supportCtorType});
            b.returnValue(cf.getType());
        }

        definePrepareBridges(cf, storableClass);
    }
359731
private Ref functionArgDeclaration() throws PageException {
	Ref ref = impOp();
	if (cfml.forwardIfCurrent(':') || cfml.forwardIfCurrent('=')) {
	    cfml.removeSpace();
	    ref = new LFunctionValue(ref, assignOp());
	}
	return ref;
    }
899008
private void addConstructorByKeyRef() {
    context.constructorByKeyRef = MethodSpec.constructorBuilder().addParameter(keyRefSpec);
    addCommonParameters(context.constructorByKeyRef);
    if (isBaseClass()) {
      assignKeyRefAndValue();
    } else {
      callParentByKeyRef();
    }
  }
929547
public static CFGBuilder create(@Nonnull MethodDescriptor descriptor, @Nonnull MethodGen methodGen) {
        return new BetterCFGBuilder2(descriptor, methodGen);
    }
1218142
@Override
  public final void makeFirstPrepareForSave(final Map<String, Object> pAddParam,
    final GoodsLoss pEntity,
      final IRequestData pRequestData) throws Exception {
    // nothing
  }
1313896
public void put(String cfName, String key, byte[] value) throws RocksDbException {
        put(cfName, writeOptions, key, value);
    }
972946
static void configure(final File f) {
		new Configurator() {

			@Override
			void withConfigurator(JoranConfigurator configurator)
					throws JoranException {
				configurator.doConfigure(f);

			}
		}.configure();
	}
526935
void checkFields(ClassFile cf) throws ConstantPoolException {
        for (Field f : cf.fields) {
            String type = nameFromDescType(cf.constant_pool.getUTF8Value(f.descriptor.index));
            if (type != null) {
                DeprData dd = db.getTypeDeprecated(type);
                if (dd != null) {
                    printHasField(cf, f.getName(cf.constant_pool), type, dd.isForRemoval());
                }
            }
        }
    }
96992
public Object prepare(Map<String, ?> params) throws Throwable {
    return AnnotatedExtensions.exec(getMethod(), getBlockNames(), params, this);
  }
1177479
private void init(final SecurityContext securityContext, final Class type, final Field field, final String path) throws FrameworkException {

		final QueryConfig config = getConfig(path);

		config.handleTypeArguments(securityContext, type, field.getArguments());

		final SelectionSet selectionSet = field.getSelectionSet();
		if (selectionSet != null) {

			for (final Selection selection : selectionSet.getSelections()) {

				if (selection instanceof Field) {

					final Field childField      = (Field)selection;
					final SelectionSet childSet = childField.getSelectionSet();
					final PropertyKey key       = StructrApp.key(type, childField.getName());
					final Class relatedType     = key.relatedType() != null ? key.relatedType() : type;

					// add field to property set
					config.addPropertyKey(key);
					config.handleFieldArguments(securityContext, relatedType, field, childField);

					// recurse
					if (childSet != null) {

						init(securityContext, relatedType, childField, path + "/" + childField.getName());
					}
				}
			}
		}
	}
850009
public void put(String cfName, WriteOptions writeOptions, String key, byte[] value)
            throws RocksDbException {
        if (cfName == null) {
            cfName = DEFAULT_COLUMN_FAMILY;
        }
        try {
            put(columnFamilyHandles.get(cfName), writeOptions, key.getBytes(StandardCharsets.UTF_8),
                    value);
        } catch (RocksDbException.ColumnFamilyNotExists e) {
            throw new RocksDbException.ColumnFamilyNotExists(cfName);
        }
    }
311217
static CompletableFuture<Object> orTree(CompletableFuture<?>[] cfs,
                                            int lo, int hi) {
        CompletableFuture<Object> d = new CompletableFuture<Object>();
        if (lo <= hi) {
            CompletableFuture<?> a, b;
            int mid = (lo + hi) >>> 1;
            if ((a = (lo == mid ? cfs[lo] :
                      orTree(cfs, lo, mid))) == null ||
                (b = (lo == hi ? a : (hi == mid+1) ? cfs[hi] :
                      orTree(cfs, mid+1, hi))) == null)
                throw new NullPointerException();
            if (!d.orRelay(a, b)) {
                OrRelay<?,?> c = new OrRelay<>(d, a, b);
                a.orpush(b, c);
                c.tryFire(SYNC);
            }
        }
        return d;
    }
697890
public void addFieldError (@Nonnull @Nonempty final String sFieldName, @Nonnull @Nonempty final String sText)
  {
    add (SingleError.builderError ().setErrorFieldName (sFieldName).setErrorText (sText).build ());
  }
171168
private void registerFieldsAndMethodsInContext(TemplateParserContext templateParserContext,
      TypeElement componentTypeElement, Set<String> alreadyDoneVariable,
      Set<String> alreadyDoneMethods) {
    ElementFilter
        .fieldsIn(componentTypeElement.getEnclosedElements())
        .stream()
        .filter(field -> field.getAnnotation(Data.class) != null
            || field.getAnnotation(Prop.class) != null)
        .forEach(field -> {
          String name = field.getSimpleName().toString();
          if (alreadyDoneVariable.contains(name)) {
            return;
          }

          alreadyDoneVariable.add(name);
          templateParserContext.addRootVariable(ClassName.get(field.asType()), name);
        });

    ElementFilter
        .methodsIn(componentTypeElement.getEnclosedElements())
        .stream()
        .filter(method -> hasAnnotation(method, Computed.class))
        .filter(method -> !"void".equals(method.getReturnType().toString()))
        .forEach(method -> {
          String name = getComputedPropertyName(method);
          if (alreadyDoneVariable.contains(name)) {
            return;
          }
          alreadyDoneVariable.add(name);

          TypeMirror propertyType;
          if ("void".equals(method.getReturnType().toString())) {
            propertyType = method.getParameters().get(0).asType();
          } else {
            propertyType = method.getReturnType();
          }

          templateParserContext
              .addRootComputedProperty(ClassName.get(propertyType), name,
                  computedPropertyNameToFieldName(name));
        });

    ElementFilter
        .methodsIn(componentTypeElement.getEnclosedElements())
        .stream()
        .filter(ComponentGeneratorsUtil::isMethodVisibleInTemplate)
        .map(ExecutableElement::getSimpleName)
        .map(Object::toString)
        .forEach(methodName -> {
          if (alreadyDoneMethods.contains(methodName)) {
            return;
          }
          alreadyDoneMethods.add(methodName);

          templateParserContext.addRootMethod(methodName);
        });

    getSuperComponentType(componentTypeElement)
        .ifPresent(superComponent -> registerFieldsAndMethodsInContext(
            templateParserContext,
            superComponent,
            alreadyDoneVariable,
            alreadyDoneMethods));
  }
378811
@Override
    public void prepare(Map conf) {
        users = new HashSet<String>();
        if (conf.containsKey(WHITELIST_USERS_CONF)) {
            users.addAll((Collection<String>) conf.get(WHITELIST_USERS_CONF));
        }
    }
1099378
private GridFSInputFile createGFSInputFile(GridFS gfs, Object entity, Field f)
    {
        Object obj = PropertyAccessorHelper.getObject(entity, f);
        GridFSInputFile gridFSInputFile = null;
        if (f.getType().isAssignableFrom(byte[].class))
            gridFSInputFile = gfs.createFile((byte[]) obj);
        else if (f.getType().isAssignableFrom(File.class))
        {
            try
            {
                gridFSInputFile = gfs.createFile((File) obj);
            }
            catch (IOException e)
            {
                log.error("Error while creating GridFS file for \"" + f.getName() + "\". Caused by: ", e);
                throw new KunderaException("Error while creating GridFS file for \"" + f.getName() + "\". Caused by: ",
                        e);
            }
        }
        else
            new UnsupportedOperationException(f.getType().getSimpleName() + " is unsupported Lob object");
        return gridFSInputFile;
    }
960116
private void doValidationCompaction(ColumnFamilyStore cfs, Validator validator) throws IOException
    {
        // this isn't meant to be race-proof, because it's not -- it won't cause bugs for a CFS to be dropped
        // mid-validation, or to attempt to validate a droped CFS.  this is just a best effort to avoid useless work,
        // particularly in the scenario where a validation is submitted before the drop, and there are compactions
        // started prior to the drop keeping some sstables alive.  Since validationCompaction can run
        // concurrently with other compactions, it would otherwise go ahead and scan those again.
        if (!cfs.isValid())
            return;

        Refs<SSTableReader> sstables = null;
        try
        {

            String snapshotName = validator.desc.sessionId.toString();
            int gcBefore;
            boolean isSnapshotValidation = cfs.snapshotExists(snapshotName);
            if (isSnapshotValidation)
            {
                // If there is a snapshot created for the session then read from there.
                sstables = cfs.getSnapshotSSTableReader(snapshotName);

                // Computing gcbefore based on the current time wouldn't be very good because we know each replica will execute
                // this at a different time (that's the whole purpose of repair with snaphsot). So instead we take the creation
                // time of the snapshot, which should give us roughtly the same time on each replica (roughtly being in that case
                // 'as good as in the non-snapshot' case)
                gcBefore = cfs.gcBefore(cfs.getSnapshotCreationTime(snapshotName));
            }
            else
            {
                // flush first so everyone is validating data that is as similar as possible
                StorageService.instance.forceKeyspaceFlush(cfs.keyspace.getName(), cfs.name);
                // we don't mark validating sstables as compacting in DataTracker, so we have to mark them referenced
                // instead so they won't be cleaned up if they do get compacted during the validation
                if (validator.desc.parentSessionId == null || ActiveRepairService.instance.getParentRepairSession(validator.desc.parentSessionId) == null)
                    sstables = cfs.selectAndReference(ColumnFamilyStore.CANONICAL_SSTABLES).refs;
                else
                {
                    ColumnFamilyStore.RefViewFragment refView = cfs.selectAndReference(ColumnFamilyStore.UNREPAIRED_SSTABLES);
                    sstables = refView.refs;
                    Set<SSTableReader> currentlyRepairing = ActiveRepairService.instance.currentlyRepairing(cfs.metadata.cfId, validator.desc.parentSessionId);

                    if (!Sets.intersection(currentlyRepairing, Sets.newHashSet(refView.sstables)).isEmpty())
                    {
                        logger.error("Cannot start multiple repair sessions over the same sstables");
                        throw new RuntimeException("Cannot start multiple repair sessions over the same sstables");
                    }

                    ActiveRepairService.instance.getParentRepairSession(validator.desc.parentSessionId).addSSTables(cfs.metadata.cfId, refView.sstables);
                }

                if (validator.gcBefore > 0)
                    gcBefore = validator.gcBefore;
                else
                    gcBefore = getDefaultGcBefore(cfs);
            }

            // Create Merkle tree suitable to hold estimated partitions for given range.
            // We blindly assume that partition is evenly distributed on all sstables for now.
            long numPartitions = 0;
            for (SSTableReader sstable : sstables)
            {
                numPartitions += sstable.estimatedKeysForRanges(Collections.singleton(validator.desc.range));
            }
            // determine tree depth from number of partitions, but cap at 20 to prevent large tree.
            int depth = numPartitions > 0 ? (int) Math.min(Math.floor(Math.log(numPartitions)), 20) : 0;
            MerkleTree tree = new MerkleTree(cfs.partitioner, validator.desc.range, MerkleTree.RECOMMENDED_DEPTH, (int) Math.pow(2, depth));

            long start = System.nanoTime();
            try (AbstractCompactionStrategy.ScannerList scanners = cfs.getCompactionStrategy().getScanners(sstables, validator.desc.range))
            {
                CompactionIterable ci = new ValidationCompactionIterable(cfs, scanners.scanners, gcBefore);
                Iterator<AbstractCompactedRow> iter = ci.iterator();
                metrics.beginCompaction(ci);
                try
                {
                    // validate the CF as we iterate over it
                    validator.prepare(cfs, tree);
                    while (iter.hasNext())
                    {
                        if (ci.isStopRequested())
                            throw new CompactionInterruptedException(ci.getCompactionInfo());
                        AbstractCompactedRow row = iter.next();
                        validator.add(row);
                    }
                    validator.complete();
                }
                finally
                {
                    if (isSnapshotValidation)
                    {
                        cfs.clearSnapshot(snapshotName);
                    }

                    metrics.finishCompaction(ci);
                }
            }

            if (logger.isDebugEnabled())
            {
                // MT serialize may take time
                long duration = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
                logger.debug("Validation finished in {} msec, depth {} for {} keys, serialized size {} bytes for {}",
                             duration,
                             depth,
                             numPartitions,
                             MerkleTree.serializer.serializedSize(tree, 0),
                             validator.desc);
            }
        }
        finally
        {
            if (sstables != null)
                sstables.release();
        }
    }