text:
Simple routing for php

# Installationg

```
composer require nozols/simple-router
```

See the tests folder for an example folder structure. Don't forget the .htaccess file! Otherwise it won't work.

# Examples
In your route file call `Router::init()` and end with `Router::end()` between these two function calls put your routes.

## Routes
```php
Router::get('/path/to/respond/to', function(){
    // do someting
});
```
This will respond to a GET request where the path is equal to /path/to/respond/to

Other avalaible functions are:
- `Router::post`
- `Router::put`
- `Router::patch`
- `Router::delete`

They work exactly the same way as `Router::get`
If you want your route to respond to multiple request methods use `Router::add`:
```php
Router::add(['GET', 'POST', 'PUT'], '/path/to/respond/to', function(){
    // do someting
    // will respond when the request path is /path/to/respond/to and the method is either GET, POST or PUT.
});
```

Browsers can't usually send PUT, PATCH or DELETE request. If you want the router to think it is one of those request, add an hidden input in your form:
`<input type="hidden" name="_method" value="PATCH" />`

### Variables in path
```php
Router::get('/path/{variable}', function($variable){
    // you can access $variable here and do stuff with it.
})
```

## Retrieving GET and POST variables
You can retrieve GET and POST variables by using `Router::request()->post('key')` or `Router::request()->get('key')`. You can also call `Router::request()->post()` to retrieve all POST variables or call `Router::request()->get()` to retrieve all GET variables.

## Responses

### file
`Response::file('filename.php')` will return a page to the client. This file has to be located in the views folder.
### json
`Response::json(['this_is_json' => true])` will return json to the client, very useful for AJAX and stuff.
### public file
`Response::publicFile('/css/master.css')` will return a file that is in the public folder to the client.

# Tricks
You can call
```php
Router::init('/hey/i/am/a/url')
```
To replace the actual url in routing. Neat for testing things.

If you don't certain keys in your POST variables then add them to the `Router::request()->$ignore_post` array to ignore them, they won't be avalaible in the request class and won't show when retrieving all post variables. Same for GET but use `Router::request()->$ignore_get` instead.

Order matters! Routes which are defined before others are will be prioritized!
```php
Router::get('/user/{slug}', function($slug){
    echo $slug;
});

Router::get('/user/hello', function(){
    // this will never be called since the above route is defined first.
});
```


text:
package io.cdap.mmds.plugin;

import com.google.common.base.Joiner;
import com.google.common.collect.Sets;
import io.cdap.cdap.api.annotation.Description;
import io.cdap.cdap.api.annotation.Name;
import io.cdap.cdap.api.annotation.Plugin;
import io.cdap.cdap.api.data.format.StructuredRecord;
import io.cdap.cdap.api.data.schema.Schema;
import io.cdap.cdap.api.dataset.lib.FileSet;
import io.cdap.cdap.api.dataset.lib.IndexedTable;
import io.cdap.cdap.api.spark.sql.DataFrames;
import io.cdap.cdap.etl.api.PipelineConfigurer;
import io.cdap.cdap.etl.api.StageConfigurer;
import io.cdap.cdap.etl.api.batch.SparkCompute;
import io.cdap.cdap.etl.api.batch.SparkExecutionPluginContext;
import io.cdap.mmds.Constants;
import io.cdap.mmds.api.AlgorithmType;
import io.cdap.mmds.api.Modeler;
import io.cdap.mmds.data.ModelKey;
import io.cdap.mmds.data.ModelMeta;
import io.cdap.mmds.data.ModelTable;
import io.cdap.mmds.modeler.Modelers;
import io.cdap.mmds.modeler.feature.FeatureGenerator;
import io.cdap.mmds.modeler.feature.FeatureGeneratorPredictor;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.ml.PredictionModel;
import org.apache.spark.ml.feature.IndexToString;
import org.apache.spark.ml.feature.StringIndexerModel;
import org.apache.spark.ml.linalg.Vector;
import org.apache.spark.sql.Column;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SQLContext;
import org.apache.spark.sql.types.StructType;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;

/**
 * Uses a deployed model to add a prediction field to incoming records.
 */
@Plugin(type = SparkCompute.PLUGIN_TYPE)
@Name("MLPredictor")
@Description("Uses a deployed model to add a prediction field to incoming records.")
public class MLPredictor extends SparkCompute<StructuredRecord, StructuredRecord> {
  private final PredictorConf conf;
  private String featuregenPath;
  private String modelPath;
  private String targetIndexPath;
  private Schema inputSchema;
  private Schema outputSchema;
  private Schema.Type predictionType;
  private FeatureGenerator featureGenerator;
  private Modeler modeler;

  public MLPredictor(PredictorConf conf) {
    this.conf = conf;
  }

  @Override
  public void configurePipeline(PipelineConfigurer pipelineConfigurer) throws IllegalArgumentException {
    StageConfigurer stageConfigurer = pipelineConfigurer.getStageConfigurer();
    Schema inputSchema = stageConfigurer.getInputSchema();
    if (inputSchema == null) {
      throw new IllegalArgumentException("ML Predictor cannot be used with a null input schema. " +
                                           "Please connect it to stages that have a set output schema.");
    }
    conf.validate(inputSchema);
    stageConfigurer.setOutputSchema(conf.getOutputSchema());
  }

  @Override
  public void initialize(SparkExecutionPluginContext context) throws Exception {
    inputSchema = context.getInputSchema();
    // validate again in case there were macros
    conf.validate(inputSchema);
    outputSchema = conf.getOutputSchema();

    Schema predictionSchema = outputSchema.getField(conf.getPredictionField()).getSchema();
    predictionSchema = predictionSchema.isNullable() ? predictionSchema.getNonNullable() : predictionSchema;
    predictionType = predictionSchema.getType();

    // verify that the features used to train the model are present in the input.
    IndexedTable modelTable = context.getDataset(Constants.Dataset.MODEL_META);
    ModelTable modelMetaTable = new ModelTable(modelTable);
    ModelKey key = new ModelKey(conf.getExperimentID(), conf.getModelID());
    ModelMeta meta = modelMetaTable.get(key);
    if (meta == null) {
      throw new IllegalArgumentException(String.format("Could not find model '%s' in experiment '%s'.",
                                                       conf.getModelID(), conf.getExperimentID()));
    }
    modeler = Modelers.getModeler(meta.getAlgorithm());
    if (modeler == null) {
      // should never happen
      throw new IllegalArgumentException(String.format("Model '%s' in experiment '%s' uses unknown algorithm '%s'",
                                                       conf.getModelID(), conf.getExperimentID(), meta.getAlgorithm()));
    }
    if (modeler.getAlgorithm().getType() == AlgorithmType.REGRESSION && predictionType == Schema.Type.STRING) {
      throw new IllegalArgumentException(
        String.format("Invalid getType for prediction field '%s'. " +
                        "Model '%s' in experiment '%s' is a regression model, " +
                        "which only supports double predictions.",
                      conf.getPredictionField(), conf.getModelID(), conf.getExperimentID()));
    }

    // validate that the same features used to train the model are present in the input.
    Set<String> featureSet = new HashSet<>(meta.getFeatures());
    Set<String> inputFields = new HashSet<>();
    for (Schema.Field field : inputSchema.getFields()) {
      inputFields.add(field.getName());
    }
    Set<String> missingFeatures = Sets.difference(featureSet, inputFields);
    if (!missingFeatures.isEmpty()) {
      throw new IllegalArgumentException(String.format("Input is missing feature fields %s.",
                                                       Joiner.on(',').join(missingFeatures)));
    }

    // validate that the actual files are there
    FileSet modelFiles = context.getDataset(Constants.Dataset.MODEL_COMPONENTS);
    featuregenPath = getComponentPath(modelFiles, Constants.Component.FEATUREGEN);
    if (featuregenPath == null) {
      throw new IllegalArgumentException(
        String.format("Could not find feature generation data for model '%s' in experiment '%s'. " +
                        "Please verify that the same model and model meta datasets used to train " +
                        "the model are used here.", conf.getModelID(), conf.getExperimentID()));
    }
    featureGenerator = new FeatureGeneratorPredictor(meta.getFeatures(), meta.getCategoricalFeatures(), featuregenPath);

    modelPath = getComponentPath(modelFiles, Constants.Component.MODEL);
    if (modelPath == null) {
      throw new IllegalArgumentException(
        String.format("Could not find the files for model '%s' in experiment '%s'. " +
                        "Please verify that the model was successfully trained.",
                      conf.getModelID(), conf.getExperimentID()));
    }

    targetIndexPath = getComponentPath(modelFiles, Constants.Component.TARGET_INDICES);
    if (targetIndexPath == null && modeler.getAlgorithm().getType() == AlgorithmType.CLASSIFICATION &&
      predictionType == Schema.Type.STRING) {
      throw new IllegalArgumentException(
        String.format("Could not find target index data for model '%s' in experiment '%s'. " +
                        "Please change the prediction field type to double.",
                      conf.getModelID(), conf.getExperimentID()));
    }
  }

  @Override
  public JavaRDD<StructuredRecord> transform(SparkExecutionPluginContext sparkExecutionPluginContext,
                                             JavaRDD<StructuredRecord> javaRDD) throws Exception {
    PredictionModel<Vector, ?> model = modeler.loadPredictor(modelPath);

    // convert StructuredRecord into Row
    StructType rowType = DataFrames.toDataType(inputSchema);
    JavaRDD<Row> rowRDD = javaRDD.map(new RecordToRow(rowType));

    // convert RDD to DataFrame
    SQLContext sqlContext = new SQLContext(sparkExecutionPluginContext.getSparkContext().sc());
    Dataset<Row> rawData = sqlContext.createDataFrame(rowRDD, rowType);

    // keep around fields in the output schema that are not features and not the prediction field
    Set<String> featureSet = new HashSet<>(featureGenerator.getFeatures());
    List<String> extraFields = new ArrayList<>();
    for (Schema.Field outputField : outputSchema.getFields()) {
      String outputFieldName = outputField.getName();
      if (!conf.getPredictionField().equals(outputFieldName) && !featureSet.contains(outputFieldName)) {
        extraFields.add(outputFieldName);
      }
    }

    // generate features
    Dataset<Row> featureData = featureGenerator.generateFeatures(rawData, extraFields);
    // make predictions
    Dataset predictions = model.transform(featureData);

    if (modeler.getAlgorithm().getType() == AlgorithmType.CLASSIFICATION && predictionType == Schema.Type.STRING) {
      StringIndexerModel indexerModel = StringIndexerModel.load(targetIndexPath);
      String[] labels = indexerModel.labels();
      IndexToString reverseIndex = new IndexToString()
        .setLabels(labels)
        .setInputCol(Constants.TRAINER_PREDICTION_FIELD)
        .setOutputCol(conf.getPredictionField());
      predictions = reverseIndex.transform(predictions);
    } else {
      predictions = predictions.withColumnRenamed(Constants.TRAINER_PREDICTION_FIELD, conf.getPredictionField());
    }

    // select just the fields we need, in the order we expect
    Column[] cols = new Column[outputSchema.getFields().size()];
    int i = 0;
    for (Schema.Field outputField : outputSchema.getFields()) {
      cols[i] = new Column(outputField.getName());
      i++;
    }
    predictions = predictions.select(cols);

    JavaRDD<StructuredRecord> output = predictions.toJavaRDD().map(new RowToRecord(outputSchema));
    return output;
  }

  @Nullable
  private String getComponentPath(FileSet modelFiles, String component) throws IOException {
    return modelFiles.getLocation(conf.getExperimentID())
      .append(conf.getModelID())
      .append(component)
      .toURI().getPath();
  }
}

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd">

    <!-- Add Models to the lifecylce -->
    <bean depends-on="id-Models" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetObject" ref="id-Models" />
        <property name="targetMethod" value="putAll" />
        <property name="arguments" ref="id-SteerPointModels" />
    </bean>

    <util:map id="id-SteerPointModels">
        <entry>
            <key>
                <util:constant static-field="com.airportflightplanner.common.types.BeanNames.STEERPOINT_MODEL" />
            </key>
            <ref bean="id-SteerPointsCollectionModel" />
        </entry>
    </util:map>

    <bean id="id-SteerPointsCollectionModel" class="com.airportflightplanner.models.steerpoints.SteerPointsCollectionModel" />

</beans>


text:
/**
 * @file mali_kbase_replay.c
 * Replay soft job handlers
 */

#include <linux/dma-mapping.h>
#include <mali_kbase_config.h>
#include <mali_kbase.h>
#include <mali_kbase_mem.h>
#include <mali_kbase_mem_linux.h>

#define JOB_NOT_STARTED 0
#define JOB_TYPE_MASK      0xfe
#define JOB_TYPE_NULL      (1 << 1)
#define JOB_TYPE_VERTEX    (5 << 1)
#define JOB_TYPE_TILER     (7 << 1)
#define JOB_TYPE_FUSED     (8 << 1)
#define JOB_TYPE_FRAGMENT  (9 << 1)

#define JOB_FLAG_DESC_SIZE           (1 << 0)
#define JOB_FLAG_PERFORM_JOB_BARRIER (1 << 8)

#define JOB_HEADER_32_FBD_OFFSET (31*4)
#define JOB_HEADER_64_FBD_OFFSET (44*4)

#define FBD_POINTER_MASK (~0x3f)

#define SFBD_TILER_OFFSET (48*4)

#define MFBD_TILER_OFFSET       (14*4)

#define FBD_HIERARCHY_WEIGHTS 8
#define FBD_HIERARCHY_MASK_MASK 0x1fff

#define FBD_TYPE 1

#define HIERARCHY_WEIGHTS 13

#define JOB_HEADER_ID_MAX                 0xffff

#define JOB_SOURCE_ID(status)		(((status) >> 16) & 0xFFFF)
#define JOB_POLYGON_LIST		(0x03)

struct job_head {
	u32 status;
	u32 not_complete_index;
	u64 fault_addr;
	u16 flags;
	u16 index;
	u16 dependencies[2];
	union {
		u64 _64;
		u32 _32;
	} next;
	u32 x[2];
	union {
		u64 _64;
		u32 _32;
	} fragment_fbd;
};

static void dump_job_head(struct kbase_context *kctx, char *head_str,
		struct job_head *job)
{
#ifdef CONFIG_MALI_DEBUG
	dev_dbg(kctx->kbdev->dev, "%s\n", head_str);
	dev_dbg(kctx->kbdev->dev, "addr               = %p\n"
			"status             = %x\n"
			"not_complete_index = %x\n"
			"fault_addr         = %llx\n"
			"flags              = %x\n"
			"index              = %x\n"
			"dependencies       = %x,%x\n",
			job, job->status, job->not_complete_index,
			job->fault_addr, job->flags, job->index,
			job->dependencies[0],
			job->dependencies[1]);

	if (job->flags & JOB_FLAG_DESC_SIZE)
		dev_dbg(kctx->kbdev->dev, "next               = %llx\n",
				job->next._64);
	else
		dev_dbg(kctx->kbdev->dev, "next               = %x\n",
				job->next._32);
#endif
}

static int kbasep_replay_reset_sfbd(struct kbase_context *kctx,
		u64 fbd_address, u64 tiler_heap_free,
		u16 hierarchy_mask, u32 default_weight)
{
	struct {
		u32 padding_1[1];
		u32 flags;
		u64 padding_2[2];
		u64 heap_free_address;
		u32 padding[8];
		u32 weights[FBD_HIERARCHY_WEIGHTS];
	} *fbd_tiler;
	struct kbase_vmap_struct map;

	dev_dbg(kctx->kbdev->dev, "fbd_address: %llx\n", fbd_address);

	fbd_tiler = kbase_vmap(kctx, fbd_address + SFBD_TILER_OFFSET,
			sizeof(*fbd_tiler), &map);
	if (!fbd_tiler) {
		dev_err(kctx->kbdev->dev, "kbasep_replay_reset_fbd: failed to map fbd\n");
		return -EINVAL;
	}

#ifdef CONFIG_MALI_DEBUG
	dev_dbg(kctx->kbdev->dev,
		"FBD tiler:\n"
		"flags = %x\n"
		"heap_free_address = %llx\n",
		fbd_tiler->flags, fbd_tiler->heap_free_address);
#endif
	if (hierarchy_mask) {
		u32 weights[HIERARCHY_WEIGHTS];
		u16 old_hierarchy_mask = fbd_tiler->flags &
						       FBD_HIERARCHY_MASK_MASK;
		int i, j = 0;

		for (i = 0; i < HIERARCHY_WEIGHTS; i++) {
			if (old_hierarchy_mask & (1 << i)) {
				KBASE_DEBUG_ASSERT(j < FBD_HIERARCHY_WEIGHTS);
				weights[i] = fbd_tiler->weights[j++];
			} else {
				weights[i] = default_weight;
			}
		}

		dev_dbg(kctx->kbdev->dev, "Old hierarchy mask=%x  New hierarchy mask=%x\n",
				old_hierarchy_mask, hierarchy_mask);

		for (i = 0; i < HIERARCHY_WEIGHTS; i++)
			dev_dbg(kctx->kbdev->dev, " Hierarchy weight %02d: %08x\n",
					i, weights[i]);

		j = 0;

		for (i = 0; i < HIERARCHY_WEIGHTS; i++) {
			if (hierarchy_mask & (1 << i)) {
				KBASE_DEBUG_ASSERT(j < FBD_HIERARCHY_WEIGHTS);

				dev_dbg(kctx->kbdev->dev, " Writing hierarchy level %02d (%08x) to %d\n",
						i, weights[i], j);

				fbd_tiler->weights[j++] = weights[i];
			}
		}

		for (; j < FBD_HIERARCHY_WEIGHTS; j++)
			fbd_tiler->weights[j] = 0;

		fbd_tiler->flags = hierarchy_mask | (1 << 16);
	}

	fbd_tiler->heap_free_address = tiler_heap_free;

	dev_dbg(kctx->kbdev->dev, "heap_free_address=%llx flags=%x\n",
			fbd_tiler->heap_free_address, fbd_tiler->flags);

	kbase_vunmap(kctx, &map);

	return 0;
}

