APISonar


ai.grakn.engine.tasks.TaskConfiguration.json

> ai > grakn > engine > tasks > TaskConfiguration > json
ai APIs grakn APIs engine APIs tasks APIs TaskConfiguration APIs json APIs

Example 1
private Collection<InsertQuery> getInserts(TaskConfiguration configuration){
        if(configuration.json().has(TASK_LOADER_INSERTS)){
            return configuration.json().at(TASK_LOADER_INSERTS).asJsonList().stream()
                    .map(Json::asString)
                    .map(builder::<InsertQuery>parse)
                    .collect(Collectors.toList());
        }

        throw new IllegalArgumentException(ILLEGAL_ARGUMENT_EXCEPTION.getMessage("No inserts", configuration));
    }
Example 2
private TaskConfiguration mockConfiguration;

    public void mockPostProcessing(){
        mockConsumer = mock(Consumer.class);
        mockCastingIndex = UUID.randomUUID().toString();
        mockResourceIndex = UUID.randomUUID().toString();
        mockCastingSet = Sets.newHashSet();
        mockResourceSet = Sets.newHashSet();
        mockConfiguration = mock(TaskConfiguration.class);
        when(mockConfiguration.json()).thenReturn(Json.object(
                KEYSPACE, "testing",
                REST.Request.COMMIT_LOG_FIXING, Json.object(
                        Schema.BaseType.CASTING.name(), Json.object(mockCastingIndex, mockCastingSet),
                        Schema.BaseType.RESOURCE.name(), Json.object(mockResourceIndex, mockResourceSet)
                )));
    }
Example 3
private Map<TypeLabel, Long> getJobsFromConfiguration(TaskConfiguration configuration){
        return  configuration.json().at(COMMIT_LOG_COUNTING).asJsonList().stream()
                .collect(Collectors.toMap(
                        e -> TypeLabel.of(e.at(COMMIT_LOG_TYPE_NAME).asString()),
                        e -> e.at(COMMIT_LOG_INSTANCE_COUNT).asLong()));
    }
Example 4
private Map<String,Set<ConceptId>> conceptFromConfig(Schema.BaseType type, TaskConfiguration configuration) {
        return configuration.json().at(COMMIT_LOG_FIXING).at(type.name()).asJsonMap().entrySet().stream().collect(toMap(
                Map.Entry::getKey,
                e -> e.getValue().asList().stream().map(ConceptId::of).collect(toSet())
        ));
    }
Example 5
public boolean start(Consumer<TaskCheckpoint> saveCheckpoint, TaskConfiguration configuration) {
        LOG.info("Starting ResourceDeduplicationTask : " + configuration.json());
        
        String keyspace = configuration.json().at("keyspace", KEYSPACE_DEFAULT).asString();
        GraknComputer computer = Grakn.session(Grakn.DEFAULT_URI, keyspace).getGraphComputer();
        Job job = new Job().keyspace(keyspace)
                           .deleteUnattached(configuration.json().at("deletedUnattached", DELETE_UNATTACHED_DEFAULT ).asBoolean());
        this.totalEliminated = computer.compute(job).memory().get(job.getMemoryKey());
        return true;
    }