GDC Class Notes

Class Notes of Graduate Diploma in Computing in Unitec

Binary Search Tree Structure and algorithm

Traversals

  • Preorder Traversal, Process(Root), GotoLeft, GotoRight
1
2
3
4
5
process(root);

preOrder(leftSubtree);

preOrder(rightSubtree);
  • InOrder, GotoLeft, Process, GotoRight

    1
    // This will get a ordered list
  • PosrOrder, Left, Right, Process

    1
    2
    3
    // If we put operators to root, and number to lefts,

    // then this order will match postFix (expression)

And these 3 different orders can match the prefix, infix, postfix expressions.

Data Warehouse Data Quality

Issues in source data

  • out of acceptable range
  • non-standard data/ varying formats
  • outliers, outliers is above/below 3* standard deviation
  • invalid values
  • null values
  • differing culture rules (like, nz/us time date format)
  • cosmetic
  • verification (wrong post code)

strategy

  • filter/clean/correct errors in source date before transform
  • quality assured by verifying again
  • correct and complete
  • pre-processing

Data Quality(DQ) Assurance process

  • checking
    • checking if there is an error or dirty data
    • based on pre-defined data quality rules
  • Logging
    • record the data with errors
    • notify DB users/admin to correct the data
  • Correcting
    • clean or ignore the erros in the data – data cleaning

Logging errors

DQ rule is violated, log the event into a table. (the below is the fields of the table)

  • RowID of the record that vialoates the rule a physical address the row stored on disk
  • rule no that is violated
  • table name of that row id
  • Database name of the table
  • Action -> Reject/Allow/Fix

DQ Actions

  • Reject
  • Allow (low risk error, the error is in within tolerance limits)
  • Fix (Correct the error)

Reading

  • sql server trigger

Week7 Android Google Api And Polyline

  • fragmentactivity can be used to design better UI

Google map

  • polyline to generate polygen
  • marker (google map)
  • GroundOverlayOptions (google map add ground overlay)
  • addcircle
  • setonPolylineClickListener
  • moveCamera
  • use emulator with google api

Refs

  • google map api document

Data Structure, Linked list

Linked list

We only need a single pointer to identify the list, however, it is a good idea to have a node containing data about a list, this data is metadata.

Addignment requirements

  • full list, try catch no memorary exeption

Thread on Android

Thread thread = new Thread()
{
public void run()
    { //some codes here
    }
};
thread.run()

Some mistakes learners made

  • thread.start(), not use run directly
  • reading from different thread is OK, writing might be a problem

Some tips

  • threads that have dead cannot be restarted
  • lot of problmes of reading/writing

Race conditions

  • execution of threads is not-deterministic
  • executation order effects outcome
  • program may run correctly 99.99%ek5

  • no problem if you are just reading shared data

synchronized

  • only one thread can access this object or the execute this section of code one time
  • other threads will wait
  • can solve non-deterministic issues during runiing

Dead lock

  • two or more threads are locked forever - waiting to acquire locks to shared objects that each thread has a lock against
  • a circular dependacy between threads and locks

Asp.net Core data migration

how do we start

  1. database / data model
  2. class (null if you already get data model)
  3. code

data model

  • when you define a property name like <name>Id, Entity Framework treat it as a key
  • or use fluent api to define
  • fluent api get better perfomance

data migration

  • change userid in connecting string to user
  • you create multi migrations before update it

Mobile android class notes

generate shotcut

  • cmd+n
  • cmd+shift+n

constraints

  • blue button

Log

Log

invalidate

force to redraw, if you call it in onDraw(), it will be called again and again, like a loop.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package uno.bai.tim.test;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

/**
* Created by tim on 12/03/18.
*/

public class EasyView extends View {

float x =50;
float y =50;



public EasyView(Context context) {
super(context);
}

public EasyView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}

public EasyView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}


@Override
protected void onDraw(Canvas canvas) {

Paint paint = new Paint();
paint.setColor(Color.LTGRAY);

canvas.drawCircle(x,y,20,paint);
x++;
y++;

invalidate();
//


// super.onDraw(canvas);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
return super.onTouchEvent(event);
}
}

About design of data warehouse

fact and deimensions

  • name is also a measure, an indirect measure
  • cannot use a measure as a key

star schema

  • only one fact table
  • fundamental
  • widely used

  • add key, increase number of rows

  • add a measure, more duplicate values, but not change the number of rows

snow flake

  • a fact with nomalized dimensions

Fact constellation

  • multi facts sharing many dimensions (like one fact supply/buy, one fact sales)

Hybrid DW

  • realtional and DW schemas
  • 2 or more schemas
  • online and offline storage