static int kbasep_replay_reset_mfbd(struct kbase_context *kctx,
		u64 fbd_address, u64 tiler_heap_free,
		u16 hierarchy_mask, u32 default_weight)
{
	struct kbase_vmap_struct map;
	struct {
		u32 padding_0;
		u32 flags;
		u64 padding_1[2];
		u64 heap_free_address;
		u64 padding_2;
		u32 weights[FBD_HIERARCHY_WEIGHTS];
	} *fbd_tiler;

	dev_dbg(kctx->kbdev->dev, "fbd_address: %llx\n", fbd_address);

	fbd_tiler = kbase_vmap(kctx, fbd_address + MFBD_TILER_OFFSET,
			sizeof(*fbd_tiler), &map);
	if (!fbd_tiler) {
		dev_err(kctx->kbdev->dev,
			       "kbasep_replay_reset_fbd: failed to map fbd\n");
		return -EINVAL;
	}

#ifdef CONFIG_MALI_DEBUG
	dev_dbg(kctx->kbdev->dev, "FBD tiler:\n"
			"flags = %x\n"
			"heap_free_address = %llx\n",
			fbd_tiler->flags,
			fbd_tiler->heap_free_address);
#endif
	if (hierarchy_mask) {
		u32 weights[HIERARCHY_WEIGHTS];
		u16 old_hierarchy_mask = (fbd_tiler->flags) &
						       FBD_HIERARCHY_MASK_MASK;
		int i, j = 0;

		for (i = 0; i < HIERARCHY_WEIGHTS; i++) {
			if (old_hierarchy_mask & (1 << i)) {
				KBASE_DEBUG_ASSERT(j < FBD_HIERARCHY_WEIGHTS);
				weights[i] = fbd_tiler->weights[j++];
			} else {
				weights[i] = default_weight;
			}
		}

		dev_dbg(kctx->kbdev->dev, "Old hierarchy mask=%x  New hierarchy mask=%x\n",
				old_hierarchy_mask, hierarchy_mask);

		for (i = 0; i < HIERARCHY_WEIGHTS; i++)
			dev_dbg(kctx->kbdev->dev, " Hierarchy weight %02d: %08x\n",
					i, weights[i]);

		j = 0;

		for (i = 0; i < HIERARCHY_WEIGHTS; i++) {
			if (hierarchy_mask & (1 << i)) {
				KBASE_DEBUG_ASSERT(j < FBD_HIERARCHY_WEIGHTS);

				dev_dbg(kctx->kbdev->dev,
				" Writing hierarchy level %02d (%08x) to %d\n",
							     i, weights[i], j);

				fbd_tiler->weights[j++] = weights[i];
			}
		}

		for (; j < FBD_HIERARCHY_WEIGHTS; j++)
			fbd_tiler->weights[j] = 0;

		fbd_tiler->flags = hierarchy_mask | (1 << 16);
	}

	fbd_tiler->heap_free_address = tiler_heap_free;

	kbase_vunmap(kctx, &map);

	return 0;
}

/**
 * @brief Reset the status of an FBD pointed to by a tiler job
 *
 * This performs two functions :
 * - Set the hierarchy mask
 * - Reset the tiler free heap address
 *
 * @param[in] kctx              Context pointer
 * @param[in] job_header        Address of job header to reset.
 * @param[in] tiler_heap_free   The value to reset Tiler Heap Free to
 * @param[in] hierarchy_mask    The hierarchy mask to use
 * @param[in] default_weight    Default hierarchy weight to write when no other
 *                              weight is given in the FBD
 * @param[in] job_64            true if this job is using 64-bit
 *                              descriptors
 *
 * @return 0 on success, error code on failure
 */
static int kbasep_replay_reset_tiler_job(struct kbase_context *kctx,
		u64 job_header,	u64 tiler_heap_free,
		u16 hierarchy_mask, u32 default_weight,	bool job_64)
{
	struct kbase_vmap_struct map;
	u64 fbd_address;

	if (job_64) {
		u64 *job_ext;

		job_ext = kbase_vmap(kctx,
				job_header + JOB_HEADER_64_FBD_OFFSET,
				sizeof(*job_ext), &map);

		if (!job_ext) {
			dev_err(kctx->kbdev->dev, "kbasep_replay_reset_tiler_job: failed to map jc\n");
			return -EINVAL;
		}

		fbd_address = *job_ext;

		kbase_vunmap(kctx, &map);
	} else {
		u32 *job_ext;

		job_ext = kbase_vmap(kctx,
				job_header + JOB_HEADER_32_FBD_OFFSET,
				sizeof(*job_ext), &map);

		if (!job_ext) {
			dev_err(kctx->kbdev->dev, "kbasep_replay_reset_tiler_job: failed to map jc\n");
			return -EINVAL;
		}

		fbd_address = *job_ext;

		kbase_vunmap(kctx, &map);
	}

	if (fbd_address & FBD_TYPE) {
		return kbasep_replay_reset_mfbd(kctx,
						fbd_address & FBD_POINTER_MASK,
						tiler_heap_free,
						hierarchy_mask,
						default_weight);
	} else {
		return kbasep_replay_reset_sfbd(kctx,
						fbd_address & FBD_POINTER_MASK,
						tiler_heap_free,
						hierarchy_mask,
						default_weight);
	}
}

/**
 * @brief Reset the status of a job
 *
 * This performs the following functions :
 *
 * - Reset the Job Status field of each job to NOT_STARTED.
 * - Set the Job Type field of any Vertex Jobs to Null Job.
 * - For any jobs using an FBD, set the Tiler Heap Free field to the value of
 *   the tiler_heap_free parameter, and set the hierarchy level mask to the
 *   hier_mask parameter.
 * - Offset HW dependencies by the hw_job_id_offset parameter
 * - Set the Perform Job Barrier flag if this job is the first in the chain
 * - Read the address of the next job header
 *
 * @param[in] kctx              Context pointer
 * @param[in,out] job_header    Address of job header to reset. Set to address
 *                              of next job header on exit.
 * @param[in] prev_jc           Previous job chain to link to, if this job is
 *                              the last in the chain.
 * @param[in] hw_job_id_offset  Offset for HW job IDs
 * @param[in] tiler_heap_free   The value to reset Tiler Heap Free to
 * @param[in] hierarchy_mask    The hierarchy mask to use
 * @param[in] default_weight    Default hierarchy weight to write when no other
 *                              weight is given in the FBD
 * @param[in] first_in_chain    true if this job is the first in the chain
 * @param[in] fragment_chain    true if this job is in the fragment chain
 *
 * @return 0 on success, error code on failure
 */
static int kbasep_replay_reset_job(struct kbase_context *kctx,
		u64 *job_header, u64 prev_jc,
		u64 tiler_heap_free, u16 hierarchy_mask,
		u32 default_weight, u16 hw_job_id_offset,
		bool first_in_chain, bool fragment_chain)
{
	struct job_head *job;
	u64 new_job_header;
	struct kbase_vmap_struct map;

	job = kbase_vmap(kctx, *job_header, sizeof(*job), &map);
	if (!job) {
		dev_err(kctx->kbdev->dev,
				 "kbasep_replay_parse_jc: failed to map jc\n");
		return -EINVAL;
	}

	dump_job_head(kctx, "Job header:", job);

	if (job->status == JOB_NOT_STARTED && !fragment_chain) {
		dev_err(kctx->kbdev->dev, "Job already not started\n");
		goto out_unmap;
	}
	job->status = JOB_NOT_STARTED;

	if ((job->flags & JOB_TYPE_MASK) == JOB_TYPE_VERTEX)
		job->flags = (job->flags & ~JOB_TYPE_MASK) | JOB_TYPE_NULL;

	if ((job->flags & JOB_TYPE_MASK) == JOB_TYPE_FUSED) {
		dev_err(kctx->kbdev->dev, "Fused jobs can not be replayed\n");
		goto out_unmap;
	}

	if (first_in_chain)
		job->flags |= JOB_FLAG_PERFORM_JOB_BARRIER;

	if ((job->dependencies[0] + hw_job_id_offset) > JOB_HEADER_ID_MAX ||
	    (job->dependencies[1] + hw_job_id_offset) > JOB_HEADER_ID_MAX ||
	    (job->index + hw_job_id_offset) > JOB_HEADER_ID_MAX) {
		dev_err(kctx->kbdev->dev,
			     "Job indicies/dependencies out of valid range\n");
		goto out_unmap;
	}

	if (job->dependencies[0])
		job->dependencies[0] += hw_job_id_offset;
	if (job->dependencies[1])
		job->dependencies[1] += hw_job_id_offset;

	job->index += hw_job_id_offset;

	if (job->flags & JOB_FLAG_DESC_SIZE) {
		new_job_header = job->next._64;
		if (!job->next._64)
			job->next._64 = prev_jc;
	} else {
		new_job_header = job->next._32;
		if (!job->next._32)
			job->next._32 = prev_jc;
	}
	dump_job_head(kctx, "Updated to:", job);

	if ((job->flags & JOB_TYPE_MASK) == JOB_TYPE_TILER) {
		bool job_64 = (job->flags & JOB_FLAG_DESC_SIZE) != 0;

		if (kbasep_replay_reset_tiler_job(kctx, *job_header,
				tiler_heap_free, hierarchy_mask,
				default_weight, job_64) != 0)
			goto out_unmap;

	} else if ((job->flags & JOB_TYPE_MASK) == JOB_TYPE_FRAGMENT) {
		u64 fbd_address;

		if (job->flags & JOB_FLAG_DESC_SIZE)
			fbd_address = job->fragment_fbd._64;
		else
			fbd_address = (u64)job->fragment_fbd._32;

		if (fbd_address & FBD_TYPE) {
			if (kbasep_replay_reset_mfbd(kctx,
					fbd_address & FBD_POINTER_MASK,
					tiler_heap_free,
					hierarchy_mask,
					default_weight) != 0)
				goto out_unmap;
		} else {
			if (kbasep_replay_reset_sfbd(kctx,
					fbd_address & FBD_POINTER_MASK,
					tiler_heap_free,
					hierarchy_mask,
					default_weight) != 0)
				goto out_unmap;
		}
	}

	kbase_vunmap(kctx, &map);

	*job_header = new_job_header;

	return 0;

out_unmap:
	kbase_vunmap(kctx, &map);
	return -EINVAL;
}

/**
 * @brief Find the highest job ID in a job chain
 *
 * @param[in] kctx        Context pointer
 * @param[in] jc          Job chain start address
 * @param[out] hw_job_id  Highest job ID in chain
 *
 * @return 0 on success, error code on failure
 */
static int kbasep_replay_find_hw_job_id(struct kbase_context *kctx,
		u64 jc,	u16 *hw_job_id)
{
	while (jc) {
		struct job_head *job;
		struct kbase_vmap_struct map;

		dev_dbg(kctx->kbdev->dev,
			"kbasep_replay_find_hw_job_id: parsing jc=%llx\n", jc);

		job = kbase_vmap(kctx, jc, sizeof(*job), &map);
		if (!job) {
			dev_err(kctx->kbdev->dev, "failed to map jc\n");

			return -EINVAL;
		}

		if (job->index > *hw_job_id)
			*hw_job_id = job->index;

		if (job->flags & JOB_FLAG_DESC_SIZE)
			jc = job->next._64;
		else
			jc = job->next._32;

		kbase_vunmap(kctx, &map);
	}

	return 0;
}

