This file contains hidden or 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 class Box<T> { | |
private T t; // T is a placeholder for the type of object the box holds | |
public void set(T t) { | |
this.t = t; | |
} | |
public T get() { | |
return t; | |
} |
This file contains hidden or 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
import java.util.ArrayList; | |
import java.util.List; | |
public class GenericsExample { | |
public static void main(String[] args) { | |
// Create a type-safe List using generics | |
List<String> list = new ArrayList<String>(); | |
// Add a String | |
list.add("Hello, World!"); |
This file contains hidden or 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
import java.util.ArrayList; | |
public class PreGenericsExample { | |
public static void main(String[] args) { | |
// Create a raw ArrayList (no specified type) | |
ArrayList list = new ArrayList(); | |
// Add a String and an Integer to the same list | |
list.add("Hello, World!"); | |
list.add(123); // The compiler allows this! |
This file contains hidden or 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
INSERT OVERWRITE TABLE monthly_page_views | |
PARTITION (year, month) | |
SELECT | |
page_view, | |
COUNT(*) AS view_count, | |
YEAR(FROM_UNIXTIME(request_timestamp)) AS year, | |
MONTH(FROM_UNIXTIME(request_timestamp)) AS month | |
FROM raw_web_logs | |
GROUP BY | |
page_view, |
This file contains hidden or 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
SELECT | |
page_view, | |
COUNT(*) AS page_views | |
FROM raw_web_logs | |
GROUP BY page_view | |
ORDER BY page_views DESC | |
LIMIT 10; |
This file contains hidden or 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
CREATE EXTERNAL TABLE IF NOT EXISTS raw_web_logs ( | |
request_timestamp BIGINT, | |
ip_address STRING, | |
user_agent STRING, | |
page_view STRING | |
) | |
ROW FORMAT DELIMITED | |
FIELDS TERMINATED BY ',' | |
LOCATION '/user/data/raw/weblogs/'; |
This file contains hidden or 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
-- Create a table with a schema | |
CREATE TABLE IF NOT EXISTS web_logs ( | |
timestamp BIGINT, | |
ip_address STRING, | |
user_agent STRING, | |
page_view STRING | |
) | |
ROW FORMAT DELIMITED | |
FIELDS TERMINATED BY ',' | |
STORED AS TEXTFILE; |
This file contains hidden or 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
<template> | |
<div> | |
<h1>Welcome to the Home Page</h1> | |
<p>This is the main content of our single-page application.</p> | |
<hr> | |
<h2>A Simple Counter</h2> | |
<p>Current count: {{ count }}</p> | |
<button @click="increment">Increment</button> |
This file contains hidden or 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
<template> | |
<nav> | |
<router-link to="/">Home</router-link> | | |
<router-link to="/about">About</router-link> | |
</nav> | |
<router-view></router-view> | |
</template> | |
<script setup> | |
</script> |
This file contains hidden or 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
import { createApp } from 'vue' | |
import App from './App.vue' | |
import router from './router' | |
createApp(App).use(router).mount('#app') |