Search in sources :

Example 1 with Address

use of org.apache.ignite.examples.model.Address in project ignite by apache.

the class CacheClientBinaryPutGetExample method putGetBinary.

/**
     * Execute individual put and get, getting value in binary format, without de-serializing it.
     *
     * @param cache Cache.
     */
private static void putGetBinary(IgniteCache<Integer, Organization> cache) {
    // Create new Organization binary object to store in cache.
    Organization org = new Organization(// Name.
    "Microsoft", // Address.
    new Address("1096 Eddy Street, San Francisco, CA", 94109), // Type.
    OrganizationType.PRIVATE, // Last update time.
    new Timestamp(System.currentTimeMillis()));
    // Put created data entry to cache.
    cache.put(1, org);
    // Get cache that will get values as binary objects.
    IgniteCache<Integer, BinaryObject> binaryCache = cache.withKeepBinary();
    // Get recently created organization as a binary object.
    BinaryObject po = binaryCache.get(1);
    // Get organization's name from binary object (note that
    // object doesn't need to be fully deserialized).
    String name = po.field("name");
    System.out.println();
    System.out.println(">>> Retrieved organization name from binary object: " + name);
}
Also used : Organization(org.apache.ignite.examples.model.Organization) Address(org.apache.ignite.examples.model.Address) BinaryObject(org.apache.ignite.binary.BinaryObject) Timestamp(java.sql.Timestamp)

Example 2 with Address

use of org.apache.ignite.examples.model.Address in project ignite by apache.

the class ComputeClientBinaryTaskExecutionExample method employees.

/**
     * Creates collection of employees.
     *
     * @return Collection of employees.
     */
private static Collection<Employee> employees() {
    Collection<Employee> employees = new ArrayList<>();
    employees.add(new Employee("James Wilson", 12500, new Address("1096 Eddy Street, San Francisco, CA", 94109), Arrays.asList("Human Resources", "Customer Service")));
    employees.add(new Employee("Daniel Adams", 11000, new Address("184 Fidler Drive, San Antonio, TX", 78205), Arrays.asList("Development", "QA")));
    employees.add(new Employee("Cristian Moss", 12500, new Address("667 Jerry Dove Drive, Florence, SC", 29501), Arrays.asList("Logistics")));
    employees.add(new Employee("Allison Mathis", 25300, new Address("2702 Freedom Lane, Hornitos, CA", 95325), Arrays.asList("Development")));
    employees.add(new Employee("Breana Robbin", 6500, new Address("3960 Sundown Lane, Austin, TX", 78758), Arrays.asList("Sales")));
    employees.add(new Employee("Philip Horsley", 19800, new Address("2803 Elsie Drive, Sioux Falls, SD", 57104), Arrays.asList("Sales")));
    employees.add(new Employee("Brian Peters", 10600, new Address("1407 Pearlman Avenue, Boston, MA", 12110), Arrays.asList("Development", "QA")));
    employees.add(new Employee("Jack Yang", 12900, new Address("4425 Parrish Avenue Smithsons Valley, TX", 78130), Arrays.asList("Sales")));
    return employees;
}
Also used : Employee(org.apache.ignite.examples.model.Employee) Address(org.apache.ignite.examples.model.Address) ArrayList(java.util.ArrayList)

Example 3 with Address

use of org.apache.ignite.examples.model.Address in project ignite by apache.

the class CacheClientBinaryPutGetExample method putGet.

/**
     * Execute individual put and get.
     *
     * @param cache Cache.
     */
private static void putGet(IgniteCache<Integer, Organization> cache) {
    // Create new Organization binary object to store in cache.
    Organization org = new Organization(// Name.
    "Microsoft", // Address.
    new Address("1096 Eddy Street, San Francisco, CA", 94109), // Type.
    OrganizationType.PRIVATE, // Last update time.
    new Timestamp(System.currentTimeMillis()));
    // Put created data entry to cache.
    cache.put(1, org);
    // Get recently created organization as a strongly-typed fully de-serialized instance.
    Organization orgFromCache = cache.get(1);
    System.out.println();
    System.out.println(">>> Retrieved organization instance from cache: " + orgFromCache);
}
Also used : Organization(org.apache.ignite.examples.model.Organization) Address(org.apache.ignite.examples.model.Address) Timestamp(java.sql.Timestamp)

Example 4 with Address

use of org.apache.ignite.examples.model.Address in project ignite by apache.

the class CacheClientBinaryPutGetExample method putGetAll.

/**
     * Execute bulk {@code putAll(...)} and {@code getAll(...)} operations.
     *
     * @param cache Cache.
     */
private static void putGetAll(IgniteCache<Integer, Organization> cache) {
    // Create new Organization binary objects to store in cache.
    Organization org1 = new Organization(// Name.
    "Microsoft", // Address.
    new Address("1096 Eddy Street, San Francisco, CA", 94109), // Type.
    OrganizationType.PRIVATE, // Last update time.
    new Timestamp(System.currentTimeMillis()));
    Organization org2 = new Organization(// Name.
    "Red Cross", // Address.
    new Address("184 Fidler Drive, San Antonio, TX", 78205), // Type.
    OrganizationType.NON_PROFIT, // Last update time.
    new Timestamp(System.currentTimeMillis()));
    Map<Integer, Organization> map = new HashMap<>();
    map.put(1, org1);
    map.put(2, org2);
    // Put created data entries to cache.
    cache.putAll(map);
    // Get recently created organizations as a strongly-typed fully de-serialized instances.
    Map<Integer, Organization> mapFromCache = cache.getAll(map.keySet());
    System.out.println();
    System.out.println(">>> Retrieved organization instances from cache:");
    for (Organization org : mapFromCache.values()) System.out.println(">>>     " + org);
}
Also used : Organization(org.apache.ignite.examples.model.Organization) Address(org.apache.ignite.examples.model.Address) HashMap(java.util.HashMap) Timestamp(java.sql.Timestamp)

Example 5 with Address

use of org.apache.ignite.examples.model.Address in project ignite by apache.

the class CacheClientBinaryQueryExample method populateCache.

/**
     * Populates cache with data.
     *
     * @param orgCache Organization cache.
     * @param employeeCache Employee cache.
     */
@SuppressWarnings("TypeMayBeWeakened")
private static void populateCache(IgniteCache<Integer, Organization> orgCache, IgniteCache<EmployeeKey, Employee> employeeCache) {
    orgCache.put(1, new Organization("GridGain", new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404), OrganizationType.PRIVATE, new Timestamp(System.currentTimeMillis())));
    orgCache.put(2, new Organization("Microsoft", new Address("1096 Eddy Street, San Francisco, CA", 94109), OrganizationType.PRIVATE, new Timestamp(System.currentTimeMillis())));
    employeeCache.put(new EmployeeKey(1, 1), new Employee("James Wilson", 12500, new Address("1096 Eddy Street, San Francisco, CA", 94109), Arrays.asList("Human Resources", "Customer Service")));
    employeeCache.put(new EmployeeKey(2, 1), new Employee("Daniel Adams", 11000, new Address("184 Fidler Drive, San Antonio, TX", 78130), Arrays.asList("Development", "QA")));
    employeeCache.put(new EmployeeKey(3, 1), new Employee("Cristian Moss", 12500, new Address("667 Jerry Dove Drive, Florence, SC", 29501), Arrays.asList("Logistics")));
    employeeCache.put(new EmployeeKey(4, 2), new Employee("Allison Mathis", 25300, new Address("2702 Freedom Lane, San Francisco, CA", 94109), Arrays.asList("Development")));
    employeeCache.put(new EmployeeKey(5, 2), new Employee("Breana Robbin", 6500, new Address("3960 Sundown Lane, Austin, TX", 78130), Arrays.asList("Sales")));
    employeeCache.put(new EmployeeKey(6, 2), new Employee("Philip Horsley", 19800, new Address("2803 Elsie Drive, Sioux Falls, SD", 57104), Arrays.asList("Sales")));
    employeeCache.put(new EmployeeKey(7, 2), new Employee("Brian Peters", 10600, new Address("1407 Pearlman Avenue, Boston, MA", 12110), Arrays.asList("Development", "QA")));
}
Also used : Organization(org.apache.ignite.examples.model.Organization) Employee(org.apache.ignite.examples.model.Employee) Address(org.apache.ignite.examples.model.Address) EmployeeKey(org.apache.ignite.examples.model.EmployeeKey) Timestamp(java.sql.Timestamp)

Aggregations

Address (org.apache.ignite.examples.model.Address)6 Timestamp (java.sql.Timestamp)5 Organization (org.apache.ignite.examples.model.Organization)5 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 BinaryObject (org.apache.ignite.binary.BinaryObject)2 Employee (org.apache.ignite.examples.model.Employee)2 EmployeeKey (org.apache.ignite.examples.model.EmployeeKey)1