/**
 * @brief Reset the status of a number of jobs
 *
 * This function walks the provided job chain, and calls
 * kbasep_replay_reset_job for each job. It also links the job chain to the
 * provided previous job chain.
 *
 * The function will fail if any of the jobs passed already have status of
 * NOT_STARTED.
 *
 * @param[in] kctx              Context pointer
 * @param[in] jc                Job chain to be processed
 * @param[in] prev_jc           Job chain to be added to. May be NULL
 * @param[in] tiler_heap_free   The value to reset Tiler Heap Free to
 * @param[in] hierarchy_mask    The hierarchy mask to use
 * @param[in] default_weight    Default hierarchy weight to write when no other
 *                              weight is given in the FBD
 * @param[in] hw_job_id_offset  Offset for HW job IDs
 * @param[in] fragment_chain    true if this chain is the fragment chain
 *
 * @return 0 on success, error code otherwise
 */
static int kbasep_replay_parse_jc(struct kbase_context *kctx,
		u64 jc,	u64 prev_jc,
		u64 tiler_heap_free, u16 hierarchy_mask,
		u32 default_weight, u16 hw_job_id_offset,
		bool fragment_chain)
{
	bool first_in_chain = true;
	int nr_jobs = 0;

	dev_dbg(kctx->kbdev->dev, "kbasep_replay_parse_jc: jc=%llx hw_job_id=%x\n",
			jc, hw_job_id_offset);

	while (jc) {
		dev_dbg(kctx->kbdev->dev, "kbasep_replay_parse_jc: parsing jc=%llx\n", jc);

		if (kbasep_replay_reset_job(kctx, &jc, prev_jc,
				tiler_heap_free, hierarchy_mask,
				default_weight, hw_job_id_offset,
				first_in_chain, fragment_chain) != 0)
			return -EINVAL;

		first_in_chain = false;

		nr_jobs++;
		if (fragment_chain &&
		    nr_jobs >= BASE_JD_REPLAY_F_CHAIN_JOB_LIMIT) {
			dev_err(kctx->kbdev->dev,
				"Exceeded maximum number of jobs in fragment chain\n");
			return -EINVAL;
		}
	}

	return 0;
}

/**
 * @brief Reset the status of a replay job, and set up dependencies
 *
 * This performs the actions to allow the replay job to be re-run following
 * completion of the passed dependency.
 *
 * @param[in] katom     The atom to be reset
 * @param[in] dep_atom  The dependency to be attached to the atom
 */
static void kbasep_replay_reset_softjob(struct kbase_jd_atom *katom,
		struct kbase_jd_atom *dep_atom)
{
	katom->status = KBASE_JD_ATOM_STATE_QUEUED;
	kbase_jd_katom_dep_set(&katom->dep[0], dep_atom, BASE_JD_DEP_TYPE_DATA);
	list_add_tail(&katom->dep_item[0], &dep_atom->dep_head[0]);
}

/**
 * @brief Allocate an unused katom
 *
 * This will search the provided context for an unused katom, and will mark it
 * as KBASE_JD_ATOM_STATE_QUEUED.
 *
 * If no atoms are available then the function will fail.
 *
 * @param[in] kctx      Context pointer
 * @return An atom ID, or -1 on failure
 */
static int kbasep_allocate_katom(struct kbase_context *kctx)
{
	struct kbase_jd_context *jctx = &kctx->jctx;
	int i;

	for (i = BASE_JD_ATOM_COUNT-1; i > 0; i--) {
		if (jctx->atoms[i].status == KBASE_JD_ATOM_STATE_UNUSED) {
			jctx->atoms[i].status = KBASE_JD_ATOM_STATE_QUEUED;
			dev_dbg(kctx->kbdev->dev,
				  "kbasep_allocate_katom: Allocated atom %d\n",
									    i);
			return i;
		}
	}

	return -1;
}

/**
 * @brief Release a katom
 *
 * This will mark the provided atom as available, and remove any dependencies.
 *
 * For use on error path.
 *
 * @param[in] kctx      Context pointer
 * @param[in] atom_id   ID of atom to release
 */
static void kbasep_release_katom(struct kbase_context *kctx, int atom_id)
{
	struct kbase_jd_context *jctx = &kctx->jctx;

	dev_dbg(kctx->kbdev->dev, "kbasep_release_katom: Released atom %d\n",
			atom_id);

	while (!list_empty(&jctx->atoms[atom_id].dep_head[0]))
		list_del(jctx->atoms[atom_id].dep_head[0].next);

	while (!list_empty(&jctx->atoms[atom_id].dep_head[1]))
		list_del(jctx->atoms[atom_id].dep_head[1].next);

	jctx->atoms[atom_id].status = KBASE_JD_ATOM_STATE_UNUSED;
}

static void kbasep_replay_create_atom(struct kbase_context *kctx,
				      struct base_jd_atom_v2 *atom,
				      int atom_nr,
				      base_jd_prio prio)
{
	atom->nr_extres = 0;
	atom->extres_list.value = NULL;
	atom->device_nr = 0;
	atom->prio = prio;
	atom->atom_number = atom_nr;

	base_jd_atom_dep_set(&atom->pre_dep[0], 0 , BASE_JD_DEP_TYPE_INVALID);
	base_jd_atom_dep_set(&atom->pre_dep[1], 0 , BASE_JD_DEP_TYPE_INVALID);

	atom->udata.blob[0] = 0;
	atom->udata.blob[1] = 0;
}

/**
 * @brief Create two atoms for the purpose of replaying jobs
 *
 * Two atoms are allocated and created. The jc pointer is not set at this
 * stage. The second atom has a dependency on the first. The remaining fields
 * are set up as follows :
 *
 * - No external resources. Any required external resources will be held by the
 *   replay atom.
 * - device_nr is set to 0. This is not relevant as
 *   BASE_JD_REQ_SPECIFIC_COHERENT_GROUP should not be set.
 * - Priority is inherited from the replay job.
 *
 * @param[out] t_atom      Atom to use for tiler jobs
 * @param[out] f_atom      Atom to use for fragment jobs
 * @param[in]  prio        Priority of new atom (inherited from replay soft
 *                         job)
 * @return 0 on success, error code on failure
 */
static int kbasep_replay_create_atoms(struct kbase_context *kctx,
		struct base_jd_atom_v2 *t_atom,
		struct base_jd_atom_v2 *f_atom,
		base_jd_prio prio)
{
	int t_atom_nr, f_atom_nr;

	t_atom_nr = kbasep_allocate_katom(kctx);
	if (t_atom_nr < 0) {
		dev_err(kctx->kbdev->dev, "Failed to allocate katom\n");
		return -EINVAL;
	}

	f_atom_nr = kbasep_allocate_katom(kctx);
	if (f_atom_nr < 0) {
		dev_err(kctx->kbdev->dev, "Failed to allocate katom\n");
		kbasep_release_katom(kctx, t_atom_nr);
		return -EINVAL;
	}

	kbasep_replay_create_atom(kctx, t_atom, t_atom_nr, prio);
	kbasep_replay_create_atom(kctx, f_atom, f_atom_nr, prio);

	base_jd_atom_dep_set(&f_atom->pre_dep[0], t_atom_nr , BASE_JD_DEP_TYPE_DATA);

	return 0;
}

#ifdef CONFIG_MALI_DEBUG
static void payload_dump(struct kbase_context *kctx, base_jd_replay_payload *payload)
{
	u64 next;

	dev_dbg(kctx->kbdev->dev, "Tiler jc list :\n");
	next = payload->tiler_jc_list;

	while (next) {
		struct kbase_vmap_struct map;
		base_jd_replay_jc *jc_struct;

		jc_struct = kbase_vmap(kctx, next, sizeof(*jc_struct), &map);

		if (!jc_struct)
			return;

		dev_dbg(kctx->kbdev->dev, "* jc_struct=%p jc=%llx next=%llx\n",
				jc_struct, jc_struct->jc, jc_struct->next);

		next = jc_struct->next;

		kbase_vunmap(kctx, &map);
	}
}
#endif

/**
 * @brief Parse a base_jd_replay_payload provided by userspace
 *
 * This will read the payload from userspace, and parse the job chains.
 *
 * @param[in] kctx         Context pointer
 * @param[in] replay_atom  Replay soft job atom
 * @param[in] t_atom       Atom to use for tiler jobs
 * @param[in] f_atom       Atom to use for fragment jobs
 * @return 0 on success, error code on failure
 */
static int kbasep_replay_parse_payload(struct kbase_context *kctx,
					      struct kbase_jd_atom *replay_atom,
					      struct base_jd_atom_v2 *t_atom,
					      struct base_jd_atom_v2 *f_atom)
{
	base_jd_replay_payload *payload;
	u64 next;
	u64 prev_jc = 0;
	u16 hw_job_id_offset = 0;
	int ret = -EINVAL;
	struct kbase_vmap_struct map;

	dev_dbg(kctx->kbdev->dev, "kbasep_replay_parse_payload: replay_atom->jc = %llx sizeof(payload) = %zu\n",
			replay_atom->jc, sizeof(payload));

	payload = kbase_vmap(kctx, replay_atom->jc, sizeof(*payload), &map);

	if (!payload) {
		dev_err(kctx->kbdev->dev, "kbasep_replay_parse_payload: failed to map payload into kernel space\n");
		return -EINVAL;
	}

#ifdef CONFIG_MALI_DEBUG
	dev_dbg(kctx->kbdev->dev, "kbasep_replay_parse_payload: payload=%p\n", payload);
	dev_dbg(kctx->kbdev->dev, "Payload structure:\n"
				  "tiler_jc_list            = %llx\n"
				  "fragment_jc              = %llx\n"
				  "tiler_heap_free          = %llx\n"
				  "fragment_hierarchy_mask  = %x\n"
				  "tiler_hierarchy_mask     = %x\n"
				  "hierarchy_default_weight = %x\n"
				  "tiler_core_req           = %x\n"
				  "fragment_core_req        = %x\n",
							payload->tiler_jc_list,
							  payload->fragment_jc,
						      payload->tiler_heap_free,
					      payload->fragment_hierarchy_mask,
						 payload->tiler_hierarchy_mask,
					     payload->hierarchy_default_weight,
						       payload->tiler_core_req,
						   payload->fragment_core_req);
	payload_dump(kctx, payload);
#endif

	t_atom->core_req = payload->tiler_core_req | BASEP_JD_REQ_EVENT_NEVER;
	f_atom->core_req = payload->fragment_core_req | BASEP_JD_REQ_EVENT_NEVER;

	/* Sanity check core requirements*/
	if ((t_atom->core_req & BASEP_JD_REQ_ATOM_TYPE &
			       ~BASE_JD_REQ_COHERENT_GROUP) != BASE_JD_REQ_T ||
	    (f_atom->core_req & BASEP_JD_REQ_ATOM_TYPE &
			      ~BASE_JD_REQ_COHERENT_GROUP) != BASE_JD_REQ_FS ||
	     t_atom->core_req & BASE_JD_REQ_EXTERNAL_RESOURCES ||
	     f_atom->core_req & BASE_JD_REQ_EXTERNAL_RESOURCES) {
		dev_err(kctx->kbdev->dev, "Invalid core requirements\n");
		goto out;
	}

	/* Process tiler job chains */
	next = payload->tiler_jc_list;
	if (!next) {
		dev_err(kctx->kbdev->dev, "Invalid tiler JC list\n");
		goto out;
	}

	while (next) {
		base_jd_replay_jc *jc_struct;
		struct kbase_vmap_struct jc_map;
		u64 jc;

		jc_struct = kbase_vmap(kctx, next, sizeof(*jc_struct), &jc_map);

		if (!jc_struct) {
			dev_err(kctx->kbdev->dev, "Failed to map jc struct\n");
			goto out;
		}

		jc = jc_struct->jc;
		next = jc_struct->next;
		if (next)
			jc_struct->jc = 0;

		kbase_vunmap(kctx, &jc_map);

		if (jc) {
			u16 max_hw_job_id = 0;

			if (kbasep_replay_find_hw_job_id(kctx, jc,
					&max_hw_job_id) != 0)
				goto out;

			if (kbasep_replay_parse_jc(kctx, jc, prev_jc,
					payload->tiler_heap_free,
					payload->tiler_hierarchy_mask,
					payload->hierarchy_default_weight,
					hw_job_id_offset, false) != 0) {
				goto out;
			}

			hw_job_id_offset += max_hw_job_id;

			prev_jc = jc;
		}
	}
	t_atom->jc = prev_jc;

	/* Process fragment job chain */
	f_atom->jc = payload->fragment_jc;
	if (kbasep_replay_parse_jc(kctx, payload->fragment_jc, 0,
			payload->tiler_heap_free,
			payload->fragment_hierarchy_mask,
			payload->hierarchy_default_weight, 0,
			true) != 0) {
		goto out;
	}

	if (!t_atom->jc || !f_atom->jc) {
		dev_err(kctx->kbdev->dev, "Invalid payload\n");
		goto out;
	}

	dev_dbg(kctx->kbdev->dev, "t_atom->jc=%llx f_atom->jc=%llx\n",
			t_atom->jc, f_atom->jc);
	ret = 0;

out:
	kbase_vunmap(kctx, &map);

	return ret;
}

static void kbase_replay_process_worker(struct work_struct *data)
{
	struct kbase_jd_atom *katom;
	struct kbase_context *kctx;
	struct kbase_jd_context *jctx;
	bool need_to_try_schedule_context = false;

	struct base_jd_atom_v2 t_atom, f_atom;
	struct kbase_jd_atom *t_katom, *f_katom;
	base_jd_prio atom_prio;

	katom = container_of(data, struct kbase_jd_atom, work);
	kctx = katom->kctx;
	jctx = &kctx->jctx;

	mutex_lock(&jctx->lock);

	atom_prio = kbasep_js_sched_prio_to_atom_prio(katom->sched_priority);

	if (kbasep_replay_create_atoms(
			kctx, &t_atom, &f_atom, atom_prio) != 0) {
		katom->event_code = BASE_JD_EVENT_JOB_CANCELLED;
		goto out;
	}

	t_katom = &jctx->atoms[t_atom.atom_number];
	f_katom = &jctx->atoms[f_atom.atom_number];

	if (kbasep_replay_parse_payload(kctx, katom, &t_atom, &f_atom) != 0) {
		kbasep_release_katom(kctx, t_atom.atom_number);
		kbasep_release_katom(kctx, f_atom.atom_number);
		katom->event_code = BASE_JD_EVENT_JOB_CANCELLED;
		goto out;
	}

	kbasep_replay_reset_softjob(katom, f_katom);

	need_to_try_schedule_context |= jd_submit_atom(kctx, &t_atom, t_katom);
	if (t_katom->event_code == BASE_JD_EVENT_JOB_INVALID) {
		dev_err(kctx->kbdev->dev, "Replay failed to submit atom\n");
		kbasep_release_katom(kctx, f_atom.atom_number);
		katom->event_code = BASE_JD_EVENT_JOB_CANCELLED;
		goto out;
	}
	need_to_try_schedule_context |= jd_submit_atom(kctx, &f_atom, f_katom);
	if (f_katom->event_code == BASE_JD_EVENT_JOB_INVALID) {
		dev_err(kctx->kbdev->dev, "Replay failed to submit atom\n");
		katom->event_code = BASE_JD_EVENT_JOB_CANCELLED;
		goto out;
	}

	katom->event_code = BASE_JD_EVENT_DONE;

out:
	if (katom->event_code != BASE_JD_EVENT_DONE) {
		kbase_disjoint_state_down(kctx->kbdev);

		need_to_try_schedule_context |= jd_done_nolock(katom, NULL);
	}

	if (need_to_try_schedule_context)
		kbase_js_sched_all(kctx->kbdev);

	mutex_unlock(&jctx->lock);
}

/**
 * @brief Check job replay fault
 *
 * This will read the job payload, checks fault type and source, then decides
 * whether replay is required.
 *
 * @param[in] katom       The atom to be processed
 * @return  true (success) if replay required or false on failure.
 */
static bool kbase_replay_fault_check(struct kbase_jd_atom *katom)
{
	struct kbase_context *kctx = katom->kctx;
	struct device *dev = kctx->kbdev->dev;
	base_jd_replay_payload *payload;
	u64 job_header;
	u64 job_loop_detect;
	struct job_head *job;
	struct kbase_vmap_struct job_map;
	struct kbase_vmap_struct map;
	bool err = false;

	/* Replay job if fault is of type BASE_JD_EVENT_JOB_WRITE_FAULT or
	 * if force_replay is enabled.
	 */
	if (BASE_JD_EVENT_TERMINATED == katom->event_code) {
		return false;
	} else if (BASE_JD_EVENT_JOB_WRITE_FAULT == katom->event_code) {
		return true;
	} else if (BASE_JD_EVENT_FORCE_REPLAY == katom->event_code) {
		katom->event_code = BASE_JD_EVENT_DATA_INVALID_FAULT;
		return true;
	} else if (BASE_JD_EVENT_DATA_INVALID_FAULT != katom->event_code) {
		/* No replay for faults of type other than
		 * BASE_JD_EVENT_DATA_INVALID_FAULT.
		 */
		return false;
	}

	/* Job fault is BASE_JD_EVENT_DATA_INVALID_FAULT, now scan fragment jc
	 * to find out whether the source of exception is POLYGON_LIST. Replay
	 * is required if the source of fault is POLYGON_LIST.
	 */
	payload = kbase_vmap(kctx, katom->jc, sizeof(*payload), &map);
	if (!payload) {
		dev_err(dev, "kbase_replay_fault_check: failed to map payload.\n");
		return false;
	}

#ifdef CONFIG_MALI_DEBUG
	dev_dbg(dev, "kbase_replay_fault_check: payload=%p\n", payload);
	dev_dbg(dev, "\nPayload structure:\n"
		     "fragment_jc              = 0x%llx\n"
		     "fragment_hierarchy_mask  = 0x%x\n"
		     "fragment_core_req        = 0x%x\n",
		     payload->fragment_jc,
		     payload->fragment_hierarchy_mask,
		     payload->fragment_core_req);
#endif
	/* Process fragment job chain */
	job_header      = (u64) payload->fragment_jc;
	job_loop_detect = job_header;
	while (job_header) {
		job = kbase_vmap(kctx, job_header, sizeof(*job), &job_map);
		if (!job) {
			dev_err(dev, "failed to map jc\n");
			/* unmap payload*/
			kbase_vunmap(kctx, &map);
			return false;
		}

#ifdef CONFIG_MALI_DEBUG
		dev_dbg(dev, "\njob_head structure:\n"
			     "Source ID:0x%x Access:0x%x Exception:0x%x\n"
			     "at job addr               = %p\n"
			     "not_complete_index        = 0x%x\n"
			     "fault_addr                = 0x%llx\n"
			     "flags                     = 0x%x\n"
			     "index                     = 0x%x\n"
			     "dependencies              = 0x%x,0x%x\n",
			     JOB_SOURCE_ID(job->status),
			     ((job->status >> 8) & 0x3),
			     (job->status  & 0xFF),
			     job,
			     job->not_complete_index,
			     job->fault_addr,
			     job->flags,
			     job->index,
			     job->dependencies[0],
			     job->dependencies[1]);
#endif

		/* Replay only when the polygon list reader caused the
		 * DATA_INVALID_FAULT */
		if ((BASE_JD_EVENT_DATA_INVALID_FAULT == katom->event_code) &&
		    (JOB_POLYGON_LIST == JOB_SOURCE_ID(job->status))) {
			err = true;
			kbase_vunmap(kctx, &job_map);
			break;
		}

		/* Move on to next fragment job in the list */
		if (job->flags & JOB_FLAG_DESC_SIZE)
			job_header = job->next._64;
		else
			job_header = job->next._32;

		kbase_vunmap(kctx, &job_map);

		/* Job chain loop detected */
		if (job_header == job_loop_detect)
			break;
	}

	/* unmap payload*/
	kbase_vunmap(kctx, &map);

	return err;
}

