All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.datarouter.client.mysql.node.MysqlReaderNode Maven / Gradle / Ivy

There is a newer version: 0.0.125
Show newest version
/*
 * Copyright © 2009 HotPads ([email protected])
 *
 * 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 io.datarouter.client.mysql.node;

import java.util.Collection;
import java.util.List;

import io.datarouter.client.mysql.MysqlClientType;
import io.datarouter.model.databean.Databean;
import io.datarouter.model.index.IndexEntry;
import io.datarouter.model.key.primary.PrimaryKey;
import io.datarouter.model.key.unique.UniqueKey;
import io.datarouter.model.serialize.fielder.DatabeanFielder;
import io.datarouter.scanner.Scanner;
import io.datarouter.storage.config.Config;
import io.datarouter.storage.node.NodeParams;
import io.datarouter.storage.node.op.combo.reader.IndexedSortedMapStorageReader.PhysicalIndexedSortedMapStorageReaderNode;
import io.datarouter.storage.node.type.index.ManagedNode;
import io.datarouter.storage.node.type.physical.base.BasePhysicalNode;
import io.datarouter.storage.serialize.fieldcache.IndexEntryFieldInfo;
import io.datarouter.util.tuple.Range;

public class MysqlReaderNode<
		PK extends PrimaryKey,
		D extends Databean,
		F extends DatabeanFielder>
extends BasePhysicalNode
implements PhysicalIndexedSortedMapStorageReaderNode{

	public static final int DEFAULT_ITERATE_BATCH_SIZE = 1000;

	private final MysqlNodeManager mysqlNodeManager;

	public MysqlReaderNode(
			NodeParams params,
			MysqlClientType mysqlClientType,
			MysqlNodeManager mysqlNodeManager){
		super(params, mysqlClientType);
		this.mysqlNodeManager = mysqlNodeManager;
	}

	/*------------------------- MapStorageReader methods --------------------*/

	@Override
	public boolean exists(PK key, Config config){
		return mysqlNodeManager.exists(getFieldInfo(), key, config);
	}

	@Override
	public D get(PK key, Config config){
		return mysqlNodeManager.get(getFieldInfo(), key, config);
	}

	@Override
	public List getMulti(Collection keys, Config config){
		return mysqlNodeManager.getMulti(getFieldInfo(), keys, config);
	}

	@Override
	public List getKeys(Collection keys, Config config){
		return mysqlNodeManager.getKeys(getFieldInfo(), keys, config);
	}


	/*------------------------ IndexedStorageReader methods -----------------*/

	@Override
	public D lookupUnique(UniqueKey uniqueKey, Config config){
		return mysqlNodeManager.lookupUnique(getFieldInfo(), uniqueKey, config);
	}

	@Override
	public List lookupMultiUnique(Collection> uniqueKeys, Config config){
		return mysqlNodeManager.lookupMultiUnique(getFieldInfo(), uniqueKeys, config);
	}

	@Override
	public ,
			IE extends IndexEntry,
			IF extends DatabeanFielder>
	Scanner scanRangesIndex(
			IndexEntryFieldInfo indexEntryFieldInfo,
			Collection> ranges,
			Config config){
		return mysqlNodeManager.scanRangesIndex(getFieldInfo(), indexEntryFieldInfo, ranges, config);
	}

	@Override
	public ,
			IE extends IndexEntry,
			IF extends DatabeanFielder>
	Scanner scanRangesByIndex(
			IndexEntryFieldInfo indexEntryFieldInfo,
			Collection> ranges,
			Config config){
		return mysqlNodeManager.scanRangesByIndex(getFieldInfo(), indexEntryFieldInfo, ranges, config);
	}

	@Override
	public ,
			IE extends IndexEntry,
			IF extends DatabeanFielder>
	Scanner scanRangesIndexKeys(
			IndexEntryFieldInfo indexEntryFieldInfo,
			Collection> ranges,
			Config config){
		return mysqlNodeManager.scanRangesIndexKeys(getFieldInfo(), indexEntryFieldInfo, ranges, config);
	}

	@Override
	public ,
			IE extends IndexEntry,
			IF extends DatabeanFielder>
	List getMultiFromIndex(Collection keys, Config config, IndexEntryFieldInfo indexEntryFieldInfo){
		return mysqlNodeManager.getMultiFromIndex(getFieldInfo(), keys, config, indexEntryFieldInfo);
	}

	@Override
	public ,
			IE extends IndexEntry,
			IF extends DatabeanFielder>
	List getMultiByIndex(Collection keys, Config config, IndexEntryFieldInfo indexEntryFieldInfo){
		return mysqlNodeManager.getMultiByIndex(getFieldInfo(), keys, config, indexEntryFieldInfo);
	}

	@Override
	public ,
			IE extends IndexEntry,
			IF extends DatabeanFielder,
			N extends ManagedNode>
	N registerManaged(N managedNode){
		return mysqlNodeManager.registerManaged(getFieldInfo(), managedNode);
	}

	@Override
	public List> getManagedNodes(){
		return mysqlNodeManager.getManagedNodes(getFieldInfo());
	}

	/*--------------------- SortedStorageReader methods ---------------------*/

	@Override
	public Scanner scanRangesKeys(Collection> ranges, Config config){
		return mysqlNodeManager.scanRangesKeys(getFieldInfo(), ranges, config);
	}

	@Override
	public Scanner scanRanges(Collection> ranges, Config config){
		return mysqlNodeManager.scanRanges(getFieldInfo(), ranges, config);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy