This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Player> sqlQuerySearch(String text) { | |
log.info("SqlQuery search to find players whose team contain the given text"); | |
IgniteCache<Long, Player> playerCache = Ignition.ignite().getOrCreateCache(PLAYER); | |
Collection<QueryEntity> queryEntities = playerCache.getConfiguration(CacheConfiguration.class).getQueryEntities(); | |
String tableName = queryEntities.stream().findFirst().orElseThrow(() -> new IllegalArgumentException(PLAYER + "doesn't exists")).getTableName(); | |
SqlFieldsQuery sqlQuery = new SqlFieldsQuery("select * from " + tableName + " where team='" + text + "'"); | |
log.info("Query :: " + sqlQuery.getSql()); | |
List<List<?>> records = playerCache.query(sqlQuery).getAll(); | |
return records.stream().map(objects -> convert((List<Object>) objects)).collect(Collectors.toList()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Player> scanQuerySearch(String text) { | |
log.info("ScanQuery search to find players with the given field name and text"); | |
IgniteCache<Long, Player> playerCache = Ignition.ignite().getOrCreateCache(PLAYER); | |
ScanQuery<Long, Player> scanQuery = new ScanQuery<>((k, v) -> v.getTeam().equalsIgnoreCase(text)); | |
List<Player> players = new ArrayList<>(); | |
log.info("Query :: " + scanQuery); | |
try (QueryCursor<Cache.Entry<Long, Player>> cursor = playerCache.query(scanQuery)) { | |
Iterator<Cache.Entry<Long, Player>> iterator = cursor.iterator(); | |
while (iterator.hasNext()) { | |
Cache.Entry<Long, Player> entry = iterator.next(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Data | |
@AllArgsConstructor | |
@NoArgsConstructor | |
@Builder | |
public class Player implements Serializable { | |
private static final long serialVersionUID = 1389818123283358176L; | |
@QuerySqlField(index = true) | |
private Long id; | |
@QueryTextField | |
@QuerySqlField |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" | |
xsi:schemaLocation=" | |
http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans.xsd | |
http://www.springframework.org/schema/util | |
http://www.springframework.org/schema/util/spring-util.xsd"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.gridgain</groupId> | |
<artifactId>ignite-core</artifactId> | |
<version>${gridgain.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>org.gridgain</groupId> | |
<artifactId>ignite-spring</artifactId> | |
<version>${gridgain.version}</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class IgniteCacheManagerConfiguration { | |
private final String igniteConfigPath; | |
public IgniteCacheManagerConfiguration(@Value(IGNITE_CONFIG_PROP_SPRING) String igniteConfigPath) { | |
this.igniteConfigPath = igniteConfigPath; | |
} | |
@DependsOn(IGNITE_SYSTEM_PROPERTIES_CONFIGURATION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation=" | |
http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans.xsd"> | |
<import resource="classpath:cache/ignite-cache-definition.xml"/> | |
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> | |
<property name="metricsLogFrequency" value="60000"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from db import db | |
from models.entities import Item | |
from typing import List | |
class ItemRepo: | |
def create(self,item): | |
db.session.add(item) | |
db.session.commit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, Blueprint, jsonify | |
from flask_restplus import Api | |
from ma import ma | |
from db import db | |
from resources.store import Store, StoreList, store_ns, stores_ns | |
from resources.item import Item, ItemList, items_ns, item_ns | |
from marshmallow import ValidationError | |
app = Flask(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import request | |
from flask_restplus import Resource, fields, Namespace | |
from models.store import StoreModel | |
from schemas.store import StoreSchema | |
STORE_NOT_FOUND = "Store not found." | |
STORE_ALREADY_EXISTS = "Store '{}' Already exists." | |
store_ns = Namespace('store', description='Store related operations') |
NewerOlder