/**
 * @brief Process a replay job
 *
 * Called from kbase_process_soft_job.
 *
 * On exit, if the job has completed, katom->event_code will have been updated.
 * If the job has not completed, and is replaying jobs, then the atom status
 * will have been reset to KBASE_JD_ATOM_STATE_QUEUED.
 *
 * @param[in] katom  The atom to be processed
 * @return           false if the atom has completed
 *                   true if the atom is replaying jobs
 */
bool kbase_replay_process(struct kbase_jd_atom *katom)
{
	struct kbase_context *kctx = katom->kctx;
	struct kbase_jd_context *jctx = &kctx->jctx;
	struct kbase_device *kbdev = kctx->kbdev;

	/* Don't replay this atom if these issues are not present in the
	 * hardware */
	if (!kbase_hw_has_issue(kbdev, BASE_HW_ISSUE_11020) &&
			!kbase_hw_has_issue(kbdev, BASE_HW_ISSUE_11024)) {
		dev_dbg(kbdev->dev, "Hardware does not need replay workaround");

		/* Signal failure to userspace */
		katom->event_code = BASE_JD_EVENT_JOB_INVALID;

		return false;
	}

	if (katom->event_code == BASE_JD_EVENT_DONE) {
		dev_dbg(kbdev->dev, "Previous job succeeded - not replaying\n");

		if (katom->retry_count)
			kbase_disjoint_state_down(kbdev);

		return false;
	}

	if (jctx->sched_info.ctx.is_dying) {
		dev_dbg(kbdev->dev, "Not replaying; context is dying\n");

		if (katom->retry_count)
			kbase_disjoint_state_down(kbdev);

		return false;
	}

	/* Check job exception type and source before replaying. */
	if (!kbase_replay_fault_check(katom)) {
		dev_dbg(kbdev->dev,
			"Replay cancelled on event %x\n", katom->event_code);
		/* katom->event_code is already set to the failure code of the
		 * previous job.
		 */
		return false;
	}

	dev_warn(kbdev->dev, "Replaying jobs retry=%d\n",
			katom->retry_count);

	katom->retry_count++;

	if (katom->retry_count > BASEP_JD_REPLAY_LIMIT) {
		dev_err(kbdev->dev, "Replay exceeded limit - failing jobs\n");

		kbase_disjoint_state_down(kbdev);

		/* katom->event_code is already set to the failure code of the
		   previous job */
		return false;
	}

	/* only enter the disjoint state once for the whole time while the replay is ongoing */
	if (katom->retry_count == 1)
		kbase_disjoint_state_up(kbdev);

	INIT_WORK(&katom->work, kbase_replay_process_worker);
	queue_work(kctx->event_workq, &katom->work);

	return true;
}


text:
from __future__ import absolute_import

from .attribute import (
    html_attribute,
    boolean_html_attribute,
    int_html_attribute,
    float_html_attribute,
    list_html_attribute,
    time_html_attribute,
    data_attribute,
    css_class_attribute,
)
from .block import Division, Paragraph, Preformatted
from .document import (
    Document,
    HTMLRoot,
    Head,
    Body,
    Title,
    Meta,
    Script,
    HeadLink,
    Main,
    json_script,
)
from .element import ElementBase, Element, VoidElement, is_element
from .form import (
    Autocomplete,
    Form,
    Input,
    TextInput,
    PasswordInput,
    NumberInput,
    DateInput,
    TimeInput,
    SearchInput,
    FileInput,
    HiddenInput,
    SubmitButton,
    Button,
    TextArea,
    Select,
    OptionGroup,
    Option,
    Checkbox,
    RadioButton,
    Label,
)
from .generator import (
    Generator,
    NullGenerator,
    IteratorGenerator,
    ChildGenerator,
    HTMLChildGenerator,
    JoinGenerator,
    HTMLJoinGenerator,
    GenValue,
    GenValueGenerator,
    generate_html_string,
)
from .image import Image
from .inline import (
    Span,
    Highlight,
    Strong,
    Alternate,
    Emphasis,
    Small,
    LineBreak,
)
from .link import Link
from .list import (
    OrderedList,
    UnorderedList,
    ListItem,
    DescriptionList,
    DescriptionDefinition,
    DescriptionTerm,
)
from .structure import (
    Section,
    Article,
    Navigation,
    Aside,
    Header,
    Footer,
    Heading,
)
from .table import (
    Table,
    TableHead,
    TableBody,
    TableRow,
    TableHeaderCell,
    TableCell,
    ColumnGroup,
    Column,
)
from .time import Time
from .video import Preload, Video


text:
package uk.co.ribot.androidboilerplate.util;

import android.animation.Animator;
import android.transition.ChangeBounds;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.RelativeLayout;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * Created by anduser on 07.06.17.
 */

@Singleton
public class AnimationUtil {

    @Inject AnimationUtil() {};

    public static void performAlphaAnimation(View view, boolean show) {
        performAlphaAnimation(view, show, false);
    }

    public static void clearAnimation(View v) {
        if (v.getAnimation() != null) {
            v.getAnimation().cancel();
            v.getAnimation().setAnimationListener(null);
            v.clearAnimation();
            v.setAnimation(null);
        }
    }

    private static void performAlphaAnimation(View view, boolean show, boolean gone) {

        if ((show && view.getVisibility() == View.VISIBLE) || (!show && view.getVisibility() == View.INVISIBLE) || (!show && view.getVisibility() == View.GONE)) {
            return;
        }

        final boolean finalShow = show;
        final boolean finalGone = gone;
        final View finalView = view;

        AlphaAnimation alphaAnimation = new AlphaAnimation((show ? 0.0f : 1.0f), (show ? 1.0f : 0.0f));
        alphaAnimation.setDuration(250);
        alphaAnimation.setFillAfter(false);
        view.startAnimation(alphaAnimation);

        alphaAnimation.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {

                if (finalShow) {
                    finalView.setVisibility(View.VISIBLE);
                } else if (!finalGone) {
                    finalView.setVisibility(View.INVISIBLE);
                } else {
                    finalView.setVisibility(View.GONE);
                }
            }
        });
    }

    /*
     *  To animate view slide out from top to bottom
     */
    public static void slideToBottom(View view) {
        int height = view.getHeight();
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) view.getLayoutParams();
        params.height = 0;
        view.setLayoutParams(params);
        view.setVisibility(View.VISIBLE);
        TranslateAnimation animate = new TranslateAnimation(0, 0, 0, height);
        animate.setDuration(300);
        animate.setFillAfter(true);
        view.startAnimation(animate);
    }

    /*
     *  To animate view slide out from bottom to top
     */
    public static void slideToTop(View view) {
        TranslateAnimation animate = new TranslateAnimation(0, 0, 0, -view.getHeight());
        animate.setDuration(300);
        animate.setFillAfter(true);
        view.startAnimation(animate);
        view.setVisibility(View.GONE);
    }

    public static void clipViewBounds(View view) {
        ChangeBounds changeBounds = new ChangeBounds();
    }
}


text:
package org.fest.swing.util;

import static org.fest.assertions.Assertions.assertThat;

import org.junit.Test;

/**
 * Tests for {@link OSIdentifier#isX11()}.
 *
 * @author Alex Ruiz
 */
public class OSIdentifier_isX11_Test extends OSIdentifier_TestCase {
  @Test
  public void should_return_X11_if_OS_not_OSX_or_Windows() {
    returnOSName("");
    returnNoMRJVersion();
    OSIdentifier osIdentifier = new OSIdentifier(propertyReader);
    assertThat(osIdentifier.isX11()).isTrue();
    assertThat(osIdentifier.isHPUX()).isFalse();
    assertThat(osIdentifier.isLinux()).isFalse();
    assertThat(osIdentifier.isMacintosh()).isFalse();
    assertThat(osIdentifier.isOSX()).isFalse();
    assertThat(osIdentifier.isSolaris()).isFalse();
    assertThat(osIdentifier.isWindows()).isFalse();
    assertThat(osIdentifier.isWindows9x()).isFalse();
    assertThat(osIdentifier.isWindowsXP()).isFalse();
  }
}


text:
#pragma once

#if ENABLE(WEBASSEMBLY)

#include "InternalFunction.h"
#include "JSObject.h"

namespace JSC {

class WebAssemblyTablePrototype;

class WebAssemblyTableConstructor : public InternalFunction {
public:
    typedef InternalFunction Base;
    static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;

    static WebAssemblyTableConstructor* create(VM&, Structure*, WebAssemblyTablePrototype*);
    static Structure* createStructure(VM&, JSGlobalObject*, JSValue);

    DECLARE_INFO;

protected:
    void finishCreation(VM&, WebAssemblyTablePrototype*);

private:
    WebAssemblyTableConstructor(VM&, Structure*);
    static ConstructType getConstructData(JSCell*, ConstructData&);
    static CallType getCallData(JSCell*, CallData&);
    static void visitChildren(JSCell*, SlotVisitor&);
};

} // namespace JSC

