com.cinchapi.impromptu.server.api.derive.Recipe Maven / Gradle / Ivy
/*
* Copyright (c) 2013-2017 Cinchapi Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.cinchapi.impromptu.server.api.derive;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import com.cinchapi.impromptu.server.api.store.Cache;
import com.cinchapi.impromptu.server.api.store.Datastore;
/**
* A {@link Recipe} is a formula that takes arbitrary data and derives
* additional data to insert in a {@link Datasource}.
*
* @author Jeff Nelson
*/
public interface Recipe {
/**
* Apply this {@link Recipe} to the {@code data} from {@code record} and
* insert the derived data into the {@code container}.
*
* @param container the {@link Datastore} into which data derived by this
* {@link Recipe} is inserted
* @param record the id of the record from which {@code data} comes and for
* which the derived data in inserted
* @param ingredients the {@link #required() required} and
* {@link #optional()
* optional} data that is necessary to apply the recipe
* @param cache a {@link Cache} the recipe can leverage for better
* performance
*/
public void apply(Datastore datastore, long record,
Map> ingredients, Cache cache);
/**
* Return the key keys that are required for this
* {@link Recipe}.
*
* @return the required keys
*/
public Set required();
/**
* Return the key keys that can optionally enhance the
* data derived by this {@link Recipe}.
*
* @return the optional keys
*/
public default Set optional() {
return Collections.emptySet();
}
/**
* Return the keys that are used for all derived data of this recipe.
*
* @return the {@code String} keys
*/
public Set derived();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy