001/*
002 * Copyright 2014 Global Biodiversity Information Facility (GBIF)
003 * Licensed under the Apache License, Version 2.0 (the "License");
004 * you may not use this file except in compliance with the License.
005 * You may obtain a copy of the License at
006 * http://www.apache.org/licenses/LICENSE-2.0
007 * Unless required by applicable law or agreed to in writing, software
008 * distributed under the License is distributed on an "AS IS" BASIS,
009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010 * See the License for the specific language governing permissions and
011 * limitations under the License.
012 */
013package org.gbif.api.service.metrics;
014
015import org.gbif.api.model.metrics.cube.ReadBuilder;
016import org.gbif.api.model.metrics.cube.Rollup;
017
018import java.util.List;
019
020/**
021 * The cube API service, for reading addressable counts from a basic cube.
022 */
023public interface CubeService {
024
025  /**
026   * Using the supplied {@link ReadBuilder} to obtain the address, looks up the cube value.
027   * Should the cube support no dimensions (e.g. count all), then calling with an empty ReadBuilder
028   * will return this.  E.g. cubeService.get(new ReadBuilder());
029   *
030   * @param addressBuilder To obtain the address at which to look up from the cube
031   * @return The value which might be 0. A value of 0 means that the count is truly at 0
032   * @throws IllegalArgumentException Should the addressBuilder provide an address that does not exist in the cube
033   */
034  long get(ReadBuilder addressBuilder) throws IllegalArgumentException;
035
036  /**
037   * Provides the list of rollups thus specifying the available combinations of addressable dimensions for a cube.
038   *
039   * @return The schema for the cube (defined by the queryable addresses)
040   */
041  List<Rollup> getSchema();
042}