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