#endif // ENABLE(WEBASSEMBLY)


text:
Bootstrap Tags Input is a jQuery plugin providing a Twitter Bootstrap user interface for managing tags.

## Usage
Examples can be found [here](http://timschlechter.github.com/bootstrap-tagsinput/examples/).

## Features
* Objects as tags
* True multi value
* Typeahead
* AngularJS directive included
* Designed for Bootstrap 2.3.2 and 3

### Objects as tags
Not just support for using strings! This means you can use different values
for a tag's label and value. Each tag also holds a reference to the object
by which it was created, so by calling tagsinput('items') an
array of the original items is returned.

### True multi value support
Other implementations just concatenate the values to a comma separated string.
This results in val() returning just this string, and when
submitting the form, only one big, concatenated value is sent in the request.

Bootstrap Tags Input provides true multivalue support. Just use a
<select multiple /> as your input element, and
val() will return an array of the tag values. When submitting the
form, an array of values will be sent with the request.

### Typeahead support
Integrates with Twitter Bootstraps' 2.3.2 typeahead, or use custom typeahead when using Bootstrap 3.

### Angular JS directive
Include [bootstrap-tagsinput-angular.js](https://github.com/TimSchlechter/bootstrap-tagsinput/blob/master/src/bootstrap-tagsinput-angular.js) and register the 'bootstrap-tagsinput' in your Angular JS application to use the bootstrap-tagsinput directive. Look at [the examples page](http://timschlechter.github.io/bootstrap-tagsinput/examples/#angular) how to use the directive.

## History
__0.3.7__
* [#39: flash when duplicate is entered](https://github.com/TimSchlechter/bootstrap-tagsinput/issues/39)

__0.3.6__

* [#34: Error in ReloadPage](https://github.com/TimSchlechter/bootstrap-tagsinput/issues/34)

__0.3.5__

* [#10: confirmKeys option](https://github.com/TimSchlechter/bootstrap-tagsinput/issues/10)

__0.3.4__

* [#24: Add bsTagsInput angular directive & example for bootstrap3 with typeahea...](https://github.com/TimSchlechter/bootstrap-tagsinput/pull/24)
* [#28: Limit number of tags, enable/disable input](https://github.com/TimSchlechter/bootstrap-tagsinput/pull/28)
* [#33: Avoid conflict with other selects when checking for value presence](https://github.com/TimSchlechter/bootstrap-tagsinput/pull/33)

## License
This project is licensed under [MIT](https://raw.github.com/TimSchlechter/bootstrap-tagsinput/master/LICENSE "Read more about the MIT license").


text:
package org.apache.calcite.sql.fun;

import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.rel.type.RelDataTypeField;
import org.apache.calcite.sql.SqlCall;
import org.apache.calcite.sql.SqlCallBinding;
import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.SqlOperandCountRange;
import org.apache.calcite.sql.SqlOperatorBinding;
import org.apache.calcite.sql.SqlSpecialOperator;
import org.apache.calcite.sql.SqlWriter;
import org.apache.calcite.sql.parser.SqlParserPos;
import org.apache.calcite.sql.type.OperandTypes;
import org.apache.calcite.sql.type.SqlOperandCountRanges;
import org.apache.calcite.sql.type.SqlSingleOperandTypeChecker;
import org.apache.calcite.sql.type.SqlTypeFamily;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.sql.type.SqlTypeUtil;

import java.util.Arrays;

import static org.apache.calcite.sql.type.NonNullableAccessors.getComponentTypeOrThrow;
import static org.apache.calcite.sql.validate.SqlNonNullableAccessors.getOperandLiteralValueOrThrow;

import static java.util.Objects.requireNonNull;

/**
 * The item operator {@code [ ... ]}, used to access a given element of an
 * array, map or struct. For example, {@code myArray[3]}, {@code "myMap['foo']"},
 * {@code myStruct[2]} or {@code myStruct['fieldName']}.
 */
class SqlItemOperator extends SqlSpecialOperator {

  private static final SqlSingleOperandTypeChecker ARRAY_OR_MAP =
      OperandTypes.family(SqlTypeFamily.ARRAY)
          .or(OperandTypes.family(SqlTypeFamily.MAP))
          .or(OperandTypes.family(SqlTypeFamily.ANY));

  SqlItemOperator() {
    super("ITEM", SqlKind.ITEM, 100, true, null, null, null);
  }

  @Override public ReduceResult reduceExpr(int ordinal,
      TokenSequence list) {
    SqlNode left = list.node(ordinal - 1);
    SqlNode right = list.node(ordinal + 1);
    return new ReduceResult(ordinal - 1,
        ordinal + 2,
        createCall(
            SqlParserPos.sum(
                Arrays.asList(requireNonNull(left, "left").getParserPosition(),
                    requireNonNull(right, "right").getParserPosition(),
                    list.pos(ordinal))),
            left,
            right));
  }

  @Override public void unparse(
      SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) {
    call.operand(0).unparse(writer, leftPrec, 0);
    final SqlWriter.Frame frame = writer.startList("[", "]");
    call.operand(1).unparse(writer, 0, 0);
    writer.endList(frame);
  }

  @Override public SqlOperandCountRange getOperandCountRange() {
    return SqlOperandCountRanges.of(2);
  }

  @Override public boolean checkOperandTypes(
      SqlCallBinding callBinding,
      boolean throwOnFailure) {
    final SqlNode left = callBinding.operand(0);
    final SqlNode right = callBinding.operand(1);
    if (!ARRAY_OR_MAP.checkSingleOperandType(callBinding, left, 0,
        throwOnFailure)) {
      return false;
    }
    final SqlSingleOperandTypeChecker checker = getChecker(callBinding);
    return checker.checkSingleOperandType(callBinding, right, 0,
        throwOnFailure);
  }

  private static SqlSingleOperandTypeChecker getChecker(SqlCallBinding callBinding) {
    final RelDataType operandType = callBinding.getOperandType(0);
    switch (operandType.getSqlTypeName()) {
    case ARRAY:
      return OperandTypes.family(SqlTypeFamily.INTEGER);
    case MAP:
      RelDataType keyType = requireNonNull(operandType.getKeyType(),
          "operandType.getKeyType()");
      SqlTypeName sqlTypeName = keyType.getSqlTypeName();
      return OperandTypes.family(
          requireNonNull(sqlTypeName.getFamily(),
              () -> "keyType.getSqlTypeName().getFamily() null, type is " + sqlTypeName));
    case ROW:
    case ANY:
    case DYNAMIC_STAR:
      return OperandTypes.family(SqlTypeFamily.INTEGER)
          .or(OperandTypes.family(SqlTypeFamily.CHARACTER));
    default:
      throw callBinding.newValidationSignatureError();
    }
  }

  @Override public String getAllowedSignatures(String name) {
    return "<ARRAY>[<INTEGER>]\n"
        + "<MAP>[<ANY>]\n"
        + "<ROW>[<CHARACTER>|<INTEGER>]";
  }

  @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
    final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
    final RelDataType operandType = opBinding.getOperandType(0);
    switch (operandType.getSqlTypeName()) {
    case ARRAY:
      return typeFactory.createTypeWithNullability(
          getComponentTypeOrThrow(operandType), true);
    case MAP:
      return typeFactory.createTypeWithNullability(
          requireNonNull(operandType.getValueType(),
              () -> "operandType.getValueType() is null for " + operandType),
          true);
    case ROW:
      RelDataType fieldType;
      RelDataType indexType = opBinding.getOperandType(1);

      if (SqlTypeUtil.isString(indexType)) {
        final String fieldName = getOperandLiteralValueOrThrow(opBinding, 1, String.class);
        RelDataTypeField field = operandType.getField(fieldName, false, false);
        if (field == null) {
          throw new AssertionError("Cannot infer type of field '"
              + fieldName + "' within ROW type: " + operandType);
        } else {
          fieldType = field.getType();
        }
      } else if (SqlTypeUtil.isIntType(indexType)) {
        Integer index = opBinding.getOperandLiteralValue(1, Integer.class);
        if (index == null || index < 1 || index > operandType.getFieldCount()) {
          throw new AssertionError("Cannot infer type of field at position "
              + index + " within ROW type: " + operandType);
        } else {
          fieldType = operandType.getFieldList().get(index - 1).getType(); // 1 indexed
        }
      } else {
        throw new AssertionError("Unsupported field identifier type: '"
            + indexType + "'");
      }
      if (fieldType != null && operandType.isNullable()) {
        fieldType = typeFactory.createTypeWithNullability(fieldType, true);
      }
      return fieldType;
    case ANY:
    case DYNAMIC_STAR:
      return typeFactory.createTypeWithNullability(
          typeFactory.createSqlType(SqlTypeName.ANY), true);
    default:
      throw new AssertionError();
    }
  }
}


text:
package com.like.common.util;

import java.util.Arrays;

/**
 * 数组相关的工具类
 */
public class ArrayUtils {

    /**
     * 合并数组
     *
     * @param appSecrets
     * @param b
     * @return
     */
    public static byte[] concatArray(byte[] appSecrets, byte[]... b) {
        int totalLength = appSecrets.length;
        for (byte[] array : b) {
            totalLength += array.length;
        }
        byte[] result = Arrays.copyOf(appSecrets, totalLength);
        int offset = appSecrets.length;
        for (byte[] array : b) {
            System.arraycopy(array, 0, result, offset, array.length);
            offset += array.length;
        }
        return result;
    }

    /**
     * 组合两个数组为一个
     *
     * @param array1
     * @param array2
     * @return
     */
    public static String[] composeArray(String[] array1, String[] array2) {
        if (array1 == null && array2 == null) {
            return null;
        } else if (array1 == null && array2 != null) {
            return array2;
        } else if (array1 != null && array2 == null) {
            return array1;
        } else {
            String[] results = new String[array1.length + array2.length];
            results = Arrays.copyOf(array2, results.length);
            System.arraycopy(array1, 0, results, array2.length, array1.length);
            return results;
        }
    }

    /**
     * 组合两个数组为一个
     *
     * @param array1
     * @param array2
     * @return
     */
    public static Double[] composeArray(Double[] array1, Double[] array2) {
        if (array1 == null && array2 == null) {
            return null;
        } else if (array1 == null && array2 != null) {
            return array2;
        } else if (array1 != null && array2 == null) {
            return array1;
        } else {
            Double[] results = new Double[array1.length + array2.length];
            results = Arrays.copyOf(array2, results.length);
            System.arraycopy(array1, 0, results, array2.length, array1.length);
            return results;
        }
    }
}


text:
namespace DT2 {

//==============================================================================
/// Register with object factory
//==============================================================================

IMPLEMENT_FACTORY_CREATION(DeviceGraphicsDX11PixelShader)

//==============================================================================
/// Standard class constructors/destructors
//==============================================================================

DeviceGraphicsDX11PixelShader::DeviceGraphicsDX11PixelShader (void)
    :   _shader (NULL)
{

}

DeviceGraphicsDX11PixelShader::~DeviceGraphicsDX11PixelShader (void)
{
    SAFE_RELEASE(_shader);
}

//==============================================================================
//==============================================================================

void DeviceGraphicsDX11PixelShader::loadShader (const FilePath &path, const String *shader)
{
    Assert(shader);

    DeviceGraphicsDX11Renderer *renderer = checkedCast<DeviceGraphicsDX11Renderer*>(System::getRenderer());

    ID3D11Device1 *device = renderer->getD3D11Device();

    SAFE_RELEASE(_shader);
    HRESULT hr = device->CreatePixelShader(&(*shader)[0], shader->size(), NULL, &_shader);
    Assert(SUCCEEDED(hr));
}

//==============================================================================
//==============================================================================

void DeviceGraphicsDX11PixelShader::syncToResource (FragmentShaderResource *program)
{
	if (program->getRecacheData()) {
		loadShader(program->getPath(), program->getShader("HLSL"));

		program->setRecacheData(false);
    }

	program->setRecacheParameters(false);
}

//==============================================================================
//==============================================================================

} // DT2


text:
require 'chef/provisioning/azure_driver/azure_provider'

class Chef
  class Provider
    class AzureCloudService < Chef::Provisioning::AzureDriver::AzureProvider
      action :create do
        Chef::Log.info("Creating AzureCloudService: #{new_resource.name}")
        csms = Azure::CloudServiceManagementService.new
        csms.create_cloud_service(new_resource.name, new_resource.options)
        properties = csms.get_cloud_service_properties(new_resource.name)
        Chef::Log.debug("Properties of #{new_resource.name}: #{properties.inspect}")
      end

      action :destroy do
        Chef::Log.info("Destroying AzureCloudService: #{new_resource.name}")
        csms = Azure::CloudServiceManagementService.new
        csms.delete_cloud_service(new_resource.name)
      end
    end
  end
end


text:
#include <aws/ec2/model/IpamPoolAllocationResourceType.h>
#include <aws/core/utils/HashingUtils.h>
#include <aws/core/Globals.h>
#include <aws/core/utils/EnumParseOverflowContainer.h>

using namespace Aws::Utils;

namespace Aws
{
  namespace EC2
  {
    namespace Model
    {
      namespace IpamPoolAllocationResourceTypeMapper
      {

        static const int ipam_pool_HASH = HashingUtils::HashString("ipam-pool");
        static const int vpc_HASH = HashingUtils::HashString("vpc");
        static const int ec2_public_ipv4_pool_HASH = HashingUtils::HashString("ec2-public-ipv4-pool");
        static const int custom_HASH = HashingUtils::HashString("custom");

        IpamPoolAllocationResourceType GetIpamPoolAllocationResourceTypeForName(const Aws::String& name)
        {
          int hashCode = HashingUtils::HashString(name.c_str());
          if (hashCode == ipam_pool_HASH)
          {
            return IpamPoolAllocationResourceType::ipam_pool;
          }
          else if (hashCode == vpc_HASH)
          {
            return IpamPoolAllocationResourceType::vpc;
          }
          else if (hashCode == ec2_public_ipv4_pool_HASH)
          {
            return IpamPoolAllocationResourceType::ec2_public_ipv4_pool;
          }
          else if (hashCode == custom_HASH)
          {
            return IpamPoolAllocationResourceType::custom;
          }
          EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
          if(overflowContainer)
          {
            overflowContainer->StoreOverflow(hashCode, name);
            return static_cast<IpamPoolAllocationResourceType>(hashCode);
          }

          return IpamPoolAllocationResourceType::NOT_SET;
        }

        Aws::String GetNameForIpamPoolAllocationResourceType(IpamPoolAllocationResourceType enumValue)
        {
          switch(enumValue)
          {
          case IpamPoolAllocationResourceType::ipam_pool:
            return "ipam-pool";
          case IpamPoolAllocationResourceType::vpc:
            return "vpc";
          case IpamPoolAllocationResourceType::ec2_public_ipv4_pool:
            return "ec2-public-ipv4-pool";
          case IpamPoolAllocationResourceType::custom:
            return "custom";
          default:
            EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
            if(overflowContainer)
            {
              return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue));
            }

            return {};
          }
        }

      } // namespace IpamPoolAllocationResourceTypeMapper
    } // namespace Model
  } // namespace EC2
} // namespace Aws


text:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.dumu.housego.ErShouAllDetailActivity"
    tools:ignore="ContentDescription,UselessParent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:background="#f0eff5">

        <ImageView
            android:id="@+id/iv_ershoualldetall_close"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            android:src="@drawable/map_closed" />
    </RelativeLayout>

    <ScrollView
        android:id="@+id/shuxing"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#fff"
        android:visibility="gone">

        <!-- 查看更多属性 -->

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="基础属性/交易属性"
                android:textColor="#333"
                android:textSize="16sp"
                android:textStyle="bold" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="房屋户型"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_huxing"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="所在楼层"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_louceng"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="建筑面积"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_jianzhumianji"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="户型结构"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_huxingjiegou"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="套内面积"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_taoneimianji"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="建筑类型"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_jianzhuleixing"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="房屋朝向"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_chaoxiang"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="建筑结构"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_jianzhujiegou"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="装修情况"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_zhuangxiu"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="梯户比例"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_tihubili"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="备用电梯"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_beiyongdianti"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="挂牌时间"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_guapaitime"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="物业类型"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_wuyetype"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text=""
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="上次交易"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_shangcijiaoyi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="房屋类型"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_fangwutype"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="产权所属"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_chanquansuoshu"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="唯一住宅"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_weiYizhuzhai"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="抵押信息"
                android:textColor="#333"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/tv_alldetail_diyaxinxi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="房屋户型"
                android:textColor="#999"
                android:textSize="12sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />
        </LinearLayout>
    </ScrollView>

    <!-- 更多特色 -->

    <ScrollView
        android:id="@+id/tese"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#fff">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="房源特色"
                android:textColor="#333"
                android:textSize="16sp"
                android:textStyle="bold" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="周边配套"
                android:textColor="#999"
                android:textSize="12sp" />

            <TextView
                android:id="@+id/tv_alldetail_zhoubianpeitao"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="周边配套"
                android:textColor="#333"
                android:textSize="14sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="小区优势"
                android:textColor="#999"
                android:textSize="12sp" />

            <TextView
                android:id="@+id/tv_alldetail_xiaoquyoushi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="小区优势"
                android:textColor="#333"
                android:textSize="14sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="教育配套"
                android:textColor="#999"
                android:textSize="12sp" />

            <TextView
                android:id="@+id/tv_alldetail_jiaoyupeitao"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="教育配套"
                android:textColor="#333"
                android:textSize="14sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="投资分析"
                android:textColor="#999"
                android:textSize="12sp" />

            <TextView
                android:id="@+id/tv_alldetail_touzifenxi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="投资分析"
                android:textColor="#333"
                android:textSize="14sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="核心卖点"
                android:textColor="#999"
                android:textSize="12sp" />

            <TextView
                android:id="@+id/tv_alldetail_hexinmaidian"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="核心卖点"
                android:textColor="#333"
                android:textSize="14sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="权属抵押"
                android:textColor="#999"
                android:textSize="12sp" />

            <TextView
                android:id="@+id/tv_alldetail_quansudiya"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="权属抵押"
                android:textColor="#333"
                android:textSize="14sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="交通出行"
                android:textColor="#999"
                android:textSize="12sp" />

            <TextView
                android:id="@+id/tv_alldetail_jiaotongchuxing"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="交通出行"
                android:textColor="#333"
                android:textSize="14sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="税费解析"
                android:textColor="#999"
                android:textSize="12sp" />

            <TextView
                android:id="@+id/tv_alldetail_shuifeijiexi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="税费解析"
                android:textColor="#333"
                android:textSize="14sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="装修描述"
                android:textColor="#999"
                android:textSize="12sp" />

            <TextView
                android:id="@+id/tv_alldetail_zhuangxiumiaoshu"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="装修描述"
                android:textColor="#333"
                android:textSize="14sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="推荐理由"
                android:textColor="#999"
                android:textSize="12sp" />

            <TextView
                android:id="@+id/tv_alldetail_tuijianliyou"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:text="推荐理由"
                android:textColor="#333"
                android:textSize="14sp" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="@dimen/fengexian"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:background="#c9c9cb" />
        </LinearLayout>
    </ScrollView>

</LinearLayout>


text:
package com.codebroker.web.api.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/")

public class IndexController {

    @RequestMapping(value="/",method = {RequestMethod.GET})
    @ApiOperation(value ="index",hidden = true)
    public String index(){
        return "redirect:/swagger-ui.html";
    }

}